@lokalise/fastify-extras
Version:
Opinionated set of fastify plugins, commonly used in Lokalise
25 lines • 742 B
JavaScript
import { z } from 'zod/v4';
export const AMPLITUDE_BASE_MESSAGE_SCHEMA = z
.object({
event_type: z.literal('<replace.me>'),
user_id: z.string().min(1).or(z.literal('SYSTEM')),
groups: z.record(z.string(), z.any()).optional(),
})
.strip();
/**
* Amplitude adapter which provides type safe tracking of events
*/
export class AmplitudeAdapter {
amplitude;
constructor({ amplitude }) {
this.amplitude = amplitude;
}
track(supportedMessage, data) {
const message = supportedMessage.schema.parse({
event_type: supportedMessage.schema.shape.event_type.value,
...data,
});
this.amplitude.track(message);
}
}
//# sourceMappingURL=AmplitudeAdapter.js.map