-
Notifications
You must be signed in to change notification settings - Fork 5
/
Event.ts
78 lines (67 loc) · 2.42 KB
/
Event.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import { KlaviyoReactNativeSdk } from './KlaviyoReactNativeSdk';
const { EVENT_NAMES } = KlaviyoReactNativeSdk.getConstants();
/**
* EventName is a convenience enum for the names of common events that can be tracked.
*/
export enum EventName {
/**
* The 'Added to Cart' event is used to track when a user adds a product to their cart.
*/
ADDED_TO_CART_METRIC = EVENT_NAMES.ADDED_TO_CART,
/**
* The 'Opened App' event is used to track when a user opens the app.
*/
OPENED_APP_METRIC = EVENT_NAMES.OPENED_APP,
/**
* The 'Started Checkout' event is used to track when a user starts the checkout process.
*/
STARTED_CHECKOUT_METRIC = EVENT_NAMES.STARTED_CHECKOUT,
/**
* The 'Viewed Product' event is used to track when a user views a product.
*/
VIEWED_PRODUCT_METRIC = EVENT_NAMES.VIEWED_PRODUCT,
}
/**
* Type for event properties
*/
export type EventProperties = Record<string, Object>;
/**
* Interface for an event
*/
export interface Event {
/**
* Name of the event. Must be less than 128 characters.
*/
readonly name: EventName | string;
/**
* A numeric value to associate with this event. For example, the dollar amount of a purchase.
*/
readonly value?: number;
/**
* A unique identifier for an event. If the uniqueId is repeated for the same
* profile and metric, only the first processed event will be recorded. If this is not
* present, this will use the time to the second. Using the default, this limits only one
* event per profile per second.
*/
readonly uniqueId?: string;
/**
* Properties of this event. Any top level property (that are not objects) can be
* used to create segments. The $extra property is a special property. This records any
* non-segmentable values that can be referenced later. For example, HTML templates are
* useful on a segment but are not used to create a segment. There are limits
* placed onto the size of the data present. This must not exceed 5 MB. This must not
* exceed 300 event properties. A single string cannot be larger than 100 KB. Each array
* must not exceed 4000 elements. The properties cannot contain more than 10 nested levels.
*/
readonly properties?: EventProperties;
}
/**
* Interface for the Klaviyo Event API
*/
export interface KlaviyoEventAPI {
/**
* Create a new event to track a profile's activity.
* @param event - The event to track
*/
createEvent(event: Event): void;
}