(
event: string,
properties: TelemetryProperties = {},
context: TelemetryContextIds,
)
| 76 | } |
| 77 | |
| 78 | trackWithContext( |
| 79 | event: string, |
| 80 | properties: TelemetryProperties = {}, |
| 81 | context: TelemetryContextIds, |
| 82 | ): void { |
| 83 | if (this.disabled) return; |
| 84 | const record: PendingTelemetryEvent = { |
| 85 | event_id: randomUUID().replaceAll('-', ''), |
| 86 | device_id: context.deviceId === undefined ? this.deviceId : context.deviceId, |
| 87 | session_id: context.sessionId === undefined ? this.sessionId : context.sessionId, |
| 88 | event, |
| 89 | timestamp: Date.now() / 1000, |
| 90 | properties: sanitizeProperties(properties), |
| 91 | contextOverrides: { |
| 92 | deviceId: context.deviceId !== undefined, |
| 93 | sessionId: context.sessionId !== undefined, |
| 94 | }, |
| 95 | }; |
| 96 | if (this.sink !== null) { |
| 97 | this.sink.accept(toTelemetryEvent(record)); |
| 98 | return; |
| 99 | } |
| 100 | this.queue.push(record); |
| 101 | if (this.queue.length > MAX_QUEUE_SIZE) { |
| 102 | this.queue = this.queue.slice(this.queue.length - MAX_QUEUE_SIZE); |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | getSink(): EventSink | null { |
| 107 | return this.sink; |
no test coverage detected