1
0
Fork 0
mirror of synced 2024-09-26 06:11:49 +12:00
budibase/packages/backend-core/src/events/events.ts

18 lines
468 B
TypeScript
Raw Normal View History

2022-05-04 04:13:13 +12:00
import { getTenantId } from "../context"
2022-05-05 19:32:14 +12:00
import analytics from "../analytics"
import { Event } from "@budibase/types"
2022-04-02 09:29:44 +13:00
2022-05-05 19:32:14 +12:00
const logEvent = (messsage: string) => {
2022-04-02 09:29:44 +13:00
const tenantId = getTenantId()
const userId = getTenantId() // TODO
2022-04-08 12:28:22 +12:00
console.log(`[audit] [tenant=${tenantId}] [user=${userId}] ${messsage}`)
2022-04-02 09:29:44 +13:00
}
2022-05-05 19:32:14 +12:00
export const processEvent = (event: Event, properties: any) => {
2022-04-02 09:29:44 +13:00
// logging
logEvent(event)
// analytics
2022-05-05 19:32:14 +12:00
analytics.captureEvent(event, properties)
2022-04-02 09:29:44 +13:00
}