import test from 'ava'; test('pass if this snowtype-generated file passes typechecks', (t) => t.pass()); // generated with Snowtype v0.8.4, package import on below line needs to be updated to '../src' import { buildSelfDescribingEvent, SelfDescribingJson, Timestamp, Tracker } from '../src'; // Automatically generated by Snowtype /** * Schema for an example event */ export type SubscriptionFunnel = { /** * the action of the funnel step */ action?: null | string; /** * the number of the funnel step */ step: number; /** * the type of subscription the user is signing up to */ subscription_type?: null | string; }; interface CommonEventProperties> { /** Add context to an event by setting an Array of Self Describing JSON */ context?: Array> | null; /** Set the true timestamp or overwrite the device sent timestamp on an event */ timestamp?: Timestamp | null; } /** * Creates a Snowplow Event Specification entity. */ export function createEventSpecification(eventSpecification: EventSpecification) { return { schema: 'iglu:com.snowplowanalytics.snowplow/event_specification/jsonschema/1-0-2', data: eventSpecification, }; } /** * Automatically attached context for event specifications */ interface EventSpecification { id: string; name: string; data_product_id: string; data_product_name: string; } type ContextsOrTimestamp = Omit, 'context'> & { context?: SelfDescribingJson[] | null | undefined; }; /** * Track a Snowplow event for SubscriptionFunnel. * Schema for an example event */ export function trackSubscriptionFunnel( tracker: Tracker, subscriptionFunnel: SubscriptionFunnel & ContextsOrTimestamp ) { const { context, timestamp, ...data } = subscriptionFunnel; tracker.track( buildSelfDescribingEvent({ event: { schema: 'iglu:com.example/subscription_funnel/jsonschema/1-0-0', data, }, }), context, timestamp ); } /** * Creates a Snowplow SubscriptionFunnel entity. */ export function createSubscriptionFunnel(subscriptionFunnel: SubscriptionFunnel) { return { schema: 'iglu:com.example/subscription_funnel/jsonschema/1-0-0', data: subscriptionFunnel, }; }