@snowplow/react-native-tracker 4.0.2-dev.0 → 4.0.2-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs/event_store.js +150 -0
- package/dist/commonjs/event_store.js.map +1 -0
- package/dist/commonjs/events.js +42 -0
- package/dist/commonjs/events.js.map +1 -0
- package/dist/commonjs/index.js +29 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/subject.js +82 -0
- package/dist/commonjs/subject.js.map +1 -0
- package/dist/commonjs/tracker.js +77 -0
- package/dist/commonjs/tracker.js.map +1 -0
- package/dist/commonjs/types.js +223 -0
- package/dist/commonjs/types.js.map +1 -0
- package/dist/module/event_store.js +145 -0
- package/dist/module/event_store.js.map +1 -0
- package/dist/module/events.js +38 -0
- package/dist/module/events.js.map +1 -0
- package/dist/module/index.js +7 -0
- package/dist/module/index.js.map +1 -0
- package/dist/module/subject.js +78 -0
- package/dist/module/subject.js.map +1 -0
- package/dist/module/tracker.js +74 -0
- package/dist/module/tracker.js.map +1 -0
- package/dist/module/types.js +73 -0
- package/dist/module/types.js.map +1 -0
- package/dist/typescript/commonjs/package.json +1 -0
- package/dist/typescript/commonjs/src/event_store.d.ts +4 -0
- package/dist/typescript/commonjs/src/event_store.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/events.d.ts +10 -0
- package/dist/typescript/commonjs/src/events.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/index.d.ts +4 -0
- package/dist/typescript/commonjs/src/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/subject.d.ts +19 -0
- package/dist/typescript/commonjs/src/subject.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/tracker.d.ts +9 -0
- package/dist/typescript/commonjs/src/tracker.d.ts.map +1 -0
- package/dist/{index.cjs.d.ts → typescript/commonjs/src/types.d.ts} +18 -65
- package/dist/typescript/commonjs/src/types.d.ts.map +1 -0
- package/dist/typescript/module/package.json +1 -0
- package/dist/typescript/module/src/event_store.d.ts +4 -0
- package/dist/typescript/module/src/event_store.d.ts.map +1 -0
- package/dist/typescript/module/src/events.d.ts +10 -0
- package/dist/typescript/module/src/events.d.ts.map +1 -0
- package/dist/typescript/module/src/index.d.ts +4 -0
- package/dist/typescript/module/src/index.d.ts.map +1 -0
- package/dist/typescript/module/src/subject.d.ts +19 -0
- package/dist/typescript/module/src/subject.d.ts.map +1 -0
- package/dist/typescript/module/src/tracker.d.ts +9 -0
- package/dist/typescript/module/src/tracker.d.ts.map +1 -0
- package/dist/{index.module.d.ts → typescript/module/src/types.d.ts} +18 -65
- package/dist/typescript/module/src/types.d.ts.map +1 -0
- package/package.json +52 -14
- package/dist/index.cjs.js +0 -2656
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.cjs.min.d.ts +0 -499
- package/dist/index.cjs.min.js +0 -63
- package/dist/index.cjs.min.js.map +0 -1
- package/dist/index.module.js +0 -250
- package/dist/index.module.js.map +0 -1
package/dist/index.cjs.min.d.ts
DELETED
|
@@ -1,499 +0,0 @@
|
|
|
1
|
-
import { ConditionalContextProvider, ContextPrimitive, CorePluginConfiguration, PageViewEvent, SelfDescribingJson, StructuredEvent, EmitterConfiguration } from "@snowplow/tracker-core";
|
|
2
|
-
/**
|
|
3
|
-
* Configuration for the event store
|
|
4
|
-
*/
|
|
5
|
-
interface EventStoreConfiguration {
|
|
6
|
-
/**
|
|
7
|
-
* The maximum amount of events that will be buffered in the event store
|
|
8
|
-
*
|
|
9
|
-
* Will drop events once the limit is hit
|
|
10
|
-
* @defaultValue 1000
|
|
11
|
-
*/
|
|
12
|
-
maxEventStoreSize?: number;
|
|
13
|
-
/**
|
|
14
|
-
* Whether to use the AsyncStorage library as the persistent event store for the event store
|
|
15
|
-
* @defaultValue true
|
|
16
|
-
*/
|
|
17
|
-
useAsyncStorageForEventStore?: boolean;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Configuration for session tracking
|
|
21
|
-
*/
|
|
22
|
-
interface SessionConfiguration {
|
|
23
|
-
/**
|
|
24
|
-
* The amount of time in seconds before the session id is updated while the app is in the foreground
|
|
25
|
-
* @defaultValue 1800
|
|
26
|
-
*/
|
|
27
|
-
foregroundSessionTimeout?: number;
|
|
28
|
-
/**
|
|
29
|
-
* The amount of time in seconds before the session id is updated while the app is in the background
|
|
30
|
-
* @defaultValue 1800
|
|
31
|
-
*/
|
|
32
|
-
backgroundSessionTimeout?: number;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* The configuration object for initialising the tracker
|
|
36
|
-
*/
|
|
37
|
-
interface TrackerConfiguration {
|
|
38
|
-
/** The namespace of the tracker */
|
|
39
|
-
namespace: string;
|
|
40
|
-
/** The application ID */
|
|
41
|
-
appId?: string;
|
|
42
|
-
/**
|
|
43
|
-
* Whether unstructured events and custom contexts should be base64 encoded.
|
|
44
|
-
* @defaultValue false
|
|
45
|
-
**/
|
|
46
|
-
encodeBase64?: boolean;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Configuration of subject properties tracked with events
|
|
50
|
-
*/
|
|
51
|
-
interface SubjectConfiguration {
|
|
52
|
-
/**
|
|
53
|
-
* Business-defined user ID for this user
|
|
54
|
-
*/
|
|
55
|
-
userId?: string;
|
|
56
|
-
/**
|
|
57
|
-
* Override the network user id (UUIDv4) that is assigned by the collector and stored in cookies
|
|
58
|
-
*/
|
|
59
|
-
networkUserId?: string;
|
|
60
|
-
/**
|
|
61
|
-
* The domain user id (DUID) is a generated identifier that is stored in a first party cookie on Web.
|
|
62
|
-
* The React Native tracker does not assign it automatically.
|
|
63
|
-
*/
|
|
64
|
-
domainUserId?: string;
|
|
65
|
-
/**
|
|
66
|
-
* The custom user-agent. It overrides the user-agent used by default.
|
|
67
|
-
*/
|
|
68
|
-
useragent?: string;
|
|
69
|
-
/**
|
|
70
|
-
* Override the IP address of the device
|
|
71
|
-
*/
|
|
72
|
-
ipAddress?: string;
|
|
73
|
-
/**
|
|
74
|
-
* The timezone label
|
|
75
|
-
*/
|
|
76
|
-
timezone?: string;
|
|
77
|
-
/**
|
|
78
|
-
* The language set in the device
|
|
79
|
-
*/
|
|
80
|
-
language?: string;
|
|
81
|
-
/**
|
|
82
|
-
* The screen resolution
|
|
83
|
-
*/
|
|
84
|
-
screenResolution?: ScreenSize;
|
|
85
|
-
/**
|
|
86
|
-
* The screen viewport size
|
|
87
|
-
*/
|
|
88
|
-
screenViewport?: ScreenSize;
|
|
89
|
-
/**
|
|
90
|
-
* Color depth (integer)
|
|
91
|
-
*/
|
|
92
|
-
colorDepth?: number;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Screen size in pixels
|
|
96
|
-
*/
|
|
97
|
-
type ScreenSize = [
|
|
98
|
-
number,
|
|
99
|
-
number
|
|
100
|
-
];
|
|
101
|
-
/**
|
|
102
|
-
* Trigger for MessageNotification event
|
|
103
|
-
*/
|
|
104
|
-
type Trigger = "push" | "location" | "calendar" | "timeInterval" | "other";
|
|
105
|
-
/**
|
|
106
|
-
* Attachment object that identify an attachment in the MessageNotification.
|
|
107
|
-
*/
|
|
108
|
-
type MessageNotificationAttachmentProps = {
|
|
109
|
-
identifier: string;
|
|
110
|
-
type: string;
|
|
111
|
-
url: string;
|
|
112
|
-
};
|
|
113
|
-
/**
|
|
114
|
-
* MessageNotification event properties
|
|
115
|
-
* schema: iglu:com.snowplowanalytics.mobile/message_notification/jsonschema/1-0-0
|
|
116
|
-
*/
|
|
117
|
-
type MessageNotificationProps = {
|
|
118
|
-
/**
|
|
119
|
-
* The action associated with the notification.
|
|
120
|
-
*/
|
|
121
|
-
action?: string;
|
|
122
|
-
/*
|
|
123
|
-
* Attachments added to the notification (they can be part of the data object).
|
|
124
|
-
*/
|
|
125
|
-
attachments?: MessageNotificationAttachmentProps[];
|
|
126
|
-
/**
|
|
127
|
-
* The notification's body.
|
|
128
|
-
*/
|
|
129
|
-
body: string;
|
|
130
|
-
/*
|
|
131
|
-
* Variable string values to be used in place of the format specifiers in bodyLocArgs to use to localize the body text to the user's current localization.
|
|
132
|
-
*/
|
|
133
|
-
bodyLocArgs?: string[];
|
|
134
|
-
/**
|
|
135
|
-
* The key to the body string in the app's string resources to use to localize the body text to the user's current localization.
|
|
136
|
-
*/
|
|
137
|
-
bodyLocKey?: string;
|
|
138
|
-
/**
|
|
139
|
-
* The category associated to the notification.
|
|
140
|
-
*/
|
|
141
|
-
category?: string;
|
|
142
|
-
/**
|
|
143
|
-
* The application is notified of the delivery of the notification if it's in the foreground or background, the app will be woken up (iOS only).
|
|
144
|
-
*/
|
|
145
|
-
contentAvailable?: boolean;
|
|
146
|
-
/**
|
|
147
|
-
* The group which this notification is part of.
|
|
148
|
-
*/
|
|
149
|
-
group?: string;
|
|
150
|
-
/**
|
|
151
|
-
* The icon associated to the notification (Android only).
|
|
152
|
-
*/
|
|
153
|
-
icon?: string;
|
|
154
|
-
/**
|
|
155
|
-
* The number of items this notification represent.
|
|
156
|
-
*/
|
|
157
|
-
notificationCount?: number;
|
|
158
|
-
/**
|
|
159
|
-
* The time when the event of the notification occurred.
|
|
160
|
-
*/
|
|
161
|
-
notificationTimestamp?: string;
|
|
162
|
-
/**
|
|
163
|
-
* The sound played when the device receives the notification.
|
|
164
|
-
*/
|
|
165
|
-
sound?: string;
|
|
166
|
-
/**
|
|
167
|
-
* The notification's subtitle. (iOS only)
|
|
168
|
-
*/
|
|
169
|
-
subtitle?: string;
|
|
170
|
-
/**
|
|
171
|
-
* An identifier similar to 'group' but usable for different purposes (Android only).
|
|
172
|
-
*/
|
|
173
|
-
tag?: string;
|
|
174
|
-
/**
|
|
175
|
-
* An identifier similar to 'group' but usable for different purposes (iOS only).
|
|
176
|
-
*/
|
|
177
|
-
threadIdentifier?: string;
|
|
178
|
-
/**
|
|
179
|
-
* The notification's title.
|
|
180
|
-
*/
|
|
181
|
-
title: string;
|
|
182
|
-
/**
|
|
183
|
-
* Variable string values to be used in place of the format specifiers in titleLocArgs to use to localize the title text to the user's current localization.
|
|
184
|
-
*/
|
|
185
|
-
titleLocArgs?: string[];
|
|
186
|
-
/**
|
|
187
|
-
* The key to the title string in the app's string resources to use to localize the title text to the user's current localization.
|
|
188
|
-
*/
|
|
189
|
-
titleLocKey?: string;
|
|
190
|
-
/**
|
|
191
|
-
* The trigger that raised the notification message. Must be one of: push, location, calendar, timeInterval, other
|
|
192
|
-
*/
|
|
193
|
-
trigger: Trigger;
|
|
194
|
-
};
|
|
195
|
-
/**
|
|
196
|
-
* EventContext type
|
|
197
|
-
*/
|
|
198
|
-
type EventContext = SelfDescribingJson;
|
|
199
|
-
/**
|
|
200
|
-
* ScreenView event properties
|
|
201
|
-
* schema: iglu:com.snowplowanalytics.mobile/screen_view/jsonschema/1-0-0
|
|
202
|
-
*/
|
|
203
|
-
type ScreenViewProps = {
|
|
204
|
-
/**
|
|
205
|
-
* The name of the screen viewed
|
|
206
|
-
*/
|
|
207
|
-
name: string;
|
|
208
|
-
/**
|
|
209
|
-
* The id(UUID) of screen that was viewed
|
|
210
|
-
*/
|
|
211
|
-
id?: string;
|
|
212
|
-
/**
|
|
213
|
-
* The type of screen that was viewed
|
|
214
|
-
*/
|
|
215
|
-
type?: string;
|
|
216
|
-
/**
|
|
217
|
-
* The name of the previous screen that was viewed
|
|
218
|
-
*/
|
|
219
|
-
previousName?: string;
|
|
220
|
-
/**
|
|
221
|
-
* The id(UUID) of the previous screen that was viewed
|
|
222
|
-
*/
|
|
223
|
-
previousId?: string;
|
|
224
|
-
/**
|
|
225
|
-
* The type of the previous screen that was viewed
|
|
226
|
-
*/
|
|
227
|
-
previousType?: string;
|
|
228
|
-
/**
|
|
229
|
-
* The type of transition that led to the screen being viewed
|
|
230
|
-
*/
|
|
231
|
-
transitionType?: string;
|
|
232
|
-
};
|
|
233
|
-
/**
|
|
234
|
-
* Event tracked when a scroll view's scroll position changes.
|
|
235
|
-
* If screen engagement tracking is enabled, the scroll changed events will be aggregated into a `screen_summary` entity.
|
|
236
|
-
*
|
|
237
|
-
* Schema: `iglu:com.snowplowanalytics.mobile/scroll_changed/jsonschema/1-0-0`
|
|
238
|
-
*/
|
|
239
|
-
type ScrollChangedProps = {
|
|
240
|
-
/**
|
|
241
|
-
* Vertical scroll offset in pixels
|
|
242
|
-
*/
|
|
243
|
-
yOffset?: number;
|
|
244
|
-
/**
|
|
245
|
-
* Horizontal scroll offset in pixels.
|
|
246
|
-
*/
|
|
247
|
-
xOffset?: number;
|
|
248
|
-
/**
|
|
249
|
-
* The height of the scroll view in pixels
|
|
250
|
-
*/
|
|
251
|
-
viewHeight?: number;
|
|
252
|
-
/**
|
|
253
|
-
* The width of the scroll view in pixels
|
|
254
|
-
*/
|
|
255
|
-
viewWidth?: number;
|
|
256
|
-
/**
|
|
257
|
-
* The height of the content in the scroll view in pixels
|
|
258
|
-
*/
|
|
259
|
-
contentHeight?: number;
|
|
260
|
-
/**
|
|
261
|
-
* The width of the content in the scroll view in pixels
|
|
262
|
-
*/
|
|
263
|
-
contentWidth?: number;
|
|
264
|
-
};
|
|
265
|
-
/**
|
|
266
|
-
* Event tracking the view of an item in a list.
|
|
267
|
-
* If screen engagement tracking is enabled, the list item view events will be aggregated into a `screen_summary` entity.
|
|
268
|
-
*
|
|
269
|
-
* Schema: `iglu:com.snowplowanalytics.mobile/list_item_view/jsonschema/1-0-0`
|
|
270
|
-
*/
|
|
271
|
-
type ListItemViewProps = {
|
|
272
|
-
/**
|
|
273
|
-
* Index of the item in the list
|
|
274
|
-
*/
|
|
275
|
-
index: number;
|
|
276
|
-
/**
|
|
277
|
-
* Total number of items in the list
|
|
278
|
-
*/
|
|
279
|
-
itemsCount?: number;
|
|
280
|
-
};
|
|
281
|
-
/**
|
|
282
|
-
* Timing event properties
|
|
283
|
-
*/
|
|
284
|
-
type TimingProps = {
|
|
285
|
-
/**
|
|
286
|
-
* The timing category
|
|
287
|
-
*/
|
|
288
|
-
category: string;
|
|
289
|
-
/**
|
|
290
|
-
* The timing variable
|
|
291
|
-
*/
|
|
292
|
-
variable: string;
|
|
293
|
-
/**
|
|
294
|
-
* The time
|
|
295
|
-
*/
|
|
296
|
-
timing: number;
|
|
297
|
-
/**
|
|
298
|
-
* The timing label
|
|
299
|
-
*/
|
|
300
|
-
label?: string;
|
|
301
|
-
};
|
|
302
|
-
/**
|
|
303
|
-
* DeepLinkReceived event properties
|
|
304
|
-
* schema: iglu:com.snowplowanalytics.mobile/deep_link_received/jsonschema/1-0-0
|
|
305
|
-
*/
|
|
306
|
-
type DeepLinkReceivedProps = {
|
|
307
|
-
/**
|
|
308
|
-
* URL in the received deep-link.
|
|
309
|
-
*/
|
|
310
|
-
url: string;
|
|
311
|
-
/**
|
|
312
|
-
* Referrer URL, source of this deep-link.
|
|
313
|
-
*/
|
|
314
|
-
referrer?: string;
|
|
315
|
-
};
|
|
316
|
-
/**
|
|
317
|
-
* The ReactNativeTracker type
|
|
318
|
-
*/
|
|
319
|
-
type ReactNativeTracker = {
|
|
320
|
-
/**
|
|
321
|
-
* Tracks a self-describing event
|
|
322
|
-
*
|
|
323
|
-
* @param argmap - The self-describing event properties
|
|
324
|
-
* @param contexts - The array of event contexts
|
|
325
|
-
* @typeParam TData - The type of the data object within the SelfDescribing object
|
|
326
|
-
*/
|
|
327
|
-
readonly trackSelfDescribingEvent: <T extends Record<string, unknown> = Record<string, unknown>>(argmap: SelfDescribingJson<T>, contexts?: EventContext[]) => void;
|
|
328
|
-
// TODO:
|
|
329
|
-
// /**
|
|
330
|
-
// * Tracks a screen-view event
|
|
331
|
-
// *
|
|
332
|
-
// * @param argmap - The screen-view event's properties
|
|
333
|
-
// * @param contexts - The array of event contexts
|
|
334
|
-
// */
|
|
335
|
-
// readonly trackScreenViewEvent: (argmap: ScreenViewProps, contexts?: EventContext[]) => string | undefined;
|
|
336
|
-
// TODO:
|
|
337
|
-
// /**
|
|
338
|
-
// * Tracks a scroll changed event
|
|
339
|
-
// *
|
|
340
|
-
// * @param argmap - The scroll changed event's properties
|
|
341
|
-
// * @param contexts - The array of event contexts
|
|
342
|
-
// */
|
|
343
|
-
// readonly trackScrollChangedEvent: (argmap: ScrollChangedProps, contexts?: EventContext[]) => string | undefined;
|
|
344
|
-
// TODO:
|
|
345
|
-
// /**
|
|
346
|
-
// * Tracks a list item view event
|
|
347
|
-
// *
|
|
348
|
-
// * @param argmap - The list item view event's properties
|
|
349
|
-
// * @param contexts - The array of event contexts
|
|
350
|
-
// */
|
|
351
|
-
// readonly trackListItemViewEvent: (argmap: ListItemViewProps, contexts?: EventContext[]) => string | undefined;
|
|
352
|
-
/**
|
|
353
|
-
* Tracks a structured event
|
|
354
|
-
*
|
|
355
|
-
* @param argmap - The structured event properties
|
|
356
|
-
* @param contexts - The array of event contexts
|
|
357
|
-
*/
|
|
358
|
-
readonly trackStructuredEvent: (argmap: StructuredEvent, contexts?: EventContext[]) => void;
|
|
359
|
-
/**
|
|
360
|
-
* Tracks a page-view event
|
|
361
|
-
*
|
|
362
|
-
* @param argmap - The page-view event properties
|
|
363
|
-
* @param contexts - The array of event contexts
|
|
364
|
-
*/
|
|
365
|
-
readonly trackPageViewEvent: (argmap: PageViewEvent, contexts?: EventContext[]) => void;
|
|
366
|
-
/**
|
|
367
|
-
* Tracks a timing event
|
|
368
|
-
*
|
|
369
|
-
* @param argmap - The timing event properties
|
|
370
|
-
* @param contexts - The array of event contexts
|
|
371
|
-
*/
|
|
372
|
-
readonly trackTimingEvent: (argmap: TimingProps, contexts?: EventContext[]) => void;
|
|
373
|
-
// TODO:
|
|
374
|
-
// /**
|
|
375
|
-
// * Tracks a deep link received event
|
|
376
|
-
// *
|
|
377
|
-
// * @param argmap - The deep link received event properties
|
|
378
|
-
// * @param contexts - The array of event contexts
|
|
379
|
-
// */
|
|
380
|
-
// readonly trackDeepLinkReceivedEvent: (argmap: DeepLinkReceivedProps, contexts?: EventContext[]) => void;
|
|
381
|
-
/**
|
|
382
|
-
* Tracks a message notification event
|
|
383
|
-
*
|
|
384
|
-
* @param argmap - The message notification event properties
|
|
385
|
-
* @param contexts - The array of event contexts
|
|
386
|
-
*/
|
|
387
|
-
readonly trackMessageNotificationEvent: (argmap: MessageNotificationProps, contexts?: EventContext[]) => void;
|
|
388
|
-
/**
|
|
389
|
-
* Adds contexts globally, contexts added here will be attached to all applicable events
|
|
390
|
-
* @param contexts - An array containing either contexts or a conditional contexts
|
|
391
|
-
*/
|
|
392
|
-
addGlobalContexts(contexts: Array<ConditionalContextProvider | ContextPrimitive> | Record<string, ConditionalContextProvider | ContextPrimitive>): void;
|
|
393
|
-
/**
|
|
394
|
-
* Removes all global contexts
|
|
395
|
-
*/
|
|
396
|
-
clearGlobalContexts(): void;
|
|
397
|
-
/**
|
|
398
|
-
* Removes previously added global context, performs a deep comparison of the contexts or conditional contexts
|
|
399
|
-
* @param contexts - An array containing either contexts or a conditional contexts
|
|
400
|
-
*/
|
|
401
|
-
removeGlobalContexts(contexts: Array<ConditionalContextProvider | ContextPrimitive | string>): void;
|
|
402
|
-
/**
|
|
403
|
-
* Add a plugin into the plugin collection after Core has already been initialised
|
|
404
|
-
* @param configuration - The plugin to add
|
|
405
|
-
*/
|
|
406
|
-
addPlugin(configuration: CorePluginConfiguration): void;
|
|
407
|
-
/**
|
|
408
|
-
* Calls flush on all emitters in order to send all queued events to the collector
|
|
409
|
-
* @returns Promise<void> - Promise that resolves when all emitters have flushed
|
|
410
|
-
*/
|
|
411
|
-
flush: () => Promise<void>;
|
|
412
|
-
/**
|
|
413
|
-
* Set the application ID
|
|
414
|
-
*
|
|
415
|
-
* @param appId - An application ID which identifies the current application
|
|
416
|
-
*/
|
|
417
|
-
readonly setAppId: (appId: string) => void;
|
|
418
|
-
/**
|
|
419
|
-
* Set the platform
|
|
420
|
-
*
|
|
421
|
-
* @param value - A valid Snowplow platform value
|
|
422
|
-
*/
|
|
423
|
-
readonly setPlatform: (value: string) => void;
|
|
424
|
-
/**
|
|
425
|
-
* Sets the business-defined user ID for this user
|
|
426
|
-
*
|
|
427
|
-
* @param newUid - The new userId
|
|
428
|
-
*/
|
|
429
|
-
readonly setUserId: (newUid: string) => void;
|
|
430
|
-
/**
|
|
431
|
-
* Override the network user id (UUIDv4) that is assigned by the collector and stored in cookies
|
|
432
|
-
*
|
|
433
|
-
* @param newNuid - The new networkUserId
|
|
434
|
-
*/
|
|
435
|
-
readonly setNetworkUserId: (newNuid: string | undefined) => void;
|
|
436
|
-
/**
|
|
437
|
-
* The domain user id (DUID) is a generated identifier that is stored in a first party cookie on Web.
|
|
438
|
-
* The React Native tracker does not assign it automatically.
|
|
439
|
-
*
|
|
440
|
-
* @param newDuid - The new domainUserId
|
|
441
|
-
*/
|
|
442
|
-
readonly setDomainUserId: (newDuid: string | undefined) => void;
|
|
443
|
-
/**
|
|
444
|
-
* Override the IP address of the device
|
|
445
|
-
*
|
|
446
|
-
* @param newIp - The new ipAddress
|
|
447
|
-
*/
|
|
448
|
-
readonly setIpAddress: (newIp: string) => void;
|
|
449
|
-
/**
|
|
450
|
-
* The custom user-agent. It overrides the user-agent used by default.
|
|
451
|
-
*
|
|
452
|
-
* @param newUagent - The new useragent
|
|
453
|
-
*/
|
|
454
|
-
readonly setUseragent: (newUagent: string) => void;
|
|
455
|
-
/**
|
|
456
|
-
* Sets the timezone of the tracker subject
|
|
457
|
-
*
|
|
458
|
-
* @param newTz - The new timezone
|
|
459
|
-
*/
|
|
460
|
-
readonly setTimezone: (newTz: string) => void;
|
|
461
|
-
/**
|
|
462
|
-
* Sets the language of the tracker subject
|
|
463
|
-
*
|
|
464
|
-
* @param newLang - The new language
|
|
465
|
-
*/
|
|
466
|
-
readonly setLanguage: (newLang: string) => void;
|
|
467
|
-
/**
|
|
468
|
-
* Sets the screenResolution of the tracker subject
|
|
469
|
-
*
|
|
470
|
-
* @param newRes - The new screenResolution
|
|
471
|
-
*/
|
|
472
|
-
readonly setScreenResolution: (newRes: ScreenSize) => void;
|
|
473
|
-
/**
|
|
474
|
-
* Sets the screenViewport of the tracker subject
|
|
475
|
-
*
|
|
476
|
-
* @param newView - The new screenViewport
|
|
477
|
-
*/
|
|
478
|
-
readonly setScreenViewport: (newView: ScreenSize) => void;
|
|
479
|
-
/**
|
|
480
|
-
* Sets the colorDepth of the tracker subject
|
|
481
|
-
*
|
|
482
|
-
* @param newColorD - The new colorDepth
|
|
483
|
-
*/
|
|
484
|
-
readonly setColorDepth: (newLang: number) => void;
|
|
485
|
-
/**
|
|
486
|
-
* Sets subject data
|
|
487
|
-
*
|
|
488
|
-
* @param config - The new subject data
|
|
489
|
-
*/
|
|
490
|
-
readonly setSubjectData: (config: SubjectConfiguration) => void;
|
|
491
|
-
};
|
|
492
|
-
/**
|
|
493
|
-
* Creates a new tracker instance with the given configuration
|
|
494
|
-
* @param configuration - Configuration for the tracker
|
|
495
|
-
* @returns Tracker instance
|
|
496
|
-
*/
|
|
497
|
-
declare function newTracker(configuration: TrackerConfiguration & EmitterConfiguration & SessionConfiguration & SubjectConfiguration & EventStoreConfiguration): Promise<ReactNativeTracker>;
|
|
498
|
-
export { EventStoreConfiguration, SessionConfiguration, TrackerConfiguration, SubjectConfiguration, ScreenSize, Trigger, MessageNotificationAttachmentProps, MessageNotificationProps, EventContext, ScreenViewProps, ScrollChangedProps, ListItemViewProps, TimingProps, DeepLinkReceivedProps, ReactNativeTracker, newTracker };
|
|
499
|
-
export { version, PageViewEvent, StructuredEvent, FormFocusOrChangeEvent, SelfDescribingJson, Timestamp, PayloadBuilder, Payload, CorePlugin, CoreConfiguration, ContextGenerator, ContextFilter, EventPayloadAndContext, EventStore, EventStoreIterator, EventStorePayload, TrackerCore, Logger, EmitterConfiguration, EmitterConfigurationBase, EventJson, JsonProcessor, TrueTimestamp, DeviceTimestamp, EventMethod, RequestFailure, EventBatch, EventJsonWithKeys, LOG_LEVEL, ConditionalContextProvider, ContextPrimitive, CorePluginConfiguration, Emitter, FilterProvider, RuleSetProvider, RuleSet } from "@snowplow/tracker-core";
|
package/dist/index.cjs.min.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* React Native tracker for Snowplow v4.0.2-dev.0 (https://docs.snowplow.io/docs/collecting-data/collecting-from-own-applications/javascript-trackers/)
|
|
3
|
-
* Copyright 2022 Snowplow Analytics Ltd, 2010 Anthon Pang
|
|
4
|
-
* Licensed under BSD-3-Clause
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
'use strict';(function(C,G){"object"===typeof exports&&"undefined"!==typeof module?G(exports):"function"===typeof define&&define.amd?define(["exports"],G):(C="undefined"!==typeof globalThis?globalThis:C||self,G(C.snowplowBrowserTracking={}))})(this,function(C){function G(a,b,c,d){function e(g){return g instanceof c?g:new c(function(h){h(g)})}return new (c||(c=Promise))(function(g,h){function k(n){try{l(d.next(n))}catch(p){h(p)}}function f(n){try{l(d["throw"](n))}catch(p){h(p)}}function l(n){n.done?
|
|
8
|
-
g(n.value):e(n.value).then(k,f)}l((d=d.apply(a,b||[])).next())})}function J(a,b){function c(l){return function(n){return d([l,n])}}function d(l){if(g)throw new TypeError("Generator is already executing.");for(;f&&(f=0,l[0]&&(e=0)),e;)try{if(g=1,h&&(k=l[0]&2?h["return"]:l[0]?h["throw"]||((k=h["return"])&&k.call(h),0):h.next)&&!(k=k.call(h,l[1])).done)return k;if(h=0,k)l=[l[0]&2,k.value];switch(l[0]){case 0:case 1:k=l;break;case 4:return e.label++,{value:l[1],done:!1};case 5:e.label++;h=l[1];l=[0];
|
|
9
|
-
continue;case 7:l=e.ops.pop();e.trys.pop();continue;default:if(!(k=e.trys,k=0<k.length&&k[k.length-1])&&(6===l[0]||2===l[0])){e=0;continue}if(3===l[0]&&(!k||l[1]>k[0]&&l[1]<k[3]))e.label=l[1];else if(6===l[0]&&e.label<k[1])e.label=k[1],k=l;else if(k&&e.label<k[2])e.label=k[2],e.ops.push(l);else{k[2]&&e.ops.pop();e.trys.pop();continue}}l=b.call(a,e)}catch(n){l=[6,n],h=0}finally{g=k=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}var e={label:0,sent:function(){if(k[0]&1)throw k[1];return k[1]},
|
|
10
|
-
trys:[],ops:[]},g,h,k,f=Object.create(("function"===typeof Iterator?Iterator:Object).prototype);return f.next=c(0),f["throw"]=c(1),f["return"]=c(2),"function"===typeof Symbol&&(f[Symbol.iterator]=function(){return this}),f}function K(a,b,c){if(c||2===arguments.length)for(var d=0,e=b.length,g;d<e;d++)!g&&d in b||(g||(g=Array.prototype.slice.call(b,0,d)),g[d]=b[d]);return a.concat(g||Array.prototype.slice.call(b))}function Oa(a,b=0){return(D[a[b+0]]+D[a[b+1]]+D[a[b+2]]+D[a[b+3]]+"-"+D[a[b+4]]+D[a[b+
|
|
11
|
-
5]]+"-"+D[a[b+6]]+D[a[b+7]]+"-"+D[a[b+8]]+D[a[b+9]]+"-"+D[a[b+10]]+D[a[b+11]]+D[a[b+12]]+D[a[b+13]]+D[a[b+14]]+D[a[b+15]]).toLowerCase()}function Pa(){if(!ca&&(ca="undefined"!==typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!ca))throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ca(Qa)}function Ra(a,b,c){if(ua.randomUUID&&!b&&!a)return ua.randomUUID();a=a||{};a=a.random||(a.rng||Pa)();a[6]=a[6]&
|
|
12
|
-
15|64;a[8]=a[8]&63|128;if(b){c=c||0;for(var d=0;16>d;++d)b[c+d]=a[d];return b}return Oa(a)}function Sa(a){var b=0,c=0;var d="";var e=[];if(!a)return a;a+="";do{var g=R.indexOf(a.charAt(b++));var h=R.indexOf(a.charAt(b++));d=R.indexOf(a.charAt(b++));var k=R.indexOf(a.charAt(b++));var f=g<<18|h<<12|d<<6|k;g=f>>16&255;h=f>>8&255;f&=255;64===d?e[c++]=String.fromCharCode(g):64===k?e[c++]=String.fromCharCode(g,h):e[c++]=String.fromCharCode(g,h,f)}while(b<a.length);d=e.join("");return function(l){return decodeURIComponent(l.split("").map(function(n){return"%"+
|
|
13
|
-
("00"+n.charCodeAt(0).toString(16)).slice(-2)}).join(""))}(d.replace(/\0+$/,""))}function ma(){var a={},b=[],c=[],d=[],e,g=function(h,k){null!=k&&""!==k&&(a[h]=k)};return{add:g,addDict:function(h){for(var k in h)Object.prototype.hasOwnProperty.call(h,k)&&g(k,h[k])},addJson:function(h,k,f){f&&va(f)&&(h={keyIfEncoded:h,keyIfNotEncoded:k,json:f},c.push(h),b.push(h))},addContextEntity:function(h){d.push(h)},getPayload:function(){return a},getJson:function(){return b},withJsonProcessor:function(h){e=h},
|
|
14
|
-
build:function(){null===e||void 0===e?void 0:e(this,c,d);return a}}}function Ta(a){return function(b,c,d){for(var e=function(l,n,p){l=JSON.stringify(l);if(a){p=b.add;if(l){var q=0,m=0,r=[];if(l){l=unescape(encodeURIComponent(l));do{var z=l.charCodeAt(q++);var A=l.charCodeAt(q++);var v=l.charCodeAt(q++);var w=z<<16|A<<8|v;z=w>>18&63;A=w>>12&63;v=w>>6&63;w&=63;r[m++]=R.charAt(z)+R.charAt(A)+R.charAt(v)+R.charAt(w)}while(q<l.length);q=r.join("");l=l.length%3;l=(l?q.slice(0,l-3):q)+"===".slice(l||3)}l=
|
|
15
|
-
l.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}p.call(b,n,l)}else b.add(p,l)},g=function(l,n){if(!l){var p=b.getPayload();if(a?p.cx:p.co){l=JSON;var q=l.parse;if(a){if(p=p.cx){switch(4-p.length%4){case 2:p+="==";break;case 3:p+="="}p=p.replace(/-/g,"+").replace(/_/g,"/");p=Sa(p)}}else p=p.co;l=q.call(l,p)}else l=void 0}l?l.data=l.data.concat(n.data):l=n;return l},h=void 0,k=0;k<c.length;k++){var f=c[k];"cx"===f.keyIfEncoded?h=g(h,f.json):e(f.json,f.keyIfEncoded,f.keyIfNotEncoded)}c.length=
|
|
16
|
-
0;d.length&&(c={schema:"iglu:com.snowplowanalytics.snowplow/contexts/jsonschema/1-0-0",data:K([],d,!0)},h=g(h,c),d.length=0);h&&e(h,"cx","co")}}function va(a){if(!wa(a))return!1;for(var b in a)if(Object.prototype.hasOwnProperty.call(a,b))return!0;return!1}function wa(a){return"undefined"!==typeof a&&null!==a&&(a.constructor==={}.constructor||a.constructor===[].constructor)}function Ua(){var a=[],b=[],c={},d={};return{getGlobalPrimitives:function(){return a.concat(Object.values(c))},getConditionalProviders:function(){return b.concat(Object.values(d))},
|
|
17
|
-
addGlobalContexts:function(e){if(Array.isArray(e)){for(var g=[],h=[],k=0;k<e.length;k++){var f=e[k];Z(f)?g.push(f):N(f)&&h.push(f)}a=a.concat(h);b=b.concat(g)}else for(g=0,e=Object.entries(e);g<e.length;g++)f=e[g],h=f[0],f=f[1],Z(f)?d[h]=f:N(f)&&(c[h]=f)},clearGlobalContexts:function(){b=[];a=[];d={};c={}},removeGlobalContexts:function(e){for(var g=function(k){"string"===typeof k?(delete d[k],delete c[k]):Z(k)?b=b.filter(function(f){return!xa(k,f)}):N(k)&&(a=a.filter(function(f){return!xa(k,f)}))},
|
|
18
|
-
h=0;h<e.length;h++)g(e[h])},getApplicableContexts:function(e){a:{var g=0;for(var h=e.getJson();g<h.length;g++){var k=h[g];if("ue_px"===k.keyIfEncoded&&"object"===typeof k.json.data&&(k=k.json.data.schema,"string"==typeof k)){g=k;break a}}g=""}h=e.getPayload().e;k="string"===typeof h?h:"";h=[];var f=na(a.concat(Object.values(c)),e,k,g);h.push.apply(h,f);e=Va(b.concat(Object.values(d)),e,k,g);h.push.apply(h,e);return h}}}function Wa(a){return{addPluginContexts:function(b){var c=b?K([],b,!0):[];a.forEach(function(d){try{d.contexts&&
|
|
19
|
-
c.push.apply(c,d.contexts())}catch(e){I.error("Error adding plugin contexts",e)}});return c}}}function Xa(a){if("*"===a[0]||"*"===a[1])return!1;if(0<a.slice(2).length){var b=!1,c=0;for(a=a.slice(2);c<a.length;c++)if("*"===a[c])b=!0;else if(b)return!1;return!0}return 2==a.length?!0:!1}function ya(a){return(a=a.split("."))&&1<a.length?Xa(a):!1}function za(a){a=/^iglu:((?:(?:[a-zA-Z0-9-_]+|\*).)+(?:[a-zA-Z0-9-_]+|\*))\/([a-zA-Z0-9-_.]+|\*)\/jsonschema\/([1-9][0-9]*|\*)-(0|[1-9][0-9]*|\*)-(0|[1-9][0-9]*|\*)$/.exec(a);
|
|
20
|
-
if(null!==a&&ya(a[1]))return a.slice(1,6)}function oa(a){if(a=za(a)){var b=a[0];return 5===a.length&&ya(b)}return!1}function Ya(a){return Array.isArray(a)&&a.every(function(b){return"string"===typeof b})}function Aa(a){return Ya(a)?a.every(function(b){return oa(b)}):"string"===typeof a?oa(a):!1}function aa(a){return va(a)&&"schema"in a&&"data"in a?"string"===typeof a.schema&&"object"===typeof a.data:!1}function Za(a){var b=0;if(null!=a&&"object"===typeof a&&!Array.isArray(a)){if(Object.prototype.hasOwnProperty.call(a,
|
|
21
|
-
"accept"))if(Aa(a.accept))b+=1;else return!1;if(Object.prototype.hasOwnProperty.call(a,"reject"))if(Aa(a.reject))b+=1;else return!1;return 0<b&&2>=b}return!1}function da(a){return"function"===typeof a&&1>=a.length}function N(a){return da(a)||aa(a)}function Ba(a){return Array.isArray(a)&&2===a.length?Array.isArray(a[1])?da(a[0])&&a[1].every(N):da(a[0])&&N(a[1]):!1}function Ca(a){return Array.isArray(a)&&2===a.length?Za(a[0])?Array.isArray(a[1])?a[1].every(N):N(a[1]):!1:!1}function Z(a){return Ba(a)||
|
|
22
|
-
Ca(a)}function $a(a,b){var c=0,d=0,e=a.accept;Array.isArray(e)?a.accept.some(function(g){return ea(g,b)})&&d++:"string"===typeof e&&ea(e,b)&&d++;e=a.reject;Array.isArray(e)?a.reject.some(function(g){return ea(g,b)})&&c++:"string"===typeof e&&ea(e,b)&&c++;return 0<d&&0===c?!0:!1}function ea(a,b){if(!oa(a))return!1;a=za(a);b=/^iglu:([a-zA-Z0-9-_.]+)\/([a-zA-Z0-9-_]+)\/jsonschema\/([1-9][0-9]*)-(0|[1-9][0-9]*)-(0|[1-9][0-9]*)$/.exec(b);b=null!==b?b.slice(1,6):void 0;if(a&&b){if(!ab(a[0],b[0]))return!1;
|
|
23
|
-
for(var c=1;5>c;c++)if(!Da(a[c],b[c]))return!1;return!0}return!1}function ab(a,b){b=b.split(".");a=a.split(".");if(b&&a){if(b.length!==a.length)return!1;for(var c=0;c<a.length;c++)if(!Da(b[c],a[c]))return!1;return!0}return!1}function Da(a,b){return a&&b&&"*"===a||a===b}function Ea(a){return Array.isArray(a)?a:[a]}function na(a,b,c,d){var e;a=Ea(a).map(function(g){a:if(aa(g))g=[g];else{if(da(g)){b:{var h=void 0;try{var k={event:b.getPayload(),eventType:c,eventSchema:d};h=g(k);if(Array.isArray(h)&&
|
|
24
|
-
h.every(aa)||aa(h)){var f=h;break b}f=void 0;break b}catch(l){}f=void 0}if(aa(f)){g=[f];break a}else if(Array.isArray(f)){g=f;break a}}g=void 0}if(g&&0!==g.length)return g});return(e=[]).concat.apply(e,a.filter(function(g){return null!=g&&g.filter(Boolean)}))}function fa(a,b){return"function"===typeof a?a===b:JSON.stringify(a)===JSON.stringify(b)}function xa(a,b){if(Z(a)){if(!Z(b))return!1;var c=a[1],d=b[1];return fa(a[0],b[0])?Array.isArray(c)?Array.isArray(d)&&c.length===d.length?c.reduce(function(e,
|
|
25
|
-
g,h){return e&&fa(g,d[h])},!0):!1:Array.isArray(d)?!1:fa(c,d):!1}return N(a)?N(b)?fa(a,b):!1:!1}function Va(a,b,c,d){var e;a=Ea(a).map(function(g){a:{if(Ba(g)){var h=g[0],k=!1;try{var f={event:b.getPayload(),eventType:c,eventSchema:d};k=h(f)}catch(l){k=!1}if(!0===k){g=na(g[1],b,c,d);break a}}else if(Ca(g)&&$a(g[0],d)){g=na(g[1],b,c,d);break a}g=[]}if(g&&0!==g.length)return g});return(e=[]).concat.apply(e,a.filter(function(g){return null!=g&&g.filter(Boolean)}))}function bb(a){return null==a?{type:"dtm",
|
|
26
|
-
value:(new Date).getTime()}:"number"===typeof a?{type:"dtm",value:a}:"ttm"===a.type?{type:"ttm",value:a.value}:{type:"dtm",value:a.value||(new Date).getTime()}}function cb(a){void 0===a&&(a={});var b=a.base64,c=a.corePlugins,d=null!==c&&void 0!==c?c:[];a=function(g,h,k){function f(m,r){m=n.getApplicableContexts(m);var z=[];r&&r.length&&z.push.apply(z,r);m&&m.length&&z.push.apply(z,m);return z}var l=Wa(h),n=Ua(),p=g,q={};return{track:function(m,r,z){m.withJsonProcessor(Ta(p));m.add("eid",Ra());m.addDict(q);
|
|
27
|
-
z=bb(z);m.add(z.type,z.value.toString());r=f(m,l.addPluginContexts(r));r=r&&r.length?{schema:"iglu:com.snowplowanalytics.snowplow/contexts/jsonschema/1-0-0",data:r}:void 0;void 0!==r&&m.addJson("cx","co",r);h.forEach(function(v){try{v.beforeTrack&&v.beforeTrack(m)}catch(w){I.error("Plugin beforeTrack",w)}});if(!h.find(function(v){try{return v.filter&&!1===v.filter(m.build())}catch(w){return I.error("Plugin filter",w),!1}})){"function"===typeof k&&k(m);var A=m.build();h.forEach(function(v){try{v.afterTrack&&
|
|
28
|
-
v.afterTrack(A)}catch(w){I.error("Plugin afterTrack",w)}});return A}},addPayloadPair:function(m,r){q[m]=r},getBase64Encoding:function(){return p},setBase64Encoding:function(m){p=m},addPayloadDict:function(m){for(var r in m)Object.prototype.hasOwnProperty.call(m,r)&&(q[r]=m[r])},resetPayloadPairs:function(m){q=wa(m)?m:{}},setTrackerVersion:function(m){q.tv=m},setTrackerNamespace:function(m){q.tna=m},setAppId:function(m){q.aid=m},setPlatform:function(m){q.p=m},setUserId:function(m){q.uid=m},setScreenResolution:function(m,
|
|
29
|
-
r){q.res=m+"x"+r},setViewport:function(m,r){q.vp=m+"x"+r},setColorDepth:function(m){q.cd=m},setTimezone:function(m){q.tz=m},setLang:function(m){q.lang=m},setIpAddress:function(m){q.ip=m},setUseragent:function(m){q.ua=m},addGlobalContexts:function(m){n.addGlobalContexts(m)},clearGlobalContexts:function(){n.clearGlobalContexts()},removeGlobalContexts:function(m){n.removeGlobalContexts(m)}}}(null!==b&&void 0!==b?b:!0,d,a.callback);var e=S(S({},a),{addPlugin:function(g){var h,k;g=g.plugin;d.push(g);null===
|
|
30
|
-
(h=g.logger)||void 0===h?void 0:h.call(g,I);null===(k=g.activateCorePlugin)||void 0===k?void 0:k.call(g,e)}});null===d||void 0===d?void 0:d.forEach(function(g){var h,k;null===(h=g.logger)||void 0===h?void 0:h.call(g,I);null===(k=g.activateCorePlugin)||void 0===k?void 0:k.call(g,e)});return e}function pa(a){var b=a.maxSize,c=void 0===b?1E3:b;a=a.events;var d=K([],void 0===a?[]:a,!0),e=function(){return Promise.resolve(d.length)};return{count:e,add:function(g){for(d.push(g);d.length>c;)d.shift();return e()},
|
|
31
|
-
removeHead:function(g){for(var h=0;h<g;h++)d.shift();return Promise.resolve()},iterator:function(){var g=0,h=K([],d,!0);return{next:function(){return g<h.length?Promise.resolve({value:h[g++],done:!1}):Promise.resolve({value:void 0,done:!0})}}},getAll:function(){return Promise.resolve(K([],d,!0))},getAllPayloads:function(){return Promise.resolve(d.map(function(g){return g.payload}))}}}function db(a){for(var b=(new Date).getTime().toString(),c=0;c<a.length;c++)a[c].stm=b;return a}function eb(a){function b(){var x=
|
|
32
|
-
E.reduce(function(H,O){return H+(T?O.getPOSTRequestBytesCount():O.getGETRequestBytesCount())},0);T&&(x+=88);return x}function c(){var x=new Headers;T&&x.append("Content-Type","application/json; charset=UTF-8");p&&Object.keys(p).forEach(function(H){x.append(H,p[H])});0<E.length&&E[0].getServerAnonymization()&&x.append("SP-Anonymous","*");return x}function d(){var x=k;k.includes("://")||(x="".concat(l,"://").concat(k));n&&(x="".concat(x,":").concat(n));return x+(T?z:"/i")}function e(x,H){h(!1);P=new AbortController;
|
|
33
|
-
U=setTimeout(function(){console.error("Request timed out");U=void 0;h(!1,"Request timed out")},null!==q&&void 0!==q?q:5E3);H=S({headers:c(),signal:P.signal,keepalive:r,credentials:w},H);return new Request(x,H)}function g(){var x=db(E.map(function(H){return H.getPOSTRequestBody()}));return e(d(),{method:"POST",body:JSON.stringify({schema:"iglu:com.snowplowanalytics.snowplow/payload_data/jsonschema/1-0-4",data:x})})}function h(x,H){void 0!==U&&(clearTimeout(U),U=void 0);if(void 0!==P){var O=P;P=void 0;
|
|
34
|
-
x||O.abort(H)}}var k=a.endpoint,f=a.protocol,l=void 0===f?"https":f,n=a.port;f=a.eventMethod;var p=a.customHeaders,q=a.connectionTimeout,m=a.keepalive,r=void 0===m?!1:m;m=a.postPath;var z=void 0===m?"/com.snowplowanalytics.snowplow/tp2":m;m=a.useStm;var A=void 0===m?!0:m;m=a.maxPostBytes;var v=void 0===m?4E4:m;a=a.credentials;var w=void 0===a?"include":a,E=[],T="post"===(void 0===f?"post":f).toLowerCase(),U,P;return{addEvent:function(x){if(0<E.length&&(0<E.length?E[0].getServerAnonymization():void 0)!==
|
|
35
|
-
x.getServerAnonymization())return!1;E.push(x);return!0},getEvents:function(){return E},toRequest:function(){if(0!==E.length){if(T)return g();if(1!==E.length)throw Error("Only one event can be sent in a GET request");var x=E[0].getGETRequestURL(d(),A);return e(x,{method:"GET"})}},countBytes:b,countEvents:function(){return E.length},isFull:function(){return T?b()>=v:1<=E.length},closeRequest:h}}function Fa(a){for(var b=0,c=0;c<a.length;c++){var d=a.charCodeAt(c);127>=d?b+=1:2047>=d?b+=2:55296<=d&&57343>=
|
|
36
|
-
d?(b+=4,c++):b=65535>d?b+3:b+4}return b}function fb(a){return Object.keys(a).map(function(b){return[b,a[b]]}).reduce(function(b,c){b[c[0]]=c[1].toString();return b},{})}function Ga(a){function b(){return a.payload}function c(f){if(null===e){var l={co:!0,cx:!0},n=[],p;for(p in f)f.hasOwnProperty(p)&&!l[p]&&n.push(p+"="+encodeURIComponent(f[p]));for(var q in l)f.hasOwnProperty(q)&&l[q]&&n.push(q+"="+encodeURIComponent(f[q]));e="?"+n.join("&")}return e}function d(){null===g&&(g=fb(b()));return g}var e=
|
|
37
|
-
null,g=null,h=null,k=null;return{getPayload:b,getServerAnonymization:function(){var f;return null!==(f=a.svrAnon)&&void 0!==f?f:!1},getGETRequestURL:function(f,l){var n=c(b());return l?f+n.replace("?","?stm="+(new Date).getTime()+"&"):f+n},getGETRequestBytesCount:function(){if(null===h){var f=c(b());h=Fa(f)}return h},getPOSTRequestBody:d,getPOSTRequestBytesCount:function(){null===k&&(k=Fa(JSON.stringify(d())));return k}}}function gb(a){function b(t){return 200<=t&&300>t||!H?!1:x.includes(t)?!0:!P.includes(t)}
|
|
38
|
-
function c(t,y){void 0!==ha&&setTimeout(function(){try{null===ha||void 0===ha?void 0:ha(t,y)}catch(F){I.error("Error in onRequestSuccess",F)}},0)}function d(t,y){void 0!==O&&setTimeout(function(){try{null===O||void 0===O?void 0:O(t,y)}catch(F){I.error("Error in onRequestFailure",F)}},0)}function e(t){return G(this,void 0,void 0,function(){var y,F,B,V,u,L;return J(this,function(M){switch(M.label){case 0:y=t.toRequest();if(void 0===y)throw Error("Empty batch");F=t.getEvents().map(function(ia){return ia.getPayload()});
|
|
39
|
-
M.label=1;case 1:return M.trys.push([1,4,,5]),[4,Ha(y)];case 2:return B=M.sent(),[4,B.text()];case 3:M.sent();t.closeRequest(!0);if(B.ok)return c(F,B),[2,{success:!0,retry:!1,status:B.status}];V=b(B.status);d({events:F,status:B.status,message:B.statusText,willRetry:V},B);return[2,{success:!1,retry:V,status:B.status}];case 4:return u=M.sent(),t.closeRequest(!1),L="string"===typeof u?u:u?u.message:"Unknown error",d({events:F,message:L,willRetry:!0}),[2,{success:!1,retry:!0}];case 5:return[2]}})})}function g(){return eb({endpoint:l,
|
|
40
|
-
protocol:q,port:m,eventMethod:p,customHeaders:v,connectionTimeout:E,keepalive:T,maxPostBytes:r,useStm:hb,credentials:ib})}function h(){return G(this,void 0,void 0,function(){var t;return J(this,function(y){switch(y.label){case 0:if(!U||Ia)return[3,2];Ia=!0;t=new Request(U,{method:"GET"});return[4,Ha(t)];case 1:y.sent(),y.label=2;case 2:return[2]}})})}function k(){return G(this,void 0,void 0,function(){var t;return J(this,function(y){switch(y.label){case 0:if(qa)return[3,5];qa=!0;y.label=1;case 1:return y.trys.push([1,
|
|
41
|
-
3,4,5]),[4,f()];case 2:return y.sent(),[3,5];case 3:return t=y.sent(),I.error("Error sending events",t),[3,5];case 4:return qa=!1,[7];case 5:return[2]}})})}function f(){return G(this,void 0,void 0,function(){var t,y,F,B,V,u,L,M,ia,Ja;return J(this,function(Q){switch(Q.label){case 0:return[4,h()];case 1:Q.sent(),t=g(),y=ra.iterator(),Q.label=2;case 2:return t.isFull()?[3,4]:[4,y.next()];case 3:F=Q.sent();B=F.value;if((V=F.done)||void 0===B)return[3,4];u=Ga(B);return t.addEvent(u)?[3,2]:[3,4];case 4:return 0===
|
|
42
|
-
t.countEvents()?[2]:[4,e(t)];case 5:L=Q.sent();M=L.success;ia=L.retry;Ja=L.status;if(!M&&ia)return[3,7];M||I.error("Status ".concat(Ja,", will not retry."));return[4,ra.removeHead(t.countEvents())];case 6:Q.sent(),Q.label=7;case 7:return M?[4,f()]:[3,9];case 8:Q.sent(),Q.label=9;case 9:return[2]}})})}var l=a.endpoint,n=a.eventMethod,p=void 0===n?"post":n,q=a.protocol,m=a.port;n=a.maxPostBytes;var r=void 0===n?4E4:n,z=a.maxGetBytes;n=a.bufferSize;var A=void 0===n?1:n,v=a.customHeaders,w=a.serverAnonymization,
|
|
43
|
-
E=a.connectionTimeout,T=a.keepalive,U=a.idService;n=a.dontRetryStatusCodes;var P=void 0===n?[]:n;n=a.retryStatusCodes;var x=void 0===n?[]:n;n=a.retryFailedRequests;var H=void 0===n?!0:n,O=a.onRequestFailure,ha=a.onRequestSuccess;n=a.customFetch;var Ha=void 0===n?fetch:n,hb=a.useStm;n=a.eventStore;var ra=void 0===n?pa({}):n,ib=a.credentials,Ia=!1,qa=!1,jb="post"===p.toLowerCase();P=P.concat([400,401,403,410,422]);return{flush:k,input:function(t){return G(this,void 0,void 0,function(){var y,F,B,V;return J(this,
|
|
44
|
-
function(u){switch(u.label){case 0:u=w;y={payload:t,svrAnon:void 0===u?!1:u};F=Ga(y);a:{u=F;if(jb){u=u.getPOSTRequestBytesCount()+88;var L=u>r;L&&I.warn("Event ("+u+"B) too big, max is "+r)}else{if(void 0===z){u=!1;break a}u=u.getGETRequestBytesCount();(L=u>z)&&I.warn("Event ("+u+"B) too big, max is "+z)}u=L}if(!u)return[3,2];B=g();B.addEvent(F);return[4,e(B)];case 1:return u.sent(),[3,5];case 2:return[4,ra.add(y)];case 3:return V=u.sent(),V>=A?[4,k()]:[3,5];case 4:u.sent(),u.label=5;case 5:return[2]}})})},
|
|
45
|
-
setCollectorUrl:function(t){l=t},setAnonymousTracking:function(t){w=t},setBufferSize:function(t){A=t}}}function W(a){return Array.isArray(a)?kb(a):ja(a)?lb(a):a}function kb(a){let b=a.slice(0,0);ka(a).forEach(c=>{X(b,c,W(a[c]))});return b}function lb(a){let b=null===Object.getPrototypeOf(a)?Object.create(null):{};ka(a).forEach(c=>{X(b,c,W(a[c]))});return b}function sa(a,b,c){return c.concatArrays&&Array.isArray(a)&&Array.isArray(b)?mb(a,b,c):ja(b)&&ja(a)?Ka(a,b,ka(b),c):W(b)}function Y(a,b){return new Promise((c,
|
|
46
|
-
d)=>{try{let e=a();null===b||void 0===b?void 0:b(null,e);c(e)}catch(e){null===b||void 0===b?void 0:b(e),d(e)}})}function la(a,b,c){return Promise.all(a).then(d=>{d=(null===c||void 0===c?void 0:c(d))??null;null===b||void 0===b?void 0:b(null,d);return Promise.resolve(d)},d=>{null===b||void 0===b?void 0:b(d);return Promise.reject(d)})}function nb(a){var b=a.namespace,c=a.maxEventStoreSize,d=void 0===c?1E3:c;a=a.useAsyncStorageForEventStore;var e=void 0===a?!0:a;return G(this,void 0,void 0,function(){function g(){return G(this,
|
|
47
|
-
void 0,void 0,function(){var A,v;return J(this,function(w){switch(w.label){case 0:return e?[4,La.getItem(k)]:[3,2];case 1:return v=(A=w.sent())?JSON.parse(A):[],[2,pa({maxSize:d,events:v})];case 2:return[2,pa({maxSize:d})]}})})}function h(){return G(this,void 0,void 0,function(){var A;return J(this,function(v){switch(v.label){case 0:return e?[4,l()]:[3,3];case 1:return A=v.sent(),[4,La.setItem(k,JSON.stringify(A))];case 2:v.sent(),v.label=3;case 3:return[2]}})})}var k,f,l,n,p,q,m,r,z=this;return J(this,
|
|
48
|
-
function(A){switch(A.label){case 0:return k="snowplow_".concat(b),[4,g()];case 1:return f=A.sent(),l=f.getAll,n=f.getAllPayloads,p=f.add,q=f.count,m=f.iterator,r=f.removeHead,[2,{count:q,add:function(v){return G(z,void 0,void 0,function(){return J(this,function(w){switch(w.label){case 0:return[4,p(v)];case 1:return w.sent(),[4,h()];case 2:return w.sent(),[4,q()];case 3:return[2,w.sent()]}})})},removeHead:function(v){return G(z,void 0,void 0,function(){return J(this,function(w){switch(w.label){case 0:return r(v),
|
|
49
|
-
[4,h()];case 1:return w.sent(),[2]}})})},iterator:m,getAll:l,getAllPayloads:n}]}})})}function ob(a){var b=function(c,d){var e=a.track,g=c.schema,h=c.data;c=ma();g={schema:"iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0",data:{schema:g,data:h}};c.add("e","ue");c.addJson("ue_px","ue_pr",g);e.call(a,c,d)};return{trackSelfDescribingEvent:b,trackStructuredEvent:function(c,d){var e,g=a.track,h=c.category,k=c.action,f=c.label,l=c.property;c=c.value;var n=ma();n.add("e","se");n.add("se_ca",
|
|
50
|
-
h);n.add("se_ac",k);n.add("se_la",f);n.add("se_pr",l);n.add("se_va",null==c?void 0:c.toString());return null===(e=g.call(a,n,d))||void 0===e?void 0:e.eid},trackPageViewEvent:function(c,d){var e,g=a.track,h=c.pageUrl,k=c.pageTitle;c=c.referrer;var f=ma();f.add("e","pv");f.add("url",h);f.add("page",k);f.add("refr",c);return null===(e=g.call(a,f,d))||void 0===e?void 0:e.eid},trackTimingEvent:function(c,d){b({schema:"iglu:com.snowplowanalytics.snowplow/timing/jsonschema/1-0-0",data:c},d)},trackMessageNotificationEvent:function(c,
|
|
51
|
-
d){b({schema:"iglu:com.snowplowanalytics.mobile/message_notification/jsonschema/1-0-0",data:c},d)}}}function pb(a,b){var c,d,e=function(f){return a.setScreenResolution(String(f[0]),String(f[1]))},g=function(f){a.setColorDepth(String(f))},h=function(f){a.setViewport(String(f[0]),String(f[1]))},k=function(f){d=f.networkUserId;c=f.domainUserId;f.userId&&a.setUserId(f.userId);f.useragent&&a.setUseragent(f.useragent);f.ipAddress&&a.setIpAddress(f.ipAddress);f.timezone&&a.setTimezone(f.timezone);f.language&&
|
|
52
|
-
a.setLang(f.language);f.screenResolution&&e(f.screenResolution);f.colorDepth&&g(f.colorDepth);f.screenViewport&&h(f.screenViewport)};b&&k(b);return{subjectPlugin:{plugin:{beforeTrack:function(f){f.add("duid",c);f.add("nuid",d)}}},properties:{setUserId:a.setUserId,setIpAddress:a.setIpAddress,setUseragent:a.setUseragent,setTimezone:a.setTimezone,setLanguage:a.setLang,setScreenResolution:e,setNetworkUserId:function(f){d=f},setDomainUserId:function(f){c=f},setSubjectData:k,setColorDepth:g,setScreenViewport:h}}}
|
|
53
|
-
var S=function(){S=Object.assign||function(a){for(var b,c=1,d=arguments.length;c<d;c++){b=arguments[c];for(var e in b)Object.prototype.hasOwnProperty.call(b,e)&&(a[e]=b[e])}return a};return S.apply(this,arguments)};"function"===typeof SuppressedError?SuppressedError:function(a,b,c){c=Error(c);return c.name="SuppressedError",c.error=a,c.suppressed=b,c};for(var D=[],ta=0;256>ta;++ta)D.push((ta+256).toString(16).slice(1));var ca,Qa=new Uint8Array(16),ua={randomUUID:"undefined"!==typeof crypto&&crypto.randomUUID&&
|
|
54
|
-
crypto.randomUUID.bind(crypto)},R="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";C.LOG_LEVEL=void 0;(function(a){a[a.none=0]="none";a[a.error=1]="error";a[a.warn=2]="warn";a[a.debug=3]="debug";a[a.info=4]="info"})(C.LOG_LEVEL||(C.LOG_LEVEL={}));var I=function(a){void 0===a&&(a=C.LOG_LEVEL.warn);return{setLogLevel:function(b){a=C.LOG_LEVEL[b]?b:C.LOG_LEVEL.warn},warn:function(b,c){for(var d=[],e=2;e<arguments.length;e++)d[e-2]=arguments[e];a>=C.LOG_LEVEL.warn&&"undefined"!==typeof console&&
|
|
55
|
-
(e="Snowplow: "+b,c?console.warn.apply(console,K([e+"\n",c],d,!1)):console.warn.apply(console,K([e],d,!1)))},error:function(b,c){for(var d=[],e=2;e<arguments.length;e++)d[e-2]=arguments[e];a>=C.LOG_LEVEL.error&&"undefined"!==typeof console&&(e="Snowplow: "+b+"\n",c?console.error.apply(console,K([e+"\n",c],d,!1)):console.error.apply(console,K([e],d,!1)))},debug:function(b){for(var c=[],d=1;d<arguments.length;d++)c[d-1]=arguments[d];a>=C.LOG_LEVEL.debug&&"undefined"!==typeof console&&console.debug.apply(console,
|
|
56
|
-
K(["Snowplow: "+b],c,!1))},info:function(b){for(var c=[],d=1;d<arguments.length;d++)c[d-1]=arguments[d];a>=C.LOG_LEVEL.info&&"undefined"!==typeof console&&console.info.apply(console,K(["Snowplow: "+b],c,!1))}}}(),qb="undefined"!==typeof globalThis?globalThis:"undefined"!==typeof window?window:"undefined"!==typeof global?global:"undefined"!==typeof self?self:{};let ja=a=>{if("[object Object]"!==Object.prototype.toString.call(a))return!1;a=Object.getPrototypeOf(a);return null===a||a===Object.prototype},
|
|
57
|
-
{hasOwnProperty:Ma}=Object.prototype,{propertyIsEnumerable:rb}=Object,X=(a,b,c)=>Object.defineProperty(a,b,{value:c,writable:!0,enumerable:!0,configurable:!0}),Na={concatArrays:!1,ignoreUndefined:!1},ka=a=>{const b=[];for(var c in a)Ma.call(a,c)&&b.push(c);if(Object.getOwnPropertySymbols){c=Object.getOwnPropertySymbols(a);for(const d of c)rb.call(a,d)&&b.push(d)}return b},Ka=(a,b,c,d)=>{c.forEach(e=>{"undefined"===typeof b[e]&&d.ignoreUndefined||(e in a&&a[e]!==Object.getPrototypeOf(a)?X(a,e,sa(a[e],
|
|
58
|
-
b[e],d)):X(a,e,W(b[e])))});return a},mb=(a,b,c)=>{let d=a.slice(0,0),e=0;[a,b].forEach(g=>{const h=[];for(let k=0;k<g.length;k++)Ma.call(g,k)&&(h.push(String(k)),g===a?X(d,e++,g[k]):X(d,e++,W(g[k])));d=Ka(d,g,ka(g).filter(k=>!h.includes(k)),c)});return d},sb=function(...a){let b=sa(W(Na),this!==qb&&this||{},Na),c={_:{}};for(let d of a)if(void 0!==d){if(!ja(d))throw new TypeError("`"+d+"` is not an Option Object");c=sa(c,{_:d},b)}return c._}.bind({concatArrays:!0,ignoreUndefined:!0}),ba={getItem:(a,
|
|
59
|
-
b)=>Y(()=>window.localStorage.getItem(a),b),setItem:(a,b,c)=>Y(()=>window.localStorage.setItem(a,b),c),removeItem:(a,b)=>Y(()=>window.localStorage.removeItem(a),b),mergeItem:(a,b,c)=>Y(()=>{var d=window.localStorage.getItem(a);if(d){d=JSON.parse(d);let e=JSON.parse(b);d=JSON.stringify(sb(d,e));window.localStorage.setItem(a,d)}else window.localStorage.setItem(a,b)},c),clear:a=>Y(()=>window.localStorage.clear(),a),getAllKeys:a=>Y(()=>{const b=window.localStorage.length,c=[];for(let d=0;d<b;d+=1){const e=
|
|
60
|
-
window.localStorage.key(d)||"";c.push(e)}return c},a),flushGetRequests:()=>{},multiGet:(a,b)=>{const c=a.map(d=>ba.getItem(d));return la(c,b,d=>d.map((e,g)=>[a[g],e]))},multiSet:(a,b)=>{a=a.map(c=>ba.setItem(c[0],c[1]));return la(a,b)},multiRemove:(a,b)=>{a=a.map(c=>ba.removeItem(c));return la(a,b)},multiMerge:(a,b)=>{a=a.map(c=>ba.mergeItem(c[0],c[1]));return la(a,b)}};var La=ba;if("undefined"===typeof crypto)throw Error("Web Crypto is not available. Please use a polyfill like react-native-get-random-values");
|
|
61
|
-
C.newTracker=function(a){return G(this,void 0,void 0,function(){var b,c,d,e,g,h,k,f,l;return J(this,function(n){switch(n.label){case 0:b=a.namespace;c=a.appId;d=a.encodeBase64;e=void 0===d?!1:d;if(void 0!==a.eventStore)return[3,2];g=a;return[4,nb(a)];case 1:g.eventStore=n.sent(),n.label=2;case 2:return h=gb(a),k=function(p){h.input(p.build())},f=cb({base64:e,callback:k}),l=pb(f,a),f.addPlugin(l.subjectPlugin),f.setPlatform("mob"),f.setTrackerVersion("rn-4.0.2-dev.0"),f.setTrackerNamespace(b),c&&f.setAppId(c),
|
|
62
|
-
[2,S(S(S({},ob(f)),l.properties),{setAppId:f.setAppId,setPlatform:f.setPlatform,flush:h.flush,addGlobalContexts:f.addGlobalContexts,removeGlobalContexts:f.removeGlobalContexts,clearGlobalContexts:f.clearGlobalContexts,addPlugin:f.addPlugin})]}})})};C.version="4.0.2-dev.0";Object.defineProperty(C,"__esModule",{value:!0})})
|
|
63
|
-
//# sourceMappingURL=index.cjs.min.js.map
|