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 CHANGED
@@ -28,14 +28,13 @@ export interface KochavaInstance {
28
28
  kochavaConfig?: KvConfig;
29
29
  }
30
30
  export declare class Kochava {
31
- private instance;
32
- private jobQueue;
33
- private constructor();
31
+ #private;
32
+ constructor();
34
33
  static create(): Kochava;
35
- static createWithNode(): Kochava;
36
- static createWithReact(): Kochava;
37
- static createWithVue(): Kochava;
38
- static createWithAngular(): Kochava;
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
- // ============================= PUBLIC =============================== //
26
+ // User will use the below factories instead of directly calling
27
+ // the constructor
15
28
  constructor() {
16
- this.resetInstance();
17
- this.jobQueue = new JobQueue();
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 createWithNode() {
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 createWithReact() {
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 createWithVue() {
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 createWithAngular() {
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.instance.useCookies = condition;
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.instance.disableAutoPage = condition;
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.instance)
79
- this.resetInstance();
80
- if (this.instance.started) {
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.instance.started = true;
86
- this.checkFirstLaunchAndMigrate();
87
- this.initInstance(appGuid);
88
- if (!this.instance.disableAutoPage)
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.checkPersistedState();
91
- this.checkPersistedKvinit();
92
- this.printStartupMsgs(appGuid);
93
- this.beginStart();
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.instance.started) {
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.jobQueue.stop();
129
+ __classPrivateFieldGet(this, _Kochava_jobQueue, "f").stop();
113
130
  // wipe whatever was previously in the queue
114
- this.jobQueue = new JobQueue();
115
- this.resetInstance();
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.instance.version)
145
- this.instance.version = "WebTracker 3.0.0";
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.instance.version += ` (${wrapperVersion.name} ${wrapperVersion.version})`;
165
+ __classPrivateFieldGet(this, _Kochava_instance, "f").version += ` (${wrapperVersion.name} ${wrapperVersion.version})`;
149
166
  break;
150
167
  default:
151
- this.instance.version += ` (${wrapperVersion.name})`;
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.instance.overrideUrls.init = overrideUrls.init;
177
+ __classPrivateFieldGet(this, _Kochava_instance, "f").overrideUrls.init = overrideUrls.init;
161
178
  if (overrideUrls.event)
162
- this.instance.overrideUrls.event = overrideUrls.event;
179
+ __classPrivateFieldGet(this, _Kochava_instance, "f").overrideUrls.event = overrideUrls.event;
163
180
  if (overrideUrls.install)
164
- this.instance.overrideUrls.install = overrideUrls.install;
181
+ __classPrivateFieldGet(this, _Kochava_instance, "f").overrideUrls.install = overrideUrls.install;
165
182
  if (overrideUrls.identityLink)
166
- this.instance.overrideUrls.identityLink = overrideUrls.identityLink;
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.instance.overrideUrls.init = DEFAULTS.networking.urls.init;
191
+ __classPrivateFieldGet(this, _Kochava_instance, "f").overrideUrls.init = DEFAULTS.networking.urls.init;
175
192
  if (url === "event")
176
- this.instance.overrideUrls.event = DEFAULTS.networking.urls.event;
193
+ __classPrivateFieldGet(this, _Kochava_instance, "f").overrideUrls.event = DEFAULTS.networking.urls.event;
177
194
  if (url === "install")
178
- this.instance.overrideUrls.install =
195
+ __classPrivateFieldGet(this, _Kochava_instance, "f").overrideUrls.install =
179
196
  DEFAULTS.networking.urls.install;
180
197
  if (url === "identityLink")
181
- this.instance.overrideUrls.identityLink =
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.instance);
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.jobQueue.enqueueEvent(this.instance, [name, data]);
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.instance.useCookies);
247
- if (this.instance.installStarted || this.instance.installDone) {
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.jobQueue.enqueueIdLink(this.instance, idLink);
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.instance.customValues.push({ data: dataToAdorn, isDeviceId: false });
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.instance.customValues.push({ data: dataToAdorn, isDeviceId: true });
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.instance.started;
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.instance.started)
290
- return this.instance.kochavaDeviceId;
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.instance.sleep) {
318
+ if (sleep && !__classPrivateFieldGet(this, _Kochava_instance, "f").sleep) {
302
319
  // only pause if it was running
303
- this.instance.sleep = sleep;
304
- this.jobQueue.pause();
320
+ __classPrivateFieldGet(this, _Kochava_instance, "f").sleep = sleep;
321
+ __classPrivateFieldGet(this, _Kochava_jobQueue, "f").pause();
305
322
  }
306
- else if (!sleep && this.instance.sleep) {
323
+ else if (!sleep && __classPrivateFieldGet(this, _Kochava_instance, "f").sleep) {
307
324
  // only resume queueing if it was paused
308
- this.instance.sleep = sleep;
309
- this.beginStart();
325
+ __classPrivateFieldGet(this, _Kochava_instance, "f").sleep = sleep;
326
+ __classPrivateFieldGet(this, _Kochava_instances, "m", _Kochava_beginStart).call(this);
310
327
  }
311
328
  }
312
- // ============================= PRIVATE =============================== //
313
- // Unintialized/invalid state.
314
- // start must be called before these values will be correct.
315
- resetInstance() {
316
- this.instance = {
317
- appGuid: "",
318
- started: false,
319
- installStarted: false,
320
- kvinitDone: false,
321
- installDone: false,
322
- disableAutoPage: false,
323
- useCookies: false,
324
- sleep: false,
325
- version: "",
326
- buildDate: "",
327
- overrideUrls: {
328
- init: "",
329
- install: "",
330
- event: "",
331
- identityLink: "",
332
- },
333
- customValues: [],
334
- kochavaSession: "",
335
- retryWaterfall: [],
336
- startTimeMS: 0,
337
- utm: "",
338
- kochavaDeviceId: "",
339
- kochavaInstallId: "",
340
- kochavaSessionCount: -1,
341
- kochavaInstallDate: -1,
342
- kochavaConfig: undefined,
343
- };
344
- }
345
- initInstance(appGuid) {
346
- // init instance with defaults
347
- this.instance.appGuid = appGuid;
348
- this.instance.disableAutoPage = this.instance.disableAutoPage || false;
349
- this.instance.useCookies = this.instance.useCookies || false;
350
- this.instance.version = this.instance.version || "WebTracker 3.0.0";
351
- this.instance.buildDate = "kbd: 3/31/2022, 10:12:19 AM";
352
- this.instance.kochavaSession = utils.uuidv4().substring(0, 5);
353
- this.instance.startTimeMS = utils.getCurrTimeMS();
354
- this.instance.retryWaterfall = [7, 30, 300, 1800];
355
- this.instance.kochavaConfig = JSON.parse(JSON.stringify(DEFAULTS));
356
- }
357
- checkFirstLaunchAndMigrate() {
358
- // If this is our first launch ever, set it in persistence.
359
- if (!readAndUpdatePersistedValue(PersistKey.FirstStartDate, this.instance.useCookies)) {
360
- updatePersistedValue(PersistKey.FirstStartDate, String(utils.getCurrTimeSec()), this.instance.useCookies);
361
- /*
362
- On a first launch of the v3 sdk, we need to migrate old persisted kv_id
363
- from v2.2, v2.3, and v2.5
364
- */
365
- // perform migration
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
- checkPersistedKvinit() {
374
- // check if persisted kvinit
375
- let persistedKvinit = {};
376
- const persistedKvinitStr = readAndUpdatePersistedValue(PersistKey.LastKvinit, this.instance.useCookies);
377
- if (persistedKvinitStr) {
378
- persistedKvinit = JSON.parse(persistedKvinitStr);
379
- if (persistedKvinit) {
380
- // if persisted kvinit, apply it
381
- Log.trace("Found persisted kvinit.", persistedKvinit);
382
- Kvinit.applyKvinitResp(this.instance, persistedKvinit);
383
- Log.trace("KochavaConfig after persistedKvinit:", JSON.parse(JSON.stringify(this.instance.kochavaConfig)));
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
- // check refresh minimum too
387
- const persistedKvinitDateStr = readAndUpdatePersistedValue(PersistKey.KvinitSentDate, this.instance.useCookies);
388
- if (persistedKvinitDateStr) {
389
- const lastKvinitDate = JSON.parse(persistedKvinitDateStr);
390
- if (lastKvinitDate) {
391
- const refreshMin = this.instance.kochavaConfig.config.refresh_minimum;
392
- if (utils.getCurrTimeSec() - lastKvinitDate < refreshMin)
393
- this.instance.kvinitDone = true;
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
- checkPersistedState() {
398
- this.instance.installDone =
399
- readAndUpdatePersistedValue(PersistKey.InstallSentDate, this.instance.useCookies).length > 0;
400
- this.instance.kochavaInstallId = readAndUpdatePersistedValue(PersistKey.InstallId, this.instance.useCookies);
401
- this.instance.kochavaDeviceId = readAndUpdateDeviceId(this.instance.useCookies);
402
- this.instance.kochavaSessionCount = readAndUpdateSessionCount(this.instance.useCookies);
403
- this.instance.utm = readAndUpdateUTM(this.instance.appGuid, this.instance.useCookies);
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
- printStartupMsgs(appGuid) {
406
- Log.diagInfo(`Started SDK ${this.instance.version}
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
- async beginStart() {
414
- // if we need to send a new kvinit, send it
415
- if (!this.instance.kvinitDone) {
416
- Log.diagDebug(`A new kvinit will be sent`);
417
- await this.performNewKvinit();
418
- }
419
- else {
420
- Log.diagDebug(`A new kvinit will not be sent`);
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
- async performNewKvinit() {
436
- this.instance.kvinitDone = await Kvinit.send(this.instance, this.instance.retryWaterfall);
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
- checkResendId() {
448
- let resendId = "";
449
- if (this.instance.kochavaConfig.install) {
450
- resendId = this.instance.kochavaConfig.install.resend_id;
451
- }
452
- const needsNewInstall = checkInstallIdChange(resendId, this.instance.useCookies);
453
- if (needsNewInstall) {
454
- Log.debug(`resend_id ${resendId} found, forcing new install`);
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
- async performInstall() {
459
- const request = Install.build(this.instance);
460
- this.instance.installDone = await Install.send(this.instance, request);
461
- if (!this.instance.installDone)
462
- return;
463
- // If the install succeeded, remove all idLink that were passed to it
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();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "kv-test-lib",
4
- "version": "1.0.22",
4
+ "version": "1.0.23",
5
5
  "main": "dist/kochava.js",
6
6
  "files": [
7
7
  "dist/"