@convivainc/conviva-react-native-appanalytics 0.0.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/CHANGELOG.md +4 -0
- package/ConvivaLegalNotice.txt +1 -0
- package/README.md +104 -0
- package/index.d.ts +842 -0
- package/index.js +1860 -0
- package/package.json +22 -0
package/index.js
ADDED
|
@@ -0,0 +1,1860 @@
|
|
|
1
|
+
import { NativeModules } from 'react-native';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright (c) 2020-2023 Snowplow Analytics Ltd. All rights reserved.
|
|
5
|
+
*
|
|
6
|
+
* This program is licensed to you under the Apache License Version 2.0,
|
|
7
|
+
* and you may not use this file except in compliance with the Apache License Version 2.0.
|
|
8
|
+
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing,
|
|
11
|
+
* software distributed under the Apache License Version 2.0 is distributed on an
|
|
12
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Returns a function that accepts a side-effect function as its argument and subscribes
|
|
17
|
+
* that function to aPromise's fullfillment,
|
|
18
|
+
* and errHandle to aPromise's rejection.
|
|
19
|
+
*
|
|
20
|
+
* @param aPromise - A void Promise
|
|
21
|
+
* @param errHandle - A function to handle the promise being rejected
|
|
22
|
+
* @returns - A function subscribed to the Promise's fullfillment
|
|
23
|
+
*/
|
|
24
|
+
function safeWait(aPromise, errHandle) {
|
|
25
|
+
return ((func) => {
|
|
26
|
+
return (...args) => {
|
|
27
|
+
return aPromise.then(() => func(...args)).catch((err) => errHandle(err));
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Returns a function that accepts a callback function as its argument and subscribes
|
|
33
|
+
* that function to aPromise's fullfillment,
|
|
34
|
+
* and errHandle to aPromise's rejection.
|
|
35
|
+
*
|
|
36
|
+
* @param aPromise - A void Promise
|
|
37
|
+
* @param errHandle - A function to handle the promise being rejected
|
|
38
|
+
* @returns - A function subscribed to the Promise's fullfillment
|
|
39
|
+
*/
|
|
40
|
+
function safeWaitCallback(callPromise, errHandle) {
|
|
41
|
+
return ((func) => {
|
|
42
|
+
return (...args) => {
|
|
43
|
+
return callPromise.then(() => func(...args)).catch((err) => errHandle(err));
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Handles an error.
|
|
49
|
+
*
|
|
50
|
+
* @param err - The error to be handled.
|
|
51
|
+
*/
|
|
52
|
+
function errorHandler(err) {
|
|
53
|
+
if (__DEV__) {
|
|
54
|
+
console.warn('ConvivaTracker:' + err.message);
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Helper to check whether its argument is of object type
|
|
61
|
+
*
|
|
62
|
+
* @param x - The argument to check.
|
|
63
|
+
* @returns - A boolean
|
|
64
|
+
*/
|
|
65
|
+
function isObject(x) {
|
|
66
|
+
return Object.prototype.toString.call(x) === '[object Object]';
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/*
|
|
70
|
+
* Copyright (c) 2020-2023 Snowplow Analytics Ltd. All rights reserved.
|
|
71
|
+
*
|
|
72
|
+
* This program is licensed to you under the Apache License Version 2.0,
|
|
73
|
+
* and you may not use this file except in compliance with the Apache License Version 2.0.
|
|
74
|
+
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
|
|
75
|
+
*
|
|
76
|
+
* Unless required by applicable law or agreed to in writing,
|
|
77
|
+
* software distributed under the Apache License Version 2.0 is distributed on an
|
|
78
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
79
|
+
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
|
|
80
|
+
*/
|
|
81
|
+
const isAvailable = NativeModules.RNConvivaTracker != null;
|
|
82
|
+
if (!isAvailable) {
|
|
83
|
+
errorHandler(new Error('Unable to access the native iOS/Android Conviva tracker, a tracker implementation with very limited functionality is used.'));
|
|
84
|
+
}
|
|
85
|
+
const RNConvivaTracker = NativeModules.RNConvivaTracker;
|
|
86
|
+
|
|
87
|
+
/*
|
|
88
|
+
* Copyright (c) 2020-2023 Snowplow Analytics Ltd. All rights reserved.
|
|
89
|
+
*
|
|
90
|
+
* This program is licensed to you under the Apache License Version 2.0,
|
|
91
|
+
* and you may not use this file except in compliance with the Apache License Version 2.0.
|
|
92
|
+
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
|
|
93
|
+
*
|
|
94
|
+
* Unless required by applicable law or agreed to in writing,
|
|
95
|
+
* software distributed under the Apache License Version 2.0 is distributed on an
|
|
96
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
97
|
+
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
|
|
98
|
+
*/
|
|
99
|
+
const logMessages = {
|
|
100
|
+
// configuration errors
|
|
101
|
+
customerKey: 'customerKey parameter is required to be set',
|
|
102
|
+
appName: 'appName parameter is required to be set',
|
|
103
|
+
namespace: 'namespace parameter is required to be set fail',
|
|
104
|
+
endpoint: 'endpoint parameter is required to be set',
|
|
105
|
+
network: 'networkConfig is invalid',
|
|
106
|
+
tracker: 'trackerConfig is invalid',
|
|
107
|
+
session: 'sessionConfig is invalid',
|
|
108
|
+
emitter: 'emitterConfig is invalid',
|
|
109
|
+
subject: 'subjectConfig is invalid',
|
|
110
|
+
gdpr: 'gdprConfig is invalid',
|
|
111
|
+
gc: 'gcConfig is invalid',
|
|
112
|
+
remote: 'remoteConfig is invalid',
|
|
113
|
+
// event errors
|
|
114
|
+
context: 'invalid contexts parameter',
|
|
115
|
+
selfDesc: 'selfDescribing event requires schema and data parameters to be set',
|
|
116
|
+
evType: 'event argument can only be an object',
|
|
117
|
+
screenViewReq: 'screenView event requires name as string parameter to be set',
|
|
118
|
+
structuredReq: 'structured event requires category and action parameters to be set',
|
|
119
|
+
pageviewReq: 'pageView event requires pageUrl parameter to be set',
|
|
120
|
+
timingReq: 'timing event requires category, variable and timing parameters to be set',
|
|
121
|
+
consentGReq: 'consentGranted event requires expiry, documentId and version parameters to be set',
|
|
122
|
+
consentWReq: 'consentWithdrawn event requires all, documentId and version parameters to be set',
|
|
123
|
+
ecomReq: 'ecommerceTransaction event requires orderId, totalValue to be set and items to be an array of valid ecommerceItems',
|
|
124
|
+
deepLinkReq: 'deepLinkReceived event requires the url parameter to be set',
|
|
125
|
+
messageNotificationReq: 'messageNotification event requires title, body, and trigger parameters to be set',
|
|
126
|
+
trackCustomEvent: 'trackCustomEvent event requires name and data',
|
|
127
|
+
// custom tags contexts
|
|
128
|
+
setCustomTags: 'setCustomTags requires tags',
|
|
129
|
+
clearCustomTags: 'clearCustomTags requires tag keys',
|
|
130
|
+
clearAllCustomTags: 'clearAllCustomTags requires earlier set tags',
|
|
131
|
+
// global contexts errors
|
|
132
|
+
gcTagType: 'tag argument is required to be a string',
|
|
133
|
+
gcType: 'global context argument is invalid',
|
|
134
|
+
// api error prefix
|
|
135
|
+
createTracker: 'createTracker:',
|
|
136
|
+
removeTracker: 'removeTracker: trackerNamespace can only be a string',
|
|
137
|
+
// methods
|
|
138
|
+
trackSelfDesc: 'trackSelfDescribingEvent:',
|
|
139
|
+
trackScreenView: 'trackScreenViewEvent:',
|
|
140
|
+
trackStructured: 'trackStructuredEvent:',
|
|
141
|
+
trackPageView: 'trackPageView:',
|
|
142
|
+
trackTiming: 'trackTimingEvent:',
|
|
143
|
+
trackConsentGranted: 'trackConsentGranted:',
|
|
144
|
+
trackConsentWithdrawn: 'trackConsentWithdrawn:',
|
|
145
|
+
trackEcommerceTransaction: 'trackEcommerceTransaction:',
|
|
146
|
+
trackDeepLinkReceived: 'trackDeepLinkReceivedEvent:',
|
|
147
|
+
trackMessageNotification: 'trackMessageNotificationEvent:',
|
|
148
|
+
removeGlobalContexts: 'removeGlobalContexts:',
|
|
149
|
+
addGlobalContexts: 'addGlobalContexts:',
|
|
150
|
+
// setters
|
|
151
|
+
setUserId: 'setUserId: userId can only be a string or null',
|
|
152
|
+
setNetworkUserId: 'setNetworkUserId: networkUserId can only be a string(UUID) or null',
|
|
153
|
+
setDomainUserId: 'setDomainUserId: domainUserId can only be a string(UUID) or null',
|
|
154
|
+
setIpAddress: 'setIpAddress: ipAddress can only be a string or null',
|
|
155
|
+
setUseragent: 'setUseragent: useragent can only be a string or null',
|
|
156
|
+
setTimezone: 'setTimezone: timezone can only be a string or null',
|
|
157
|
+
setLanguage: 'setLanguage: language can only be a string or null',
|
|
158
|
+
setScreenResolution: 'setScreenResolution: screenResolution can only be of ScreenSize type or null',
|
|
159
|
+
setScreenViewport: 'setScreenViewport: screenViewport can only be of ScreenSize type or null',
|
|
160
|
+
setColorDepth: 'setColorDepth: colorDepth can only be a number(integer) or null',
|
|
161
|
+
setSubjectData: 'setSubjectData:',
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
/*
|
|
165
|
+
* Copyright (c) 2020-2023 Snowplow Analytics Ltd. All rights reserved.
|
|
166
|
+
*
|
|
167
|
+
* This program is licensed to you under the Apache License Version 2.0,
|
|
168
|
+
* and you may not use this file except in compliance with the Apache License Version 2.0.
|
|
169
|
+
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
|
|
170
|
+
*
|
|
171
|
+
* Unless required by applicable law or agreed to in writing,
|
|
172
|
+
* software distributed under the Apache License Version 2.0 is distributed on an
|
|
173
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
174
|
+
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
|
|
175
|
+
*/
|
|
176
|
+
/**
|
|
177
|
+
* Validates whether an object is valid self-describing
|
|
178
|
+
*
|
|
179
|
+
* @param sd {Object} - the object to validate
|
|
180
|
+
* @returns - boolean
|
|
181
|
+
*/
|
|
182
|
+
function isValidSD(sd) {
|
|
183
|
+
return isObject(sd)
|
|
184
|
+
&& typeof sd.schema === 'string'
|
|
185
|
+
&& isObject(sd.data);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Validates whether an object is a valid array of contexts
|
|
189
|
+
*
|
|
190
|
+
* @param contexts {Object} - the object to validate
|
|
191
|
+
* @returns - boolean promise
|
|
192
|
+
*/
|
|
193
|
+
function validateContexts(contexts) {
|
|
194
|
+
const isValid = Object.prototype.toString.call(contexts) === '[object Array]'
|
|
195
|
+
&& contexts
|
|
196
|
+
.map((c) => isValidSD(c))
|
|
197
|
+
.reduce((acc, curr) => acc !== false && curr, true);
|
|
198
|
+
if (!isValid) {
|
|
199
|
+
return Promise.reject(new Error(logMessages.context));
|
|
200
|
+
}
|
|
201
|
+
return Promise.resolve(true);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Validates whether an object is valid self describing
|
|
205
|
+
*
|
|
206
|
+
* @param argmap {Object} - the object to validate
|
|
207
|
+
* @returns - boolean promise
|
|
208
|
+
*/
|
|
209
|
+
function validateSelfDesc(argmap) {
|
|
210
|
+
if (!isValidSD(argmap)) {
|
|
211
|
+
return Promise.reject(new Error(logMessages.selfDesc));
|
|
212
|
+
}
|
|
213
|
+
return Promise.resolve(true);
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Validates a screen view event
|
|
217
|
+
*
|
|
218
|
+
* @param argmap {Object} - the object to validate
|
|
219
|
+
* @returns - boolean promise
|
|
220
|
+
*/
|
|
221
|
+
function validateScreenView(argmap) {
|
|
222
|
+
// validate type
|
|
223
|
+
if (!isObject(argmap)) {
|
|
224
|
+
return Promise.reject(new Error(logMessages.evType));
|
|
225
|
+
}
|
|
226
|
+
// validate required props
|
|
227
|
+
if (typeof argmap.name !== 'string') {
|
|
228
|
+
return Promise.reject(new Error(logMessages.screenViewReq));
|
|
229
|
+
}
|
|
230
|
+
return Promise.resolve(true);
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Validates a structured event
|
|
234
|
+
*
|
|
235
|
+
* @param argmap {Object} - the object to validate
|
|
236
|
+
* @returns - boolean promise
|
|
237
|
+
*/
|
|
238
|
+
function validateStructured(argmap) {
|
|
239
|
+
// validate type
|
|
240
|
+
if (!isObject(argmap)) {
|
|
241
|
+
return Promise.reject(new Error(logMessages.evType));
|
|
242
|
+
}
|
|
243
|
+
// validate required props
|
|
244
|
+
if (typeof argmap.category !== 'string'
|
|
245
|
+
|| typeof argmap.action !== 'string') {
|
|
246
|
+
return Promise.reject(new Error(logMessages.structuredReq));
|
|
247
|
+
}
|
|
248
|
+
return Promise.resolve(true);
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Validates a page-view event
|
|
252
|
+
*
|
|
253
|
+
* @param argmap {Object} - the object to validate
|
|
254
|
+
* @returns - boolean promise
|
|
255
|
+
*/
|
|
256
|
+
function validatePageView(argmap) {
|
|
257
|
+
// validate type
|
|
258
|
+
if (!isObject(argmap)) {
|
|
259
|
+
return Promise.reject(new Error(logMessages.evType));
|
|
260
|
+
}
|
|
261
|
+
// validate required props
|
|
262
|
+
if (typeof argmap.pageUrl !== 'string') {
|
|
263
|
+
return Promise.reject(new Error(logMessages.pageviewReq));
|
|
264
|
+
}
|
|
265
|
+
return Promise.resolve(true);
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Validates a timing event
|
|
269
|
+
*
|
|
270
|
+
* @param argmap {Object} - the object to validate
|
|
271
|
+
* @returns - boolean promise
|
|
272
|
+
*/
|
|
273
|
+
function validateTiming(argmap) {
|
|
274
|
+
// validate type
|
|
275
|
+
if (!isObject(argmap)) {
|
|
276
|
+
return Promise.reject(new Error(logMessages.evType));
|
|
277
|
+
}
|
|
278
|
+
// validate required props
|
|
279
|
+
if (typeof argmap.category !== 'string'
|
|
280
|
+
|| typeof argmap.variable !== 'string'
|
|
281
|
+
|| typeof argmap.timing !== 'number') {
|
|
282
|
+
return Promise.reject(new Error(logMessages.timingReq));
|
|
283
|
+
}
|
|
284
|
+
return Promise.resolve(true);
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Validates a consent-granted event
|
|
288
|
+
*
|
|
289
|
+
* @param argmap {Object} - the object to validate
|
|
290
|
+
* @returns - boolean promise
|
|
291
|
+
*/
|
|
292
|
+
function validateConsentGranted(argmap) {
|
|
293
|
+
// validate type
|
|
294
|
+
if (!isObject(argmap)) {
|
|
295
|
+
return Promise.reject(new Error(logMessages.evType));
|
|
296
|
+
}
|
|
297
|
+
// validate required props
|
|
298
|
+
if (typeof argmap.expiry !== 'string'
|
|
299
|
+
|| typeof argmap.documentId !== 'string'
|
|
300
|
+
|| typeof argmap.version !== 'string') {
|
|
301
|
+
return Promise.reject(new Error(logMessages.consentGReq));
|
|
302
|
+
}
|
|
303
|
+
return Promise.resolve(true);
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Validates a consent-withdrawn event
|
|
307
|
+
*
|
|
308
|
+
* @param argmap {Object} - the object to validate
|
|
309
|
+
* @returns - boolean promise
|
|
310
|
+
*/
|
|
311
|
+
function validateConsentWithdrawn(argmap) {
|
|
312
|
+
// validate type
|
|
313
|
+
if (!isObject(argmap)) {
|
|
314
|
+
return Promise.reject(new Error(logMessages.evType));
|
|
315
|
+
}
|
|
316
|
+
// validate required props
|
|
317
|
+
if (typeof argmap.all !== 'boolean'
|
|
318
|
+
|| typeof argmap.documentId !== 'string'
|
|
319
|
+
|| typeof argmap.version !== 'string') {
|
|
320
|
+
return Promise.reject(new Error(logMessages.consentWReq));
|
|
321
|
+
}
|
|
322
|
+
return Promise.resolve(true);
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Validates a deep link received event
|
|
326
|
+
*
|
|
327
|
+
* @param argmap {Object} - the object to validate
|
|
328
|
+
* @returns - boolean promise
|
|
329
|
+
*/
|
|
330
|
+
function validateDeepLinkReceived(argmap) {
|
|
331
|
+
// validate type
|
|
332
|
+
if (!isObject(argmap)) {
|
|
333
|
+
return Promise.reject(new Error(logMessages.evType));
|
|
334
|
+
}
|
|
335
|
+
// validate required props
|
|
336
|
+
if (typeof argmap.url !== 'string') {
|
|
337
|
+
return Promise.reject(new Error(logMessages.deepLinkReq));
|
|
338
|
+
}
|
|
339
|
+
return Promise.resolve(true);
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Validates a message notification event
|
|
343
|
+
*
|
|
344
|
+
* @param argmap {Object} - the object to validate
|
|
345
|
+
* @returns - boolean promise
|
|
346
|
+
*/
|
|
347
|
+
function validateMessageNotification(argmap) {
|
|
348
|
+
// validate type
|
|
349
|
+
if (!isObject(argmap)) {
|
|
350
|
+
return Promise.reject(new Error(logMessages.evType));
|
|
351
|
+
}
|
|
352
|
+
// validate required props
|
|
353
|
+
if (typeof argmap.title !== 'string'
|
|
354
|
+
|| typeof argmap.body !== 'string'
|
|
355
|
+
|| typeof argmap.trigger !== 'string'
|
|
356
|
+
|| !['push', 'location', 'calendar', 'timeInterval', 'other'].includes(argmap.trigger)) {
|
|
357
|
+
return Promise.reject(new Error(logMessages.messageNotificationReq));
|
|
358
|
+
}
|
|
359
|
+
return Promise.resolve(true);
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Validates whether an object is valid ecommerce-item
|
|
363
|
+
*
|
|
364
|
+
* @param item {Object} - the object to validate
|
|
365
|
+
* @returns - boolean
|
|
366
|
+
*/
|
|
367
|
+
function isValidEcomItem(item) {
|
|
368
|
+
if (isObject(item)
|
|
369
|
+
&& typeof item.sku === 'string'
|
|
370
|
+
&& typeof item.price === 'number'
|
|
371
|
+
&& typeof item.quantity === 'number') {
|
|
372
|
+
return true;
|
|
373
|
+
}
|
|
374
|
+
return false;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Validates an array of ecommerce-items
|
|
378
|
+
*
|
|
379
|
+
* @param items {Object} - the object to validate
|
|
380
|
+
* @returns - boolean promise
|
|
381
|
+
*/
|
|
382
|
+
function validItemsArg(items) {
|
|
383
|
+
return Object.prototype.toString.call(items) === '[object Array]'
|
|
384
|
+
&& items
|
|
385
|
+
.map((i) => isValidEcomItem(i))
|
|
386
|
+
.reduce((acc, curr) => acc !== false && curr, true);
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Validates an ecommerce-transaction event
|
|
390
|
+
*
|
|
391
|
+
* @param argmap {Object} - the object to validate
|
|
392
|
+
* @returns - boolean promise
|
|
393
|
+
*/
|
|
394
|
+
function validateEcommerceTransaction(argmap) {
|
|
395
|
+
// validate type
|
|
396
|
+
if (!isObject(argmap)) {
|
|
397
|
+
return Promise.reject(new Error(logMessages.evType));
|
|
398
|
+
}
|
|
399
|
+
// validate required props
|
|
400
|
+
if (typeof argmap.orderId !== 'string'
|
|
401
|
+
|| typeof argmap.totalValue !== 'number'
|
|
402
|
+
|| !validItemsArg(argmap.items)) {
|
|
403
|
+
return Promise.reject(new Error(logMessages.ecomReq));
|
|
404
|
+
}
|
|
405
|
+
return Promise.resolve(true);
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Validates a custom event
|
|
409
|
+
*
|
|
410
|
+
* @param argmap {Object} - the object to validate
|
|
411
|
+
* @returns - boolean promise
|
|
412
|
+
*/
|
|
413
|
+
function validateCustomEvent(argmap) {
|
|
414
|
+
// validate type
|
|
415
|
+
if (!isObject(argmap)) {
|
|
416
|
+
return Promise.reject(new Error(logMessages.evType));
|
|
417
|
+
}
|
|
418
|
+
return Promise.resolve(true);
|
|
419
|
+
}
|
|
420
|
+
function validateCustomTags(argmap) {
|
|
421
|
+
// validate type
|
|
422
|
+
if (!isObject(argmap)) {
|
|
423
|
+
return Promise.reject(new Error(logMessages.evType));
|
|
424
|
+
}
|
|
425
|
+
return Promise.resolve(true);
|
|
426
|
+
}
|
|
427
|
+
function validateClearCustomTags(tagKeys) {
|
|
428
|
+
// validate type
|
|
429
|
+
if (Object.prototype.toString.call(tagKeys) !== '[object Array]') {
|
|
430
|
+
return Promise.reject(new Error(logMessages.evType));
|
|
431
|
+
}
|
|
432
|
+
return Promise.resolve(true);
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/*
|
|
436
|
+
* Copyright (c) 2020-2023 Snowplow Analytics Ltd. All rights reserved.
|
|
437
|
+
*
|
|
438
|
+
* This program is licensed to you under the Apache License Version 2.0,
|
|
439
|
+
* and you may not use this file except in compliance with the Apache License Version 2.0.
|
|
440
|
+
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
|
|
441
|
+
*
|
|
442
|
+
* Unless required by applicable law or agreed to in writing,
|
|
443
|
+
* software distributed under the Apache License Version 2.0 is distributed on an
|
|
444
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
445
|
+
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
|
|
446
|
+
*/
|
|
447
|
+
/**
|
|
448
|
+
* Configuration properties
|
|
449
|
+
*/
|
|
450
|
+
const networkProps = [
|
|
451
|
+
'endpoint',
|
|
452
|
+
'method',
|
|
453
|
+
'customPostPath',
|
|
454
|
+
'requestHeaders',
|
|
455
|
+
];
|
|
456
|
+
const trackerProps = [
|
|
457
|
+
'devicePlatform',
|
|
458
|
+
'base64Encoding',
|
|
459
|
+
'logLevel',
|
|
460
|
+
'applicationContext',
|
|
461
|
+
'platformContext',
|
|
462
|
+
'geoLocationContext',
|
|
463
|
+
'sessionContext',
|
|
464
|
+
'deepLinkContext',
|
|
465
|
+
'screenContext',
|
|
466
|
+
'screenViewAutotracking',
|
|
467
|
+
'lifecycleAutotracking',
|
|
468
|
+
'installAutotracking',
|
|
469
|
+
'exceptionAutotracking',
|
|
470
|
+
'diagnosticAutotracking',
|
|
471
|
+
'userAnonymisation'
|
|
472
|
+
// TODO: add all the features included by Conviva
|
|
473
|
+
];
|
|
474
|
+
const sessionProps = [
|
|
475
|
+
'foregroundTimeout',
|
|
476
|
+
'backgroundTimeout'
|
|
477
|
+
];
|
|
478
|
+
const emitterProps = [
|
|
479
|
+
'bufferOption',
|
|
480
|
+
'emitRange',
|
|
481
|
+
'threadPoolSize',
|
|
482
|
+
'byteLimitPost',
|
|
483
|
+
'byteLimitGet',
|
|
484
|
+
'serverAnonymisation',
|
|
485
|
+
];
|
|
486
|
+
const subjectProps = [
|
|
487
|
+
'userId',
|
|
488
|
+
'networkUserId',
|
|
489
|
+
'domainUserId',
|
|
490
|
+
'useragent',
|
|
491
|
+
'ipAddress',
|
|
492
|
+
'timezone',
|
|
493
|
+
'language',
|
|
494
|
+
'screenResolution',
|
|
495
|
+
'screenViewport',
|
|
496
|
+
'colorDepth'
|
|
497
|
+
];
|
|
498
|
+
const gdprProps = [
|
|
499
|
+
'basisForProcessing',
|
|
500
|
+
'documentId',
|
|
501
|
+
'documentVersion',
|
|
502
|
+
'documentDescription'
|
|
503
|
+
];
|
|
504
|
+
const gcProps = [
|
|
505
|
+
'tag',
|
|
506
|
+
'globalContexts'
|
|
507
|
+
];
|
|
508
|
+
const remoteProps = [
|
|
509
|
+
'endpoint',
|
|
510
|
+
'method'
|
|
511
|
+
];
|
|
512
|
+
/**
|
|
513
|
+
* Validates whether an object is of valid configuration given its default keys
|
|
514
|
+
*
|
|
515
|
+
* @param config {Object} - the object to validate
|
|
516
|
+
* @param defaultKeys {Array} - the default keys to validate against
|
|
517
|
+
* @returns - boolean
|
|
518
|
+
*/
|
|
519
|
+
function isValidConfig(config, defaultKeys) {
|
|
520
|
+
return Object.keys(config).every(key => defaultKeys.includes(key));
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* Validates the networkConfig
|
|
524
|
+
*
|
|
525
|
+
* @param config {Object} - the config to validate
|
|
526
|
+
* @returns - boolean
|
|
527
|
+
*/
|
|
528
|
+
function isValidNetworkConf(config) {
|
|
529
|
+
if (!isObject(config)
|
|
530
|
+
|| !isValidConfig(config, networkProps)
|
|
531
|
+
|| typeof config.endpoint !== 'string'
|
|
532
|
+
|| !config.endpoint) {
|
|
533
|
+
return false;
|
|
534
|
+
}
|
|
535
|
+
return true;
|
|
536
|
+
}
|
|
537
|
+
/**
|
|
538
|
+
* Validates the trackerConfig
|
|
539
|
+
*
|
|
540
|
+
* @param config {Object} - the config to validate
|
|
541
|
+
* @returns - boolean
|
|
542
|
+
*/
|
|
543
|
+
function isValidTrackerConf(config) {
|
|
544
|
+
if (!isObject(config) || !isValidConfig(config, trackerProps)) {
|
|
545
|
+
return false;
|
|
546
|
+
}
|
|
547
|
+
return true;
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Validates the sessionConfig
|
|
551
|
+
*
|
|
552
|
+
* @param config {Object} - the config to validate
|
|
553
|
+
* @returns - boolean
|
|
554
|
+
*/
|
|
555
|
+
function isValidSessionConf(config) {
|
|
556
|
+
if (!isObject(config)
|
|
557
|
+
|| !isValidConfig(config, sessionProps)
|
|
558
|
+
|| !sessionProps.every(key => Object.keys(config).includes(key))) {
|
|
559
|
+
return false;
|
|
560
|
+
}
|
|
561
|
+
return true;
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* Validates the emitterConfig
|
|
565
|
+
*
|
|
566
|
+
* @param config {Object} - the config to validate
|
|
567
|
+
* @returns - boolean
|
|
568
|
+
*/
|
|
569
|
+
function isValidEmitterConf(config) {
|
|
570
|
+
if (!isObject(config) || !isValidConfig(config, emitterProps)) {
|
|
571
|
+
return false;
|
|
572
|
+
}
|
|
573
|
+
return true;
|
|
574
|
+
}
|
|
575
|
+
/**
|
|
576
|
+
* Validates whether an object is of ScreenSize type
|
|
577
|
+
*
|
|
578
|
+
* @param arr {Object} - the object to validate
|
|
579
|
+
* @returns - boolean
|
|
580
|
+
*/
|
|
581
|
+
function isScreenSize(arr) {
|
|
582
|
+
return Array.isArray(arr)
|
|
583
|
+
&& arr.length === 2
|
|
584
|
+
&& arr.every((n) => typeof n === 'number');
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* Validates the subjectConfig
|
|
588
|
+
*
|
|
589
|
+
* @param config {Object} - the config to validate
|
|
590
|
+
* @returns - boolean
|
|
591
|
+
*/
|
|
592
|
+
function isValidSubjectConf(config) {
|
|
593
|
+
if (!isObject(config) || !isValidConfig(config, subjectProps)) {
|
|
594
|
+
return false;
|
|
595
|
+
}
|
|
596
|
+
// validating ScreenSize here to simplify array handling in bridge
|
|
597
|
+
if (Object.prototype.hasOwnProperty.call(config, 'screenResolution')
|
|
598
|
+
&& config.screenResolution !== null
|
|
599
|
+
&& !isScreenSize(config.screenResolution)) {
|
|
600
|
+
return false;
|
|
601
|
+
}
|
|
602
|
+
if (Object.prototype.hasOwnProperty.call(config, 'screenViewport')
|
|
603
|
+
&& config.screenViewport !== null
|
|
604
|
+
&& !isScreenSize(config.screenViewport)) {
|
|
605
|
+
return false;
|
|
606
|
+
}
|
|
607
|
+
return true;
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* Validates the gdprConfig
|
|
611
|
+
*
|
|
612
|
+
* @param config {Object} - the config to validate
|
|
613
|
+
* @returns - boolean
|
|
614
|
+
*/
|
|
615
|
+
function isValidGdprConf(config) {
|
|
616
|
+
if (!isObject(config)
|
|
617
|
+
|| !isValidConfig(config, gdprProps)
|
|
618
|
+
|| !gdprProps.every(key => Object.keys(config).includes(key))
|
|
619
|
+
|| !['consent', 'contract', 'legal_obligation', 'legitimate_interests', 'public_task', 'vital_interests'].includes(config.basisForProcessing)) {
|
|
620
|
+
return false;
|
|
621
|
+
}
|
|
622
|
+
return true;
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* Validates whether an object is of GlobalContext type
|
|
626
|
+
*
|
|
627
|
+
* @param gc {Object} - the object to validate
|
|
628
|
+
* @returns - boolean
|
|
629
|
+
*/
|
|
630
|
+
function isValidGC(gc) {
|
|
631
|
+
return isObject(gc)
|
|
632
|
+
&& isValidConfig(gc, gcProps)
|
|
633
|
+
&& typeof gc.tag === 'string'
|
|
634
|
+
&& Array.isArray(gc.globalContexts)
|
|
635
|
+
&& gc.globalContexts.every(c => isValidSD(c));
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* Validates the GCConfig (global contexts)
|
|
639
|
+
*
|
|
640
|
+
* @param config {Object} - the config to validate
|
|
641
|
+
* @returns - boolean
|
|
642
|
+
*/
|
|
643
|
+
function isValidGCConf(config) {
|
|
644
|
+
if (!Array.isArray(config)) {
|
|
645
|
+
return false;
|
|
646
|
+
}
|
|
647
|
+
if (!config.every(gc => isValidGC(gc))) {
|
|
648
|
+
return false;
|
|
649
|
+
}
|
|
650
|
+
return true;
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Validates the RemoteConfig (remote config)
|
|
654
|
+
*
|
|
655
|
+
* @param config {Object} - the config to validate
|
|
656
|
+
* @returns - boolean
|
|
657
|
+
*/
|
|
658
|
+
function isValidRemoteConf(config) {
|
|
659
|
+
if (!isObject(config)
|
|
660
|
+
|| !isValidConfig(config, remoteProps)
|
|
661
|
+
|| typeof config.endpoint !== 'string'
|
|
662
|
+
|| !config.endpoint) {
|
|
663
|
+
return false;
|
|
664
|
+
}
|
|
665
|
+
return true;
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* Validates the initTrackerConfiguration
|
|
669
|
+
*
|
|
670
|
+
* @param init {Object} - the config to validate
|
|
671
|
+
* @returns - boolean promise
|
|
672
|
+
*/
|
|
673
|
+
function initValidate(init) {
|
|
674
|
+
if (typeof init.customerKey !== 'string' || !init.customerKey || init.customerKey === "") {
|
|
675
|
+
return Promise.reject(new Error(logMessages.customerKey));
|
|
676
|
+
}
|
|
677
|
+
if (typeof init.appName !== 'string' || !init.appName || init.appName === "") {
|
|
678
|
+
return Promise.reject(new Error(logMessages.appName));
|
|
679
|
+
}
|
|
680
|
+
if (!Object.prototype.hasOwnProperty.call(init, 'networkConfig')
|
|
681
|
+
|| !isValidNetworkConf(init.networkConfig)) {
|
|
682
|
+
return Promise.reject(new Error(logMessages.network));
|
|
683
|
+
}
|
|
684
|
+
if (Object.prototype.hasOwnProperty.call(init, 'trackerConfig')
|
|
685
|
+
&& !isValidTrackerConf(init.trackerConfig)) {
|
|
686
|
+
return Promise.reject(new Error(logMessages.tracker));
|
|
687
|
+
}
|
|
688
|
+
if (Object.prototype.hasOwnProperty.call(init, 'sessionConfig')
|
|
689
|
+
&& (!isValidSessionConf(init.sessionConfig))) {
|
|
690
|
+
return Promise.reject(new Error(logMessages.session));
|
|
691
|
+
}
|
|
692
|
+
if (Object.prototype.hasOwnProperty.call(init, 'emitterConfig')
|
|
693
|
+
&& !isValidEmitterConf(init.emitterConfig)) {
|
|
694
|
+
return Promise.reject(new Error(logMessages.emitter));
|
|
695
|
+
}
|
|
696
|
+
if (Object.prototype.hasOwnProperty.call(init, 'subjectConfig')
|
|
697
|
+
&& !isValidSubjectConf(init.subjectConfig)) {
|
|
698
|
+
return Promise.reject(new Error(logMessages.subject));
|
|
699
|
+
}
|
|
700
|
+
if (Object.prototype.hasOwnProperty.call(init, 'gdprConfig')
|
|
701
|
+
&& !isValidGdprConf(init.gdprConfig)) {
|
|
702
|
+
return Promise.reject(new Error(logMessages.gdpr));
|
|
703
|
+
}
|
|
704
|
+
if (Object.prototype.hasOwnProperty.call(init, 'gcConfig')
|
|
705
|
+
&& !isValidGCConf(init.gcConfig)) {
|
|
706
|
+
return Promise.reject(new Error(logMessages.gc));
|
|
707
|
+
}
|
|
708
|
+
if (Object.prototype.hasOwnProperty.call(init, 'remoteConfig')
|
|
709
|
+
&& !isValidRemoteConf(init.remoteConfig)) {
|
|
710
|
+
return Promise.reject(new Error(logMessages.remote));
|
|
711
|
+
}
|
|
712
|
+
return Promise.resolve(true);
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
/*
|
|
716
|
+
* Copyright (c) 2020-2023 Snowplow Analytics Ltd. All rights reserved.
|
|
717
|
+
*
|
|
718
|
+
* This program is licensed to you under the Apache License Version 2.0,
|
|
719
|
+
* and you may not use this file except in compliance with the Apache License Version 2.0.
|
|
720
|
+
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
|
|
721
|
+
*
|
|
722
|
+
* Unless required by applicable law or agreed to in writing,
|
|
723
|
+
* software distributed under the Apache License Version 2.0 is distributed on an
|
|
724
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
725
|
+
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
|
|
726
|
+
*/
|
|
727
|
+
/**
|
|
728
|
+
* Tracks a self-describing event
|
|
729
|
+
*
|
|
730
|
+
* @param namespace {string} - the tracker namespace
|
|
731
|
+
* @param argmap {Object} - the event data
|
|
732
|
+
* @param contexts {Array}- the event contexts
|
|
733
|
+
* @returns {Promise}
|
|
734
|
+
*/
|
|
735
|
+
function trackSelfDescribingEvent$1(namespace, argmap, contexts = []) {
|
|
736
|
+
return validateSelfDesc(argmap)
|
|
737
|
+
.then(() => validateContexts(contexts))
|
|
738
|
+
.then(() => RNConvivaTracker.trackSelfDescribingEvent({
|
|
739
|
+
tracker: namespace,
|
|
740
|
+
eventData: argmap,
|
|
741
|
+
contexts: contexts
|
|
742
|
+
}))
|
|
743
|
+
.catch((error) => {
|
|
744
|
+
throw new Error(`${logMessages.trackSelfDesc} ${error.message}`);
|
|
745
|
+
});
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* Tracks a screen-view event
|
|
749
|
+
*
|
|
750
|
+
* @param namespace {string} - the tracker namespace
|
|
751
|
+
* @param argmap {Object} - the event data
|
|
752
|
+
* @param contexts {Array}- the event contexts
|
|
753
|
+
* @returns {Promise}
|
|
754
|
+
*/
|
|
755
|
+
function trackScreenViewEvent$1(namespace, argmap, contexts = []) {
|
|
756
|
+
return validateScreenView(argmap)
|
|
757
|
+
.then(() => validateContexts(contexts))
|
|
758
|
+
.then(() => RNConvivaTracker.trackScreenViewEvent({
|
|
759
|
+
tracker: namespace,
|
|
760
|
+
eventData: argmap,
|
|
761
|
+
contexts: contexts
|
|
762
|
+
}))
|
|
763
|
+
.catch((error) => {
|
|
764
|
+
throw new Error(`${logMessages.trackScreenView} ${error.message}`);
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
/**
|
|
768
|
+
* Tracks a structured event
|
|
769
|
+
*
|
|
770
|
+
* @param namespace {string} - the tracker namespace
|
|
771
|
+
* @param argmap {Object} - the event data
|
|
772
|
+
* @param contexts {Array}- the event contexts
|
|
773
|
+
* @returns {Promise}
|
|
774
|
+
*/
|
|
775
|
+
function trackStructuredEvent$1(namespace, argmap, contexts = []) {
|
|
776
|
+
return validateStructured(argmap)
|
|
777
|
+
.then(() => validateContexts(contexts))
|
|
778
|
+
.then(() => RNConvivaTracker.trackStructuredEvent({
|
|
779
|
+
tracker: namespace,
|
|
780
|
+
eventData: argmap,
|
|
781
|
+
contexts: contexts
|
|
782
|
+
}))
|
|
783
|
+
.catch((error) => {
|
|
784
|
+
throw new Error(`${logMessages.trackStructured} ${error.message}`);
|
|
785
|
+
});
|
|
786
|
+
}
|
|
787
|
+
/**
|
|
788
|
+
* Tracks a page-view event
|
|
789
|
+
*
|
|
790
|
+
* @param namespace {string} - the tracker namespace
|
|
791
|
+
* @param argmap {Object} - the event data
|
|
792
|
+
* @param contexts {Array}- the event contexts
|
|
793
|
+
* @returns {Promise}
|
|
794
|
+
*/
|
|
795
|
+
function trackPageView$1(namespace, argmap, contexts = []) {
|
|
796
|
+
return validatePageView(argmap)
|
|
797
|
+
.then(() => validateContexts(contexts))
|
|
798
|
+
.then(() => RNConvivaTracker.trackPageView({
|
|
799
|
+
tracker: namespace,
|
|
800
|
+
eventData: argmap,
|
|
801
|
+
contexts: contexts
|
|
802
|
+
}))
|
|
803
|
+
.catch((error) => {
|
|
804
|
+
throw new Error(`${logMessages.trackPageView} ${error.message}`);
|
|
805
|
+
});
|
|
806
|
+
}
|
|
807
|
+
/**
|
|
808
|
+
* Tracks a timing event
|
|
809
|
+
*
|
|
810
|
+
* @param namespace {string} - the tracker namespace
|
|
811
|
+
* @param argmap {Object} - the event data
|
|
812
|
+
* @param contexts {Array}- the event contexts
|
|
813
|
+
* @returns {Promise}
|
|
814
|
+
*/
|
|
815
|
+
function trackTimingEvent$1(namespace, argmap, contexts = []) {
|
|
816
|
+
return validateTiming(argmap)
|
|
817
|
+
.then(() => validateContexts(contexts))
|
|
818
|
+
.then(() => RNConvivaTracker.trackTimingEvent({
|
|
819
|
+
tracker: namespace,
|
|
820
|
+
eventData: argmap,
|
|
821
|
+
contexts: contexts
|
|
822
|
+
}))
|
|
823
|
+
.catch((error) => {
|
|
824
|
+
throw new Error(`${logMessages.trackTiming} ${error.message}`);
|
|
825
|
+
});
|
|
826
|
+
}
|
|
827
|
+
/**
|
|
828
|
+
* Tracks a consent-granted event
|
|
829
|
+
*
|
|
830
|
+
* @param namespace {string} - the tracker namespace
|
|
831
|
+
* @param argmap {Object} - the event data
|
|
832
|
+
* @param contexts {Array}- the event contexts
|
|
833
|
+
* @returns {Promise}
|
|
834
|
+
*/
|
|
835
|
+
function trackConsentGrantedEvent$1(namespace, argmap, contexts = []) {
|
|
836
|
+
return validateConsentGranted(argmap)
|
|
837
|
+
.then(() => validateContexts(contexts))
|
|
838
|
+
.then(() => RNConvivaTracker.trackConsentGrantedEvent({
|
|
839
|
+
tracker: namespace,
|
|
840
|
+
eventData: argmap,
|
|
841
|
+
contexts: contexts
|
|
842
|
+
}))
|
|
843
|
+
.catch((error) => {
|
|
844
|
+
throw new Error(`${logMessages.trackConsentGranted} ${error.message}`);
|
|
845
|
+
});
|
|
846
|
+
}
|
|
847
|
+
/**
|
|
848
|
+
* Tracks a consent-withdrawn event
|
|
849
|
+
*
|
|
850
|
+
* @param namespace {string} - the tracker namespace
|
|
851
|
+
* @param argmap {Object} - the event data
|
|
852
|
+
* @param contexts {Array}- the event contexts
|
|
853
|
+
* @returns {Promise}
|
|
854
|
+
*/
|
|
855
|
+
function trackConsentWithdrawnEvent$1(namespace, argmap, contexts = []) {
|
|
856
|
+
return validateConsentWithdrawn(argmap)
|
|
857
|
+
.then(() => validateContexts(contexts))
|
|
858
|
+
.then(() => RNConvivaTracker.trackConsentWithdrawnEvent({
|
|
859
|
+
tracker: namespace,
|
|
860
|
+
eventData: argmap,
|
|
861
|
+
contexts: contexts
|
|
862
|
+
}))
|
|
863
|
+
.catch((error) => {
|
|
864
|
+
throw new Error(`${logMessages.trackConsentWithdrawn} ${error.message}`);
|
|
865
|
+
});
|
|
866
|
+
}
|
|
867
|
+
/**
|
|
868
|
+
* Tracks an ecommerce-transaction event
|
|
869
|
+
*
|
|
870
|
+
* @param namespace {string} - the tracker namespace
|
|
871
|
+
* @param argmap {Object} - the event data
|
|
872
|
+
* @param contexts {Array}- the event contexts
|
|
873
|
+
* @returns {Promise}
|
|
874
|
+
*/
|
|
875
|
+
function trackEcommerceTransactionEvent$1(namespace, argmap, contexts = []) {
|
|
876
|
+
return validateEcommerceTransaction(argmap)
|
|
877
|
+
.then(() => validateContexts(contexts))
|
|
878
|
+
.then(() => RNConvivaTracker.trackEcommerceTransactionEvent({
|
|
879
|
+
tracker: namespace,
|
|
880
|
+
eventData: argmap,
|
|
881
|
+
contexts: contexts
|
|
882
|
+
}))
|
|
883
|
+
.catch((error) => {
|
|
884
|
+
throw new Error(`${logMessages.trackEcommerceTransaction} ${error.message}`);
|
|
885
|
+
});
|
|
886
|
+
}
|
|
887
|
+
/**
|
|
888
|
+
* Tracks a deep link received event
|
|
889
|
+
*
|
|
890
|
+
* @param namespace {string} - the tracker namespace
|
|
891
|
+
* @param argmap {Object} - the event data
|
|
892
|
+
* @param contexts {Array}- the event contexts
|
|
893
|
+
* @returns {Promise}
|
|
894
|
+
*/
|
|
895
|
+
function trackDeepLinkReceivedEvent$1(namespace, argmap, contexts = []) {
|
|
896
|
+
return validateDeepLinkReceived(argmap)
|
|
897
|
+
.then(() => validateContexts(contexts))
|
|
898
|
+
.then(() => RNConvivaTracker.trackDeepLinkReceivedEvent({
|
|
899
|
+
tracker: namespace,
|
|
900
|
+
eventData: argmap,
|
|
901
|
+
contexts: contexts
|
|
902
|
+
}))
|
|
903
|
+
.catch((error) => {
|
|
904
|
+
throw new Error(`${logMessages.trackDeepLinkReceived} ${error.message}`);
|
|
905
|
+
});
|
|
906
|
+
}
|
|
907
|
+
/**
|
|
908
|
+
* Tracks a message notification event
|
|
909
|
+
*
|
|
910
|
+
* @param namespace {string} - the tracker namespace
|
|
911
|
+
* @param argmap {Object} - the event data
|
|
912
|
+
* @param contexts {Array}- the event contexts
|
|
913
|
+
* @returns {Promise}
|
|
914
|
+
*/
|
|
915
|
+
function trackMessageNotificationEvent$1(namespace, argmap, contexts = []) {
|
|
916
|
+
return validateMessageNotification(argmap)
|
|
917
|
+
.then(() => validateContexts(contexts))
|
|
918
|
+
.then(() => RNConvivaTracker.trackMessageNotificationEvent({
|
|
919
|
+
tracker: namespace,
|
|
920
|
+
eventData: argmap,
|
|
921
|
+
contexts: contexts
|
|
922
|
+
}))
|
|
923
|
+
.catch((error) => {
|
|
924
|
+
throw new Error(`${logMessages.trackMessageNotification} ${error.message}`);
|
|
925
|
+
});
|
|
926
|
+
}
|
|
927
|
+
/**
|
|
928
|
+
* Tracks a Custom Event
|
|
929
|
+
*
|
|
930
|
+
* @param namespace {string} - the tracker namespace
|
|
931
|
+
* @param name {string} - the custom event name
|
|
932
|
+
* @param arg {any} - the event data
|
|
933
|
+
* @param contexts {Array}- the event contexts
|
|
934
|
+
* @returns {Promise}
|
|
935
|
+
*/
|
|
936
|
+
function trackCustomEvent$1(namespace, name, arg, contexts = []) {
|
|
937
|
+
return validateCustomEvent(arg)
|
|
938
|
+
.then(() => validateContexts(contexts))
|
|
939
|
+
.then(() => RNConvivaTracker.trackCustomEvent({
|
|
940
|
+
tracker: namespace,
|
|
941
|
+
eventName: name,
|
|
942
|
+
eventData: arg,
|
|
943
|
+
contexts: contexts
|
|
944
|
+
}))
|
|
945
|
+
.catch((error) => {
|
|
946
|
+
throw new Error(`${logMessages.trackCustomEvent} ${error.message}`);
|
|
947
|
+
});
|
|
948
|
+
}
|
|
949
|
+
/**
|
|
950
|
+
* Sets custom tags
|
|
951
|
+
*
|
|
952
|
+
* @param namespace {string} - the tracker namespace
|
|
953
|
+
* @param arg {any} - the custom tags
|
|
954
|
+
* @param contexts {Array}- the event contexts
|
|
955
|
+
* @returns {Promise}
|
|
956
|
+
*/
|
|
957
|
+
function setCustomTags$1(namespace, arg, contexts = []) {
|
|
958
|
+
return validateCustomTags(arg)
|
|
959
|
+
.then(() => validateContexts(contexts))
|
|
960
|
+
.then(() => RNConvivaTracker.setCustomTags({
|
|
961
|
+
tracker: namespace,
|
|
962
|
+
tags: arg,
|
|
963
|
+
contexts: contexts
|
|
964
|
+
}))
|
|
965
|
+
.catch((error) => {
|
|
966
|
+
throw new Error(`${logMessages.setCustomTags} ${error.message}`);
|
|
967
|
+
});
|
|
968
|
+
}
|
|
969
|
+
/**
|
|
970
|
+
* Sets custom tags
|
|
971
|
+
*
|
|
972
|
+
* @param namespace {string} - the tracker namespace
|
|
973
|
+
* @param category {string} - category
|
|
974
|
+
* @param arg {any} - the custom tags
|
|
975
|
+
* @param contexts {Array}- the event contexts
|
|
976
|
+
* @returns {Promise}
|
|
977
|
+
*/
|
|
978
|
+
function setCustomTagsWithCategory$1(namespace, category, arg, contexts = []) {
|
|
979
|
+
return validateCustomTags(arg)
|
|
980
|
+
.then(() => validateContexts(contexts))
|
|
981
|
+
.then(() => RNConvivaTracker.setCustomTagsWithCategory({
|
|
982
|
+
tracker: namespace,
|
|
983
|
+
category: category,
|
|
984
|
+
tags: arg,
|
|
985
|
+
contexts: contexts
|
|
986
|
+
}))
|
|
987
|
+
.catch((error) => {
|
|
988
|
+
throw new Error(`${logMessages.setCustomTags} ${error.message}`);
|
|
989
|
+
});
|
|
990
|
+
}
|
|
991
|
+
/**
|
|
992
|
+
* Clears few of the Custom Tags which are set previously
|
|
993
|
+
*
|
|
994
|
+
* @param namespace {string} - the tracker namespace
|
|
995
|
+
* @param argArray {string []} - the custom tag keys to be deleted
|
|
996
|
+
* @param contexts {Array}- the event contexts
|
|
997
|
+
* @returns {Promise}
|
|
998
|
+
*/
|
|
999
|
+
function clearCustomTags$1(namespace, argArray, contexts = []) {
|
|
1000
|
+
return validateClearCustomTags(argArray)
|
|
1001
|
+
.then(() => validateContexts(contexts))
|
|
1002
|
+
.then(() => RNConvivaTracker.clearCustomTags({
|
|
1003
|
+
tracker: namespace,
|
|
1004
|
+
tagKeys: argArray,
|
|
1005
|
+
contexts: contexts
|
|
1006
|
+
}))
|
|
1007
|
+
.catch((error) => {
|
|
1008
|
+
throw new Error(`${logMessages.clearCustomTags} ${error.message}`);
|
|
1009
|
+
});
|
|
1010
|
+
}
|
|
1011
|
+
/**
|
|
1012
|
+
* Clears all the previously set Custom Tags
|
|
1013
|
+
*
|
|
1014
|
+
* @param namespace {string} - the tracker namespace
|
|
1015
|
+
* @param contexts {Array}- the event contexts
|
|
1016
|
+
* @returns {Promise}
|
|
1017
|
+
*/
|
|
1018
|
+
function clearAllCustomTags$1(namespace, contexts = []) {
|
|
1019
|
+
return validateContexts(contexts)
|
|
1020
|
+
.then(() => RNConvivaTracker.clearAllCustomTags({
|
|
1021
|
+
tracker: namespace,
|
|
1022
|
+
contexts: contexts
|
|
1023
|
+
}))
|
|
1024
|
+
.catch((error) => {
|
|
1025
|
+
throw new Error(`${logMessages.clearAllCustomTags} ${error.message}`);
|
|
1026
|
+
});
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
/*
|
|
1030
|
+
* Copyright (c) 2020-2023 Snowplow Analytics Ltd. All rights reserved.
|
|
1031
|
+
*
|
|
1032
|
+
* This program is licensed to you under the Apache License Version 2.0,
|
|
1033
|
+
* and you may not use this file except in compliance with the Apache License Version 2.0.
|
|
1034
|
+
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
|
|
1035
|
+
*
|
|
1036
|
+
* Unless required by applicable law or agreed to in writing,
|
|
1037
|
+
* software distributed under the Apache License Version 2.0 is distributed on an
|
|
1038
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1039
|
+
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
|
|
1040
|
+
*/
|
|
1041
|
+
/**
|
|
1042
|
+
* Sets the userId of the tracker subject
|
|
1043
|
+
*
|
|
1044
|
+
* @param namespace {string} - the tracker namespace
|
|
1045
|
+
* @param newUid {string | null} - the new userId
|
|
1046
|
+
* @returns - Promise
|
|
1047
|
+
*/
|
|
1048
|
+
function setUserId$1(namespace, newUid) {
|
|
1049
|
+
if (!(newUid === null || typeof newUid === 'string')) {
|
|
1050
|
+
return Promise.reject(new Error(logMessages.setUserId));
|
|
1051
|
+
}
|
|
1052
|
+
return Promise.resolve(RNConvivaTracker.setUserId({
|
|
1053
|
+
tracker: namespace,
|
|
1054
|
+
userId: newUid
|
|
1055
|
+
}));
|
|
1056
|
+
}
|
|
1057
|
+
/**
|
|
1058
|
+
* Sets the networkUserId of the tracker subject
|
|
1059
|
+
*
|
|
1060
|
+
* @param namespace {string} - the tracker namespace
|
|
1061
|
+
* @param newNuid {string | null} - the new networkUserId
|
|
1062
|
+
* @returns - Promise
|
|
1063
|
+
*/
|
|
1064
|
+
function setNetworkUserId$1(namespace, newNuid) {
|
|
1065
|
+
if (!(newNuid === null || typeof newNuid === 'string')) {
|
|
1066
|
+
return Promise.reject(new Error(logMessages.setNetworkUserId));
|
|
1067
|
+
}
|
|
1068
|
+
return Promise.resolve(RNConvivaTracker.setNetworkUserId({
|
|
1069
|
+
tracker: namespace,
|
|
1070
|
+
networkUserId: newNuid
|
|
1071
|
+
}));
|
|
1072
|
+
}
|
|
1073
|
+
/**
|
|
1074
|
+
* Sets the domainUserId of the tracker subject
|
|
1075
|
+
*
|
|
1076
|
+
* @param namespace {string} - the tracker namespace
|
|
1077
|
+
* @param newDuid {string | null} - the new domainUserId
|
|
1078
|
+
* @returns - Promise
|
|
1079
|
+
*/
|
|
1080
|
+
function setDomainUserId$1(namespace, newDuid) {
|
|
1081
|
+
if (!(newDuid === null || typeof newDuid === 'string')) {
|
|
1082
|
+
return Promise.reject(new Error(logMessages.setDomainUserId));
|
|
1083
|
+
}
|
|
1084
|
+
return Promise.resolve(RNConvivaTracker.setDomainUserId({
|
|
1085
|
+
tracker: namespace,
|
|
1086
|
+
domainUserId: newDuid
|
|
1087
|
+
}));
|
|
1088
|
+
}
|
|
1089
|
+
/**
|
|
1090
|
+
* Sets the ipAddress of the tracker subject
|
|
1091
|
+
*
|
|
1092
|
+
* @param namespace {string} - the tracker namespace
|
|
1093
|
+
* @param newIp {string | null} - the new ipAddress
|
|
1094
|
+
* @returns - Promise
|
|
1095
|
+
*/
|
|
1096
|
+
function setIpAddress$1(namespace, newIp) {
|
|
1097
|
+
if (!(newIp === null || typeof newIp === 'string')) {
|
|
1098
|
+
return Promise.reject(new Error(logMessages.setIpAddress));
|
|
1099
|
+
}
|
|
1100
|
+
return Promise.resolve(RNConvivaTracker.setIpAddress({
|
|
1101
|
+
tracker: namespace,
|
|
1102
|
+
ipAddress: newIp
|
|
1103
|
+
}));
|
|
1104
|
+
}
|
|
1105
|
+
/**
|
|
1106
|
+
* Sets the useragent of the tracker subject
|
|
1107
|
+
*
|
|
1108
|
+
* @param namespace {string} - the tracker namespace
|
|
1109
|
+
* @param newUagent {string | null} - the new useragent
|
|
1110
|
+
* @returns - Promise
|
|
1111
|
+
*/
|
|
1112
|
+
function setUseragent$1(namespace, newUagent) {
|
|
1113
|
+
if (!(newUagent === null || typeof newUagent === 'string')) {
|
|
1114
|
+
return Promise.reject(new Error(logMessages.setUseragent));
|
|
1115
|
+
}
|
|
1116
|
+
return Promise.resolve(RNConvivaTracker.setUseragent({
|
|
1117
|
+
tracker: namespace,
|
|
1118
|
+
useragent: newUagent
|
|
1119
|
+
}));
|
|
1120
|
+
}
|
|
1121
|
+
/**
|
|
1122
|
+
* Sets the timezone of the tracker subject
|
|
1123
|
+
*
|
|
1124
|
+
* @param namespace {string} - the tracker namespace
|
|
1125
|
+
* @param newTz {string | null} - the new timezone
|
|
1126
|
+
* @returns - Promise
|
|
1127
|
+
*/
|
|
1128
|
+
function setTimezone$1(namespace, newTz) {
|
|
1129
|
+
if (!(newTz === null || typeof newTz === 'string')) {
|
|
1130
|
+
return Promise.reject(new Error(logMessages.setTimezone));
|
|
1131
|
+
}
|
|
1132
|
+
return Promise.resolve(RNConvivaTracker.setTimezone({
|
|
1133
|
+
tracker: namespace,
|
|
1134
|
+
timezone: newTz
|
|
1135
|
+
}));
|
|
1136
|
+
}
|
|
1137
|
+
/**
|
|
1138
|
+
* Sets the language of the tracker subject
|
|
1139
|
+
*
|
|
1140
|
+
* @param namespace {string} - the tracker namespace
|
|
1141
|
+
* @param newLang {string | null} - the new language
|
|
1142
|
+
* @returns - Promise
|
|
1143
|
+
*/
|
|
1144
|
+
function setLanguage$1(namespace, newLang) {
|
|
1145
|
+
if (!(newLang === null || typeof newLang === 'string')) {
|
|
1146
|
+
return Promise.reject(new Error(logMessages.setLanguage));
|
|
1147
|
+
}
|
|
1148
|
+
return Promise.resolve(RNConvivaTracker.setLanguage({
|
|
1149
|
+
tracker: namespace,
|
|
1150
|
+
language: newLang
|
|
1151
|
+
}));
|
|
1152
|
+
}
|
|
1153
|
+
/**
|
|
1154
|
+
* Sets the screenResolution of the tracker subject
|
|
1155
|
+
*
|
|
1156
|
+
* @param namespace {string} - the tracker namespace
|
|
1157
|
+
* @param newRes {ScreenSize | null} - the new screenResolution
|
|
1158
|
+
* @returns - Promise
|
|
1159
|
+
*/
|
|
1160
|
+
function setScreenResolution$1(namespace, newRes) {
|
|
1161
|
+
if (!(newRes === null || isScreenSize(newRes))) {
|
|
1162
|
+
return Promise.reject(new Error(logMessages.setScreenResolution));
|
|
1163
|
+
}
|
|
1164
|
+
return Promise.resolve(RNConvivaTracker.setScreenResolution({
|
|
1165
|
+
tracker: namespace,
|
|
1166
|
+
screenResolution: newRes
|
|
1167
|
+
}));
|
|
1168
|
+
}
|
|
1169
|
+
/**
|
|
1170
|
+
* Sets the screenViewport of the tracker subject
|
|
1171
|
+
*
|
|
1172
|
+
* @param namespace {string} - the tracker namespace
|
|
1173
|
+
* @param newView {ScreenSize | null} - the new screenViewport
|
|
1174
|
+
* @returns - Promise
|
|
1175
|
+
*/
|
|
1176
|
+
function setScreenViewport$1(namespace, newView) {
|
|
1177
|
+
if (!(newView === null || isScreenSize(newView))) {
|
|
1178
|
+
return Promise.reject(new Error(logMessages.setScreenViewport));
|
|
1179
|
+
}
|
|
1180
|
+
return Promise.resolve(RNConvivaTracker.setScreenViewport({
|
|
1181
|
+
tracker: namespace,
|
|
1182
|
+
screenViewport: newView
|
|
1183
|
+
}));
|
|
1184
|
+
}
|
|
1185
|
+
/**
|
|
1186
|
+
* Sets the colorDepth of the tracker subject
|
|
1187
|
+
*
|
|
1188
|
+
* @param namespace {string} - the tracker namespace
|
|
1189
|
+
* @param newColorD {number | null} - the new colorDepth
|
|
1190
|
+
* @returns - Promise
|
|
1191
|
+
*/
|
|
1192
|
+
function setColorDepth$1(namespace, newColorD) {
|
|
1193
|
+
if (!(newColorD === null || typeof newColorD === 'number')) {
|
|
1194
|
+
return Promise.reject(new Error(logMessages.setColorDepth));
|
|
1195
|
+
}
|
|
1196
|
+
return Promise.resolve(RNConvivaTracker.setColorDepth({
|
|
1197
|
+
tracker: namespace,
|
|
1198
|
+
colorDepth: newColorD
|
|
1199
|
+
}));
|
|
1200
|
+
}
|
|
1201
|
+
const setterMap = {
|
|
1202
|
+
userId: setUserId$1,
|
|
1203
|
+
networkUserId: setNetworkUserId$1,
|
|
1204
|
+
domainUserId: setDomainUserId$1,
|
|
1205
|
+
ipAddress: setIpAddress$1,
|
|
1206
|
+
useragent: setUseragent$1,
|
|
1207
|
+
timezone: setTimezone$1,
|
|
1208
|
+
language: setLanguage$1,
|
|
1209
|
+
screenResolution: setScreenResolution$1,
|
|
1210
|
+
screenViewport: setScreenViewport$1,
|
|
1211
|
+
colorDepth: setColorDepth$1
|
|
1212
|
+
};
|
|
1213
|
+
/**
|
|
1214
|
+
* Sets the tracker subject
|
|
1215
|
+
*
|
|
1216
|
+
* @param namespace {string} - the tracker namespace
|
|
1217
|
+
* @param config {SubjectConfiguration} - the new subject data
|
|
1218
|
+
* @returns - Promise
|
|
1219
|
+
*/
|
|
1220
|
+
function setSubjectData$1(namespace, config) {
|
|
1221
|
+
if (!isValidSubjectConf(config)) {
|
|
1222
|
+
return Promise.reject(new Error(`${logMessages.setSubjectData} ${logMessages.subject}`));
|
|
1223
|
+
}
|
|
1224
|
+
const promises = Object.keys(config)
|
|
1225
|
+
.map((k) => {
|
|
1226
|
+
const fun = setterMap[k];
|
|
1227
|
+
return fun ? fun(namespace, config[k]) : undefined;
|
|
1228
|
+
})
|
|
1229
|
+
.filter((f) => f !== undefined);
|
|
1230
|
+
// to use Promise.all (Promise.allSettled not supported in all RN versions)
|
|
1231
|
+
const safePromises = promises
|
|
1232
|
+
.map((p) => p
|
|
1233
|
+
.then((x) => Object.assign({
|
|
1234
|
+
status: 'fulfilled',
|
|
1235
|
+
value: x
|
|
1236
|
+
}))
|
|
1237
|
+
.catch((err) => Object.assign({
|
|
1238
|
+
status: 'rejected',
|
|
1239
|
+
reason: err.message
|
|
1240
|
+
})));
|
|
1241
|
+
return Promise.all(safePromises).then((outcomes) => {
|
|
1242
|
+
const anyReasons = outcomes.filter((res) => res.status === 'rejected');
|
|
1243
|
+
if (anyReasons.length > 0) {
|
|
1244
|
+
const allReasons = anyReasons
|
|
1245
|
+
.reduce((acc, curr) => acc + ':' + curr.reason, logMessages.setSubjectData);
|
|
1246
|
+
throw new Error(allReasons);
|
|
1247
|
+
}
|
|
1248
|
+
return true;
|
|
1249
|
+
});
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
/*
|
|
1253
|
+
* Copyright (c) 2020-2023 Snowplow Analytics Ltd. All rights reserved.
|
|
1254
|
+
*
|
|
1255
|
+
* This program is licensed to you under the Apache License Version 2.0,
|
|
1256
|
+
* and you may not use this file except in compliance with the Apache License Version 2.0.
|
|
1257
|
+
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
|
|
1258
|
+
*
|
|
1259
|
+
* Unless required by applicable law or agreed to in writing,
|
|
1260
|
+
* software distributed under the Apache License Version 2.0 is distributed on an
|
|
1261
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1262
|
+
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
|
|
1263
|
+
*/
|
|
1264
|
+
/**
|
|
1265
|
+
* Create a tracker from specified initial configuration.
|
|
1266
|
+
*
|
|
1267
|
+
* @param initConfig {Object} - The initial tracker configuration
|
|
1268
|
+
* @returns - A promise fullfilled if the tracker is initialized
|
|
1269
|
+
*/
|
|
1270
|
+
function createTracker$1(initConfig) {
|
|
1271
|
+
return initValidate(initConfig)
|
|
1272
|
+
.then(() => RNConvivaTracker.createTracker(initConfig))
|
|
1273
|
+
.catch((error) => {
|
|
1274
|
+
throw new Error(`${logMessages.createTracker} ${error.message}.`);
|
|
1275
|
+
});
|
|
1276
|
+
}
|
|
1277
|
+
/**
|
|
1278
|
+
* Removes the tracker with given namespace
|
|
1279
|
+
*
|
|
1280
|
+
* @param trackerNamespace {string} - The tracker namespace
|
|
1281
|
+
* @returns - A boolean promise
|
|
1282
|
+
*/
|
|
1283
|
+
function removeTracker$1(trackerNamespace) {
|
|
1284
|
+
if (typeof trackerNamespace !== 'string') {
|
|
1285
|
+
return Promise.reject(new Error(logMessages.removeTracker));
|
|
1286
|
+
}
|
|
1287
|
+
return Promise.resolve(RNConvivaTracker.removeTracker({ tracker: trackerNamespace }));
|
|
1288
|
+
}
|
|
1289
|
+
/**
|
|
1290
|
+
* Removes all existing trackers
|
|
1291
|
+
*
|
|
1292
|
+
* @returns - A void promise
|
|
1293
|
+
*/
|
|
1294
|
+
function removeAllTrackers$1() {
|
|
1295
|
+
return Promise.resolve(RNConvivaTracker.removeAllTrackers());
|
|
1296
|
+
}
|
|
1297
|
+
/**
|
|
1298
|
+
* Returns a function to track a SelfDescribing event by a tracker
|
|
1299
|
+
*
|
|
1300
|
+
* @param namespace {string} - The tracker namespace
|
|
1301
|
+
* @returns - A function to track a SelfDescribing event
|
|
1302
|
+
*/
|
|
1303
|
+
function trackSelfDescribingEvent(namespace) {
|
|
1304
|
+
return function (argmap, contexts = []) {
|
|
1305
|
+
return trackSelfDescribingEvent$1(namespace, argmap, contexts);
|
|
1306
|
+
};
|
|
1307
|
+
}
|
|
1308
|
+
/**
|
|
1309
|
+
* Returns a function to track a ScreenView event by a tracker
|
|
1310
|
+
*
|
|
1311
|
+
* @param namespace {string} - The tracker namespace
|
|
1312
|
+
* @returns - A function to track a ScreenView event
|
|
1313
|
+
*/
|
|
1314
|
+
function trackScreenViewEvent(namespace) {
|
|
1315
|
+
return function (argmap, contexts = []) {
|
|
1316
|
+
return trackScreenViewEvent$1(namespace, argmap, contexts);
|
|
1317
|
+
};
|
|
1318
|
+
}
|
|
1319
|
+
/**
|
|
1320
|
+
* Returns a function to track a Structured event by a tracker
|
|
1321
|
+
*
|
|
1322
|
+
* @param namespace {string} - The tracker namespace
|
|
1323
|
+
* @returns - A function to track a Structured event
|
|
1324
|
+
*/
|
|
1325
|
+
function trackStructuredEvent(namespace) {
|
|
1326
|
+
return function (argmap, contexts = []) {
|
|
1327
|
+
return trackStructuredEvent$1(namespace, argmap, contexts);
|
|
1328
|
+
};
|
|
1329
|
+
}
|
|
1330
|
+
/**
|
|
1331
|
+
* Returns a function to track a PageView event by a tracker
|
|
1332
|
+
*
|
|
1333
|
+
* @param namespace {string} - The tracker namespace
|
|
1334
|
+
* @returns - A function to track a PageView event
|
|
1335
|
+
*/
|
|
1336
|
+
function trackPageView(namespace) {
|
|
1337
|
+
return function (argmap, contexts = []) {
|
|
1338
|
+
return trackPageView$1(namespace, argmap, contexts);
|
|
1339
|
+
};
|
|
1340
|
+
}
|
|
1341
|
+
/**
|
|
1342
|
+
* Returns a function to track a Timing event by a tracker
|
|
1343
|
+
*
|
|
1344
|
+
* @param namespace {string} - The tracker namespace
|
|
1345
|
+
* @returns - A function to track a Timing event
|
|
1346
|
+
*/
|
|
1347
|
+
function trackTimingEvent(namespace) {
|
|
1348
|
+
return function (argmap, contexts = []) {
|
|
1349
|
+
return trackTimingEvent$1(namespace, argmap, contexts);
|
|
1350
|
+
};
|
|
1351
|
+
}
|
|
1352
|
+
/**
|
|
1353
|
+
* Returns a function to track a ConsentGranted event by a tracker
|
|
1354
|
+
*
|
|
1355
|
+
* @param namespace {string} - The tracker namespace
|
|
1356
|
+
* @returns - A function to track a ConsentGranted event
|
|
1357
|
+
*/
|
|
1358
|
+
function trackConsentGrantedEvent(namespace) {
|
|
1359
|
+
return function (argmap, contexts = []) {
|
|
1360
|
+
return trackConsentGrantedEvent$1(namespace, argmap, contexts);
|
|
1361
|
+
};
|
|
1362
|
+
}
|
|
1363
|
+
/**
|
|
1364
|
+
* Returns a function to track a ConsentWithdrawn event by a tracker
|
|
1365
|
+
*
|
|
1366
|
+
* @param namespace {string} - The tracker namespace
|
|
1367
|
+
* @returns - A function to track a ConsentWithdrawn event
|
|
1368
|
+
*/
|
|
1369
|
+
function trackConsentWithdrawnEvent(namespace) {
|
|
1370
|
+
return function (argmap, contexts = []) {
|
|
1371
|
+
return trackConsentWithdrawnEvent$1(namespace, argmap, contexts);
|
|
1372
|
+
};
|
|
1373
|
+
}
|
|
1374
|
+
/**
|
|
1375
|
+
* Returns a function to track an EcommerceTransaction event by a tracker
|
|
1376
|
+
*
|
|
1377
|
+
* @param namespace {string} - The tracker namespace
|
|
1378
|
+
* @returns - A function to track an EcommerceTransaction event
|
|
1379
|
+
*/
|
|
1380
|
+
function trackEcommerceTransactionEvent(namespace) {
|
|
1381
|
+
return function (argmap, contexts = []) {
|
|
1382
|
+
return trackEcommerceTransactionEvent$1(namespace, argmap, contexts);
|
|
1383
|
+
};
|
|
1384
|
+
}
|
|
1385
|
+
/**
|
|
1386
|
+
* Returns a function to track an DeepLinkReceived event by a tracker
|
|
1387
|
+
*
|
|
1388
|
+
* @param namespace {string} - The tracker namespace
|
|
1389
|
+
* @returns - A function to track an DeepLinkReceived event
|
|
1390
|
+
*/
|
|
1391
|
+
function trackDeepLinkReceivedEvent(namespace) {
|
|
1392
|
+
return function (argmap, contexts = []) {
|
|
1393
|
+
return trackDeepLinkReceivedEvent$1(namespace, argmap, contexts);
|
|
1394
|
+
};
|
|
1395
|
+
}
|
|
1396
|
+
/**
|
|
1397
|
+
* Returns a function to track an MessageNotification event by a tracker
|
|
1398
|
+
*
|
|
1399
|
+
* @param namespace {string} - The tracker namespace
|
|
1400
|
+
* @returns - A function to track an MessageNotification event
|
|
1401
|
+
*/
|
|
1402
|
+
function trackMessageNotificationEvent(namespace) {
|
|
1403
|
+
return function (argmap, contexts = []) {
|
|
1404
|
+
return trackMessageNotificationEvent$1(namespace, argmap, contexts);
|
|
1405
|
+
};
|
|
1406
|
+
}
|
|
1407
|
+
/**
|
|
1408
|
+
* Returns a function to track an MessageNotification event by a tracker
|
|
1409
|
+
*
|
|
1410
|
+
* @param namespace {string} - The tracker namespace
|
|
1411
|
+
* @returns - A function to track an MessageNotification event
|
|
1412
|
+
*/
|
|
1413
|
+
function trackCustomEvent(namespace) {
|
|
1414
|
+
return function (eventName, eventData, contexts = []) {
|
|
1415
|
+
return trackCustomEvent$1(namespace, eventName, eventData, contexts);
|
|
1416
|
+
};
|
|
1417
|
+
}
|
|
1418
|
+
function setCustomTags(namespace) {
|
|
1419
|
+
return function (tags, contexts = []) {
|
|
1420
|
+
return setCustomTags$1(namespace, tags, contexts);
|
|
1421
|
+
};
|
|
1422
|
+
}
|
|
1423
|
+
function setCustomTagsWithCategory(namespace) {
|
|
1424
|
+
return function (category, tags, contexts = []) {
|
|
1425
|
+
return setCustomTagsWithCategory$1(namespace, category, tags, contexts);
|
|
1426
|
+
};
|
|
1427
|
+
}
|
|
1428
|
+
function clearCustomTags(namespace) {
|
|
1429
|
+
return function (tagKeys, contexts = []) {
|
|
1430
|
+
return clearCustomTags$1(namespace, tagKeys, contexts);
|
|
1431
|
+
};
|
|
1432
|
+
}
|
|
1433
|
+
function clearAllCustomTags(namespace) {
|
|
1434
|
+
return function (contexts = []) {
|
|
1435
|
+
return clearAllCustomTags$1(namespace, contexts);
|
|
1436
|
+
};
|
|
1437
|
+
}
|
|
1438
|
+
/**
|
|
1439
|
+
* Returns a function to remove global contexts by a tracker
|
|
1440
|
+
*
|
|
1441
|
+
* @param namespace {string} - The tracker namespace
|
|
1442
|
+
* @returns - A function to remove global contexts
|
|
1443
|
+
*/
|
|
1444
|
+
function removeGlobalContexts(namespace) {
|
|
1445
|
+
return function (tag) {
|
|
1446
|
+
if (typeof tag !== 'string') {
|
|
1447
|
+
return Promise.reject(new Error(`${logMessages.removeGlobalContexts} ${logMessages.gcTagType}`));
|
|
1448
|
+
}
|
|
1449
|
+
return Promise.resolve(RNConvivaTracker.removeGlobalContexts({ tracker: namespace, removeTag: tag }));
|
|
1450
|
+
};
|
|
1451
|
+
}
|
|
1452
|
+
/**
|
|
1453
|
+
* Returns a function to add global contexts by a tracker
|
|
1454
|
+
*
|
|
1455
|
+
* @param namespace {string} - The tracker namespace
|
|
1456
|
+
* @returns - A function to add global contexts
|
|
1457
|
+
*/
|
|
1458
|
+
function addGlobalContexts(namespace) {
|
|
1459
|
+
return function (gc) {
|
|
1460
|
+
if (!isValidGC(gc)) {
|
|
1461
|
+
return Promise.reject(new Error(`${logMessages.addGlobalContexts} ${logMessages.gcType}`));
|
|
1462
|
+
}
|
|
1463
|
+
return Promise.resolve(RNConvivaTracker.addGlobalContexts({ tracker: namespace, addGlobalContext: gc }));
|
|
1464
|
+
};
|
|
1465
|
+
}
|
|
1466
|
+
/**
|
|
1467
|
+
* Returns a function to set the subject userId
|
|
1468
|
+
*
|
|
1469
|
+
* @param namespace {string} - The tracker namespace
|
|
1470
|
+
* @returns - A function to set the userId
|
|
1471
|
+
*/
|
|
1472
|
+
function setUserId(namespace) {
|
|
1473
|
+
return function (newUid) {
|
|
1474
|
+
return setUserId$1(namespace, newUid);
|
|
1475
|
+
};
|
|
1476
|
+
}
|
|
1477
|
+
/**
|
|
1478
|
+
* Returns a function to set the subject networkUserId
|
|
1479
|
+
*
|
|
1480
|
+
* @param namespace {string} - The tracker namespace
|
|
1481
|
+
* @returns - A function to set the networkUserId
|
|
1482
|
+
*/
|
|
1483
|
+
function setNetworkUserId(namespace) {
|
|
1484
|
+
return function (newNuid) {
|
|
1485
|
+
return setNetworkUserId$1(namespace, newNuid);
|
|
1486
|
+
};
|
|
1487
|
+
}
|
|
1488
|
+
/**
|
|
1489
|
+
* Returns a function to set the subject domainUserId
|
|
1490
|
+
*
|
|
1491
|
+
* @param namespace {string} - The tracker namespace
|
|
1492
|
+
* @returns - A function to set the domainUserId
|
|
1493
|
+
*/
|
|
1494
|
+
function setDomainUserId(namespace) {
|
|
1495
|
+
return function (newDuid) {
|
|
1496
|
+
return setDomainUserId$1(namespace, newDuid);
|
|
1497
|
+
};
|
|
1498
|
+
}
|
|
1499
|
+
/**
|
|
1500
|
+
* Returns a function to set the subject ipAddress
|
|
1501
|
+
*
|
|
1502
|
+
* @param namespace {string} - The tracker namespace
|
|
1503
|
+
* @returns - A function to set the ipAddress
|
|
1504
|
+
*/
|
|
1505
|
+
function setIpAddress(namespace) {
|
|
1506
|
+
return function (newIp) {
|
|
1507
|
+
return setIpAddress$1(namespace, newIp);
|
|
1508
|
+
};
|
|
1509
|
+
}
|
|
1510
|
+
/**
|
|
1511
|
+
* Returns a function to set the subject useragent
|
|
1512
|
+
*
|
|
1513
|
+
* @param namespace {string} - The tracker namespace
|
|
1514
|
+
* @returns - A function to set the useragent
|
|
1515
|
+
*/
|
|
1516
|
+
function setUseragent(namespace) {
|
|
1517
|
+
return function (newUagent) {
|
|
1518
|
+
return setUseragent$1(namespace, newUagent);
|
|
1519
|
+
};
|
|
1520
|
+
}
|
|
1521
|
+
/**
|
|
1522
|
+
* Returns a function to set the subject timezone
|
|
1523
|
+
*
|
|
1524
|
+
* @param namespace {string} - The tracker namespace
|
|
1525
|
+
* @returns - A function to set the timezone
|
|
1526
|
+
*/
|
|
1527
|
+
function setTimezone(namespace) {
|
|
1528
|
+
return function (newTz) {
|
|
1529
|
+
return setTimezone$1(namespace, newTz);
|
|
1530
|
+
};
|
|
1531
|
+
}
|
|
1532
|
+
/**
|
|
1533
|
+
* Returns a function to set the subject language
|
|
1534
|
+
*
|
|
1535
|
+
* @param namespace {string} - The tracker namespace
|
|
1536
|
+
* @returns - A function to set the language
|
|
1537
|
+
*/
|
|
1538
|
+
function setLanguage(namespace) {
|
|
1539
|
+
return function (newLang) {
|
|
1540
|
+
return setLanguage$1(namespace, newLang);
|
|
1541
|
+
};
|
|
1542
|
+
}
|
|
1543
|
+
/**
|
|
1544
|
+
* Returns a function to set the subject screenResolution
|
|
1545
|
+
*
|
|
1546
|
+
* @param namespace {string} - The tracker namespace
|
|
1547
|
+
* @returns - A function to set the screenResolution
|
|
1548
|
+
*/
|
|
1549
|
+
function setScreenResolution(namespace) {
|
|
1550
|
+
return function (newRes) {
|
|
1551
|
+
return setScreenResolution$1(namespace, newRes);
|
|
1552
|
+
};
|
|
1553
|
+
}
|
|
1554
|
+
/**
|
|
1555
|
+
* Returns a function to set the subject screenViewport
|
|
1556
|
+
*
|
|
1557
|
+
* @param namespace {string} - The tracker namespace
|
|
1558
|
+
* @returns - A function to set the screenViewport
|
|
1559
|
+
*/
|
|
1560
|
+
function setScreenViewport(namespace) {
|
|
1561
|
+
return function (newView) {
|
|
1562
|
+
return setScreenViewport$1(namespace, newView);
|
|
1563
|
+
};
|
|
1564
|
+
}
|
|
1565
|
+
/**
|
|
1566
|
+
* Returns a function to set the subject colorDepth
|
|
1567
|
+
*
|
|
1568
|
+
* @param namespace {string} - The tracker namespace
|
|
1569
|
+
* @returns - A function to set the colorDepth
|
|
1570
|
+
*/
|
|
1571
|
+
function setColorDepth(namespace) {
|
|
1572
|
+
return function (newColorD) {
|
|
1573
|
+
return setColorDepth$1(namespace, newColorD);
|
|
1574
|
+
};
|
|
1575
|
+
}
|
|
1576
|
+
/**
|
|
1577
|
+
* Returns a function to set subject data
|
|
1578
|
+
*
|
|
1579
|
+
* @param namespace {string} - The tracker namespace
|
|
1580
|
+
* @returns - A function to set subject data
|
|
1581
|
+
*/
|
|
1582
|
+
function setSubjectData(namespace) {
|
|
1583
|
+
return function (config) {
|
|
1584
|
+
return setSubjectData$1(namespace, config);
|
|
1585
|
+
};
|
|
1586
|
+
}
|
|
1587
|
+
/**
|
|
1588
|
+
* Returns a function to get the current session userId
|
|
1589
|
+
*
|
|
1590
|
+
* @param namespace {string} - The tracker namespace
|
|
1591
|
+
* @returns - A function to get the session userId
|
|
1592
|
+
*/
|
|
1593
|
+
function getSessionUserId(namespace) {
|
|
1594
|
+
return function () {
|
|
1595
|
+
return Promise
|
|
1596
|
+
.resolve(RNConvivaTracker.getSessionUserId({ tracker: namespace }));
|
|
1597
|
+
};
|
|
1598
|
+
}
|
|
1599
|
+
/**
|
|
1600
|
+
* Returns a function to get the current sessionId
|
|
1601
|
+
*
|
|
1602
|
+
* @param namespace {string} - The tracker namespace
|
|
1603
|
+
* @returns - A function to get the sessionId
|
|
1604
|
+
*/
|
|
1605
|
+
function getSessionId(namespace) {
|
|
1606
|
+
return function () {
|
|
1607
|
+
return Promise
|
|
1608
|
+
.resolve(RNConvivaTracker.getSessionId({ tracker: namespace }));
|
|
1609
|
+
};
|
|
1610
|
+
}
|
|
1611
|
+
/**
|
|
1612
|
+
* Returns a function to get the current session index
|
|
1613
|
+
*
|
|
1614
|
+
* @param namespace {string} - The tracker namespace
|
|
1615
|
+
* @returns - A function to get the session index
|
|
1616
|
+
*/
|
|
1617
|
+
function getSessionIndex(namespace) {
|
|
1618
|
+
return function () {
|
|
1619
|
+
return Promise
|
|
1620
|
+
.resolve(RNConvivaTracker.getSessionIndex({ tracker: namespace }));
|
|
1621
|
+
};
|
|
1622
|
+
}
|
|
1623
|
+
/**
|
|
1624
|
+
* Returns a function to get whether the app is in background
|
|
1625
|
+
*
|
|
1626
|
+
* @param namespace {string} - The tracker namespace
|
|
1627
|
+
* @returns - A function to get whether the app isInBackground
|
|
1628
|
+
*/
|
|
1629
|
+
function getIsInBackground(namespace) {
|
|
1630
|
+
return function () {
|
|
1631
|
+
return Promise
|
|
1632
|
+
.resolve(RNConvivaTracker.getIsInBackground({ tracker: namespace }));
|
|
1633
|
+
};
|
|
1634
|
+
}
|
|
1635
|
+
/**
|
|
1636
|
+
* Returns a function to get the background index
|
|
1637
|
+
*
|
|
1638
|
+
* @param namespace {string} - The tracker namespace
|
|
1639
|
+
* @returns - A function to get the backgroundIndex
|
|
1640
|
+
*/
|
|
1641
|
+
function getBackgroundIndex(namespace) {
|
|
1642
|
+
return function () {
|
|
1643
|
+
return Promise
|
|
1644
|
+
.resolve(RNConvivaTracker.getBackgroundIndex({ tracker: namespace }));
|
|
1645
|
+
};
|
|
1646
|
+
}
|
|
1647
|
+
/**
|
|
1648
|
+
* Returns a function to get the foreground index
|
|
1649
|
+
*
|
|
1650
|
+
* @param namespace {string} - The tracker namespace
|
|
1651
|
+
* @returns - A function to get the foregroundIndex
|
|
1652
|
+
*/
|
|
1653
|
+
function getForegroundIndex(namespace) {
|
|
1654
|
+
return function () {
|
|
1655
|
+
return Promise
|
|
1656
|
+
.resolve(RNConvivaTracker.getForegroundIndex({ tracker: namespace }));
|
|
1657
|
+
};
|
|
1658
|
+
}
|
|
1659
|
+
|
|
1660
|
+
/*
|
|
1661
|
+
* Copyright (c) 2020-2023 Snowplow Analytics Ltd. All rights reserved.
|
|
1662
|
+
*
|
|
1663
|
+
* This program is licensed to you under the Apache License Version 2.0,
|
|
1664
|
+
* and you may not use this file except in compliance with the Apache License Version 2.0.
|
|
1665
|
+
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
|
|
1666
|
+
*
|
|
1667
|
+
* Unless required by applicable law or agreed to in writing,
|
|
1668
|
+
* software distributed under the Apache License Version 2.0 is distributed on an
|
|
1669
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1670
|
+
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
|
|
1671
|
+
*/
|
|
1672
|
+
function forEachTracker(trackers, iterator) {
|
|
1673
|
+
if (trackers && trackers.length > 0) {
|
|
1674
|
+
trackers.forEach(iterator);
|
|
1675
|
+
}
|
|
1676
|
+
else {
|
|
1677
|
+
iterator(null);
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
/**
|
|
1681
|
+
* Enables tracking events from apps rendered in react-native-webview components.
|
|
1682
|
+
* The apps need to use the Conviva WebView tracker to track the events.
|
|
1683
|
+
*
|
|
1684
|
+
* To subscribe for the events, set the `onMessage` attribute:
|
|
1685
|
+
* <WebView onMessage={getWebViewCallback()} ... />
|
|
1686
|
+
*
|
|
1687
|
+
* @returns Callback to subscribe for events from Web views tracked using the Conviva WebView tracker.
|
|
1688
|
+
*/
|
|
1689
|
+
function getWebViewCallback() {
|
|
1690
|
+
return (message) => {
|
|
1691
|
+
const data = JSON.parse(message.nativeEvent.data);
|
|
1692
|
+
switch (data.command) {
|
|
1693
|
+
case 'trackSelfDescribingEvent':
|
|
1694
|
+
forEachTracker(data.trackers, (namespace) => {
|
|
1695
|
+
trackSelfDescribingEvent$1(namespace, data.event, data.context || []).catch((error) => {
|
|
1696
|
+
errorHandler(error);
|
|
1697
|
+
});
|
|
1698
|
+
});
|
|
1699
|
+
break;
|
|
1700
|
+
case 'trackStructEvent':
|
|
1701
|
+
forEachTracker(data.trackers, (namespace) => {
|
|
1702
|
+
trackStructuredEvent$1(namespace, data.event, data.context || []).catch((error) => {
|
|
1703
|
+
errorHandler(error);
|
|
1704
|
+
});
|
|
1705
|
+
});
|
|
1706
|
+
break;
|
|
1707
|
+
case 'trackPageView':
|
|
1708
|
+
forEachTracker(data.trackers, (namespace) => {
|
|
1709
|
+
const event = data.event;
|
|
1710
|
+
trackPageView$1(namespace, {
|
|
1711
|
+
pageTitle: event.title ?? '',
|
|
1712
|
+
pageUrl: event.url ?? '',
|
|
1713
|
+
referrer: event.referrer,
|
|
1714
|
+
}).catch((error) => {
|
|
1715
|
+
errorHandler(error);
|
|
1716
|
+
});
|
|
1717
|
+
});
|
|
1718
|
+
break;
|
|
1719
|
+
case 'trackScreenView':
|
|
1720
|
+
forEachTracker(data.trackers, (namespace) => {
|
|
1721
|
+
trackScreenViewEvent$1(namespace, data.event, data.context || []).catch((error) => {
|
|
1722
|
+
errorHandler(error);
|
|
1723
|
+
});
|
|
1724
|
+
});
|
|
1725
|
+
break;
|
|
1726
|
+
}
|
|
1727
|
+
};
|
|
1728
|
+
}
|
|
1729
|
+
|
|
1730
|
+
/*
|
|
1731
|
+
* Copyright (c) 2020-2023 Snowplow Analytics Ltd. All rights reserved.
|
|
1732
|
+
*
|
|
1733
|
+
* This program is licensed to you under the Apache License Version 2.0,
|
|
1734
|
+
* and you may not use this file except in compliance with the Apache License Version 2.0.
|
|
1735
|
+
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
|
|
1736
|
+
*
|
|
1737
|
+
* Unless required by applicable law or agreed to in writing,
|
|
1738
|
+
* software distributed under the Apache License Version 2.0 is distributed on an
|
|
1739
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1740
|
+
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
|
|
1741
|
+
*/
|
|
1742
|
+
/**
|
|
1743
|
+
* Creates a React Native Tracker object
|
|
1744
|
+
*
|
|
1745
|
+
* @param networkConfig {Object} - The network configuration
|
|
1746
|
+
* @param control {Array} - The tracker controller configuration
|
|
1747
|
+
* @returns The tracker object
|
|
1748
|
+
*/
|
|
1749
|
+
function createTracker(customerKey, appName,
|
|
1750
|
+
// networkConfig: NetworkConfiguration,
|
|
1751
|
+
controllerConfig = {}) {
|
|
1752
|
+
// initTrackerPromise
|
|
1753
|
+
const initTrackerPromise = Promise.resolve(createTracker$1({
|
|
1754
|
+
customerKey,
|
|
1755
|
+
appName,
|
|
1756
|
+
...controllerConfig
|
|
1757
|
+
}));
|
|
1758
|
+
// mkMethod creates methods subscribed to the initTrackerPromise
|
|
1759
|
+
const mkMethod = safeWait(initTrackerPromise, errorHandler);
|
|
1760
|
+
// mkCallback creates callbacks subscribed to the initTrackerPromise
|
|
1761
|
+
const mkCallback = safeWaitCallback(initTrackerPromise, errorHandler);
|
|
1762
|
+
// track methods
|
|
1763
|
+
const namespace = "CAT"; //default namespace is "CAT"
|
|
1764
|
+
const trackSelfDescribingEvent$1 = mkMethod(trackSelfDescribingEvent(namespace));
|
|
1765
|
+
const trackScreenViewEvent$1 = mkMethod(trackScreenViewEvent(namespace));
|
|
1766
|
+
const trackStructuredEvent$1 = mkMethod(trackStructuredEvent(namespace));
|
|
1767
|
+
const trackPageView$1 = mkMethod(trackPageView(namespace));
|
|
1768
|
+
const trackTimingEvent$1 = mkMethod(trackTimingEvent(namespace));
|
|
1769
|
+
const trackConsentGrantedEvent$1 = mkMethod(trackConsentGrantedEvent(namespace));
|
|
1770
|
+
const trackConsentWithdrawnEvent$1 = mkMethod(trackConsentWithdrawnEvent(namespace));
|
|
1771
|
+
const trackEcommerceTransactionEvent$1 = mkMethod(trackEcommerceTransactionEvent(namespace));
|
|
1772
|
+
const trackDeepLinkReceivedEvent$1 = mkMethod(trackDeepLinkReceivedEvent(namespace));
|
|
1773
|
+
const trackMessageNotificationEvent$1 = mkMethod(trackMessageNotificationEvent(namespace));
|
|
1774
|
+
const trackCustomEvent$1 = mkMethod(trackCustomEvent(namespace));
|
|
1775
|
+
// custom tags contexts
|
|
1776
|
+
const setCustomTags$1 = mkMethod(setCustomTags(namespace));
|
|
1777
|
+
const setCustomTagsWithCategory$1 = mkMethod(setCustomTagsWithCategory(namespace));
|
|
1778
|
+
const clearCustomTags$1 = mkMethod(clearCustomTags(namespace));
|
|
1779
|
+
const clearAllCustomTags$1 = mkMethod(clearAllCustomTags(namespace));
|
|
1780
|
+
// Global Contexts
|
|
1781
|
+
const removeGlobalContexts$1 = mkMethod(removeGlobalContexts(namespace));
|
|
1782
|
+
const addGlobalContexts$1 = mkMethod(addGlobalContexts(namespace));
|
|
1783
|
+
// setters
|
|
1784
|
+
const setUserId$1 = mkMethod(setUserId(namespace));
|
|
1785
|
+
const setNetworkUserId$1 = mkMethod(setNetworkUserId(namespace));
|
|
1786
|
+
const setDomainUserId$1 = mkMethod(setDomainUserId(namespace));
|
|
1787
|
+
const setIpAddress$1 = mkMethod(setIpAddress(namespace));
|
|
1788
|
+
const setUseragent$1 = mkMethod(setUseragent(namespace));
|
|
1789
|
+
const setTimezone$1 = mkMethod(setTimezone(namespace));
|
|
1790
|
+
const setLanguage$1 = mkMethod(setLanguage(namespace));
|
|
1791
|
+
const setScreenResolution$1 = mkMethod(setScreenResolution(namespace));
|
|
1792
|
+
const setScreenViewport$1 = mkMethod(setScreenViewport(namespace));
|
|
1793
|
+
const setColorDepth$1 = mkMethod(setColorDepth(namespace));
|
|
1794
|
+
const setSubjectData$1 = mkMethod(setSubjectData(namespace));
|
|
1795
|
+
// callbacks
|
|
1796
|
+
const getSessionUserId$1 = mkCallback(getSessionUserId(namespace));
|
|
1797
|
+
const getSessionId$1 = mkCallback(getSessionId(namespace));
|
|
1798
|
+
const getSessionIndex$1 = mkCallback(getSessionIndex(namespace));
|
|
1799
|
+
const getIsInBackground$1 = mkCallback(getIsInBackground(namespace));
|
|
1800
|
+
const getBackgroundIndex$1 = mkCallback(getBackgroundIndex(namespace));
|
|
1801
|
+
const getForegroundIndex$1 = mkCallback(getForegroundIndex(namespace));
|
|
1802
|
+
return Object.freeze({
|
|
1803
|
+
trackSelfDescribingEvent: trackSelfDescribingEvent$1,
|
|
1804
|
+
trackScreenViewEvent: trackScreenViewEvent$1,
|
|
1805
|
+
trackStructuredEvent: trackStructuredEvent$1,
|
|
1806
|
+
trackPageView: trackPageView$1,
|
|
1807
|
+
trackTimingEvent: trackTimingEvent$1,
|
|
1808
|
+
trackConsentGrantedEvent: trackConsentGrantedEvent$1,
|
|
1809
|
+
trackConsentWithdrawnEvent: trackConsentWithdrawnEvent$1,
|
|
1810
|
+
trackEcommerceTransactionEvent: trackEcommerceTransactionEvent$1,
|
|
1811
|
+
trackDeepLinkReceivedEvent: trackDeepLinkReceivedEvent$1,
|
|
1812
|
+
trackMessageNotificationEvent: trackMessageNotificationEvent$1,
|
|
1813
|
+
trackCustomEvent: trackCustomEvent$1,
|
|
1814
|
+
setCustomTags: setCustomTags$1,
|
|
1815
|
+
setCustomTagsWithCategory: setCustomTagsWithCategory$1,
|
|
1816
|
+
clearCustomTags: clearCustomTags$1,
|
|
1817
|
+
clearAllCustomTags: clearAllCustomTags$1,
|
|
1818
|
+
removeGlobalContexts: removeGlobalContexts$1,
|
|
1819
|
+
addGlobalContexts: addGlobalContexts$1,
|
|
1820
|
+
setUserId: setUserId$1,
|
|
1821
|
+
setNetworkUserId: setNetworkUserId$1,
|
|
1822
|
+
setDomainUserId: setDomainUserId$1,
|
|
1823
|
+
setIpAddress: setIpAddress$1,
|
|
1824
|
+
setUseragent: setUseragent$1,
|
|
1825
|
+
setTimezone: setTimezone$1,
|
|
1826
|
+
setLanguage: setLanguage$1,
|
|
1827
|
+
setScreenResolution: setScreenResolution$1,
|
|
1828
|
+
setScreenViewport: setScreenViewport$1,
|
|
1829
|
+
setColorDepth: setColorDepth$1,
|
|
1830
|
+
setSubjectData: setSubjectData$1,
|
|
1831
|
+
getSessionUserId: getSessionUserId$1,
|
|
1832
|
+
getSessionId: getSessionId$1,
|
|
1833
|
+
getSessionIndex: getSessionIndex$1,
|
|
1834
|
+
getIsInBackground: getIsInBackground$1,
|
|
1835
|
+
getBackgroundIndex: getBackgroundIndex$1,
|
|
1836
|
+
getForegroundIndex: getForegroundIndex$1,
|
|
1837
|
+
});
|
|
1838
|
+
}
|
|
1839
|
+
/**
|
|
1840
|
+
* Removes a tracker given its namespace
|
|
1841
|
+
*
|
|
1842
|
+
* @param trackerNamespace {string}
|
|
1843
|
+
* @returns - A boolean promise
|
|
1844
|
+
*/
|
|
1845
|
+
function removeTracker(trackerNamespace) {
|
|
1846
|
+
return removeTracker$1(trackerNamespace)
|
|
1847
|
+
.catch((e) => errorHandler(e));
|
|
1848
|
+
}
|
|
1849
|
+
/**
|
|
1850
|
+
* Removes all trackers
|
|
1851
|
+
*
|
|
1852
|
+
* @returns - A boolean promise
|
|
1853
|
+
*/
|
|
1854
|
+
function removeAllTrackers() {
|
|
1855
|
+
return removeAllTrackers$1()
|
|
1856
|
+
.catch((e) => errorHandler(e));
|
|
1857
|
+
}
|
|
1858
|
+
|
|
1859
|
+
export { createTracker, getWebViewCallback, removeAllTrackers, removeTracker };
|
|
1860
|
+
//# sourceMappingURL=index.js.map
|