47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
import { Event, Identity, Group } from "@budibase/types"
|
|
import { EventProcessor } from "./types"
|
|
|
|
export default class Processor implements EventProcessor {
|
|
initialised: boolean = false
|
|
processors: EventProcessor[] = []
|
|
|
|
constructor(processors: EventProcessor[]) {
|
|
this.processors = processors
|
|
}
|
|
|
|
async processEvent(
|
|
event: Event,
|
|
identity: Identity,
|
|
properties: any,
|
|
timestamp?: string | number
|
|
): Promise<void> {
|
|
for (const eventProcessor of this.processors) {
|
|
await eventProcessor.processEvent(event, identity, properties, timestamp)
|
|
}
|
|
}
|
|
|
|
async identify(
|
|
identity: Identity,
|
|
timestamp?: string | number
|
|
): Promise<void> {
|
|
for (const eventProcessor of this.processors) {
|
|
await eventProcessor.identify(identity, timestamp)
|
|
}
|
|
}
|
|
|
|
async identifyGroup(
|
|
identity: Group,
|
|
timestamp?: string | number
|
|
): Promise<void> {
|
|
for (const eventProcessor of this.processors) {
|
|
await eventProcessor.identifyGroup(identity, timestamp)
|
|
}
|
|
}
|
|
|
|
shutdown() {
|
|
for (const eventProcessor of this.processors) {
|
|
eventProcessor.shutdown()
|
|
}
|
|
}
|
|
}
|