kv-test-lib 3.5.2-rc.1 → 3.5.2-rc.3
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/es5_dist/adapters/browser.js +13 -7
- package/es5_dist/adapters/browser.js.map +1 -1
- package/es5_dist/browser/browser.js +0 -4
- package/es5_dist/browser/browser.js.map +1 -1
- package/es5_dist/browser/cookies.js +0 -4
- package/es5_dist/browser/cookies.js.map +1 -1
- package/es5_dist/browser/persist.js +88 -112
- package/es5_dist/browser/persist.js.map +1 -1
- package/es5_dist/generated/buildInfo.js +1 -1
- package/es5_dist/generated/buildInfo.js.map +1 -1
- package/es5_dist/http.js +5 -9
- package/es5_dist/http.js.map +1 -1
- package/es5_dist/interfaces.js +0 -7
- package/es5_dist/interfaces.js.map +1 -1
- package/es5_dist/jobqueue.js +106 -93
- package/es5_dist/jobqueue.js.map +1 -1
- package/es5_dist/kochava.js +386 -289
- package/es5_dist/kochava.js.map +1 -1
- package/es5_dist/measurementEvent.js +1 -3
- package/es5_dist/measurementEvent.js.map +1 -1
- package/es5_dist/payloads/event.js +3 -7
- package/es5_dist/payloads/event.js.map +1 -1
- package/es5_dist/payloads/identityLink.js +3 -7
- package/es5_dist/payloads/identityLink.js.map +1 -1
- package/es5_dist/payloads/install.js +54 -34
- package/es5_dist/payloads/install.js.map +1 -1
- package/es5_dist/payloads/kvinit.js +41 -30
- package/es5_dist/payloads/kvinit.js.map +1 -1
- package/es5_dist/payloads/payload.js +0 -9
- package/es5_dist/payloads/payload.js.map +1 -1
- package/es5_dist/payloads/update.js +3 -7
- package/es5_dist/payloads/update.js.map +1 -1
- package/es5_dist/product.js +1 -16
- package/es5_dist/product.js.map +1 -1
- package/es5_dist/utils/log.js +1 -5
- package/es5_dist/utils/log.js.map +1 -1
- package/es5_dist/utils/utils.js +0 -7
- package/es5_dist/utils/utils.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Authored by Brett Barinaga on 11/17/21.
|
|
3
|
-
Copyright (c) Kochava, Inc. All rights reserved.
|
|
4
|
-
*/
|
|
5
1
|
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
6
2
|
function adopt(value) {
|
|
7
3
|
return value instanceof P ? value : new P(function (resolve) {
|
|
@@ -84,7 +80,6 @@ var __generator = this && this.__generator || function (thisArg, body) {
|
|
|
84
80
|
if (op[0] & 5) throw op[1];return { value: op[0] ? op[1] : void 0, done: true };
|
|
85
81
|
}
|
|
86
82
|
};
|
|
87
|
-
import * as utils from "../utils/utils";
|
|
88
83
|
import { getUrlParameter } from "./browser";
|
|
89
84
|
import { setCookie, getCookie, deleteCookie } from "./cookies";
|
|
90
85
|
import { Log } from "../utils/log";
|
|
@@ -114,28 +109,32 @@ var storage;
|
|
|
114
109
|
export var configureStorage = function (adapter) {
|
|
115
110
|
storage = adapter;
|
|
116
111
|
};
|
|
112
|
+
export var hasSyncStorage = function () {
|
|
113
|
+
return typeof (storage === null || storage === void 0 ? void 0 : storage.getItemSync) === "function";
|
|
114
|
+
};
|
|
115
|
+
export var getItemSync = function (key) {
|
|
116
|
+
return (storage === null || storage === void 0 ? void 0 : storage.getItemSync) ? storage.getItemSync(key) : null;
|
|
117
|
+
};
|
|
118
|
+
export var setItemSync = function (key, value) {
|
|
119
|
+
if (storage === null || storage === void 0 ? void 0 : storage.setItemSync) storage.setItemSync(key, value);
|
|
120
|
+
};
|
|
117
121
|
export var checkInstallIdChange = function (inputId, useCookies) {
|
|
118
122
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
119
123
|
var persistedInstallId;
|
|
120
124
|
return __generator(this, function (_a) {
|
|
121
125
|
switch (_a.label) {
|
|
122
126
|
case 0:
|
|
123
|
-
return [4
|
|
127
|
+
return [4, readAndUpdatePersistedValue(PersistKey.InstallId, useCookies)];
|
|
124
128
|
case 1:
|
|
125
129
|
persistedInstallId = _a.sent();
|
|
126
|
-
|
|
127
|
-
if (!inputId) return [2 /*return*/, false];
|
|
128
|
-
// if the persistedId is empty, we will need to change
|
|
130
|
+
if (!inputId) return [2, false];
|
|
129
131
|
if (!persistedInstallId) {
|
|
130
132
|
updatePersistedValue(PersistKey.InstallId, inputId, useCookies);
|
|
131
|
-
return [2
|
|
133
|
+
return [2, true];
|
|
132
134
|
}
|
|
133
|
-
|
|
134
|
-
if (inputId === persistedInstallId) return [2 /*return*/, false];
|
|
135
|
-
// at this point both inputId and persistedInstallId exist and are not equal,
|
|
136
|
-
// so we must need to change
|
|
135
|
+
if (inputId === persistedInstallId) return [2, false];
|
|
137
136
|
updatePersistedValue(PersistKey.InstallId, inputId, useCookies);
|
|
138
|
-
return [2
|
|
137
|
+
return [2, true];
|
|
139
138
|
}
|
|
140
139
|
});
|
|
141
140
|
});
|
|
@@ -146,16 +145,16 @@ export var addToPersistedEventQueue = function (job) {
|
|
|
146
145
|
return __generator(this, function (_a) {
|
|
147
146
|
switch (_a.label) {
|
|
148
147
|
case 0:
|
|
149
|
-
return [4
|
|
148
|
+
return [4, storage.getItem(PersistKey.EventQueue)];
|
|
150
149
|
case 1:
|
|
151
150
|
persistedQueueStr = _a.sent();
|
|
152
151
|
if (persistedQueueStr === null || persistedQueueStr === undefined || persistedQueueStr === '{}') persistedQueueStr = '[]';
|
|
153
152
|
persistedQueue = JSON.parse(persistedQueueStr) || [];
|
|
154
153
|
persistedQueue.push(job);
|
|
155
|
-
return [4
|
|
154
|
+
return [4, storage.setItem(PersistKey.EventQueue, JSON.stringify(persistedQueue))];
|
|
156
155
|
case 2:
|
|
157
156
|
_a.sent();
|
|
158
|
-
return [2
|
|
157
|
+
return [2];
|
|
159
158
|
}
|
|
160
159
|
});
|
|
161
160
|
});
|
|
@@ -166,17 +165,17 @@ export var removeFromEventPersistedQueue = function (job) {
|
|
|
166
165
|
return __generator(this, function (_a) {
|
|
167
166
|
switch (_a.label) {
|
|
168
167
|
case 0:
|
|
169
|
-
return [4
|
|
168
|
+
return [4, storage.getItem(PersistKey.EventQueue)];
|
|
170
169
|
case 1:
|
|
171
170
|
persistedQueueStr = _a.sent();
|
|
172
171
|
persistedQueue = JSON.parse(persistedQueueStr) || [];
|
|
173
172
|
queueWithJobRemoved = persistedQueue.filter(function (persistedJob) {
|
|
174
173
|
return persistedJob.id !== job.id;
|
|
175
174
|
});
|
|
176
|
-
return [4
|
|
175
|
+
return [4, storage.setItem(PersistKey.EventQueue, JSON.stringify(queueWithJobRemoved))];
|
|
177
176
|
case 2:
|
|
178
177
|
_a.sent();
|
|
179
|
-
return [2
|
|
178
|
+
return [2];
|
|
180
179
|
}
|
|
181
180
|
});
|
|
182
181
|
});
|
|
@@ -188,7 +187,7 @@ export var updateOrAddPersistedIdLinkQueue = function (job) {
|
|
|
188
187
|
switch (_a.label) {
|
|
189
188
|
case 0:
|
|
190
189
|
idLinkKey = Object.keys(job.idLink)[0];
|
|
191
|
-
return [4
|
|
190
|
+
return [4, storage.getItem(PersistKey.IdLinkQueue)];
|
|
192
191
|
case 1:
|
|
193
192
|
persistedQueueStr = _a.sent();
|
|
194
193
|
persistedQueue = JSON.parse(persistedQueueStr) || [];
|
|
@@ -196,20 +195,18 @@ export var updateOrAddPersistedIdLinkQueue = function (job) {
|
|
|
196
195
|
for (_i = 0, persistedQueue_1 = persistedQueue; _i < persistedQueue_1.length; _i++) {
|
|
197
196
|
persistedJob = persistedQueue_1[_i];
|
|
198
197
|
persistedKey = Object.keys(persistedJob.idLink)[0];
|
|
199
|
-
// if the key is already there, update it
|
|
200
198
|
if (idLinkKey === persistedKey) {
|
|
201
199
|
persistedJob.idLink[idLinkKey] = job.idLink[idLinkKey];
|
|
202
200
|
updated = true;
|
|
203
201
|
}
|
|
204
202
|
}
|
|
205
|
-
// if the key is new, add it
|
|
206
203
|
if (!updated) {
|
|
207
204
|
persistedQueue.push(job);
|
|
208
205
|
}
|
|
209
|
-
return [4
|
|
206
|
+
return [4, storage.setItem(PersistKey.IdLinkQueue, JSON.stringify(persistedQueue))];
|
|
210
207
|
case 2:
|
|
211
208
|
_a.sent();
|
|
212
|
-
return [2
|
|
209
|
+
return [2];
|
|
213
210
|
}
|
|
214
211
|
});
|
|
215
212
|
});
|
|
@@ -220,17 +217,17 @@ export var removeFromIdLinkPersistedQueue = function (job) {
|
|
|
220
217
|
return __generator(this, function (_a) {
|
|
221
218
|
switch (_a.label) {
|
|
222
219
|
case 0:
|
|
223
|
-
return [4
|
|
220
|
+
return [4, storage.getItem(PersistKey.IdLinkQueue)];
|
|
224
221
|
case 1:
|
|
225
222
|
persistedQueueStr = _a.sent();
|
|
226
223
|
persistedQueue = JSON.parse(persistedQueueStr) || [];
|
|
227
224
|
queueWithJobRemoved = persistedQueue.filter(function (persistedJob) {
|
|
228
225
|
return persistedJob.id !== job.id;
|
|
229
226
|
});
|
|
230
|
-
return [4
|
|
227
|
+
return [4, storage.setItem(PersistKey.IdLinkQueue, JSON.stringify(queueWithJobRemoved))];
|
|
231
228
|
case 2:
|
|
232
229
|
_a.sent();
|
|
233
|
-
return [2
|
|
230
|
+
return [2];
|
|
234
231
|
}
|
|
235
232
|
});
|
|
236
233
|
});
|
|
@@ -241,7 +238,7 @@ export var addPersistedIdLinks = function (key, value, useCookies) {
|
|
|
241
238
|
return __generator(this, function (_a) {
|
|
242
239
|
switch (_a.label) {
|
|
243
240
|
case 0:
|
|
244
|
-
return [4
|
|
241
|
+
return [4, storage.getItem(PersistKey.IdentityLinks)];
|
|
245
242
|
case 1:
|
|
246
243
|
persistedIdLinksStr = _a.sent();
|
|
247
244
|
persistedIdLinks = JSON.parse(persistedIdLinksStr) || {};
|
|
@@ -253,7 +250,7 @@ export var addPersistedIdLinks = function (key, value, useCookies) {
|
|
|
253
250
|
}
|
|
254
251
|
persistedIdLinks[key] = value;
|
|
255
252
|
updatePersistedValue(PersistKey.IdentityLinks, JSON.stringify(persistedIdLinks), useCookies);
|
|
256
|
-
return [2
|
|
253
|
+
return [2];
|
|
257
254
|
}
|
|
258
255
|
});
|
|
259
256
|
});
|
|
@@ -264,18 +261,18 @@ export var checkDuplicateIdLink = function (key, value) {
|
|
|
264
261
|
return __generator(this, function (_a) {
|
|
265
262
|
switch (_a.label) {
|
|
266
263
|
case 0:
|
|
267
|
-
return [4
|
|
264
|
+
return [4, storage.getItem(PersistKey.IdentityLinks)];
|
|
268
265
|
case 1:
|
|
269
266
|
persistedIdLinksStr = _a.sent();
|
|
270
267
|
if (persistedIdLinksStr) {
|
|
271
268
|
persistedIdLinks = JSON.parse(persistedIdLinksStr) || {};
|
|
272
269
|
for (persistedKey in persistedIdLinks) {
|
|
273
270
|
if (key === persistedKey && persistedIdLinks[persistedKey] === value) {
|
|
274
|
-
return [2
|
|
271
|
+
return [2, true];
|
|
275
272
|
}
|
|
276
273
|
}
|
|
277
274
|
}
|
|
278
|
-
return [2
|
|
275
|
+
return [2, false];
|
|
279
276
|
}
|
|
280
277
|
});
|
|
281
278
|
});
|
|
@@ -286,13 +283,13 @@ export var getPersistedIdentityLinks = function () {
|
|
|
286
283
|
return __generator(this, function (_a) {
|
|
287
284
|
switch (_a.label) {
|
|
288
285
|
case 0:
|
|
289
|
-
return [4
|
|
286
|
+
return [4, storage.getItem(PersistKey.IdentityLinks)];
|
|
290
287
|
case 1:
|
|
291
288
|
persistedIdLinksStr = _a.sent();
|
|
292
289
|
if (persistedIdLinksStr) {
|
|
293
|
-
return [2
|
|
290
|
+
return [2, JSON.parse(persistedIdLinksStr)];
|
|
294
291
|
}
|
|
295
|
-
return [2
|
|
292
|
+
return [2, undefined];
|
|
296
293
|
}
|
|
297
294
|
});
|
|
298
295
|
});
|
|
@@ -305,24 +302,24 @@ export var readAndUpdateUTM = function (appGuid, useCookies) {
|
|
|
305
302
|
case 0:
|
|
306
303
|
storageName = appGuid + "_click";
|
|
307
304
|
urlValue = getUrlParameter("ko_click_id");
|
|
308
|
-
return [4
|
|
305
|
+
return [4, storage.getItem(storageName)];
|
|
309
306
|
case 1:
|
|
310
307
|
storageValue = _a.sent();
|
|
311
308
|
cookieValue = "";
|
|
312
309
|
if (useCookies) cookieValue = getCookie(storageName);
|
|
313
|
-
if (!urlValue) return [3
|
|
314
|
-
return [4
|
|
310
|
+
if (!urlValue) return [3, 3];
|
|
311
|
+
return [4, storage.setItem(storageName, urlValue)];
|
|
315
312
|
case 2:
|
|
316
313
|
_a.sent();
|
|
317
314
|
if (useCookies) setCookie(storageName, urlValue);
|
|
318
|
-
return [3
|
|
315
|
+
return [3, 4];
|
|
319
316
|
case 3:
|
|
320
317
|
if (storageValue) {
|
|
321
318
|
if (useCookies) setCookie(storageName, urlValue);
|
|
322
319
|
}
|
|
323
320
|
_a.label = 4;
|
|
324
321
|
case 4:
|
|
325
|
-
return [2
|
|
322
|
+
return [2, urlValue ? urlValue : storageValue ? storageValue : cookieValue ? cookieValue : ""];
|
|
326
323
|
}
|
|
327
324
|
});
|
|
328
325
|
});
|
|
@@ -334,30 +331,30 @@ export var readAndUpdatePersistedValue = function (key, useCookie) {
|
|
|
334
331
|
switch (_a.label) {
|
|
335
332
|
case 0:
|
|
336
333
|
urlValue = getUrlParameter(key);
|
|
337
|
-
return [4
|
|
334
|
+
return [4, storage.getItem(key)];
|
|
338
335
|
case 1:
|
|
339
336
|
storageValue = _a.sent();
|
|
340
337
|
cookieValue = "";
|
|
341
338
|
if (useCookie) cookieValue = getCookie(key);
|
|
342
|
-
if (!urlValue) return [3
|
|
343
|
-
return [4
|
|
339
|
+
if (!urlValue) return [3, 3];
|
|
340
|
+
return [4, updatePersistedValue(key, urlValue, useCookie)];
|
|
344
341
|
case 2:
|
|
345
342
|
_a.sent();
|
|
346
|
-
return [3
|
|
343
|
+
return [3, 7];
|
|
347
344
|
case 3:
|
|
348
|
-
if (!storageValue) return [3
|
|
349
|
-
return [4
|
|
345
|
+
if (!storageValue) return [3, 5];
|
|
346
|
+
return [4, updatePersistedValue(key, storageValue, useCookie)];
|
|
350
347
|
case 4:
|
|
351
348
|
_a.sent();
|
|
352
|
-
return [3
|
|
349
|
+
return [3, 7];
|
|
353
350
|
case 5:
|
|
354
|
-
if (!cookieValue) return [3
|
|
355
|
-
return [4
|
|
351
|
+
if (!cookieValue) return [3, 7];
|
|
352
|
+
return [4, updatePersistedValue(key, storageValue, useCookie)];
|
|
356
353
|
case 6:
|
|
357
354
|
_a.sent();
|
|
358
355
|
_a.label = 7;
|
|
359
356
|
case 7:
|
|
360
|
-
return [2
|
|
357
|
+
return [2, urlValue ? urlValue : storageValue ? storageValue : cookieValue ? cookieValue : ""];
|
|
361
358
|
}
|
|
362
359
|
});
|
|
363
360
|
});
|
|
@@ -367,11 +364,11 @@ export var updatePersistedValue = function (key, value, useCookie) {
|
|
|
367
364
|
return __generator(this, function (_a) {
|
|
368
365
|
switch (_a.label) {
|
|
369
366
|
case 0:
|
|
370
|
-
return [4
|
|
367
|
+
return [4, storage.setItem(key, value)];
|
|
371
368
|
case 1:
|
|
372
369
|
_a.sent();
|
|
373
370
|
if (useCookie) setCookie(key, value);
|
|
374
|
-
return [2
|
|
371
|
+
return [2];
|
|
375
372
|
}
|
|
376
373
|
});
|
|
377
374
|
});
|
|
@@ -381,11 +378,11 @@ export var deletePersistedValue = function (item) {
|
|
|
381
378
|
return __generator(this, function (_a) {
|
|
382
379
|
switch (_a.label) {
|
|
383
380
|
case 0:
|
|
384
|
-
return [4
|
|
381
|
+
return [4, storage.removeItem(item)];
|
|
385
382
|
case 1:
|
|
386
383
|
_a.sent();
|
|
387
384
|
deleteCookie(item);
|
|
388
|
-
return [2
|
|
385
|
+
return [2];
|
|
389
386
|
}
|
|
390
387
|
});
|
|
391
388
|
});
|
|
@@ -395,33 +392,12 @@ export var deleteAllPersisted = function () {
|
|
|
395
392
|
return __generator(this, function (_a) {
|
|
396
393
|
switch (_a.label) {
|
|
397
394
|
case 0:
|
|
398
|
-
return [4
|
|
395
|
+
return [4, Promise.all(storedKeys.map(function (item) {
|
|
399
396
|
return deletePersistedValue(item);
|
|
400
397
|
}))];
|
|
401
398
|
case 1:
|
|
402
399
|
_a.sent();
|
|
403
|
-
return [2
|
|
404
|
-
}
|
|
405
|
-
});
|
|
406
|
-
});
|
|
407
|
-
};
|
|
408
|
-
export var readAndUpdateDeviceId = function (useCookie) {
|
|
409
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
410
|
-
var storedDeviceId, kvId;
|
|
411
|
-
return __generator(this, function (_a) {
|
|
412
|
-
switch (_a.label) {
|
|
413
|
-
case 0:
|
|
414
|
-
return [4 /*yield*/, readAndUpdatePersistedValue(PersistKey.DeviceId, useCookie)];
|
|
415
|
-
case 1:
|
|
416
|
-
storedDeviceId = _a.sent();
|
|
417
|
-
if (!storedDeviceId) {
|
|
418
|
-
kvId = "KB".concat(utils.getCurrTimeSec(), "T").concat(utils.uuidv4());
|
|
419
|
-
storedDeviceId = kvId.replace(/-/g, "");
|
|
420
|
-
}
|
|
421
|
-
return [4 /*yield*/, updatePersistedValue(PersistKey.DeviceId, storedDeviceId, useCookie)];
|
|
422
|
-
case 2:
|
|
423
|
-
_a.sent();
|
|
424
|
-
return [2 /*return*/, storedDeviceId];
|
|
400
|
+
return [2];
|
|
425
401
|
}
|
|
426
402
|
});
|
|
427
403
|
});
|
|
@@ -432,7 +408,7 @@ export var readAndUpdateSessionCount = function (useCookie) {
|
|
|
432
408
|
return __generator(this, function (_a) {
|
|
433
409
|
switch (_a.label) {
|
|
434
410
|
case 0:
|
|
435
|
-
return [4
|
|
411
|
+
return [4, readAndUpdatePersistedValue(PersistKey.SessionCount, useCookie)];
|
|
436
412
|
case 1:
|
|
437
413
|
storedSessionCount = _a.sent();
|
|
438
414
|
sessionCount = 1;
|
|
@@ -440,10 +416,10 @@ export var readAndUpdateSessionCount = function (useCookie) {
|
|
|
440
416
|
sessionCount = parseInt(storedSessionCount);
|
|
441
417
|
sessionCount++;
|
|
442
418
|
}
|
|
443
|
-
return [4
|
|
419
|
+
return [4, updatePersistedValue(PersistKey.SessionCount, sessionCount.toString(), useCookie)];
|
|
444
420
|
case 2:
|
|
445
421
|
_a.sent();
|
|
446
|
-
return [2
|
|
422
|
+
return [2, sessionCount];
|
|
447
423
|
}
|
|
448
424
|
});
|
|
449
425
|
});
|
|
@@ -455,11 +431,11 @@ export var updateLastInstall = function (lastInstallObject, useCookie) {
|
|
|
455
431
|
switch (_a.label) {
|
|
456
432
|
case 0:
|
|
457
433
|
lastInstallStr = JSON.stringify(lastInstallObject);
|
|
458
|
-
return [4
|
|
434
|
+
return [4, storage.setItem(PersistKey.LastInstall, lastInstallStr)];
|
|
459
435
|
case 1:
|
|
460
436
|
_a.sent();
|
|
461
437
|
if (useCookie) setCookie(PersistKey.LastInstall, lastInstallStr);
|
|
462
|
-
return [2
|
|
438
|
+
return [2];
|
|
463
439
|
}
|
|
464
440
|
});
|
|
465
441
|
});
|
|
@@ -470,18 +446,18 @@ export var getLastInstall = function (useCookie) {
|
|
|
470
446
|
return __generator(this, function (_a) {
|
|
471
447
|
switch (_a.label) {
|
|
472
448
|
case 0:
|
|
473
|
-
return [4
|
|
449
|
+
return [4, storage.getItem(PersistKey.LastInstall)];
|
|
474
450
|
case 1:
|
|
475
451
|
lastInstallStr = _a.sent();
|
|
476
452
|
if (lastInstallStr) {
|
|
477
|
-
return [2
|
|
453
|
+
return [2, JSON.parse(lastInstallStr)];
|
|
478
454
|
} else if (useCookie) {
|
|
479
455
|
cookieValue = getCookie(PersistKey.LastInstall);
|
|
480
456
|
if (cookieValue) {
|
|
481
|
-
return [2
|
|
457
|
+
return [2, JSON.parse(cookieValue)];
|
|
482
458
|
}
|
|
483
459
|
}
|
|
484
|
-
return [2
|
|
460
|
+
return [2, undefined];
|
|
485
461
|
}
|
|
486
462
|
});
|
|
487
463
|
});
|
|
@@ -491,13 +467,13 @@ export var updateInstallCount = function (installCount, useCookie) {
|
|
|
491
467
|
return __generator(this, function (_a) {
|
|
492
468
|
switch (_a.label) {
|
|
493
469
|
case 0:
|
|
494
|
-
return [4
|
|
470
|
+
return [4, storage.setItem(PersistKey.InstallCount, installCount.toString())];
|
|
495
471
|
case 1:
|
|
496
472
|
_a.sent();
|
|
497
473
|
if (useCookie) {
|
|
498
474
|
setCookie(PersistKey.InstallCount, installCount.toString());
|
|
499
475
|
}
|
|
500
|
-
return [2
|
|
476
|
+
return [2];
|
|
501
477
|
}
|
|
502
478
|
});
|
|
503
479
|
});
|
|
@@ -509,21 +485,21 @@ export var getItem = function (key) {
|
|
|
509
485
|
switch (_a.label) {
|
|
510
486
|
case 0:
|
|
511
487
|
_a.trys.push([0, 2,, 3]);
|
|
512
|
-
return [4
|
|
488
|
+
return [4, storage.getItem(key)];
|
|
513
489
|
case 1:
|
|
514
490
|
value = _a.sent();
|
|
515
491
|
if (value) {
|
|
516
|
-
return [2
|
|
492
|
+
return [2, value];
|
|
517
493
|
} else {
|
|
518
|
-
return [2
|
|
494
|
+
return [2, null];
|
|
519
495
|
}
|
|
520
|
-
return [3
|
|
496
|
+
return [3, 3];
|
|
521
497
|
case 2:
|
|
522
498
|
error_1 = _a.sent();
|
|
523
499
|
Log.error("Error getting item ".concat(key, " from localStorage:"), error_1);
|
|
524
|
-
return [2
|
|
500
|
+
return [2, null];
|
|
525
501
|
case 3:
|
|
526
|
-
return [2
|
|
502
|
+
return [2];
|
|
527
503
|
}
|
|
528
504
|
});
|
|
529
505
|
});
|
|
@@ -535,16 +511,16 @@ export var setItem = function (key, value) {
|
|
|
535
511
|
switch (_a.label) {
|
|
536
512
|
case 0:
|
|
537
513
|
_a.trys.push([0, 2,, 3]);
|
|
538
|
-
return [4
|
|
514
|
+
return [4, storage.setItem(key, value)];
|
|
539
515
|
case 1:
|
|
540
516
|
_a.sent();
|
|
541
|
-
return [3
|
|
517
|
+
return [3, 3];
|
|
542
518
|
case 2:
|
|
543
519
|
error_2 = _a.sent();
|
|
544
520
|
Log.error("Error setting item ".concat(key, " in localStorage:"), error_2);
|
|
545
|
-
return [3
|
|
521
|
+
return [3, 3];
|
|
546
522
|
case 3:
|
|
547
|
-
return [2
|
|
523
|
+
return [2];
|
|
548
524
|
}
|
|
549
525
|
});
|
|
550
526
|
});
|
|
@@ -555,16 +531,16 @@ export var getSentDeviceIds = function () {
|
|
|
555
531
|
return __generator(this, function (_a) {
|
|
556
532
|
switch (_a.label) {
|
|
557
533
|
case 0:
|
|
558
|
-
return [4
|
|
534
|
+
return [4, storage.getItem(PersistKey.SentDeviceIds)];
|
|
559
535
|
case 1:
|
|
560
536
|
raw = _a.sent();
|
|
561
|
-
if (!raw) return [2
|
|
537
|
+
if (!raw) return [2, {}];
|
|
562
538
|
try {
|
|
563
|
-
return [2
|
|
539
|
+
return [2, JSON.parse(raw)];
|
|
564
540
|
} catch (_b) {
|
|
565
|
-
return [2
|
|
541
|
+
return [2, {}];
|
|
566
542
|
}
|
|
567
|
-
return [2
|
|
543
|
+
return [2];
|
|
568
544
|
}
|
|
569
545
|
});
|
|
570
546
|
});
|
|
@@ -574,10 +550,10 @@ export var persistSentDeviceIds = function (ids) {
|
|
|
574
550
|
return __generator(this, function (_a) {
|
|
575
551
|
switch (_a.label) {
|
|
576
552
|
case 0:
|
|
577
|
-
return [4
|
|
553
|
+
return [4, storage.setItem(PersistKey.SentDeviceIds, JSON.stringify(ids))];
|
|
578
554
|
case 1:
|
|
579
555
|
_a.sent();
|
|
580
|
-
return [2
|
|
556
|
+
return [2];
|
|
581
557
|
}
|
|
582
558
|
});
|
|
583
559
|
});
|
|
@@ -589,11 +565,11 @@ export var checkAndRecordDeviceIdChange = function (name, value) {
|
|
|
589
565
|
return __generator(this, function (_a) {
|
|
590
566
|
switch (_a.label) {
|
|
591
567
|
case 0:
|
|
592
|
-
return [4
|
|
568
|
+
return [4, getSentDeviceIds()];
|
|
593
569
|
case 1:
|
|
594
570
|
sentIds = _a.sent();
|
|
595
|
-
if (sentIds[name] === value) return [2
|
|
596
|
-
if (!(name in sentIds) && !value) return [2
|
|
571
|
+
if (sentIds[name] === value) return [2, false];
|
|
572
|
+
if (!(name in sentIds) && !value) return [2, false];
|
|
597
573
|
if (!(name in sentIds) && value && Object.keys(sentIds).length >= MAX_STORED_DEVICE_IDS) {
|
|
598
574
|
oldestKey = Object.keys(sentIds)[0];
|
|
599
575
|
delete sentIds[oldestKey];
|
|
@@ -604,10 +580,10 @@ export var checkAndRecordDeviceIdChange = function (name, value) {
|
|
|
604
580
|
} else {
|
|
605
581
|
delete sentIds[name];
|
|
606
582
|
}
|
|
607
|
-
return [4
|
|
583
|
+
return [4, persistSentDeviceIds(sentIds)];
|
|
608
584
|
case 2:
|
|
609
585
|
_a.sent();
|
|
610
|
-
return [2
|
|
586
|
+
return [2, true];
|
|
611
587
|
}
|
|
612
588
|
});
|
|
613
589
|
});
|