UNPKG

@lokalise/fastify-extras

Version:

Opinionated set of fastify plugins, commonly used in Lokalise

35 lines (34 loc) 1.34 kB
import z, { type ZodObject } from 'zod'; import type { Amplitude } from './Amplitude.js'; export declare const AMPLITUDE_BASE_MESSAGE_SCHEMA: z.ZodObject<{ event_type: z.ZodLiteral<string>; event_properties: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>; user_id: z.ZodUnion<[z.ZodString, z.ZodLiteral<"SYSTEM">]>; groups: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>; }, "strip", z.ZodTypeAny, { event_type: string; event_properties: {}; user_id: string; groups?: Record<string, any> | undefined; }, { event_type: string; event_properties: {}; user_id: string; groups?: Record<string, any> | undefined; }>; export type AmplitudeAdapterDependencies = { amplitude: Amplitude; }; export type AmplitudeMessage = { schema: ZodObject<(typeof AMPLITUDE_BASE_MESSAGE_SCHEMA)['shape']>; }; type AmplitudeMessageSchemaType<T extends AmplitudeMessage> = z.infer<T['schema']>; /** * Amplitude adapter which provides type safe tracking of events */ export declare class AmplitudeAdapter<AmplitudeMessages extends AmplitudeMessage[]> { private readonly amplitude; constructor({ amplitude }: AmplitudeAdapterDependencies); track<Message extends AmplitudeMessages[number]>(supportedMessage: Message, data: Omit<AmplitudeMessageSchemaType<Message>, 'event_type'>): void; } export {};