kv-test-lib 1.0.22 → 1.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/kochava.d.ts +5 -16
- package/dist/kochava.js +209 -202
- package/package.json +1 -2
package/dist/kochava.d.ts
CHANGED
|
@@ -28,14 +28,13 @@ export interface KochavaInstance {
|
|
|
28
28
|
kochavaConfig?: KvConfig;
|
|
29
29
|
}
|
|
30
30
|
export declare class Kochava {
|
|
31
|
-
private
|
|
32
|
-
private jobQueue;
|
|
31
|
+
#private;
|
|
33
32
|
private constructor();
|
|
34
33
|
static create(): Kochava;
|
|
35
|
-
static
|
|
36
|
-
static
|
|
37
|
-
static
|
|
38
|
-
static
|
|
34
|
+
static createForNode(): Kochava;
|
|
35
|
+
static createForReact(): Kochava;
|
|
36
|
+
static createForVue(): Kochava;
|
|
37
|
+
static createForAngular(): Kochava;
|
|
39
38
|
useCookies(condition?: boolean): void;
|
|
40
39
|
disableAutoPage(condition?: boolean): void;
|
|
41
40
|
startWithAppGuid(appGuid: string): void;
|
|
@@ -50,14 +49,4 @@ export declare class Kochava {
|
|
|
50
49
|
getStarted(): boolean;
|
|
51
50
|
getDeviceId(): string;
|
|
52
51
|
setSleep(sleep: boolean): void;
|
|
53
|
-
private resetInstance;
|
|
54
|
-
private initInstance;
|
|
55
|
-
private checkFirstLaunchAndMigrate;
|
|
56
|
-
private checkPersistedKvinit;
|
|
57
|
-
private checkPersistedState;
|
|
58
|
-
private printStartupMsgs;
|
|
59
|
-
private beginStart;
|
|
60
|
-
private performNewKvinit;
|
|
61
|
-
private checkResendId;
|
|
62
|
-
private performInstall;
|
|
63
52
|
}
|
package/dist/kochava.js
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
Authored by Brett Barinaga on 11/17/21.
|
|
3
3
|
Copyright (c) Kochava, Inc. All rights reserved.
|
|
4
4
|
*/
|
|
5
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
6
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
7
|
+
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");
|
|
8
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
9
|
+
};
|
|
10
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
11
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
12
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
13
|
+
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");
|
|
14
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
15
|
+
};
|
|
16
|
+
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;
|
|
5
17
|
import { Log } from "./utils/log";
|
|
6
18
|
import JobQueue from "./jobqueue";
|
|
7
19
|
import * as Kvinit from "./payloads/kvinit";
|
|
@@ -11,32 +23,37 @@ import { deleteAllPersisted, readAndUpdatePersistedValue, updatePersistedValue,
|
|
|
11
23
|
import * as utils from "./utils/utils";
|
|
12
24
|
import { getPageName } from "./browser/browser";
|
|
13
25
|
export class Kochava {
|
|
14
|
-
//
|
|
26
|
+
// User will use the below factories instead of directly calling
|
|
27
|
+
// the constructor
|
|
15
28
|
constructor() {
|
|
16
|
-
|
|
17
|
-
this
|
|
29
|
+
_Kochava_instances.add(this);
|
|
30
|
+
_Kochava_instance.set(this, void 0);
|
|
31
|
+
_Kochava_jobQueue.set(this, void 0);
|
|
32
|
+
__classPrivateFieldGet(this, _Kochava_instances, "m", _Kochava_resetInstance).call(this);
|
|
33
|
+
__classPrivateFieldSet(this, _Kochava_jobQueue, new JobQueue(), "f");
|
|
18
34
|
}
|
|
35
|
+
// ============================= PUBLIC =============================== //
|
|
19
36
|
static create() {
|
|
20
37
|
return new Kochava();
|
|
21
38
|
}
|
|
22
|
-
static
|
|
39
|
+
static createForNode() {
|
|
23
40
|
const kochava = new Kochava();
|
|
24
|
-
kochava.executeAdvancedInstruction("wrapper", JSON.stringify({ name: "Node", version: "
|
|
41
|
+
kochava.executeAdvancedInstruction("wrapper", JSON.stringify({ name: "Node", version: "" }));
|
|
25
42
|
return kochava;
|
|
26
43
|
}
|
|
27
|
-
static
|
|
44
|
+
static createForReact() {
|
|
28
45
|
const kochava = new Kochava();
|
|
29
|
-
kochava.executeAdvancedInstruction("wrapper", JSON.stringify({ name: "React", version: "
|
|
46
|
+
kochava.executeAdvancedInstruction("wrapper", JSON.stringify({ name: "React", version: "" }));
|
|
30
47
|
return kochava;
|
|
31
48
|
}
|
|
32
|
-
static
|
|
49
|
+
static createForVue() {
|
|
33
50
|
const kochava = new Kochava();
|
|
34
|
-
kochava.executeAdvancedInstruction("wrapper", JSON.stringify({ name: "Vue", version: "
|
|
51
|
+
kochava.executeAdvancedInstruction("wrapper", JSON.stringify({ name: "Vue", version: "" }));
|
|
35
52
|
return kochava;
|
|
36
53
|
}
|
|
37
|
-
static
|
|
54
|
+
static createForAngular() {
|
|
38
55
|
const kochava = new Kochava();
|
|
39
|
-
kochava.executeAdvancedInstruction("wrapper", JSON.stringify({ name: "Angular", version: "
|
|
56
|
+
kochava.executeAdvancedInstruction("wrapper", JSON.stringify({ name: "Angular", version: "1.0.0" }));
|
|
40
57
|
return kochava;
|
|
41
58
|
}
|
|
42
59
|
/*
|
|
@@ -48,7 +65,7 @@ export class Kochava {
|
|
|
48
65
|
- defaults to false
|
|
49
66
|
*/
|
|
50
67
|
useCookies(condition = false) {
|
|
51
|
-
this.
|
|
68
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").useCookies = condition;
|
|
52
69
|
}
|
|
53
70
|
/*
|
|
54
71
|
- Set whether the sdk shouldn't automatically send a page or should.
|
|
@@ -57,7 +74,7 @@ export class Kochava {
|
|
|
57
74
|
- defaults to false
|
|
58
75
|
*/
|
|
59
76
|
disableAutoPage(condition = false) {
|
|
60
|
-
this.
|
|
77
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").disableAutoPage = condition;
|
|
61
78
|
}
|
|
62
79
|
/*
|
|
63
80
|
The primary means for starting the sdk.
|
|
@@ -75,22 +92,22 @@ export class Kochava {
|
|
|
75
92
|
Log.error(`Invalid appGuid ${appGuid}, start failed.`);
|
|
76
93
|
return;
|
|
77
94
|
}
|
|
78
|
-
if (!this
|
|
79
|
-
this.
|
|
80
|
-
if (this.
|
|
95
|
+
if (!__classPrivateFieldGet(this, _Kochava_instance, "f"))
|
|
96
|
+
__classPrivateFieldGet(this, _Kochava_instances, "m", _Kochava_resetInstance).call(this);
|
|
97
|
+
if (__classPrivateFieldGet(this, _Kochava_instance, "f").started) {
|
|
81
98
|
Log.warn("Kochava SDK already started.");
|
|
82
99
|
return;
|
|
83
100
|
}
|
|
84
101
|
Log.diagDebug(`Host called API: Start With App Guid ${appGuid}`);
|
|
85
|
-
this.
|
|
86
|
-
this.
|
|
87
|
-
this.
|
|
88
|
-
if (!this.
|
|
102
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").started = true;
|
|
103
|
+
__classPrivateFieldGet(this, _Kochava_instances, "m", _Kochava_checkFirstLaunchAndMigrate).call(this);
|
|
104
|
+
__classPrivateFieldGet(this, _Kochava_instances, "m", _Kochava_initInstance).call(this, appGuid);
|
|
105
|
+
if (!__classPrivateFieldGet(this, _Kochava_instance, "f").disableAutoPage)
|
|
89
106
|
this.sendPageEvent();
|
|
90
|
-
this.
|
|
91
|
-
this.
|
|
92
|
-
this.
|
|
93
|
-
this.
|
|
107
|
+
__classPrivateFieldGet(this, _Kochava_instances, "m", _Kochava_checkPersistedState).call(this);
|
|
108
|
+
__classPrivateFieldGet(this, _Kochava_instances, "m", _Kochava_checkPersistedKvinit).call(this);
|
|
109
|
+
__classPrivateFieldGet(this, _Kochava_instances, "m", _Kochava_printStartupMsgs).call(this, appGuid);
|
|
110
|
+
__classPrivateFieldGet(this, _Kochava_instances, "m", _Kochava_beginStart).call(this);
|
|
94
111
|
}
|
|
95
112
|
/*
|
|
96
113
|
Primary means for stopping the sdk.
|
|
@@ -103,16 +120,16 @@ export class Kochava {
|
|
|
103
120
|
Log.debug("Deleting persisted values");
|
|
104
121
|
deleteAllPersisted();
|
|
105
122
|
}
|
|
106
|
-
if (!this.
|
|
123
|
+
if (!__classPrivateFieldGet(this, _Kochava_instance, "f").started) {
|
|
107
124
|
Log.warn("SDK already shutdown.");
|
|
108
125
|
}
|
|
109
126
|
Log.info("SDK shutting down.");
|
|
110
127
|
Kvinit.cancelRetries();
|
|
111
128
|
Install.cancelRetries();
|
|
112
|
-
this.
|
|
129
|
+
__classPrivateFieldGet(this, _Kochava_jobQueue, "f").stop();
|
|
113
130
|
// wipe whatever was previously in the queue
|
|
114
|
-
this
|
|
115
|
-
this.
|
|
131
|
+
__classPrivateFieldSet(this, _Kochava_jobQueue, new JobQueue(), "f");
|
|
132
|
+
__classPrivateFieldGet(this, _Kochava_instances, "m", _Kochava_resetInstance).call(this);
|
|
116
133
|
}
|
|
117
134
|
/*
|
|
118
135
|
Changes the current logLevel.
|
|
@@ -141,14 +158,14 @@ export class Kochava {
|
|
|
141
158
|
case "wrapper":
|
|
142
159
|
{
|
|
143
160
|
const wrapperVersion = JSON.parse(valueStr);
|
|
144
|
-
if (!this.
|
|
145
|
-
this.
|
|
161
|
+
if (!__classPrivateFieldGet(this, _Kochava_instance, "f").version)
|
|
162
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").version = "WebTracker 3.0.0";
|
|
146
163
|
switch (wrapperVersion.name) {
|
|
147
164
|
case "Angular":
|
|
148
|
-
this.
|
|
165
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").version += ` (${wrapperVersion.name} ${wrapperVersion.version})`;
|
|
149
166
|
break;
|
|
150
167
|
default:
|
|
151
|
-
this.
|
|
168
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").version += ` (${wrapperVersion.name})`;
|
|
152
169
|
break;
|
|
153
170
|
}
|
|
154
171
|
}
|
|
@@ -157,13 +174,13 @@ export class Kochava {
|
|
|
157
174
|
{
|
|
158
175
|
const overrideUrls = JSON.parse(valueStr);
|
|
159
176
|
if (overrideUrls.init)
|
|
160
|
-
this.
|
|
177
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").overrideUrls.init = overrideUrls.init;
|
|
161
178
|
if (overrideUrls.event)
|
|
162
|
-
this.
|
|
179
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").overrideUrls.event = overrideUrls.event;
|
|
163
180
|
if (overrideUrls.install)
|
|
164
|
-
this.
|
|
181
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").overrideUrls.install = overrideUrls.install;
|
|
165
182
|
if (overrideUrls.identityLink)
|
|
166
|
-
this.
|
|
183
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").overrideUrls.identityLink = overrideUrls.identityLink;
|
|
167
184
|
}
|
|
168
185
|
break;
|
|
169
186
|
case "urlsRestore":
|
|
@@ -171,14 +188,14 @@ export class Kochava {
|
|
|
171
188
|
const restoreUrls = JSON.parse(valueStr);
|
|
172
189
|
for (const url of restoreUrls) {
|
|
173
190
|
if (url === "init")
|
|
174
|
-
this.
|
|
191
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").overrideUrls.init = DEFAULTS.networking.urls.init;
|
|
175
192
|
if (url === "event")
|
|
176
|
-
this.
|
|
193
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").overrideUrls.event = DEFAULTS.networking.urls.event;
|
|
177
194
|
if (url === "install")
|
|
178
|
-
this.
|
|
195
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").overrideUrls.install =
|
|
179
196
|
DEFAULTS.networking.urls.install;
|
|
180
197
|
if (url === "identityLink")
|
|
181
|
-
this.
|
|
198
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").overrideUrls.identityLink =
|
|
182
199
|
DEFAULTS.networking.urls.identityLink;
|
|
183
200
|
}
|
|
184
201
|
}
|
|
@@ -191,7 +208,7 @@ export class Kochava {
|
|
|
191
208
|
break;
|
|
192
209
|
case "getInstance":
|
|
193
210
|
{
|
|
194
|
-
const currInstance = JSON.stringify(this
|
|
211
|
+
const currInstance = JSON.stringify(__classPrivateFieldGet(this, _Kochava_instance, "f"));
|
|
195
212
|
callback(currInstance);
|
|
196
213
|
Log.debug(`capturing instance: ${valueStr}`);
|
|
197
214
|
}
|
|
@@ -213,7 +230,7 @@ export class Kochava {
|
|
|
213
230
|
Log.warn("Invalid event name, ignoring call.");
|
|
214
231
|
return;
|
|
215
232
|
}
|
|
216
|
-
this.
|
|
233
|
+
__classPrivateFieldGet(this, _Kochava_jobQueue, "f").enqueueEvent(__classPrivateFieldGet(this, _Kochava_instance, "f"), [name, data]);
|
|
217
234
|
}
|
|
218
235
|
/*
|
|
219
236
|
Wraps the sendEvent call with predefined data specific to page events.
|
|
@@ -243,10 +260,11 @@ export class Kochava {
|
|
|
243
260
|
}
|
|
244
261
|
const idLink = {};
|
|
245
262
|
idLink[name] = identifier;
|
|
246
|
-
addPersistedIdLinks(name, identifier, this.
|
|
247
|
-
if (this
|
|
263
|
+
addPersistedIdLinks(name, identifier, __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies);
|
|
264
|
+
// if (this.#instance.installStarted || this.#instance.installDone) {
|
|
265
|
+
if (localStorage.getItem("com.kochava.tracker.InstallSentDate")) {
|
|
248
266
|
// it will be sent standalone
|
|
249
|
-
this.
|
|
267
|
+
__classPrivateFieldGet(this, _Kochava_jobQueue, "f").enqueueIdLink(__classPrivateFieldGet(this, _Kochava_instance, "f"), idLink);
|
|
250
268
|
}
|
|
251
269
|
// will be sent in install
|
|
252
270
|
}
|
|
@@ -259,7 +277,7 @@ export class Kochava {
|
|
|
259
277
|
}
|
|
260
278
|
const dataToAdorn = {};
|
|
261
279
|
dataToAdorn[name] = value;
|
|
262
|
-
this.
|
|
280
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").customValues.push({ data: dataToAdorn, isDeviceId: false });
|
|
263
281
|
}
|
|
264
282
|
// Allows the client to attach arbitrary identifiers to go out in the install.
|
|
265
283
|
registerCustomDeviceIdentifier(name, value) {
|
|
@@ -270,7 +288,7 @@ export class Kochava {
|
|
|
270
288
|
}
|
|
271
289
|
const dataToAdorn = {};
|
|
272
290
|
dataToAdorn[name] = value;
|
|
273
|
-
this.
|
|
291
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").customValues.push({ data: dataToAdorn, isDeviceId: true });
|
|
274
292
|
}
|
|
275
293
|
/*
|
|
276
294
|
Returns whether or not the sdk is in a "started" state.
|
|
@@ -279,15 +297,15 @@ export class Kochava {
|
|
|
279
297
|
Likewise, shutdown will set "started" to false;
|
|
280
298
|
*/
|
|
281
299
|
getStarted() {
|
|
282
|
-
return this.
|
|
300
|
+
return __classPrivateFieldGet(this, _Kochava_instance, "f").started;
|
|
283
301
|
}
|
|
284
302
|
/*
|
|
285
303
|
Returns the current kochavaDeviceId, or "" if called too early.
|
|
286
304
|
*/
|
|
287
305
|
getDeviceId() {
|
|
288
306
|
Log.diagDebug(`Host called API: Get Kochava Device Id`);
|
|
289
|
-
if (this.
|
|
290
|
-
return this.
|
|
307
|
+
if (__classPrivateFieldGet(this, _Kochava_instance, "f").started)
|
|
308
|
+
return __classPrivateFieldGet(this, _Kochava_instance, "f").kochavaDeviceId;
|
|
291
309
|
else
|
|
292
310
|
return "";
|
|
293
311
|
}
|
|
@@ -298,171 +316,160 @@ export class Kochava {
|
|
|
298
316
|
*/
|
|
299
317
|
setSleep(sleep) {
|
|
300
318
|
Log.diagDebug(`Host called API: Sleep ${sleep ? "Stop" : "Start"}`);
|
|
301
|
-
if (sleep && !this.
|
|
319
|
+
if (sleep && !__classPrivateFieldGet(this, _Kochava_instance, "f").sleep) {
|
|
302
320
|
// only pause if it was running
|
|
303
|
-
this.
|
|
304
|
-
this.
|
|
321
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").sleep = sleep;
|
|
322
|
+
__classPrivateFieldGet(this, _Kochava_jobQueue, "f").pause();
|
|
305
323
|
}
|
|
306
|
-
else if (!sleep && this.
|
|
324
|
+
else if (!sleep && __classPrivateFieldGet(this, _Kochava_instance, "f").sleep) {
|
|
307
325
|
// only resume queueing if it was paused
|
|
308
|
-
this.
|
|
309
|
-
this.
|
|
326
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").sleep = sleep;
|
|
327
|
+
__classPrivateFieldGet(this, _Kochava_instances, "m", _Kochava_beginStart).call(this);
|
|
310
328
|
}
|
|
311
329
|
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
const oldKvId = readAndUpdatePersistedValue(PersistKey.OldKvid, this.instance.useCookies);
|
|
367
|
-
if (oldKvId) {
|
|
368
|
-
updatePersistedValue(PersistKey.DeviceId, oldKvId, this.instance.useCookies);
|
|
369
|
-
updatePersistedValue(PersistKey.InstallSentDate, JSON.stringify(utils.getCurrTimeSec()), this.instance.useCookies);
|
|
370
|
-
}
|
|
330
|
+
}
|
|
331
|
+
_Kochava_instance = new WeakMap(), _Kochava_jobQueue = new WeakMap(), _Kochava_instances = new WeakSet(), _Kochava_resetInstance = function _Kochava_resetInstance() {
|
|
332
|
+
__classPrivateFieldSet(this, _Kochava_instance, {
|
|
333
|
+
appGuid: "",
|
|
334
|
+
started: false,
|
|
335
|
+
installStarted: false,
|
|
336
|
+
kvinitDone: false,
|
|
337
|
+
installDone: false,
|
|
338
|
+
disableAutoPage: false,
|
|
339
|
+
useCookies: false,
|
|
340
|
+
sleep: false,
|
|
341
|
+
version: "",
|
|
342
|
+
buildDate: "",
|
|
343
|
+
overrideUrls: {
|
|
344
|
+
init: "",
|
|
345
|
+
install: "",
|
|
346
|
+
event: "",
|
|
347
|
+
identityLink: "",
|
|
348
|
+
},
|
|
349
|
+
customValues: [],
|
|
350
|
+
kochavaSession: "",
|
|
351
|
+
retryWaterfall: [],
|
|
352
|
+
startTimeMS: 0,
|
|
353
|
+
utm: "",
|
|
354
|
+
kochavaDeviceId: "",
|
|
355
|
+
kochavaInstallId: "",
|
|
356
|
+
kochavaSessionCount: -1,
|
|
357
|
+
kochavaInstallDate: -1,
|
|
358
|
+
kochavaConfig: undefined,
|
|
359
|
+
}, "f");
|
|
360
|
+
}, _Kochava_initInstance = function _Kochava_initInstance(appGuid) {
|
|
361
|
+
// init instance with defaults
|
|
362
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").appGuid = appGuid;
|
|
363
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").disableAutoPage = __classPrivateFieldGet(this, _Kochava_instance, "f").disableAutoPage || false;
|
|
364
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").useCookies = __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies || false;
|
|
365
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").version = __classPrivateFieldGet(this, _Kochava_instance, "f").version || "WebTracker 3.0.0";
|
|
366
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").buildDate = "kbd: 6/10/2022, 10:52:40 AM";
|
|
367
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").kochavaSession = utils.uuidv4().substring(0, 5);
|
|
368
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").startTimeMS = utils.getCurrTimeMS();
|
|
369
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").retryWaterfall = [7, 30, 300, 1800];
|
|
370
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").kochavaConfig = JSON.parse(JSON.stringify(DEFAULTS));
|
|
371
|
+
}, _Kochava_checkFirstLaunchAndMigrate = function _Kochava_checkFirstLaunchAndMigrate() {
|
|
372
|
+
// If this is our first launch ever, set it in persistence.
|
|
373
|
+
if (!readAndUpdatePersistedValue(PersistKey.FirstStartDate, __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies)) {
|
|
374
|
+
updatePersistedValue(PersistKey.FirstStartDate, String(utils.getCurrTimeSec()), __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies);
|
|
375
|
+
/*
|
|
376
|
+
On a first launch of the v3 sdk, we need to migrate old persisted kv_id
|
|
377
|
+
from v2.2, v2.3, and v2.5
|
|
378
|
+
*/
|
|
379
|
+
// perform migration
|
|
380
|
+
const oldKvId = readAndUpdatePersistedValue(PersistKey.OldKvid, __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies);
|
|
381
|
+
if (oldKvId) {
|
|
382
|
+
updatePersistedValue(PersistKey.DeviceId, oldKvId, __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies);
|
|
383
|
+
updatePersistedValue(PersistKey.InstallSentDate, JSON.stringify(utils.getCurrTimeSec()), __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies);
|
|
371
384
|
}
|
|
372
385
|
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
}
|
|
386
|
+
}, _Kochava_checkPersistedKvinit = function _Kochava_checkPersistedKvinit() {
|
|
387
|
+
// check if persisted kvinit
|
|
388
|
+
let persistedKvinit = {};
|
|
389
|
+
const persistedKvinitStr = readAndUpdatePersistedValue(PersistKey.LastKvinit, __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies);
|
|
390
|
+
if (persistedKvinitStr) {
|
|
391
|
+
persistedKvinit = JSON.parse(persistedKvinitStr);
|
|
392
|
+
if (persistedKvinit) {
|
|
393
|
+
// if persisted kvinit, apply it
|
|
394
|
+
Log.trace("Found persisted kvinit.", persistedKvinit);
|
|
395
|
+
Kvinit.applyKvinitResp(__classPrivateFieldGet(this, _Kochava_instance, "f"), persistedKvinit);
|
|
396
|
+
Log.trace("KochavaConfig after persistedKvinit:", JSON.parse(JSON.stringify(__classPrivateFieldGet(this, _Kochava_instance, "f").kochavaConfig)));
|
|
385
397
|
}
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
398
|
+
}
|
|
399
|
+
// check refresh minimum too
|
|
400
|
+
const persistedKvinitDateStr = readAndUpdatePersistedValue(PersistKey.KvinitSentDate, __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies);
|
|
401
|
+
if (persistedKvinitDateStr) {
|
|
402
|
+
const lastKvinitDate = JSON.parse(persistedKvinitDateStr);
|
|
403
|
+
if (lastKvinitDate) {
|
|
404
|
+
const refreshMin = __classPrivateFieldGet(this, _Kochava_instance, "f").kochavaConfig.config.refresh_minimum;
|
|
405
|
+
if (utils.getCurrTimeSec() - lastKvinitDate < refreshMin)
|
|
406
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").kvinitDone = true;
|
|
395
407
|
}
|
|
396
408
|
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
409
|
+
}, _Kochava_checkPersistedState = function _Kochava_checkPersistedState() {
|
|
410
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").installDone =
|
|
411
|
+
readAndUpdatePersistedValue(PersistKey.InstallSentDate, __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies).length > 0;
|
|
412
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").kochavaInstallId = readAndUpdatePersistedValue(PersistKey.InstallId, __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies);
|
|
413
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").kochavaDeviceId = readAndUpdateDeviceId(__classPrivateFieldGet(this, _Kochava_instance, "f").useCookies);
|
|
414
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").kochavaSessionCount = readAndUpdateSessionCount(__classPrivateFieldGet(this, _Kochava_instance, "f").useCookies);
|
|
415
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").utm = readAndUpdateUTM(__classPrivateFieldGet(this, _Kochava_instance, "f").appGuid, __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies);
|
|
416
|
+
}, _Kochava_printStartupMsgs = function _Kochava_printStartupMsgs(appGuid) {
|
|
417
|
+
Log.diagInfo(`Started SDK ${__classPrivateFieldGet(this, _Kochava_instance, "f").version}
|
|
418
|
+
published ${__classPrivateFieldGet(this, _Kochava_instance, "f").buildDate}`);
|
|
419
|
+
Log.diagInfo(`The log level is set to ${Log.getLogLevel()}`);
|
|
420
|
+
Log.diagDebug(`This ${!__classPrivateFieldGet(this, _Kochava_instance, "f").installDone ? "is" : "is not"} the first tracker SDK launch`);
|
|
421
|
+
Log.diagDebug(`The kochava device id is ${__classPrivateFieldGet(this, _Kochava_instance, "f").kochavaDeviceId}`);
|
|
422
|
+
Log.diagDebug(`The kochava app GUID provided was ${appGuid}`);
|
|
423
|
+
}, _Kochava_beginStart = async function _Kochava_beginStart() {
|
|
424
|
+
// if we need to send a new kvinit, send it
|
|
425
|
+
if (!__classPrivateFieldGet(this, _Kochava_instance, "f").kvinitDone) {
|
|
426
|
+
Log.diagDebug(`A new kvinit will be sent`);
|
|
427
|
+
await __classPrivateFieldGet(this, _Kochava_instances, "m", _Kochava_performNewKvinit).call(this);
|
|
404
428
|
}
|
|
405
|
-
|
|
406
|
-
Log.
|
|
407
|
-
published ${this.instance.buildDate}`);
|
|
408
|
-
Log.diagInfo(`The log level is set to ${Log.getLogLevel()}`);
|
|
409
|
-
Log.diagDebug(`This ${!this.instance.installDone ? "is" : "is not"} the first tracker SDK launch`);
|
|
410
|
-
Log.diagDebug(`The kochava device id is ${this.instance.kochavaDeviceId}`);
|
|
411
|
-
Log.diagDebug(`The kochava app GUID provided was ${appGuid}`);
|
|
429
|
+
else {
|
|
430
|
+
Log.diagDebug(`A new kvinit will not be sent`);
|
|
412
431
|
}
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
}
|
|
422
|
-
// if the install_id changed and thus a new install must go out
|
|
423
|
-
if (this.checkResendId())
|
|
424
|
-
this.instance.installDone = false;
|
|
425
|
-
Log.diagDebug(`The install ${this.instance.installDone ? "has already" : "has not yet"} been sent`);
|
|
426
|
-
if (this.instance.sleep)
|
|
427
|
-
return;
|
|
428
|
-
if (!this.instance.installDone) {
|
|
429
|
-
await this.performInstall();
|
|
430
|
-
}
|
|
431
|
-
if (this.instance.kvinitDone && this.instance.installDone) {
|
|
432
|
-
await this.jobQueue.start(this.instance);
|
|
433
|
-
}
|
|
432
|
+
// if the install_id changed and thus a new install must go out
|
|
433
|
+
if (__classPrivateFieldGet(this, _Kochava_instances, "m", _Kochava_checkResendId).call(this))
|
|
434
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").installDone = false;
|
|
435
|
+
Log.diagDebug(`The install ${__classPrivateFieldGet(this, _Kochava_instance, "f").installDone ? "has already" : "has not yet"} been sent`);
|
|
436
|
+
if (__classPrivateFieldGet(this, _Kochava_instance, "f").sleep)
|
|
437
|
+
return;
|
|
438
|
+
if (!__classPrivateFieldGet(this, _Kochava_instance, "f").installDone) {
|
|
439
|
+
await __classPrivateFieldGet(this, _Kochava_instances, "m", _Kochava_performInstall).call(this);
|
|
434
440
|
}
|
|
435
|
-
|
|
436
|
-
this
|
|
437
|
-
updatePersistedValue(PersistKey.KvinitSentDate, String(utils.getCurrTimeSec()), this.instance.useCookies);
|
|
438
|
-
// if new kvinit, apply it
|
|
439
|
-
let newKvinit = {};
|
|
440
|
-
const newKvinitStr = readAndUpdatePersistedValue(PersistKey.LastKvinit, this.instance.useCookies);
|
|
441
|
-
if (newKvinitStr) {
|
|
442
|
-
newKvinit = JSON.parse(newKvinitStr);
|
|
443
|
-
}
|
|
444
|
-
Kvinit.applyKvinitResp(this.instance, newKvinit);
|
|
445
|
-
Log.trace("KochavaConfig after new Kvinit:", JSON.parse(JSON.stringify(this.instance.kochavaConfig)));
|
|
441
|
+
if (__classPrivateFieldGet(this, _Kochava_instance, "f").kvinitDone && __classPrivateFieldGet(this, _Kochava_instance, "f").installDone) {
|
|
442
|
+
await __classPrivateFieldGet(this, _Kochava_jobQueue, "f").start(__classPrivateFieldGet(this, _Kochava_instance, "f"));
|
|
446
443
|
}
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
}
|
|
456
|
-
return needsNewInstall;
|
|
444
|
+
}, _Kochava_performNewKvinit = async function _Kochava_performNewKvinit() {
|
|
445
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").kvinitDone = await Kvinit.send(__classPrivateFieldGet(this, _Kochava_instance, "f"), __classPrivateFieldGet(this, _Kochava_instance, "f").retryWaterfall);
|
|
446
|
+
updatePersistedValue(PersistKey.KvinitSentDate, String(utils.getCurrTimeSec()), __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies);
|
|
447
|
+
// if new kvinit, apply it
|
|
448
|
+
let newKvinit = {};
|
|
449
|
+
const newKvinitStr = readAndUpdatePersistedValue(PersistKey.LastKvinit, __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies);
|
|
450
|
+
if (newKvinitStr) {
|
|
451
|
+
newKvinit = JSON.parse(newKvinitStr);
|
|
457
452
|
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
Install.onSuccess(this.instance);
|
|
465
|
-
updatePersistedValue(PersistKey.IdLinkQueue, JSON.stringify(this.jobQueue.idLinkQueue), false);
|
|
453
|
+
Kvinit.applyKvinitResp(__classPrivateFieldGet(this, _Kochava_instance, "f"), newKvinit);
|
|
454
|
+
Log.trace("KochavaConfig after new Kvinit:", JSON.parse(JSON.stringify(__classPrivateFieldGet(this, _Kochava_instance, "f").kochavaConfig)));
|
|
455
|
+
}, _Kochava_checkResendId = function _Kochava_checkResendId() {
|
|
456
|
+
let resendId = "";
|
|
457
|
+
if (__classPrivateFieldGet(this, _Kochava_instance, "f").kochavaConfig.install) {
|
|
458
|
+
resendId = __classPrivateFieldGet(this, _Kochava_instance, "f").kochavaConfig.install.resend_id;
|
|
466
459
|
}
|
|
467
|
-
|
|
468
|
-
|
|
460
|
+
const needsNewInstall = checkInstallIdChange(resendId, __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies);
|
|
461
|
+
if (needsNewInstall) {
|
|
462
|
+
Log.debug(`resend_id ${resendId} found, forcing new install`);
|
|
463
|
+
}
|
|
464
|
+
return needsNewInstall;
|
|
465
|
+
}, _Kochava_performInstall = async function _Kochava_performInstall() {
|
|
466
|
+
const request = Install.build(__classPrivateFieldGet(this, _Kochava_instance, "f"));
|
|
467
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").installDone = await Install.send(__classPrivateFieldGet(this, _Kochava_instance, "f"), request);
|
|
468
|
+
if (!__classPrivateFieldGet(this, _Kochava_instance, "f").installDone)
|
|
469
|
+
return;
|
|
470
|
+
// If the install succeeded, remove all idLink that were passed to it
|
|
471
|
+
Install.onSuccess(__classPrivateFieldGet(this, _Kochava_instance, "f"));
|
|
472
|
+
updatePersistedValue(PersistKey.IdLinkQueue, JSON.stringify(__classPrivateFieldGet(this, _Kochava_jobQueue, "f").idLinkQueue), false);
|
|
473
|
+
};
|
|
474
|
+
// Only here for generic Web integration
|
|
475
|
+
window.kochava = Kochava.create();
|