kv-test-ang 1.0.0 → 1.0.2

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.
@@ -1,1649 +0,0 @@
1
- import * as i0 from '@angular/core';
2
- import { Injectable, NgModule } from '@angular/core';
3
-
4
- /*
5
- Authored by Brett Barinaga on 11/17/21.
6
- Copyright (c) Kochava, Inc. All rights reserved.
7
- */
8
- const uuidv4 = () => {
9
- return (`${1e7}-${1e3}-${4e3}-${8e3}-${1e11}`).replace(/[018]/g, (c) => (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16));
10
- };
11
- // returns the number of milliseconds elapsed since January 1, 1970
12
- const getCurrTimeMS = () => Math.floor(Date.now());
13
- // returns the number of seconds elapsed since January 1, 1970
14
- const getCurrTimeSec = () => Math.floor(Date.now() / 1000);
15
- const formatTime = (num) => {
16
- if (num < 10 && num % 10 <= 9)
17
- return "0" + num.toFixed(1).toString();
18
- else
19
- return num.toFixed(1).toString();
20
- };
21
- const getMsTime = () => {
22
- const date = new Date();
23
- return `${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}:${date.getMilliseconds()}`;
24
- };
25
-
26
- /*
27
- Authored by Brett Barinaga on 11/17/21.
28
- Copyright (c) Kochava, Inc. All rights reserved.
29
- */
30
- var Level;
31
- (function (Level) {
32
- Level["Off"] = "Off";
33
- Level["Error"] = "Error";
34
- Level["Warn"] = "Warn";
35
- Level["Info"] = "Info";
36
- Level["Debug"] = "Debug";
37
- Level["Trace"] = "Trace";
38
- })(Level || (Level = {}));
39
- class Logger {
40
- constructor() {
41
- if (Logger.instance)
42
- return;
43
- this.levelPrio = {
44
- Off: 0,
45
- Error: 1,
46
- Warn: 2,
47
- Info: 3,
48
- Debug: 4,
49
- Trace: 5,
50
- };
51
- this.currLevel = Level.Info;
52
- this.logObjects = false;
53
- this.logsFilteredOut = {
54
- Off: false,
55
- Error: false,
56
- Warn: false,
57
- Info: false,
58
- Debug: false,
59
- Trace: false,
60
- Diag: false,
61
- };
62
- Logger.instance = this;
63
- }
64
- setLogLevel(input) {
65
- const levelStr = input[0].toUpperCase() + input.substring(1).toLowerCase();
66
- const key = levelStr;
67
- const level = Level[key];
68
- if (level !== undefined && level !== null) {
69
- this.currLevel = level;
70
- }
71
- else {
72
- console.log(`Invalid logLevel ${level} passed in, defaulting to info.`);
73
- this.currLevel = Level.Info;
74
- }
75
- }
76
- getLogLevel() {
77
- return this.currLevel.toString();
78
- }
79
- setLogObjects(enable) {
80
- this.logObjects = enable;
81
- }
82
- disableLogType(input) {
83
- const levelStr = input[0].toUpperCase() + input.substring(1).toLowerCase();
84
- const key = levelStr;
85
- this.logsFilteredOut[key] = true;
86
- }
87
- error(msg, ...args) {
88
- this.print(Level.Error, msg, ...args);
89
- }
90
- warn(msg, ...args) {
91
- this.print(Level.Warn, msg, ...args);
92
- }
93
- info(msg, ...args) {
94
- this.print(Level.Info, msg, ...args);
95
- }
96
- debug(msg, ...args) {
97
- this.print(Level.Debug, msg, ...args);
98
- }
99
- trace(msg, ...args) {
100
- this.print(Level.Trace, msg, ...args);
101
- }
102
- diagInfo(msg, ...args) {
103
- if (!this.logsFilteredOut.Diag)
104
- this.print(Level.Info, "Kochava Diagnostic - " + msg, ...args);
105
- }
106
- diagDebug(msg, ...args) {
107
- if (!this.logsFilteredOut.Diag)
108
- this.print(Level.Debug, "Kochava Diagnostic - " + msg, ...args);
109
- }
110
- print(lvl, msg, ...args) {
111
- if (this.levelPrio[this.currLevel.toString()] >= this.levelPrio[lvl.toString()] &&
112
- !this.logsFilteredOut[lvl.toString()]) {
113
- try {
114
- const obj = JSON.parse(args[0]);
115
- if (this.logObjects && obj) {
116
- console.log(`KVA :: ${getMsTime()} ${lvl.toString()}:`, msg, obj);
117
- }
118
- else {
119
- console.log(`KVA :: ${getMsTime()} ${lvl.toString()}:`, msg, ...args);
120
- }
121
- }
122
- catch (_a) {
123
- console.log(`KVA :: ${getMsTime()} ${lvl.toString()}:`, msg, ...args);
124
- }
125
- }
126
- }
127
- }
128
- const Log = new Logger();
129
-
130
- /*
131
- Authored by Brett Barinaga on 11/17/21.
132
- Copyright (c) Kochava, Inc. All rights reserved.
133
- */
134
- const sendRequest = async (payload, endpoint) => {
135
- try {
136
- const headers = new Headers();
137
- headers.append("Content-Type", "application/json");
138
- Log.trace(`Request ${payload.nt_id} being sent to: `, endpoint);
139
- const resp = await fetch(endpoint, {
140
- method: "POST",
141
- headers: headers,
142
- body: JSON.stringify(payload),
143
- });
144
- return await resp.text();
145
- }
146
- catch (e) {
147
- Log.error("Error in post request", e);
148
- return "";
149
- }
150
- };
151
- const wasRespSuccess = (success) => success === "1" || success === 1 || success === true;
152
-
153
- /*
154
- Authored by Brett Barinaga on 11/17/21.
155
- Copyright (c) Kochava, Inc. All rights reserved.
156
- */
157
- const getPackageName = () => `com.${window.location.hostname}.web`;
158
- const getLanguage = () => (navigator) ? navigator.language : "";
159
- const getDeviceWidth = () => (window) ? window.screen.availWidth : 0;
160
- const getDeviceHeight = () => (window) ? window.screen.availHeight : 0;
161
- const getDeviceOrientation = () => (window) ? window.innerWidth < window.innerHeight
162
- ? "portrait" : "landscape" : "";
163
- const getBaseDomain = () => {
164
- try {
165
- const regexResult = window.location.host.match(/[^.]*\.[^.]*$/);
166
- if (regexResult)
167
- return regexResult[0];
168
- return "";
169
- }
170
- catch (err) {
171
- return window.location.host;
172
- }
173
- };
174
- const getPageName = () => {
175
- let page = "";
176
- if (window.location) {
177
- page = window.location.pathname.substring(1);
178
- page = page.replace(/\/+$/, "");
179
- }
180
- return page === "" ? "/" : page;
181
- };
182
- const getUrlParameter = (name) => {
183
- if (!window.location || !window.location.search) {
184
- return "";
185
- }
186
- name = name.replace(/[[]/, "\\[").replace(/[\]]/, "\\]");
187
- const regex = new RegExp("[\\?&]" + name + "=([^&#]*)");
188
- const results = regex.exec(window.location.search);
189
- return results === null
190
- ? ""
191
- : decodeURIComponent(results[1].replace(/\+/g, " "));
192
- };
193
-
194
- /*
195
- Authored by Brett Barinaga on 11/17/21.
196
- Copyright (c) Kochava, Inc. All rights reserved.
197
- */
198
- const constructPayload = (action, instance, originalNtId) => {
199
- let nt_id = `${instance.kochavaSession}-${instance.kochavaSessionCount}-${uuidv4()}`;
200
- if (originalNtId) {
201
- Log.debug("Persisted call found with nt_id:", originalNtId);
202
- nt_id = originalNtId;
203
- }
204
- return {
205
- action: action,
206
- kochava_app_id: instance.appGuid,
207
- kochava_device_id: instance.kochavaDeviceId,
208
- sdk_version: instance.version,
209
- sdk_protocol: "17",
210
- nt_id: nt_id,
211
- init_token: (instance.kochavaConfig.config.init_token) || undefined,
212
- };
213
- };
214
- const constructCommonData = (instance) => {
215
- const currTime = getCurrTimeMS();
216
- let uptime = (currTime - instance.startTimeMS) / 1000;
217
- if (uptime < 0.0)
218
- uptime = 0.0;
219
- return {
220
- starttime: instance.startTimeMS / 1000,
221
- uptime: uptime,
222
- usertime: currTime / 1000,
223
- };
224
- };
225
-
226
- /*
227
- Authored by Brett Barinaga on 11/17/21.
228
- Copyright (c) Kochava, Inc. All rights reserved.
229
- */
230
- const constructPreStart$1 = (instance, eventName, eventData) => {
231
- const preStart = {
232
- action: "event",
233
- sdk_version: instance.version,
234
- sdk_protocol: "17",
235
- data: {
236
- event_name: eventName,
237
- event_data: eventData,
238
- device_orientation: getDeviceOrientation(),
239
- disp_w: getDeviceWidth(),
240
- disp_h: getDeviceHeight(),
241
- },
242
- };
243
- if (instance.kochavaConfig)
244
- preStart.init_token = (instance.kochavaConfig.config.init_token) || undefined;
245
- return preStart;
246
- };
247
- const constructPostStart$1 = (instance, preStartBody) => {
248
- const postStartBody = {
249
- kochava_app_id: instance.appGuid,
250
- kochava_device_id: instance.kochavaDeviceId,
251
- nt_id: `${instance.kochavaSession}-${instance.kochavaSessionCount}-${uuidv4()}`,
252
- };
253
- postStartBody.data = Object.assign(Object.assign({}, constructCommonData(instance)), preStartBody.data);
254
- instance.customValues.forEach((custom) => {
255
- if (!custom.isDeviceId) {
256
- const customKey = Object.keys(custom.data)[0];
257
- if (instance.kochavaConfig.privacy) {
258
- let keyAllowed = false;
259
- for (const allowed of instance.kochavaConfig.privacy.allow_custom_ids) {
260
- if (customKey === allowed) {
261
- keyAllowed = true;
262
- }
263
- }
264
- if (keyAllowed)
265
- postStartBody.data = Object.assign(Object.assign({}, custom.data), postStartBody.data);
266
- }
267
- }
268
- });
269
- return postStartBody;
270
- };
271
- const build$3 = (instance, preStartBody, postStartBody) => {
272
- const payload = Object.assign(Object.assign({}, preStartBody), postStartBody);
273
- Log.debug("Event Payload", JSON.stringify(payload));
274
- if (instance.kochavaConfig.privacy) {
275
- instance.kochavaConfig.privacy.deny_datapoints.forEach(denyPoint => {
276
- for (const point in payload.data) {
277
- const key = point;
278
- if (key === denyPoint)
279
- delete payload.data[key];
280
- }
281
- for (const point in payload) {
282
- const key = point;
283
- if (key === denyPoint)
284
- delete payload[key];
285
- }
286
- });
287
- }
288
- return payload;
289
- };
290
- const send$3 = async (instance, preStartBody, postStartBody) => {
291
- const payload = build$3(instance, preStartBody, postStartBody);
292
- const respStr = await sendRequest(payload, (instance.overrideUrls.event) ?
293
- instance.overrideUrls.event : instance.kochavaConfig.networking.urls.event);
294
- let resp;
295
- let success = false;
296
- try {
297
- Log.trace("Event Response string:", respStr);
298
- resp = JSON.parse(respStr);
299
- Log.debug("Event Response:", respStr);
300
- success = wasRespSuccess(resp.success);
301
- }
302
- catch (e) {
303
- Log.error("Error parsing Event Response", e);
304
- success = false;
305
- }
306
- if (success) {
307
- Log.info("Event success!");
308
- return true;
309
- }
310
- Log.error("Event failed!");
311
- return false;
312
- };
313
-
314
- /*
315
- Authored by Brett Barinaga on 11/18/21.
316
- Copyright (c) Kochava, Inc. All rights reserved.
317
- */
318
- const constructPreStart = (instance, idLink) => {
319
- const preStart = {
320
- action: "identityLink",
321
- sdk_version: instance.version,
322
- sdk_protocol: "17",
323
- data: {
324
- identity_link: Object.assign({}, idLink),
325
- },
326
- };
327
- if (instance.kochavaConfig)
328
- preStart.init_token = (instance.kochavaConfig.config.init_token) || undefined;
329
- return preStart;
330
- };
331
- const constructPostStart = (instance, preStartBody) => {
332
- const postStartBody = {
333
- kochava_app_id: instance.appGuid,
334
- kochava_device_id: instance.kochavaDeviceId,
335
- nt_id: `${instance.kochavaSession}-${instance.kochavaSessionCount}-${uuidv4()}`,
336
- };
337
- postStartBody.data = Object.assign(Object.assign({}, preStartBody.data), constructCommonData(instance));
338
- return postStartBody;
339
- };
340
- const build$2 = (instance, job) => {
341
- const payload = Object.assign(Object.assign({}, job.preStartBody), job.postStartBody);
342
- Log.debug("IdentityLink Payload", JSON.stringify(payload));
343
- Log.diagDebug(`IdentityLink to be sent as stand alone`);
344
- if (instance.kochavaConfig.privacy) {
345
- instance.kochavaConfig.privacy.deny_datapoints.forEach(denyPoint => {
346
- for (const point in payload.data) {
347
- const key = point;
348
- if (key === denyPoint)
349
- delete payload.data[key];
350
- }
351
- for (const point in payload) {
352
- const key = point;
353
- if (key === denyPoint)
354
- delete payload[key];
355
- }
356
- });
357
- }
358
- return payload;
359
- };
360
- const send$2 = async (instance, job) => {
361
- const payload = build$2(instance, job);
362
- const respStr = await sendRequest(payload, (instance.overrideUrls.identityLink) ?
363
- instance.overrideUrls.identityLink : instance.kochavaConfig.networking.urls.identityLink);
364
- let resp;
365
- let success = false;
366
- try {
367
- Log.trace("IdentityLink Response string:", respStr);
368
- resp = JSON.parse(respStr);
369
- Log.debug("IdentityLink Response:", respStr);
370
- success = wasRespSuccess(resp.success);
371
- }
372
- catch (e) {
373
- Log.error("Error parsing IdentityLink Response", e);
374
- success = false;
375
- }
376
- if (success) {
377
- Log.info("IdentityLink success!");
378
- return true;
379
- }
380
- Log.error("IdentityLink failed!");
381
- return false;
382
- };
383
-
384
- /*
385
- Authored by Brett Barinaga on 11/17/21.
386
- Copyright (c) Kochava, Inc. All rights reserved.
387
- */
388
- const setCookie = (name, value) => {
389
- let expires = "";
390
- const date = new Date();
391
- date.setTime(date.getTime() + 3650 * 24 * 60 * 60 * 1000);
392
- expires = `; expires=${date.toUTCString()}`;
393
- document.cookie =
394
- name +
395
- "=" +
396
- (value || "") +
397
- expires +
398
- "; path=/;domain=" +
399
- getBaseDomain();
400
- };
401
- const getCookie = (name) => {
402
- const nameEQ = name + "=";
403
- const charArray = document.cookie.split(';');
404
- for (let i = 0; i < charArray.length; i++) {
405
- let char = charArray[i];
406
- while (char.charAt(0) === " ")
407
- char = char.substring(1, char.length);
408
- if (char.indexOf(nameEQ) === 0)
409
- return char.substring(nameEQ.length, char.length);
410
- }
411
- return "";
412
- };
413
- const deleteCookie = (name) => {
414
- if (getCookie(name)) {
415
- const path = "/";
416
- const domain = getBaseDomain();
417
- document.cookie = name + "=" +
418
- ((path) ? ";path=" + path : "") +
419
- ((domain) ? ";domain=" + domain : "") +
420
- ";expires=Thu, 01 Jan 1970 00:00:01 GMT";
421
- }
422
- };
423
-
424
- /*
425
- Authored by Brett Barinaga on 11/17/21.
426
- Copyright (c) Kochava, Inc. All rights reserved.
427
- */
428
- const MAX_STORED_IDLINKS = 10;
429
- var PersistKey;
430
- (function (PersistKey) {
431
- PersistKey["LastKvinit"] = "com.kochava.tracker.LastKvinit";
432
- PersistKey["EventQueue"] = "com.kochava.tracker.EventQueue";
433
- PersistKey["IdLinkQueue"] = "com.kochava.tracker.IdLinkQueue";
434
- PersistKey["DeviceId"] = "com.kochava.tracker.DeviceId";
435
- PersistKey["InstallId"] = "com.kochava.tracker.InstallId";
436
- PersistKey["FirstStartDate"] = "com.kochava.tracker.FirstStartDate";
437
- PersistKey["InstallSentDate"] = "com.kochava.tracker.InstallSentDate";
438
- PersistKey["KvinitSentDate"] = "com.kochava.tracker.KvinitSentDate";
439
- PersistKey["SessionCount"] = "com.kochava.tracker.SessionCount";
440
- PersistKey["IdentityLinks"] = "com.kochava.tracker.IdentityLinks";
441
- PersistKey["OverrideAppId"] = "com.kochava.tracker.OverrideAppId";
442
- PersistKey["OverrideDeviceId"] = "com.kochava.tracker.OverrideDeviceId";
443
- PersistKey["OldKvid"] = "kv_id";
444
- })(PersistKey || (PersistKey = {}));
445
- const storedKeys = [
446
- PersistKey.LastKvinit,
447
- PersistKey.EventQueue,
448
- PersistKey.IdLinkQueue,
449
- PersistKey.DeviceId,
450
- PersistKey.InstallId,
451
- PersistKey.FirstStartDate,
452
- PersistKey.InstallSentDate,
453
- PersistKey.KvinitSentDate,
454
- PersistKey.SessionCount,
455
- PersistKey.IdentityLinks,
456
- PersistKey.OverrideAppId,
457
- PersistKey.OverrideDeviceId,
458
- ];
459
- const checkInstallIdChange = (inputId, useCookies) => {
460
- const persistedInstallId = readAndUpdatePersistedValue(PersistKey.InstallId, useCookies);
461
- // if the input is empty, we don't need to change
462
- if (!inputId)
463
- return false;
464
- // if the persistedId is empty, we will need to change
465
- if (!persistedInstallId) {
466
- updatePersistedValue(PersistKey.InstallId, inputId, useCookies);
467
- return true;
468
- }
469
- // if the inputId and persistedId are the same, we dont need to change
470
- if (inputId === persistedInstallId)
471
- return false;
472
- // at this point both inputId and persistedInstallId exist and are not equal,
473
- // so we must need to change
474
- updatePersistedValue(PersistKey.InstallId, inputId, useCookies);
475
- return true;
476
- };
477
- const addToPersistedEventQueue = (job) => {
478
- const persistedQueueStr = localStorage.getItem(PersistKey.EventQueue);
479
- const persistedQueue = JSON.parse(persistedQueueStr) || [];
480
- persistedQueue.push(job);
481
- localStorage.setItem(PersistKey.EventQueue, JSON.stringify(persistedQueue));
482
- };
483
- const removeFromEventPersistedQueue = (job) => {
484
- const persistedQueueStr = localStorage.getItem(PersistKey.EventQueue);
485
- const persistedQueue = JSON.parse(persistedQueueStr) || [];
486
- const queueWithJobRemoved = persistedQueue.filter(persistedJob => {
487
- return persistedJob.id !== job.id;
488
- });
489
- localStorage.setItem(PersistKey.EventQueue, JSON.stringify(queueWithJobRemoved));
490
- };
491
- const updateOrAddPersistedIdLinkQueue = (job) => {
492
- const idLinkKey = Object.keys(job.idLink)[0];
493
- const persistedQueueStr = localStorage.getItem(PersistKey.IdLinkQueue);
494
- const persistedQueue = JSON.parse(persistedQueueStr) || [];
495
- let updated = false;
496
- for (const persistedJob of persistedQueue) {
497
- const persistedKey = Object.keys(persistedJob.idLink)[0];
498
- // if the key is already there, update it
499
- if (idLinkKey === persistedKey) {
500
- persistedJob.idLink[idLinkKey] = job.idLink[idLinkKey];
501
- updated = true;
502
- }
503
- }
504
- // if the key is new, add it
505
- if (!updated)
506
- persistedQueue.push(job);
507
- localStorage.setItem(PersistKey.IdLinkQueue, JSON.stringify(persistedQueue));
508
- };
509
- const removeFromIdLinkPersistedQueue = (job) => {
510
- const persistedQueueStr = localStorage.getItem(PersistKey.IdLinkQueue);
511
- const persistedQueue = JSON.parse(persistedQueueStr) || [];
512
- const queueWithJobRemoved = persistedQueue.filter(persistedJob => {
513
- return persistedJob.id !== job.id;
514
- });
515
- localStorage.setItem(PersistKey.IdLinkQueue, JSON.stringify(queueWithJobRemoved));
516
- };
517
- const addPersistedIdLinks = (key, value, useCookies) => {
518
- const persistedIdLinksStr = localStorage.getItem(PersistKey.IdentityLinks);
519
- const persistedIdLinks = JSON.parse(persistedIdLinksStr) || {};
520
- const storedSoFar = Object.keys(persistedIdLinks);
521
- if (storedSoFar.length > MAX_STORED_IDLINKS) {
522
- Log.debug("Maximum stored idLinks reached, most recent idLink will not be stored.");
523
- return;
524
- }
525
- persistedIdLinks[key] = value;
526
- updatePersistedValue(PersistKey.IdentityLinks, JSON.stringify(persistedIdLinks), useCookies);
527
- };
528
- const checkDuplicateIdLink = (key, value) => {
529
- const persistedIdLinksStr = localStorage.getItem(PersistKey.IdentityLinks);
530
- if (persistedIdLinksStr) {
531
- const persistedIdLinks = JSON.parse(persistedIdLinksStr) || {};
532
- for (const persistedKey in persistedIdLinks) {
533
- if (key === persistedKey && persistedIdLinks[persistedKey] === value) {
534
- return true;
535
- }
536
- }
537
- }
538
- return false;
539
- };
540
- const getPersistedIdentityLinks = () => {
541
- const persistedIdLinksStr = localStorage.getItem(PersistKey.IdentityLinks);
542
- if (persistedIdLinksStr) {
543
- return JSON.parse(persistedIdLinksStr);
544
- }
545
- return undefined;
546
- };
547
- const readAndUpdateUTM = (appGuid, useCookies) => {
548
- const storageName = appGuid + "_click";
549
- const urlValue = getUrlParameter("ko_click_id");
550
- const storageValue = localStorage.getItem(storageName);
551
- let cookieValue = "";
552
- if (useCookies)
553
- cookieValue = getCookie(storageName);
554
- if (urlValue) {
555
- localStorage.setItem(storageName, urlValue);
556
- if (useCookies)
557
- setCookie(storageName, urlValue);
558
- }
559
- else if (storageValue) {
560
- if (useCookies)
561
- setCookie(storageName, urlValue);
562
- }
563
- return (urlValue) ? urlValue :
564
- (storageValue) ? storageValue :
565
- (cookieValue) ? cookieValue : "";
566
- };
567
- const readAndUpdatePersistedValue = (key, useCookie) => {
568
- const urlValue = getUrlParameter(key);
569
- const storageValue = localStorage.getItem(key);
570
- let cookieValue = "";
571
- if (useCookie)
572
- cookieValue = getCookie(key);
573
- if (urlValue) {
574
- updatePersistedValue(key, urlValue, useCookie);
575
- }
576
- else if (storageValue) {
577
- updatePersistedValue(key, storageValue, useCookie);
578
- }
579
- else if (cookieValue) {
580
- updatePersistedValue(key, storageValue, useCookie);
581
- }
582
- return (urlValue) ? urlValue :
583
- (storageValue) ? storageValue :
584
- (cookieValue) ? cookieValue : "";
585
- };
586
- const updatePersistedValue = (key, value, useCookie) => {
587
- localStorage.setItem(key, value);
588
- if (useCookie)
589
- setCookie(key, value);
590
- };
591
- const deletePersistedValue = (item) => {
592
- localStorage.removeItem(item);
593
- deleteCookie(item);
594
- };
595
- const deleteAllPersisted = () => storedKeys.forEach(item => deletePersistedValue(item));
596
- const readAndUpdateDeviceId = (useCookie) => {
597
- let storedDeviceId = readAndUpdatePersistedValue(PersistKey.DeviceId, useCookie);
598
- if (!storedDeviceId) {
599
- const kvId = `KB${getCurrTimeSec()}T${uuidv4()}`;
600
- storedDeviceId = kvId.replace(/-/g, "");
601
- }
602
- updatePersistedValue(PersistKey.DeviceId, storedDeviceId, useCookie);
603
- return storedDeviceId;
604
- };
605
- const readAndUpdateSessionCount = (useCookie) => {
606
- const storedSessionCount = readAndUpdatePersistedValue(PersistKey.SessionCount, useCookie);
607
- let sessionCount = 1;
608
- if (storedSessionCount) {
609
- sessionCount = parseInt(storedSessionCount);
610
- sessionCount++;
611
- }
612
- updatePersistedValue(PersistKey.SessionCount, sessionCount.toString(), useCookie);
613
- return sessionCount;
614
- };
615
-
616
- /*
617
- Authored by Brett Barinaga on 11/17/21.
618
- Copyright (c) Kochava, Inc. All rights reserved.
619
- */
620
- function jobIsEventJob(obj) {
621
- return 'eventName' in obj;
622
- }
623
- function jobIsIdLinkJob(obj) {
624
- return 'idLink' in obj;
625
- }
626
- class JobQueue {
627
- constructor() {
628
- this.eventQueue = [];
629
- this.idLinkQueue = [];
630
- this.processing = false;
631
- this.stopped = false;
632
- this.paused = false;
633
- }
634
- async start(instance) {
635
- this.eventQueue = JSON.parse(localStorage.getItem(PersistKey.EventQueue)) || [];
636
- this.idLinkQueue = JSON.parse(localStorage.getItem(PersistKey.IdLinkQueue)) || [];
637
- this.updateEventJobs(instance);
638
- this.updateIdLinkJobs(instance);
639
- Log.trace("Starting Event Queue", JSON.parse(JSON.stringify(this.eventQueue)));
640
- Log.trace("Starting IdLink Queue", JSON.parse(JSON.stringify(this.idLinkQueue)));
641
- this.stopped = false;
642
- this.paused = false;
643
- await this.dequeueJob(instance);
644
- }
645
- stop() {
646
- this.stopped = true;
647
- if (this.timeOut)
648
- clearTimeout(this.timeOut);
649
- this.processing = false;
650
- }
651
- pause() {
652
- this.paused = true;
653
- }
654
- async enqueueEvent(instance, args) {
655
- const eventName = args[0];
656
- const eventData = args[1];
657
- const eventPreStartBody = constructPreStart$1(instance, eventName, eventData);
658
- if (instance.installDone && instance.kvinitDone) {
659
- const postStartBody = constructPostStart$1(instance, eventPreStartBody);
660
- const newJob = {
661
- id: uuidv4(),
662
- queuedBeforeStart: false,
663
- preStartBody: eventPreStartBody,
664
- postStartBody,
665
- retries: 0,
666
- eventName,
667
- };
668
- this.eventQueue.push(newJob);
669
- addToPersistedEventQueue(newJob);
670
- await this.dequeueJob(instance);
671
- return;
672
- }
673
- const newEventJob = {
674
- id: uuidv4(),
675
- queuedBeforeStart: true,
676
- preStartBody: eventPreStartBody,
677
- postStartBody: undefined,
678
- retries: 0,
679
- eventName,
680
- };
681
- this.eventQueue.push(newEventJob);
682
- addToPersistedEventQueue(newEventJob);
683
- }
684
- async enqueueIdLink(instance, idLink) {
685
- const idLinkPreStartBody = constructPreStart(instance, idLink);
686
- if (instance.installDone && instance.kvinitDone) {
687
- const postStartBody = constructPostStart(instance, idLinkPreStartBody);
688
- const newJob = {
689
- id: uuidv4(),
690
- queuedBeforeStart: false,
691
- preStartBody: idLinkPreStartBody,
692
- postStartBody,
693
- retries: 0,
694
- idLink,
695
- };
696
- updateOrAddPersistedIdLinkQueue(newJob);
697
- this.idLinkQueue.push(newJob);
698
- await this.dequeueJob(instance);
699
- return;
700
- }
701
- const newJob = {
702
- id: uuidv4(),
703
- queuedBeforeStart: true,
704
- preStartBody: idLinkPreStartBody,
705
- postStartBody: undefined,
706
- retries: 0,
707
- idLink,
708
- };
709
- updateOrAddPersistedIdLinkQueue(newJob);
710
- this.idLinkQueue.push(newJob);
711
- }
712
- async dequeueJob(instance) {
713
- // If queue is busy, prev job not finished
714
- if (this.processing)
715
- return false;
716
- // If the queue is paused, do not dequeue a new job
717
- if (this.paused)
718
- return false;
719
- // If the queue is stopped do not dequeue a new job
720
- if (this.stopped) {
721
- return false;
722
- }
723
- // Prioritize sending identityLinks first
724
- // Remove first job from queue
725
- const idLinkJob = this.idLinkQueue.shift();
726
- if (idLinkJob) {
727
- // handle idlinkjob
728
- Log.trace("Dequeued Job: ", idLinkJob);
729
- this.processing = true;
730
- const result = await this.processJob(instance, idLinkJob);
731
- if (this.stopped) {
732
- return true;
733
- }
734
- this.processing = false;
735
- // If the job succeeded, dequeue the next job
736
- if (result) {
737
- removeFromIdLinkPersistedQueue(idLinkJob);
738
- return await this.dequeueJob(instance);
739
- }
740
- }
741
- const eventJob = this.eventQueue.shift();
742
- if (eventJob) {
743
- //handle eventJob
744
- Log.trace("Dequeued Job: ", eventJob);
745
- // Process the job
746
- this.processing = true;
747
- const result = await this.processJob(instance, eventJob);
748
- if (this.stopped) {
749
- return true;
750
- }
751
- this.processing = false;
752
- // If the job succeeded, dequeue the next job
753
- if (result) {
754
- removeFromEventPersistedQueue(eventJob);
755
- return await this.dequeueJob(instance);
756
- }
757
- }
758
- // If neither queue had a job, break out of recursion
759
- if (!idLinkJob && !eventJob)
760
- return false;
761
- return true;
762
- }
763
- async processJob(instance, job) {
764
- if (jobIsEventJob(job)) {
765
- for (const denyName of instance.kochavaConfig.privacy.deny_event_names) {
766
- if (denyName === job.eventName) {
767
- Log.debug(`Denied event_name ${denyName}, dropping request.`);
768
- return true;
769
- }
770
- }
771
- }
772
- else if (jobIsIdLinkJob(job)) {
773
- for (const denyIdLinkKey of instance.kochavaConfig.privacy.deny_identity_links) {
774
- if (denyIdLinkKey === Object.keys(job.idLink)[0]) {
775
- Log.debug(`Denied identity_link ${denyIdLinkKey}, dropping request.`);
776
- return true;
777
- }
778
- }
779
- }
780
- let success = false;
781
- do {
782
- success = await this.attemptJob(instance, job);
783
- // If our job succeeded
784
- if (success) {
785
- // Job Done
786
- Log.trace("Job processed successfully:", job);
787
- return true;
788
- }
789
- // If it didnt succeed, but we our queue isnt stopped
790
- if (!this.stopped) {
791
- //retry the job
792
- const retryWaterfall = instance.kochavaConfig.networking.retry_waterfall;
793
- const retryIndex = (job.retries > retryWaterfall.length - 1) ?
794
- retryWaterfall.length - 1 : job.retries;
795
- const retrySec = retryWaterfall[retryIndex];
796
- Log.error(`Job failed, attempting again in ${retrySec} seconds`);
797
- await new Promise(resolve => this.timeOut = setTimeout(resolve, retrySec * 1000));
798
- job.retries++;
799
- }
800
- } while (!success && !this.stopped);
801
- // Job Canceled
802
- return true;
803
- }
804
- async attemptJob(instance, job) {
805
- if (job.preStartBody.action === "event")
806
- return await send$3(instance, job.preStartBody, job.postStartBody);
807
- else if (job.preStartBody.action === "identityLink")
808
- return await send$2(instance, job);
809
- else {
810
- Log.warn("Invalid action in job from jobqueue, cancelling.");
811
- return true;
812
- }
813
- }
814
- updateEventJobs(instance) {
815
- for (const job of this.eventQueue) {
816
- if (job.queuedBeforeStart) {
817
- job.postStartBody = constructPostStart$1(instance, job.preStartBody);
818
- }
819
- }
820
- updatePersistedValue(PersistKey.EventQueue, JSON.stringify(this.eventQueue), false);
821
- }
822
- updateIdLinkJobs(instance) {
823
- for (const job of this.idLinkQueue) {
824
- if (job.queuedBeforeStart) {
825
- job.postStartBody = constructPostStart(instance, job.preStartBody);
826
- }
827
- }
828
- updatePersistedValue(PersistKey.IdLinkQueue, JSON.stringify(this.idLinkQueue), false);
829
- }
830
- }
831
-
832
- /*
833
- Authored by Brett Barinaga on 11/17/21.
834
- Copyright (c) Kochava, Inc. All rights reserved.
835
- */
836
- const DEFAULTS = {
837
- general: {
838
- // DO NOT DEFAULT
839
- app_id_override: "",
840
- // DO NOT DEFAULT
841
- device_id_override: "",
842
- },
843
- config: {
844
- init_token: "",
845
- refresh_minimum: 60,
846
- },
847
- install: {
848
- // DO NOT DEFAULT
849
- resend_id: "",
850
- updates_enabled: true,
851
- },
852
- networking: {
853
- urls: {
854
- init: "https://kvinit-prod.api.kochava.com/track/kvinit",
855
- install: "https://web-sdk.control.kochava.com/track/json/",
856
- event: "https://web-sdk.control.kochava.com/track/json/",
857
- identityLink: "https://web-sdk.control.kochava.com/v1/cpi/identityLink.php"
858
- },
859
- retry_waterfall: [7, 30, 300, 1800],
860
- },
861
- privacy: {
862
- allow_custom_ids: [],
863
- deny_datapoints: [],
864
- deny_event_names: [],
865
- deny_identity_links: [],
866
- },
867
- };
868
-
869
- /*
870
- Authored by Brett Barinaga on 11/17/21.
871
- Copyright (c) Kochava, Inc. All rights reserved.
872
- */
873
- let timeOut$1;
874
- let canceled$1 = false;
875
- const build$1 = (instance) => {
876
- const payload = constructPayload("init", instance);
877
- payload.build_date = instance.buildDate;
878
- payload.data = constructKvinitData(instance);
879
- Log.debug("Kvinit Payload", JSON.stringify(payload));
880
- return payload;
881
- };
882
- const cancelRetries$1 = () => {
883
- canceled$1 = true;
884
- clearTimeout(timeOut$1);
885
- };
886
- const send$1 = async (instance, retryWaterfall, retries = 0) => {
887
- canceled$1 = false;
888
- const payload = build$1(instance);
889
- let success = false;
890
- let resp;
891
- do {
892
- Log.trace("Kvinit endpoint:", instance.kochavaConfig.networking.urls.init);
893
- const sendTime = getCurrTimeMS() - instance.startTimeMS;
894
- Log.diagDebug(`Sending kvinit at ${formatTime(sendTime / 1000)} seconds`);
895
- const respStr = await sendRequest(payload, (instance.overrideUrls.init) ?
896
- instance.overrideUrls.init : instance.kochavaConfig.networking.urls.init);
897
- const respTime = getCurrTimeMS() - instance.startTimeMS;
898
- Log.diagDebug(`Completed kvinit at ${formatTime(respTime / 1000)}
899
- seconds with a network duration of ${formatTime((respTime - sendTime) / 1000)} seconds`);
900
- if (canceled$1) {
901
- Log.trace("Can no longer retry kvinit, cancelling.");
902
- return false;
903
- }
904
- try {
905
- resp = JSON.parse(respStr);
906
- Log.debug("Kvinit Response:", resp);
907
- success = wasRespSuccess(resp.success);
908
- }
909
- catch (e) {
910
- Log.error("Error parsing Kvinit Response", e);
911
- success = false;
912
- }
913
- if (success) {
914
- Log.info("Kvinit success!");
915
- updatePersistedValue(PersistKey.LastKvinit, JSON.stringify(resp), instance.useCookies);
916
- return success;
917
- }
918
- if (!canceled$1) {
919
- // retry kvinit
920
- const retryIndex = (retries > retryWaterfall.length - 1) ? retryWaterfall.length - 1 : retries;
921
- const retrySec = retryWaterfall[retryIndex];
922
- Log.error(`Kvinit failed, attempting again in ${retrySec} seconds`);
923
- await new Promise(resolve => { timeOut$1 = setTimeout(resolve, retrySec * 1000); });
924
- retries++;
925
- }
926
- } while (!success && !canceled$1);
927
- };
928
- const applyKvinitResp = (instance, resp) => {
929
- if (resp.general) {
930
- if (resp.general.device_id_override) {
931
- Log.trace(`Device_id override found, going from ${instance.kochavaDeviceId} to
932
- ${resp.general.device_id_override}`);
933
- instance.kochavaConfig.general.device_id_override = resp.general.device_id_override;
934
- instance.kochavaDeviceId = resp.general.device_id_override;
935
- updatePersistedValue(PersistKey.OverrideDeviceId, resp.general.device_id_override, instance.useCookies);
936
- }
937
- if (resp.general.app_id_override) {
938
- Log.trace(`App_id override found, going from ${instance.appGuid} to
939
- ${resp.general.app_id_override}`);
940
- instance.kochavaConfig.general.app_id_override = resp.general.app_id_override;
941
- instance.appGuid = resp.general.app_id_override;
942
- updatePersistedValue(PersistKey.OverrideAppId, resp.general.app_id_override, instance.useCookies);
943
- }
944
- }
945
- if (resp.config) {
946
- instance.kochavaConfig.config = {
947
- init_token: resp.config.init_token || DEFAULTS.config.init_token,
948
- refresh_minimum: (resp.config.refresh_minimum !== undefined &&
949
- resp.config.refresh_minimum !== null) ? resp.config.refresh_minimum :
950
- DEFAULTS.config.refresh_minimum,
951
- };
952
- }
953
- if (resp.install) {
954
- if (resp.install.resend_id) {
955
- instance.kochavaConfig.install.resend_id = resp.install.resend_id;
956
- }
957
- instance.kochavaConfig.install.updates_enabled =
958
- resp.install.updates_enabled || DEFAULTS.install.updates_enabled;
959
- }
960
- if (resp.networking) {
961
- instance.kochavaConfig.networking.retry_waterfall =
962
- resp.networking.retry_waterfall || DEFAULTS.networking.retry_waterfall;
963
- instance.retryWaterfall =
964
- instance.kochavaConfig.networking.retry_waterfall;
965
- if (resp.networking.urls) {
966
- instance.kochavaConfig.networking.urls = {
967
- init: resp.networking.urls.init || DEFAULTS.networking.urls.init,
968
- install: resp.networking.urls.install || DEFAULTS.networking.urls.install,
969
- event: resp.networking.urls.event || DEFAULTS.networking.urls.event,
970
- identityLink: resp.networking.urls.identityLink || DEFAULTS.networking.urls.identityLink,
971
- };
972
- }
973
- }
974
- if (resp.privacy) {
975
- instance.kochavaConfig.privacy = {
976
- allow_custom_ids: resp.privacy.allow_custom_ids || DEFAULTS.privacy.allow_custom_ids,
977
- deny_datapoints: resp.privacy.deny_datapoints || DEFAULTS.privacy.deny_datapoints,
978
- deny_event_names: resp.privacy.deny_event_names || DEFAULTS.privacy.deny_event_names,
979
- deny_identity_links: resp.privacy.deny_identity_links || DEFAULTS.privacy.deny_identity_links,
980
- };
981
- }
982
- };
983
- const constructKvinitData = (instance) => {
984
- const currTime = Math.floor(Date.now() / 1000);
985
- let uptime = (currTime - instance.startTimeMS) / 1000;
986
- if (uptime < 0.0)
987
- uptime = 0.0;
988
- return {
989
- package: getPackageName(),
990
- platform: "web",
991
- starttime: instance.startTimeMS / 1000,
992
- uptime,
993
- usertime: currTime,
994
- };
995
- };
996
-
997
- /*
998
- Authored by Brett Barinaga on 11/17/21.
999
- Copyright (c) Kochava, Inc. All rights reserved.
1000
- */
1001
- let timeOut;
1002
- let canceled = false;
1003
- const build = (instance) => {
1004
- const payload = constructPayload("install", instance);
1005
- instance.installStarted = true;
1006
- payload.data = constructInstallData(instance);
1007
- Log.debug("Install Payload", JSON.stringify(payload));
1008
- if (instance.kochavaConfig.privacy) {
1009
- instance.kochavaConfig.privacy.deny_datapoints.forEach(denyPoint => {
1010
- for (const point in payload.data) {
1011
- const key = point;
1012
- if (key === denyPoint)
1013
- delete payload.data[key];
1014
- }
1015
- for (const point in payload) {
1016
- const key = point;
1017
- if (key === denyPoint)
1018
- delete payload[key];
1019
- }
1020
- });
1021
- }
1022
- return payload;
1023
- };
1024
- const cancelRetries = () => {
1025
- canceled = true;
1026
- clearTimeout(timeOut);
1027
- };
1028
- const send = async (instance, payload, retries = 0) => {
1029
- canceled = false;
1030
- let success = false;
1031
- let resp;
1032
- do {
1033
- const sendTime = getCurrTimeMS() - instance.startTimeMS;
1034
- Log.diagDebug(`Sending install at ${formatTime(sendTime / 1000)} seconds`);
1035
- const respStr = await sendRequest(payload, (instance.overrideUrls.install) ?
1036
- instance.overrideUrls.install : instance.kochavaConfig.networking.urls.install);
1037
- const respTime = getCurrTimeMS() - instance.startTimeMS;
1038
- Log.diagDebug(`Completed install at ${new Date().toLocaleTimeString()}
1039
- seconds with a network duration of ${formatTime((respTime - sendTime) / 1000)} seconds`);
1040
- if (canceled) {
1041
- Log.trace("Can no longer retry install, cancelling.");
1042
- return false;
1043
- }
1044
- try {
1045
- Log.trace("Install Response string:", respStr);
1046
- resp = JSON.parse(respStr);
1047
- Log.debug("Install Response:", respStr);
1048
- success = wasRespSuccess(resp.success);
1049
- }
1050
- catch (e) {
1051
- Log.error("Error parsing Install Response", e);
1052
- success = false;
1053
- }
1054
- if (success) {
1055
- Log.info("Install success!");
1056
- return success;
1057
- }
1058
- if (!canceled) {
1059
- const retryWaterfall = instance.kochavaConfig.networking.retry_waterfall;
1060
- const retryIndex = (retries > retryWaterfall.length - 1) ? retryWaterfall.length - 1 : retries;
1061
- const retrySec = retryWaterfall[retryIndex];
1062
- Log.error(`Install failed, attempting again in ${retrySec} seconds`);
1063
- await new Promise(resolve => { timeOut = setTimeout(resolve, retrySec * 1000); });
1064
- retries++;
1065
- }
1066
- } while (!success && !canceled);
1067
- };
1068
- const onSuccess = (instance) => {
1069
- instance.kochavaInstallDate = getCurrTimeMS();
1070
- updatePersistedValue(PersistKey.InstallSentDate, String(instance.kochavaInstallDate), instance.useCookies);
1071
- };
1072
- const constructInstallData = (instance) => {
1073
- const currTime = Math.floor(Date.now() / 1000);
1074
- let uptime = (currTime - instance.startTimeMS) / 1000;
1075
- if (uptime < 0.0)
1076
- uptime = 0.0;
1077
- let returnObj = {
1078
- starttime: instance.startTimeMS / 1000,
1079
- uptime: uptime,
1080
- usertime: determineInstallUserTime(instance, currTime),
1081
- device_orientation: getDeviceOrientation(),
1082
- package: getPackageName(),
1083
- disp_w: getDeviceWidth(),
1084
- disp_h: getDeviceHeight(),
1085
- language: getLanguage(),
1086
- };
1087
- if (instance.utm) {
1088
- returnObj = Object.assign(Object.assign({}, returnObj), { conversion_data: { utm_source: instance.utm } });
1089
- }
1090
- if (instance.customValues.length > 0)
1091
- returnObj.device_ids = {};
1092
- instance.customValues.forEach((custom) => {
1093
- const customKey = Object.keys(custom.data)[0];
1094
- if (instance.kochavaConfig.privacy) {
1095
- let keyAllowed = false;
1096
- for (const allowed of instance.kochavaConfig.privacy.allow_custom_ids) {
1097
- if (customKey === allowed) {
1098
- keyAllowed = true;
1099
- }
1100
- }
1101
- if (keyAllowed) {
1102
- if (custom.isDeviceId)
1103
- returnObj.device_ids = Object.assign(Object.assign({}, returnObj.device_ids), custom.data);
1104
- else
1105
- returnObj = Object.assign(Object.assign({}, custom.data), returnObj);
1106
- }
1107
- }
1108
- });
1109
- // add the persisted identityLinks
1110
- const persistedIdLinks = getPersistedIdentityLinks();
1111
- if (persistedIdLinks) {
1112
- returnObj.identity_link = {};
1113
- for (const key in persistedIdLinks) {
1114
- let includeKey = true;
1115
- for (const denyIdLinkKey of instance.kochavaConfig.privacy.deny_identity_links) {
1116
- if (denyIdLinkKey === key) {
1117
- Log.debug(`Denied identity_link ${denyIdLinkKey}, dropping from install.`);
1118
- includeKey = false;
1119
- }
1120
- }
1121
- if (includeKey)
1122
- returnObj.identity_link[key] = persistedIdLinks[key];
1123
- }
1124
- }
1125
- return returnObj;
1126
- };
1127
- const determineInstallUserTime = (instance, currTime) => {
1128
- const firstStartStr = readAndUpdatePersistedValue(PersistKey.FirstStartDate, instance.useCookies);
1129
- if (firstStartStr) {
1130
- const firstStart = JSON.parse(firstStartStr);
1131
- // If its been 30 days since the sdk started
1132
- if ((currTime - firstStart) > 2592000) {
1133
- return currTime;
1134
- }
1135
- return firstStart;
1136
- }
1137
- return currTime;
1138
- };
1139
-
1140
- /*
1141
- Authored by Brett Barinaga on 11/17/21.
1142
- Copyright (c) Kochava, Inc. All rights reserved.
1143
- */
1144
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
1145
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
1146
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
1147
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
1148
- };
1149
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
1150
- if (kind === "m") throw new TypeError("Private method is not writable");
1151
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
1152
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
1153
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
1154
- };
1155
- var _Kochava_instances, _Kochava_instance, _Kochava_jobQueue, _Kochava_resetInstance, _Kochava_initInstance, _Kochava_checkFirstLaunchAndMigrate, _Kochava_checkPersistedKvinit, _Kochava_checkPersistedState, _Kochava_printStartupMsgs, _Kochava_beginStart, _Kochava_performNewKvinit, _Kochava_checkResendId, _Kochava_performInstall;
1156
- class Kochava {
1157
- // User will use the below factories instead of directly calling
1158
- // the constructor
1159
- constructor() {
1160
- _Kochava_instances.add(this);
1161
- _Kochava_instance.set(this, void 0);
1162
- _Kochava_jobQueue.set(this, void 0);
1163
- __classPrivateFieldGet(this, _Kochava_instances, "m", _Kochava_resetInstance).call(this);
1164
- __classPrivateFieldSet(this, _Kochava_jobQueue, new JobQueue(), "f");
1165
- }
1166
- // ============================= PUBLIC =============================== //
1167
- static create() {
1168
- return new Kochava();
1169
- }
1170
- static createForNode() {
1171
- const kochava = new Kochava();
1172
- kochava.executeAdvancedInstruction("wrapper", JSON.stringify({ name: "Node", version: "" }));
1173
- return kochava;
1174
- }
1175
- static createForReact() {
1176
- const kochava = new Kochava();
1177
- kochava.executeAdvancedInstruction("wrapper", JSON.stringify({ name: "React", version: "" }));
1178
- return kochava;
1179
- }
1180
- static createForVue() {
1181
- const kochava = new Kochava();
1182
- kochava.executeAdvancedInstruction("wrapper", JSON.stringify({ name: "Vue", version: "" }));
1183
- return kochava;
1184
- }
1185
- static createForAngular() {
1186
- const kochava = new Kochava();
1187
- kochava.executeAdvancedInstruction("wrapper", JSON.stringify({ name: "Angular", version: "1.0.0" }));
1188
- return kochava;
1189
- }
1190
- /*
1191
- Set if the SDK should also store persisted values in cookie storage.
1192
- - Not all values can be persisted in cookies, such as event/idlink queues
1193
- due to size constraints.
1194
- - true = yes use cookies
1195
- - no = no don't use cookies
1196
- - defaults to false
1197
- */
1198
- useCookies(condition = false) {
1199
- __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies = condition;
1200
- }
1201
- /*
1202
- - Set whether the sdk shouldn't automatically send a page or should.
1203
- - true = no auto page
1204
- - false = yes auto page
1205
- - defaults to false
1206
- */
1207
- disableAutoPage(condition = false) {
1208
- __classPrivateFieldGet(this, _Kochava_instance, "f").disableAutoPage = condition;
1209
- }
1210
- /*
1211
- The primary means for starting the sdk.
1212
- Responsibilites:
1213
- - Checks for migrations.
1214
- - Creates the sdk instance.
1215
- - Checks for persisted state.
1216
- - Determines and sends kvinit.
1217
- - Determines and sends install.
1218
- - Optionally enqueues an auto_page.
1219
- - Starts the job queue.
1220
- */
1221
- startWithAppGuid(appGuid) {
1222
- if (!appGuid) {
1223
- Log.error(`Invalid appGuid ${appGuid}, start failed.`);
1224
- return;
1225
- }
1226
- if (!__classPrivateFieldGet(this, _Kochava_instance, "f"))
1227
- __classPrivateFieldGet(this, _Kochava_instances, "m", _Kochava_resetInstance).call(this);
1228
- if (__classPrivateFieldGet(this, _Kochava_instance, "f").started) {
1229
- Log.warn("Kochava SDK already started.");
1230
- return;
1231
- }
1232
- Log.diagDebug(`Host called API: Start With App Guid ${appGuid}`);
1233
- __classPrivateFieldGet(this, _Kochava_instance, "f").started = true;
1234
- __classPrivateFieldGet(this, _Kochava_instances, "m", _Kochava_checkFirstLaunchAndMigrate).call(this);
1235
- __classPrivateFieldGet(this, _Kochava_instances, "m", _Kochava_initInstance).call(this, appGuid);
1236
- if (!__classPrivateFieldGet(this, _Kochava_instance, "f").disableAutoPage)
1237
- this.sendPageEvent();
1238
- __classPrivateFieldGet(this, _Kochava_instances, "m", _Kochava_checkPersistedState).call(this);
1239
- __classPrivateFieldGet(this, _Kochava_instances, "m", _Kochava_checkPersistedKvinit).call(this);
1240
- __classPrivateFieldGet(this, _Kochava_instances, "m", _Kochava_printStartupMsgs).call(this, appGuid);
1241
- __classPrivateFieldGet(this, _Kochava_instances, "m", _Kochava_beginStart).call(this);
1242
- }
1243
- /*
1244
- Primary means for stopping the sdk.
1245
- Will optionally delete all persisted data, and will shutdown the
1246
- sdk and job queue.
1247
- */
1248
- shutdown(deleteData) {
1249
- Log.diagDebug(`Host called API: Shutdown and ${deleteData ? "delete data" : "keep data"}`);
1250
- if (deleteData) {
1251
- Log.debug("Deleting persisted values");
1252
- deleteAllPersisted();
1253
- }
1254
- if (!__classPrivateFieldGet(this, _Kochava_instance, "f").started) {
1255
- Log.warn("SDK already shutdown.");
1256
- }
1257
- Log.info("SDK shutting down.");
1258
- cancelRetries$1();
1259
- cancelRetries();
1260
- __classPrivateFieldGet(this, _Kochava_jobQueue, "f").stop();
1261
- // wipe whatever was previously in the queue
1262
- __classPrivateFieldSet(this, _Kochava_jobQueue, new JobQueue(), "f");
1263
- __classPrivateFieldGet(this, _Kochava_instances, "m", _Kochava_resetInstance).call(this);
1264
- }
1265
- /*
1266
- Changes the current logLevel.
1267
- Options include:
1268
- - Off :: No logging whatsoever
1269
- - Error :: Only critical errors
1270
- - Warn :: Only critical errors and non-critical warnings
1271
- - Info :: High-level sdk behavior logs (default)
1272
- - Debug :: More in-depth sdk behavior logs and payload logs
1273
- - Trace :: Everything, granular detail
1274
- */
1275
- setLogLevel(logLevel) {
1276
- Log.diagDebug(`Host called API: Set Log Level ${logLevel}`);
1277
- Log.setLogLevel(logLevel);
1278
- }
1279
- /*
1280
- Used internally, for special SDK behavior not utilized by a client.
1281
- Examples include:
1282
- - urls :: purposefully changing an endpoint for testing
1283
- - wrapper :: overwriting the version of a wrapper
1284
- several more ...
1285
- */
1286
- executeAdvancedInstruction(key, valueStr, callback) {
1287
- Log.diagDebug(`Host called API: Execute Advanced Instruction ${key}`);
1288
- switch (key) {
1289
- case "wrapper":
1290
- {
1291
- const wrapperVersion = JSON.parse(valueStr);
1292
- if (!__classPrivateFieldGet(this, _Kochava_instance, "f").version)
1293
- __classPrivateFieldGet(this, _Kochava_instance, "f").version = "WebTracker 3.0.0";
1294
- switch (wrapperVersion.name) {
1295
- case "Angular":
1296
- __classPrivateFieldGet(this, _Kochava_instance, "f").version += ` (${wrapperVersion.name} ${wrapperVersion.version})`;
1297
- break;
1298
- default:
1299
- __classPrivateFieldGet(this, _Kochava_instance, "f").version += ` (${wrapperVersion.name})`;
1300
- break;
1301
- }
1302
- }
1303
- break;
1304
- case "urls":
1305
- {
1306
- const overrideUrls = JSON.parse(valueStr);
1307
- if (overrideUrls.init)
1308
- __classPrivateFieldGet(this, _Kochava_instance, "f").overrideUrls.init = overrideUrls.init;
1309
- if (overrideUrls.event)
1310
- __classPrivateFieldGet(this, _Kochava_instance, "f").overrideUrls.event = overrideUrls.event;
1311
- if (overrideUrls.install)
1312
- __classPrivateFieldGet(this, _Kochava_instance, "f").overrideUrls.install = overrideUrls.install;
1313
- if (overrideUrls.identityLink)
1314
- __classPrivateFieldGet(this, _Kochava_instance, "f").overrideUrls.identityLink = overrideUrls.identityLink;
1315
- }
1316
- break;
1317
- case "urlsRestore":
1318
- {
1319
- const restoreUrls = JSON.parse(valueStr);
1320
- for (const url of restoreUrls) {
1321
- if (url === "init")
1322
- __classPrivateFieldGet(this, _Kochava_instance, "f").overrideUrls.init = DEFAULTS.networking.urls.init;
1323
- if (url === "event")
1324
- __classPrivateFieldGet(this, _Kochava_instance, "f").overrideUrls.event = DEFAULTS.networking.urls.event;
1325
- if (url === "install")
1326
- __classPrivateFieldGet(this, _Kochava_instance, "f").overrideUrls.install =
1327
- DEFAULTS.networking.urls.install;
1328
- if (url === "identityLink")
1329
- __classPrivateFieldGet(this, _Kochava_instance, "f").overrideUrls.identityLink =
1330
- DEFAULTS.networking.urls.identityLink;
1331
- }
1332
- }
1333
- break;
1334
- case "logFilter":
1335
- {
1336
- const disabled = JSON.parse(valueStr);
1337
- disabled.forEach((level) => Log.disableLogType(level));
1338
- }
1339
- break;
1340
- case "getInstance":
1341
- {
1342
- const currInstance = JSON.stringify(__classPrivateFieldGet(this, _Kochava_instance, "f"));
1343
- callback(currInstance);
1344
- Log.debug(`capturing instance: ${valueStr}`);
1345
- }
1346
- break;
1347
- case "logObjects":
1348
- Log.setLogObjects(JSON.parse(valueStr));
1349
- break;
1350
- default:
1351
- break;
1352
- }
1353
- }
1354
- /*
1355
- Builds and enqueues a kochava event. Must include an event_name string,
1356
- with optional event_data as either another string or object.
1357
- */
1358
- sendEvent(name, data) {
1359
- Log.diagDebug(`Host called API: Send Event`);
1360
- if (!name) {
1361
- Log.warn("Invalid event name, ignoring call.");
1362
- return;
1363
- }
1364
- __classPrivateFieldGet(this, _Kochava_jobQueue, "f").enqueueEvent(__classPrivateFieldGet(this, _Kochava_instance, "f"), [name, data]);
1365
- }
1366
- /*
1367
- Wraps the sendEvent call with predefined data specific to page events.
1368
- */
1369
- sendPageEvent(pageName, additionalData) {
1370
- if (pageName)
1371
- this.sendEvent("page", Object.assign({ page_name: pageName }, additionalData));
1372
- else
1373
- this.sendEvent("page", Object.assign({ page_name: getPageName() }, additionalData));
1374
- }
1375
- /*
1376
- - Registers new identity links with the sdk, either to be sent out with
1377
- the install, or standalone.
1378
- - Will update an identity link if its key already exists in storage.
1379
- - A max of 10 identity links are currently allowed to be stored
1380
- at any one time.
1381
- */
1382
- registerIdentityLink(name, identifier) {
1383
- Log.diagDebug(`Host called API: Register Identity Link ${name}`);
1384
- if (!name || !identifier) {
1385
- Log.warn("Invalid identity link, ignoring call.");
1386
- return;
1387
- }
1388
- if (checkDuplicateIdLink(name, identifier)) {
1389
- Log.debug("Duplicate Identity Link found, ignoring.");
1390
- return;
1391
- }
1392
- const idLink = {};
1393
- idLink[name] = identifier;
1394
- addPersistedIdLinks(name, identifier, __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies);
1395
- if (__classPrivateFieldGet(this, _Kochava_instance, "f").installStarted || __classPrivateFieldGet(this, _Kochava_instance, "f").installDone) {
1396
- // it will be sent standalone
1397
- __classPrivateFieldGet(this, _Kochava_jobQueue, "f").enqueueIdLink(__classPrivateFieldGet(this, _Kochava_instance, "f"), idLink);
1398
- }
1399
- // will be sent in install
1400
- }
1401
- // Allows the client to attach arbitrary data to certain payloads.
1402
- registerCustomValue(name, value) {
1403
- Log.diagDebug(`Host called API: Register Custom Value ${name}`);
1404
- if (!name || !value) {
1405
- Log.warn("Invalid custom value, ignoring call.");
1406
- return;
1407
- }
1408
- const dataToAdorn = {};
1409
- dataToAdorn[name] = value;
1410
- __classPrivateFieldGet(this, _Kochava_instance, "f").customValues.push({ data: dataToAdorn, isDeviceId: false });
1411
- }
1412
- // Allows the client to attach arbitrary identifiers to go out in the install.
1413
- registerCustomDeviceIdentifier(name, value) {
1414
- Log.diagDebug(`Host called API: Register Custom Device Identifier ${name}`);
1415
- if (!name || !value) {
1416
- Log.warn("Invalid custom device identifier, ignoring call.");
1417
- return;
1418
- }
1419
- const dataToAdorn = {};
1420
- dataToAdorn[name] = value;
1421
- __classPrivateFieldGet(this, _Kochava_instance, "f").customValues.push({ data: dataToAdorn, isDeviceId: true });
1422
- }
1423
- /*
1424
- Returns whether or not the sdk is in a "started" state.
1425
- This basically amounts to if start has been called,
1426
- not if kvinit is done or the queue is started.
1427
- Likewise, shutdown will set "started" to false;
1428
- */
1429
- getStarted() {
1430
- return __classPrivateFieldGet(this, _Kochava_instance, "f").started;
1431
- }
1432
- /*
1433
- Returns the current kochavaDeviceId, or "" if called too early.
1434
- */
1435
- getDeviceId() {
1436
- Log.diagDebug(`Host called API: Get Kochava Device Id`);
1437
- if (__classPrivateFieldGet(this, _Kochava_instance, "f").started)
1438
- return __classPrivateFieldGet(this, _Kochava_instance, "f").kochavaDeviceId;
1439
- else
1440
- return "";
1441
- }
1442
- /*
1443
- Puts the sdk in a "sleep" state. This will stop the sdk from dequeuing
1444
- new jobs and retrying failed jobs. Different than shutdown, because the
1445
- current state is not destroyed.
1446
- */
1447
- setSleep(sleep) {
1448
- Log.diagDebug(`Host called API: Sleep ${sleep ? "Stop" : "Start"}`);
1449
- if (sleep && !__classPrivateFieldGet(this, _Kochava_instance, "f").sleep) {
1450
- // only pause if it was running
1451
- __classPrivateFieldGet(this, _Kochava_instance, "f").sleep = sleep;
1452
- __classPrivateFieldGet(this, _Kochava_jobQueue, "f").pause();
1453
- }
1454
- else if (!sleep && __classPrivateFieldGet(this, _Kochava_instance, "f").sleep) {
1455
- // only resume queueing if it was paused
1456
- __classPrivateFieldGet(this, _Kochava_instance, "f").sleep = sleep;
1457
- __classPrivateFieldGet(this, _Kochava_instances, "m", _Kochava_beginStart).call(this);
1458
- }
1459
- }
1460
- }
1461
- _Kochava_instance = new WeakMap(), _Kochava_jobQueue = new WeakMap(), _Kochava_instances = new WeakSet(), _Kochava_resetInstance = function _Kochava_resetInstance() {
1462
- __classPrivateFieldSet(this, _Kochava_instance, {
1463
- appGuid: "",
1464
- started: false,
1465
- installStarted: false,
1466
- kvinitDone: false,
1467
- installDone: false,
1468
- disableAutoPage: false,
1469
- useCookies: false,
1470
- sleep: false,
1471
- version: "",
1472
- buildDate: "",
1473
- overrideUrls: {
1474
- init: "",
1475
- install: "",
1476
- event: "",
1477
- identityLink: "",
1478
- },
1479
- customValues: [],
1480
- kochavaSession: "",
1481
- retryWaterfall: [],
1482
- startTimeMS: 0,
1483
- utm: "",
1484
- kochavaDeviceId: "",
1485
- kochavaInstallId: "",
1486
- kochavaSessionCount: -1,
1487
- kochavaInstallDate: -1,
1488
- kochavaConfig: undefined,
1489
- }, "f");
1490
- }, _Kochava_initInstance = function _Kochava_initInstance(appGuid) {
1491
- // init instance with defaults
1492
- __classPrivateFieldGet(this, _Kochava_instance, "f").appGuid = appGuid;
1493
- __classPrivateFieldGet(this, _Kochava_instance, "f").disableAutoPage = __classPrivateFieldGet(this, _Kochava_instance, "f").disableAutoPage || false;
1494
- __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies = __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies || false;
1495
- __classPrivateFieldGet(this, _Kochava_instance, "f").version = __classPrivateFieldGet(this, _Kochava_instance, "f").version || "WebTracker 3.0.0";
1496
- __classPrivateFieldGet(this, _Kochava_instance, "f").buildDate = "kbd: 3/31/2022, 11:47:52 AM";
1497
- __classPrivateFieldGet(this, _Kochava_instance, "f").kochavaSession = uuidv4().substring(0, 5);
1498
- __classPrivateFieldGet(this, _Kochava_instance, "f").startTimeMS = getCurrTimeMS();
1499
- __classPrivateFieldGet(this, _Kochava_instance, "f").retryWaterfall = [7, 30, 300, 1800];
1500
- __classPrivateFieldGet(this, _Kochava_instance, "f").kochavaConfig = JSON.parse(JSON.stringify(DEFAULTS));
1501
- }, _Kochava_checkFirstLaunchAndMigrate = function _Kochava_checkFirstLaunchAndMigrate() {
1502
- // If this is our first launch ever, set it in persistence.
1503
- if (!readAndUpdatePersistedValue(PersistKey.FirstStartDate, __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies)) {
1504
- updatePersistedValue(PersistKey.FirstStartDate, String(getCurrTimeSec()), __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies);
1505
- /*
1506
- On a first launch of the v3 sdk, we need to migrate old persisted kv_id
1507
- from v2.2, v2.3, and v2.5
1508
- */
1509
- // perform migration
1510
- const oldKvId = readAndUpdatePersistedValue(PersistKey.OldKvid, __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies);
1511
- if (oldKvId) {
1512
- updatePersistedValue(PersistKey.DeviceId, oldKvId, __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies);
1513
- updatePersistedValue(PersistKey.InstallSentDate, JSON.stringify(getCurrTimeSec()), __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies);
1514
- }
1515
- }
1516
- }, _Kochava_checkPersistedKvinit = function _Kochava_checkPersistedKvinit() {
1517
- // check if persisted kvinit
1518
- let persistedKvinit = {};
1519
- const persistedKvinitStr = readAndUpdatePersistedValue(PersistKey.LastKvinit, __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies);
1520
- if (persistedKvinitStr) {
1521
- persistedKvinit = JSON.parse(persistedKvinitStr);
1522
- if (persistedKvinit) {
1523
- // if persisted kvinit, apply it
1524
- Log.trace("Found persisted kvinit.", persistedKvinit);
1525
- applyKvinitResp(__classPrivateFieldGet(this, _Kochava_instance, "f"), persistedKvinit);
1526
- Log.trace("KochavaConfig after persistedKvinit:", JSON.parse(JSON.stringify(__classPrivateFieldGet(this, _Kochava_instance, "f").kochavaConfig)));
1527
- }
1528
- }
1529
- // check refresh minimum too
1530
- const persistedKvinitDateStr = readAndUpdatePersistedValue(PersistKey.KvinitSentDate, __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies);
1531
- if (persistedKvinitDateStr) {
1532
- const lastKvinitDate = JSON.parse(persistedKvinitDateStr);
1533
- if (lastKvinitDate) {
1534
- const refreshMin = __classPrivateFieldGet(this, _Kochava_instance, "f").kochavaConfig.config.refresh_minimum;
1535
- if (getCurrTimeSec() - lastKvinitDate < refreshMin)
1536
- __classPrivateFieldGet(this, _Kochava_instance, "f").kvinitDone = true;
1537
- }
1538
- }
1539
- }, _Kochava_checkPersistedState = function _Kochava_checkPersistedState() {
1540
- __classPrivateFieldGet(this, _Kochava_instance, "f").installDone =
1541
- readAndUpdatePersistedValue(PersistKey.InstallSentDate, __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies).length > 0;
1542
- __classPrivateFieldGet(this, _Kochava_instance, "f").kochavaInstallId = readAndUpdatePersistedValue(PersistKey.InstallId, __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies);
1543
- __classPrivateFieldGet(this, _Kochava_instance, "f").kochavaDeviceId = readAndUpdateDeviceId(__classPrivateFieldGet(this, _Kochava_instance, "f").useCookies);
1544
- __classPrivateFieldGet(this, _Kochava_instance, "f").kochavaSessionCount = readAndUpdateSessionCount(__classPrivateFieldGet(this, _Kochava_instance, "f").useCookies);
1545
- __classPrivateFieldGet(this, _Kochava_instance, "f").utm = readAndUpdateUTM(__classPrivateFieldGet(this, _Kochava_instance, "f").appGuid, __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies);
1546
- }, _Kochava_printStartupMsgs = function _Kochava_printStartupMsgs(appGuid) {
1547
- Log.diagInfo(`Started SDK ${__classPrivateFieldGet(this, _Kochava_instance, "f").version}
1548
- published ${__classPrivateFieldGet(this, _Kochava_instance, "f").buildDate}`);
1549
- Log.diagInfo(`The log level is set to ${Log.getLogLevel()}`);
1550
- Log.diagDebug(`This ${!__classPrivateFieldGet(this, _Kochava_instance, "f").installDone ? "is" : "is not"} the first tracker SDK launch`);
1551
- Log.diagDebug(`The kochava device id is ${__classPrivateFieldGet(this, _Kochava_instance, "f").kochavaDeviceId}`);
1552
- Log.diagDebug(`The kochava app GUID provided was ${appGuid}`);
1553
- }, _Kochava_beginStart = async function _Kochava_beginStart() {
1554
- // if we need to send a new kvinit, send it
1555
- if (!__classPrivateFieldGet(this, _Kochava_instance, "f").kvinitDone) {
1556
- Log.diagDebug(`A new kvinit will be sent`);
1557
- await __classPrivateFieldGet(this, _Kochava_instances, "m", _Kochava_performNewKvinit).call(this);
1558
- }
1559
- else {
1560
- Log.diagDebug(`A new kvinit will not be sent`);
1561
- }
1562
- // if the install_id changed and thus a new install must go out
1563
- if (__classPrivateFieldGet(this, _Kochava_instances, "m", _Kochava_checkResendId).call(this))
1564
- __classPrivateFieldGet(this, _Kochava_instance, "f").installDone = false;
1565
- Log.diagDebug(`The install ${__classPrivateFieldGet(this, _Kochava_instance, "f").installDone ? "has already" : "has not yet"} been sent`);
1566
- if (__classPrivateFieldGet(this, _Kochava_instance, "f").sleep)
1567
- return;
1568
- if (!__classPrivateFieldGet(this, _Kochava_instance, "f").installDone) {
1569
- await __classPrivateFieldGet(this, _Kochava_instances, "m", _Kochava_performInstall).call(this);
1570
- }
1571
- if (__classPrivateFieldGet(this, _Kochava_instance, "f").kvinitDone && __classPrivateFieldGet(this, _Kochava_instance, "f").installDone) {
1572
- await __classPrivateFieldGet(this, _Kochava_jobQueue, "f").start(__classPrivateFieldGet(this, _Kochava_instance, "f"));
1573
- }
1574
- }, _Kochava_performNewKvinit = async function _Kochava_performNewKvinit() {
1575
- __classPrivateFieldGet(this, _Kochava_instance, "f").kvinitDone = await send$1(__classPrivateFieldGet(this, _Kochava_instance, "f"), __classPrivateFieldGet(this, _Kochava_instance, "f").retryWaterfall);
1576
- updatePersistedValue(PersistKey.KvinitSentDate, String(getCurrTimeSec()), __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies);
1577
- // if new kvinit, apply it
1578
- let newKvinit = {};
1579
- const newKvinitStr = readAndUpdatePersistedValue(PersistKey.LastKvinit, __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies);
1580
- if (newKvinitStr) {
1581
- newKvinit = JSON.parse(newKvinitStr);
1582
- }
1583
- applyKvinitResp(__classPrivateFieldGet(this, _Kochava_instance, "f"), newKvinit);
1584
- Log.trace("KochavaConfig after new Kvinit:", JSON.parse(JSON.stringify(__classPrivateFieldGet(this, _Kochava_instance, "f").kochavaConfig)));
1585
- }, _Kochava_checkResendId = function _Kochava_checkResendId() {
1586
- let resendId = "";
1587
- if (__classPrivateFieldGet(this, _Kochava_instance, "f").kochavaConfig.install) {
1588
- resendId = __classPrivateFieldGet(this, _Kochava_instance, "f").kochavaConfig.install.resend_id;
1589
- }
1590
- const needsNewInstall = checkInstallIdChange(resendId, __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies);
1591
- if (needsNewInstall) {
1592
- Log.debug(`resend_id ${resendId} found, forcing new install`);
1593
- }
1594
- return needsNewInstall;
1595
- }, _Kochava_performInstall = async function _Kochava_performInstall() {
1596
- const request = build(__classPrivateFieldGet(this, _Kochava_instance, "f"));
1597
- __classPrivateFieldGet(this, _Kochava_instance, "f").installDone = await send(__classPrivateFieldGet(this, _Kochava_instance, "f"), request);
1598
- if (!__classPrivateFieldGet(this, _Kochava_instance, "f").installDone)
1599
- return;
1600
- // If the install succeeded, remove all idLink that were passed to it
1601
- onSuccess(__classPrivateFieldGet(this, _Kochava_instance, "f"));
1602
- updatePersistedValue(PersistKey.IdLinkQueue, JSON.stringify(__classPrivateFieldGet(this, _Kochava_jobQueue, "f").idLinkQueue), false);
1603
- };
1604
- // Only here for generic Web integration
1605
- window.kochava = Kochava.create();
1606
-
1607
- class KochavaAngularService {
1608
- constructor() {
1609
- this.kochava = Kochava.createForAngular();
1610
- }
1611
- }
1612
- KochavaAngularService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: KochavaAngularService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1613
- KochavaAngularService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: KochavaAngularService, providedIn: 'root' });
1614
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: KochavaAngularService, decorators: [{
1615
- type: Injectable,
1616
- args: [{
1617
- providedIn: 'root'
1618
- }]
1619
- }], ctorParameters: function () { return []; } });
1620
-
1621
- class KochavaAngularModule {
1622
- static forRoot() {
1623
- return {
1624
- ngModule: KochavaAngularModule,
1625
- providers: [KochavaAngularService],
1626
- };
1627
- }
1628
- }
1629
- KochavaAngularModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: KochavaAngularModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1630
- KochavaAngularModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: KochavaAngularModule });
1631
- KochavaAngularModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: KochavaAngularModule, imports: [[]] });
1632
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: KochavaAngularModule, decorators: [{
1633
- type: NgModule,
1634
- args: [{
1635
- declarations: [],
1636
- imports: [],
1637
- }]
1638
- }] });
1639
-
1640
- /*
1641
- * Public API Surface of kochava-angular
1642
- */
1643
-
1644
- /**
1645
- * Generated bundle index. Do not edit.
1646
- */
1647
-
1648
- export { KochavaAngularModule, KochavaAngularService };
1649
- //# sourceMappingURL=kv-test-ang.mjs.map