37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
export type TelemetryEventName =
|
|
| "app.boot.failed"
|
|
| "api.request.failed"
|
|
| "ui.render.failed"
|
|
| "release.mismatch.detected"
|
|
| "telemetry.delivery.dropped";
|
|
|
|
export type TelemetryDefinition = Readonly<{
|
|
eventName: TelemetryEventName;
|
|
trigger: string;
|
|
requiredAttributes: readonly string[];
|
|
optionalAttributes: readonly string[];
|
|
forbiddenAttributes: readonly string[];
|
|
sampling: string;
|
|
delivery: "best-effort";
|
|
}>;
|
|
|
|
export type TelemetryEvent = Readonly<{
|
|
eventName: TelemetryEventName;
|
|
timestamp: string;
|
|
attributes: Readonly<Record<string, unknown>>;
|
|
}>;
|
|
|
|
export const TELEMETRY_ATTRIBUTE_ALLOWLIST: readonly string[];
|
|
export const TELEMETRY_FORBIDDEN_ATTRIBUTES: readonly string[];
|
|
export const TELEMETRY_REGISTRY: Readonly<
|
|
Record<TelemetryEventName, TelemetryDefinition>
|
|
>;
|
|
|
|
export function projectTelemetryEvent(
|
|
eventName: string,
|
|
attributes: Record<string, unknown>,
|
|
now?: () => number,
|
|
):
|
|
| Readonly<{ success: true; event: TelemetryEvent }>
|
|
| Readonly<{ success: false; reason: string }>;
|