kv-test-lib 1.0.22 → 1.0.23
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 +6 -17
- package/dist/kochava.js +202 -197
- package/package.json +1 -1
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
|
-
|
|
33
|
-
private constructor();
|
|
31
|
+
#private;
|
|
32
|
+
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,30 +23,35 @@ 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
41
|
kochava.executeAdvancedInstruction("wrapper", JSON.stringify({ name: "Node", version: "3.0.0" }));
|
|
25
42
|
return kochava;
|
|
26
43
|
}
|
|
27
|
-
static
|
|
44
|
+
static createForReact() {
|
|
28
45
|
const kochava = new Kochava();
|
|
29
46
|
kochava.executeAdvancedInstruction("wrapper", JSON.stringify({ name: "React", version: "3.0.0" }));
|
|
30
47
|
return kochava;
|
|
31
48
|
}
|
|
32
|
-
static
|
|
49
|
+
static createForVue() {
|
|
33
50
|
const kochava = new Kochava();
|
|
34
51
|
kochava.executeAdvancedInstruction("wrapper", JSON.stringify({ name: "Vue", version: "3.0.0" }));
|
|
35
52
|
return kochava;
|
|
36
53
|
}
|
|
37
|
-
static
|
|
54
|
+
static createForAngular() {
|
|
38
55
|
const kochava = new Kochava();
|
|
39
56
|
kochava.executeAdvancedInstruction("wrapper", JSON.stringify({ name: "Angular", version: "3.0.0" }));
|
|
40
57
|
return kochava;
|
|
@@ -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,10 @@ 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 (__classPrivateFieldGet(this, _Kochava_instance, "f").installStarted || __classPrivateFieldGet(this, _Kochava_instance, "f").installDone) {
|
|
248
265
|
// it will be sent standalone
|
|
249
|
-
this.
|
|
266
|
+
__classPrivateFieldGet(this, _Kochava_jobQueue, "f").enqueueIdLink(__classPrivateFieldGet(this, _Kochava_instance, "f"), idLink);
|
|
250
267
|
}
|
|
251
268
|
// will be sent in install
|
|
252
269
|
}
|
|
@@ -259,7 +276,7 @@ export class Kochava {
|
|
|
259
276
|
}
|
|
260
277
|
const dataToAdorn = {};
|
|
261
278
|
dataToAdorn[name] = value;
|
|
262
|
-
this.
|
|
279
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").customValues.push({ data: dataToAdorn, isDeviceId: false });
|
|
263
280
|
}
|
|
264
281
|
// Allows the client to attach arbitrary identifiers to go out in the install.
|
|
265
282
|
registerCustomDeviceIdentifier(name, value) {
|
|
@@ -270,7 +287,7 @@ export class Kochava {
|
|
|
270
287
|
}
|
|
271
288
|
const dataToAdorn = {};
|
|
272
289
|
dataToAdorn[name] = value;
|
|
273
|
-
this.
|
|
290
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").customValues.push({ data: dataToAdorn, isDeviceId: true });
|
|
274
291
|
}
|
|
275
292
|
/*
|
|
276
293
|
Returns whether or not the sdk is in a "started" state.
|
|
@@ -279,15 +296,15 @@ export class Kochava {
|
|
|
279
296
|
Likewise, shutdown will set "started" to false;
|
|
280
297
|
*/
|
|
281
298
|
getStarted() {
|
|
282
|
-
return this.
|
|
299
|
+
return __classPrivateFieldGet(this, _Kochava_instance, "f").started;
|
|
283
300
|
}
|
|
284
301
|
/*
|
|
285
302
|
Returns the current kochavaDeviceId, or "" if called too early.
|
|
286
303
|
*/
|
|
287
304
|
getDeviceId() {
|
|
288
305
|
Log.diagDebug(`Host called API: Get Kochava Device Id`);
|
|
289
|
-
if (this.
|
|
290
|
-
return this.
|
|
306
|
+
if (__classPrivateFieldGet(this, _Kochava_instance, "f").started)
|
|
307
|
+
return __classPrivateFieldGet(this, _Kochava_instance, "f").kochavaDeviceId;
|
|
291
308
|
else
|
|
292
309
|
return "";
|
|
293
310
|
}
|
|
@@ -298,171 +315,159 @@ export class Kochava {
|
|
|
298
315
|
*/
|
|
299
316
|
setSleep(sleep) {
|
|
300
317
|
Log.diagDebug(`Host called API: Sleep ${sleep ? "Stop" : "Start"}`);
|
|
301
|
-
if (sleep && !this.
|
|
318
|
+
if (sleep && !__classPrivateFieldGet(this, _Kochava_instance, "f").sleep) {
|
|
302
319
|
// only pause if it was running
|
|
303
|
-
this.
|
|
304
|
-
this.
|
|
320
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").sleep = sleep;
|
|
321
|
+
__classPrivateFieldGet(this, _Kochava_jobQueue, "f").pause();
|
|
305
322
|
}
|
|
306
|
-
else if (!sleep && this.
|
|
323
|
+
else if (!sleep && __classPrivateFieldGet(this, _Kochava_instance, "f").sleep) {
|
|
307
324
|
// only resume queueing if it was paused
|
|
308
|
-
this.
|
|
309
|
-
this.
|
|
325
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").sleep = sleep;
|
|
326
|
+
__classPrivateFieldGet(this, _Kochava_instances, "m", _Kochava_beginStart).call(this);
|
|
310
327
|
}
|
|
311
328
|
}
|
|
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
|
-
}
|
|
329
|
+
}
|
|
330
|
+
_Kochava_instance = new WeakMap(), _Kochava_jobQueue = new WeakMap(), _Kochava_instances = new WeakSet(), _Kochava_resetInstance = function _Kochava_resetInstance() {
|
|
331
|
+
__classPrivateFieldSet(this, _Kochava_instance, {
|
|
332
|
+
appGuid: "",
|
|
333
|
+
started: false,
|
|
334
|
+
installStarted: false,
|
|
335
|
+
kvinitDone: false,
|
|
336
|
+
installDone: false,
|
|
337
|
+
disableAutoPage: false,
|
|
338
|
+
useCookies: false,
|
|
339
|
+
sleep: false,
|
|
340
|
+
version: "",
|
|
341
|
+
buildDate: "",
|
|
342
|
+
overrideUrls: {
|
|
343
|
+
init: "",
|
|
344
|
+
install: "",
|
|
345
|
+
event: "",
|
|
346
|
+
identityLink: "",
|
|
347
|
+
},
|
|
348
|
+
customValues: [],
|
|
349
|
+
kochavaSession: "",
|
|
350
|
+
retryWaterfall: [],
|
|
351
|
+
startTimeMS: 0,
|
|
352
|
+
utm: "",
|
|
353
|
+
kochavaDeviceId: "",
|
|
354
|
+
kochavaInstallId: "",
|
|
355
|
+
kochavaSessionCount: -1,
|
|
356
|
+
kochavaInstallDate: -1,
|
|
357
|
+
kochavaConfig: undefined,
|
|
358
|
+
}, "f");
|
|
359
|
+
}, _Kochava_initInstance = function _Kochava_initInstance(appGuid) {
|
|
360
|
+
// init instance with defaults
|
|
361
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").appGuid = appGuid;
|
|
362
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").disableAutoPage = __classPrivateFieldGet(this, _Kochava_instance, "f").disableAutoPage || false;
|
|
363
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").useCookies = __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies || false;
|
|
364
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").version = __classPrivateFieldGet(this, _Kochava_instance, "f").version || "WebTracker 3.0.0";
|
|
365
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").buildDate = "kbd: 3/31/2022, 10:50:51 AM";
|
|
366
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").kochavaSession = utils.uuidv4().substring(0, 5);
|
|
367
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").startTimeMS = utils.getCurrTimeMS();
|
|
368
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").retryWaterfall = [7, 30, 300, 1800];
|
|
369
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").kochavaConfig = JSON.parse(JSON.stringify(DEFAULTS));
|
|
370
|
+
}, _Kochava_checkFirstLaunchAndMigrate = function _Kochava_checkFirstLaunchAndMigrate() {
|
|
371
|
+
// If this is our first launch ever, set it in persistence.
|
|
372
|
+
if (!readAndUpdatePersistedValue(PersistKey.FirstStartDate, __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies)) {
|
|
373
|
+
updatePersistedValue(PersistKey.FirstStartDate, String(utils.getCurrTimeSec()), __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies);
|
|
374
|
+
/*
|
|
375
|
+
On a first launch of the v3 sdk, we need to migrate old persisted kv_id
|
|
376
|
+
from v2.2, v2.3, and v2.5
|
|
377
|
+
*/
|
|
378
|
+
// perform migration
|
|
379
|
+
const oldKvId = readAndUpdatePersistedValue(PersistKey.OldKvid, __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies);
|
|
380
|
+
if (oldKvId) {
|
|
381
|
+
updatePersistedValue(PersistKey.DeviceId, oldKvId, __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies);
|
|
382
|
+
updatePersistedValue(PersistKey.InstallSentDate, JSON.stringify(utils.getCurrTimeSec()), __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies);
|
|
371
383
|
}
|
|
372
384
|
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
}
|
|
385
|
+
}, _Kochava_checkPersistedKvinit = function _Kochava_checkPersistedKvinit() {
|
|
386
|
+
// check if persisted kvinit
|
|
387
|
+
let persistedKvinit = {};
|
|
388
|
+
const persistedKvinitStr = readAndUpdatePersistedValue(PersistKey.LastKvinit, __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies);
|
|
389
|
+
if (persistedKvinitStr) {
|
|
390
|
+
persistedKvinit = JSON.parse(persistedKvinitStr);
|
|
391
|
+
if (persistedKvinit) {
|
|
392
|
+
// if persisted kvinit, apply it
|
|
393
|
+
Log.trace("Found persisted kvinit.", persistedKvinit);
|
|
394
|
+
Kvinit.applyKvinitResp(__classPrivateFieldGet(this, _Kochava_instance, "f"), persistedKvinit);
|
|
395
|
+
Log.trace("KochavaConfig after persistedKvinit:", JSON.parse(JSON.stringify(__classPrivateFieldGet(this, _Kochava_instance, "f").kochavaConfig)));
|
|
385
396
|
}
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
397
|
+
}
|
|
398
|
+
// check refresh minimum too
|
|
399
|
+
const persistedKvinitDateStr = readAndUpdatePersistedValue(PersistKey.KvinitSentDate, __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies);
|
|
400
|
+
if (persistedKvinitDateStr) {
|
|
401
|
+
const lastKvinitDate = JSON.parse(persistedKvinitDateStr);
|
|
402
|
+
if (lastKvinitDate) {
|
|
403
|
+
const refreshMin = __classPrivateFieldGet(this, _Kochava_instance, "f").kochavaConfig.config.refresh_minimum;
|
|
404
|
+
if (utils.getCurrTimeSec() - lastKvinitDate < refreshMin)
|
|
405
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").kvinitDone = true;
|
|
395
406
|
}
|
|
396
407
|
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
408
|
+
}, _Kochava_checkPersistedState = function _Kochava_checkPersistedState() {
|
|
409
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").installDone =
|
|
410
|
+
readAndUpdatePersistedValue(PersistKey.InstallSentDate, __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies).length > 0;
|
|
411
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").kochavaInstallId = readAndUpdatePersistedValue(PersistKey.InstallId, __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies);
|
|
412
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").kochavaDeviceId = readAndUpdateDeviceId(__classPrivateFieldGet(this, _Kochava_instance, "f").useCookies);
|
|
413
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").kochavaSessionCount = readAndUpdateSessionCount(__classPrivateFieldGet(this, _Kochava_instance, "f").useCookies);
|
|
414
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").utm = readAndUpdateUTM(__classPrivateFieldGet(this, _Kochava_instance, "f").appGuid, __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies);
|
|
415
|
+
}, _Kochava_printStartupMsgs = function _Kochava_printStartupMsgs(appGuid) {
|
|
416
|
+
Log.diagInfo(`Started SDK ${__classPrivateFieldGet(this, _Kochava_instance, "f").version}
|
|
417
|
+
published ${__classPrivateFieldGet(this, _Kochava_instance, "f").buildDate}`);
|
|
418
|
+
Log.diagInfo(`The log level is set to ${Log.getLogLevel()}`);
|
|
419
|
+
Log.diagDebug(`This ${!__classPrivateFieldGet(this, _Kochava_instance, "f").installDone ? "is" : "is not"} the first tracker SDK launch`);
|
|
420
|
+
Log.diagDebug(`The kochava device id is ${__classPrivateFieldGet(this, _Kochava_instance, "f").kochavaDeviceId}`);
|
|
421
|
+
Log.diagDebug(`The kochava app GUID provided was ${appGuid}`);
|
|
422
|
+
}, _Kochava_beginStart = async function _Kochava_beginStart() {
|
|
423
|
+
// if we need to send a new kvinit, send it
|
|
424
|
+
if (!__classPrivateFieldGet(this, _Kochava_instance, "f").kvinitDone) {
|
|
425
|
+
Log.diagDebug(`A new kvinit will be sent`);
|
|
426
|
+
await __classPrivateFieldGet(this, _Kochava_instances, "m", _Kochava_performNewKvinit).call(this);
|
|
404
427
|
}
|
|
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}`);
|
|
428
|
+
else {
|
|
429
|
+
Log.diagDebug(`A new kvinit will not be sent`);
|
|
412
430
|
}
|
|
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
|
-
}
|
|
431
|
+
// if the install_id changed and thus a new install must go out
|
|
432
|
+
if (__classPrivateFieldGet(this, _Kochava_instances, "m", _Kochava_checkResendId).call(this))
|
|
433
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").installDone = false;
|
|
434
|
+
Log.diagDebug(`The install ${__classPrivateFieldGet(this, _Kochava_instance, "f").installDone ? "has already" : "has not yet"} been sent`);
|
|
435
|
+
if (__classPrivateFieldGet(this, _Kochava_instance, "f").sleep)
|
|
436
|
+
return;
|
|
437
|
+
if (!__classPrivateFieldGet(this, _Kochava_instance, "f").installDone) {
|
|
438
|
+
await __classPrivateFieldGet(this, _Kochava_instances, "m", _Kochava_performInstall).call(this);
|
|
434
439
|
}
|
|
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)));
|
|
440
|
+
if (__classPrivateFieldGet(this, _Kochava_instance, "f").kvinitDone && __classPrivateFieldGet(this, _Kochava_instance, "f").installDone) {
|
|
441
|
+
await __classPrivateFieldGet(this, _Kochava_jobQueue, "f").start(__classPrivateFieldGet(this, _Kochava_instance, "f"));
|
|
446
442
|
}
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
}
|
|
456
|
-
return needsNewInstall;
|
|
443
|
+
}, _Kochava_performNewKvinit = async function _Kochava_performNewKvinit() {
|
|
444
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").kvinitDone = await Kvinit.send(__classPrivateFieldGet(this, _Kochava_instance, "f"), __classPrivateFieldGet(this, _Kochava_instance, "f").retryWaterfall);
|
|
445
|
+
updatePersistedValue(PersistKey.KvinitSentDate, String(utils.getCurrTimeSec()), __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies);
|
|
446
|
+
// if new kvinit, apply it
|
|
447
|
+
let newKvinit = {};
|
|
448
|
+
const newKvinitStr = readAndUpdatePersistedValue(PersistKey.LastKvinit, __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies);
|
|
449
|
+
if (newKvinitStr) {
|
|
450
|
+
newKvinit = JSON.parse(newKvinitStr);
|
|
457
451
|
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
Install.onSuccess(this.instance);
|
|
465
|
-
updatePersistedValue(PersistKey.IdLinkQueue, JSON.stringify(this.jobQueue.idLinkQueue), false);
|
|
452
|
+
Kvinit.applyKvinitResp(__classPrivateFieldGet(this, _Kochava_instance, "f"), newKvinit);
|
|
453
|
+
Log.trace("KochavaConfig after new Kvinit:", JSON.parse(JSON.stringify(__classPrivateFieldGet(this, _Kochava_instance, "f").kochavaConfig)));
|
|
454
|
+
}, _Kochava_checkResendId = function _Kochava_checkResendId() {
|
|
455
|
+
let resendId = "";
|
|
456
|
+
if (__classPrivateFieldGet(this, _Kochava_instance, "f").kochavaConfig.install) {
|
|
457
|
+
resendId = __classPrivateFieldGet(this, _Kochava_instance, "f").kochavaConfig.install.resend_id;
|
|
466
458
|
}
|
|
467
|
-
|
|
459
|
+
const needsNewInstall = checkInstallIdChange(resendId, __classPrivateFieldGet(this, _Kochava_instance, "f").useCookies);
|
|
460
|
+
if (needsNewInstall) {
|
|
461
|
+
Log.debug(`resend_id ${resendId} found, forcing new install`);
|
|
462
|
+
}
|
|
463
|
+
return needsNewInstall;
|
|
464
|
+
}, _Kochava_performInstall = async function _Kochava_performInstall() {
|
|
465
|
+
const request = Install.build(__classPrivateFieldGet(this, _Kochava_instance, "f"));
|
|
466
|
+
__classPrivateFieldGet(this, _Kochava_instance, "f").installDone = await Install.send(__classPrivateFieldGet(this, _Kochava_instance, "f"), request);
|
|
467
|
+
if (!__classPrivateFieldGet(this, _Kochava_instance, "f").installDone)
|
|
468
|
+
return;
|
|
469
|
+
// If the install succeeded, remove all idLink that were passed to it
|
|
470
|
+
Install.onSuccess(__classPrivateFieldGet(this, _Kochava_instance, "f"));
|
|
471
|
+
updatePersistedValue(PersistKey.IdLinkQueue, JSON.stringify(__classPrivateFieldGet(this, _Kochava_jobQueue, "f").idLinkQueue), false);
|
|
472
|
+
};
|
|
468
473
|
// window.kochava = new Kochava();
|