kv-test-lib 3.5.2-rc.2 → 3.5.2-rc.4
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 +7 -11
- 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 +79 -96
- 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 +92 -112
- package/es5_dist/jobqueue.js.map +1 -1
- package/es5_dist/kochava.js +134 -366
- 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 +28 -46
- package/es5_dist/payloads/install.js.map +1 -1
- package/es5_dist/payloads/kvinit.js +25 -38
- 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) {
|
|
@@ -113,15 +109,9 @@ var storage;
|
|
|
113
109
|
export var configureStorage = function (adapter) {
|
|
114
110
|
storage = adapter;
|
|
115
111
|
};
|
|
116
|
-
// Synchronous storage capability — true when the configured adapter exposes a
|
|
117
|
-
// synchronous fast-path (browser localStorage). Drives whether the SDK can
|
|
118
|
-
// restore persisted state during construction or must do so asynchronously.
|
|
119
112
|
export var hasSyncStorage = function () {
|
|
120
113
|
return typeof (storage === null || storage === void 0 ? void 0 : storage.getItemSync) === "function";
|
|
121
114
|
};
|
|
122
|
-
// Unlike the other persist helpers these do NOT catch — per the StorageAdapter
|
|
123
|
-
// contract a throwing sync accessor (e.g. private browsing mode) is the signal
|
|
124
|
-
// for the caller to fall back to the async restore path.
|
|
125
115
|
export var getItemSync = function (key) {
|
|
126
116
|
return (storage === null || storage === void 0 ? void 0 : storage.getItemSync) ? storage.getItemSync(key) : null;
|
|
127
117
|
};
|
|
@@ -134,22 +124,17 @@ export var checkInstallIdChange = function (inputId, useCookies) {
|
|
|
134
124
|
return __generator(this, function (_a) {
|
|
135
125
|
switch (_a.label) {
|
|
136
126
|
case 0:
|
|
137
|
-
return [4
|
|
127
|
+
return [4, readAndUpdatePersistedValue(PersistKey.InstallId, useCookies)];
|
|
138
128
|
case 1:
|
|
139
129
|
persistedInstallId = _a.sent();
|
|
140
|
-
|
|
141
|
-
if (!inputId) return [2 /*return*/, false];
|
|
142
|
-
// if the persistedId is empty, we will need to change
|
|
130
|
+
if (!inputId) return [2, false];
|
|
143
131
|
if (!persistedInstallId) {
|
|
144
132
|
updatePersistedValue(PersistKey.InstallId, inputId, useCookies);
|
|
145
|
-
return [2
|
|
133
|
+
return [2, true];
|
|
146
134
|
}
|
|
147
|
-
|
|
148
|
-
if (inputId === persistedInstallId) return [2 /*return*/, false];
|
|
149
|
-
// at this point both inputId and persistedInstallId exist and are not equal,
|
|
150
|
-
// so we must need to change
|
|
135
|
+
if (inputId === persistedInstallId) return [2, false];
|
|
151
136
|
updatePersistedValue(PersistKey.InstallId, inputId, useCookies);
|
|
152
|
-
return [2
|
|
137
|
+
return [2, true];
|
|
153
138
|
}
|
|
154
139
|
});
|
|
155
140
|
});
|
|
@@ -160,16 +145,16 @@ export var addToPersistedEventQueue = function (job) {
|
|
|
160
145
|
return __generator(this, function (_a) {
|
|
161
146
|
switch (_a.label) {
|
|
162
147
|
case 0:
|
|
163
|
-
return [4
|
|
148
|
+
return [4, storage.getItem(PersistKey.EventQueue)];
|
|
164
149
|
case 1:
|
|
165
150
|
persistedQueueStr = _a.sent();
|
|
166
151
|
if (persistedQueueStr === null || persistedQueueStr === undefined || persistedQueueStr === '{}') persistedQueueStr = '[]';
|
|
167
152
|
persistedQueue = JSON.parse(persistedQueueStr) || [];
|
|
168
153
|
persistedQueue.push(job);
|
|
169
|
-
return [4
|
|
154
|
+
return [4, storage.setItem(PersistKey.EventQueue, JSON.stringify(persistedQueue))];
|
|
170
155
|
case 2:
|
|
171
156
|
_a.sent();
|
|
172
|
-
return [2
|
|
157
|
+
return [2];
|
|
173
158
|
}
|
|
174
159
|
});
|
|
175
160
|
});
|
|
@@ -180,17 +165,17 @@ export var removeFromEventPersistedQueue = function (job) {
|
|
|
180
165
|
return __generator(this, function (_a) {
|
|
181
166
|
switch (_a.label) {
|
|
182
167
|
case 0:
|
|
183
|
-
return [4
|
|
168
|
+
return [4, storage.getItem(PersistKey.EventQueue)];
|
|
184
169
|
case 1:
|
|
185
170
|
persistedQueueStr = _a.sent();
|
|
186
171
|
persistedQueue = JSON.parse(persistedQueueStr) || [];
|
|
187
172
|
queueWithJobRemoved = persistedQueue.filter(function (persistedJob) {
|
|
188
173
|
return persistedJob.id !== job.id;
|
|
189
174
|
});
|
|
190
|
-
return [4
|
|
175
|
+
return [4, storage.setItem(PersistKey.EventQueue, JSON.stringify(queueWithJobRemoved))];
|
|
191
176
|
case 2:
|
|
192
177
|
_a.sent();
|
|
193
|
-
return [2
|
|
178
|
+
return [2];
|
|
194
179
|
}
|
|
195
180
|
});
|
|
196
181
|
});
|
|
@@ -202,7 +187,7 @@ export var updateOrAddPersistedIdLinkQueue = function (job) {
|
|
|
202
187
|
switch (_a.label) {
|
|
203
188
|
case 0:
|
|
204
189
|
idLinkKey = Object.keys(job.idLink)[0];
|
|
205
|
-
return [4
|
|
190
|
+
return [4, storage.getItem(PersistKey.IdLinkQueue)];
|
|
206
191
|
case 1:
|
|
207
192
|
persistedQueueStr = _a.sent();
|
|
208
193
|
persistedQueue = JSON.parse(persistedQueueStr) || [];
|
|
@@ -210,20 +195,18 @@ export var updateOrAddPersistedIdLinkQueue = function (job) {
|
|
|
210
195
|
for (_i = 0, persistedQueue_1 = persistedQueue; _i < persistedQueue_1.length; _i++) {
|
|
211
196
|
persistedJob = persistedQueue_1[_i];
|
|
212
197
|
persistedKey = Object.keys(persistedJob.idLink)[0];
|
|
213
|
-
// if the key is already there, update it
|
|
214
198
|
if (idLinkKey === persistedKey) {
|
|
215
199
|
persistedJob.idLink[idLinkKey] = job.idLink[idLinkKey];
|
|
216
200
|
updated = true;
|
|
217
201
|
}
|
|
218
202
|
}
|
|
219
|
-
// if the key is new, add it
|
|
220
203
|
if (!updated) {
|
|
221
204
|
persistedQueue.push(job);
|
|
222
205
|
}
|
|
223
|
-
return [4
|
|
206
|
+
return [4, storage.setItem(PersistKey.IdLinkQueue, JSON.stringify(persistedQueue))];
|
|
224
207
|
case 2:
|
|
225
208
|
_a.sent();
|
|
226
|
-
return [2
|
|
209
|
+
return [2];
|
|
227
210
|
}
|
|
228
211
|
});
|
|
229
212
|
});
|
|
@@ -234,17 +217,17 @@ export var removeFromIdLinkPersistedQueue = function (job) {
|
|
|
234
217
|
return __generator(this, function (_a) {
|
|
235
218
|
switch (_a.label) {
|
|
236
219
|
case 0:
|
|
237
|
-
return [4
|
|
220
|
+
return [4, storage.getItem(PersistKey.IdLinkQueue)];
|
|
238
221
|
case 1:
|
|
239
222
|
persistedQueueStr = _a.sent();
|
|
240
223
|
persistedQueue = JSON.parse(persistedQueueStr) || [];
|
|
241
224
|
queueWithJobRemoved = persistedQueue.filter(function (persistedJob) {
|
|
242
225
|
return persistedJob.id !== job.id;
|
|
243
226
|
});
|
|
244
|
-
return [4
|
|
227
|
+
return [4, storage.setItem(PersistKey.IdLinkQueue, JSON.stringify(queueWithJobRemoved))];
|
|
245
228
|
case 2:
|
|
246
229
|
_a.sent();
|
|
247
|
-
return [2
|
|
230
|
+
return [2];
|
|
248
231
|
}
|
|
249
232
|
});
|
|
250
233
|
});
|
|
@@ -255,7 +238,7 @@ export var addPersistedIdLinks = function (key, value, useCookies) {
|
|
|
255
238
|
return __generator(this, function (_a) {
|
|
256
239
|
switch (_a.label) {
|
|
257
240
|
case 0:
|
|
258
|
-
return [4
|
|
241
|
+
return [4, storage.getItem(PersistKey.IdentityLinks)];
|
|
259
242
|
case 1:
|
|
260
243
|
persistedIdLinksStr = _a.sent();
|
|
261
244
|
persistedIdLinks = JSON.parse(persistedIdLinksStr) || {};
|
|
@@ -267,7 +250,7 @@ export var addPersistedIdLinks = function (key, value, useCookies) {
|
|
|
267
250
|
}
|
|
268
251
|
persistedIdLinks[key] = value;
|
|
269
252
|
updatePersistedValue(PersistKey.IdentityLinks, JSON.stringify(persistedIdLinks), useCookies);
|
|
270
|
-
return [2
|
|
253
|
+
return [2];
|
|
271
254
|
}
|
|
272
255
|
});
|
|
273
256
|
});
|
|
@@ -278,18 +261,18 @@ export var checkDuplicateIdLink = function (key, value) {
|
|
|
278
261
|
return __generator(this, function (_a) {
|
|
279
262
|
switch (_a.label) {
|
|
280
263
|
case 0:
|
|
281
|
-
return [4
|
|
264
|
+
return [4, storage.getItem(PersistKey.IdentityLinks)];
|
|
282
265
|
case 1:
|
|
283
266
|
persistedIdLinksStr = _a.sent();
|
|
284
267
|
if (persistedIdLinksStr) {
|
|
285
268
|
persistedIdLinks = JSON.parse(persistedIdLinksStr) || {};
|
|
286
269
|
for (persistedKey in persistedIdLinks) {
|
|
287
270
|
if (key === persistedKey && persistedIdLinks[persistedKey] === value) {
|
|
288
|
-
return [2
|
|
271
|
+
return [2, true];
|
|
289
272
|
}
|
|
290
273
|
}
|
|
291
274
|
}
|
|
292
|
-
return [2
|
|
275
|
+
return [2, false];
|
|
293
276
|
}
|
|
294
277
|
});
|
|
295
278
|
});
|
|
@@ -300,13 +283,13 @@ export var getPersistedIdentityLinks = function () {
|
|
|
300
283
|
return __generator(this, function (_a) {
|
|
301
284
|
switch (_a.label) {
|
|
302
285
|
case 0:
|
|
303
|
-
return [4
|
|
286
|
+
return [4, storage.getItem(PersistKey.IdentityLinks)];
|
|
304
287
|
case 1:
|
|
305
288
|
persistedIdLinksStr = _a.sent();
|
|
306
289
|
if (persistedIdLinksStr) {
|
|
307
|
-
return [2
|
|
290
|
+
return [2, JSON.parse(persistedIdLinksStr)];
|
|
308
291
|
}
|
|
309
|
-
return [2
|
|
292
|
+
return [2, undefined];
|
|
310
293
|
}
|
|
311
294
|
});
|
|
312
295
|
});
|
|
@@ -319,24 +302,24 @@ export var readAndUpdateUTM = function (appGuid, useCookies) {
|
|
|
319
302
|
case 0:
|
|
320
303
|
storageName = appGuid + "_click";
|
|
321
304
|
urlValue = getUrlParameter("ko_click_id");
|
|
322
|
-
return [4
|
|
305
|
+
return [4, storage.getItem(storageName)];
|
|
323
306
|
case 1:
|
|
324
307
|
storageValue = _a.sent();
|
|
325
308
|
cookieValue = "";
|
|
326
309
|
if (useCookies) cookieValue = getCookie(storageName);
|
|
327
|
-
if (!urlValue) return [3
|
|
328
|
-
return [4
|
|
310
|
+
if (!urlValue) return [3, 3];
|
|
311
|
+
return [4, storage.setItem(storageName, urlValue)];
|
|
329
312
|
case 2:
|
|
330
313
|
_a.sent();
|
|
331
314
|
if (useCookies) setCookie(storageName, urlValue);
|
|
332
|
-
return [3
|
|
315
|
+
return [3, 4];
|
|
333
316
|
case 3:
|
|
334
317
|
if (storageValue) {
|
|
335
318
|
if (useCookies) setCookie(storageName, urlValue);
|
|
336
319
|
}
|
|
337
320
|
_a.label = 4;
|
|
338
321
|
case 4:
|
|
339
|
-
return [2
|
|
322
|
+
return [2, urlValue ? urlValue : storageValue ? storageValue : cookieValue ? cookieValue : ""];
|
|
340
323
|
}
|
|
341
324
|
});
|
|
342
325
|
});
|
|
@@ -348,30 +331,30 @@ export var readAndUpdatePersistedValue = function (key, useCookie) {
|
|
|
348
331
|
switch (_a.label) {
|
|
349
332
|
case 0:
|
|
350
333
|
urlValue = getUrlParameter(key);
|
|
351
|
-
return [4
|
|
334
|
+
return [4, storage.getItem(key)];
|
|
352
335
|
case 1:
|
|
353
336
|
storageValue = _a.sent();
|
|
354
337
|
cookieValue = "";
|
|
355
338
|
if (useCookie) cookieValue = getCookie(key);
|
|
356
|
-
if (!urlValue) return [3
|
|
357
|
-
return [4
|
|
339
|
+
if (!urlValue) return [3, 3];
|
|
340
|
+
return [4, updatePersistedValue(key, urlValue, useCookie)];
|
|
358
341
|
case 2:
|
|
359
342
|
_a.sent();
|
|
360
|
-
return [3
|
|
343
|
+
return [3, 7];
|
|
361
344
|
case 3:
|
|
362
|
-
if (!storageValue) return [3
|
|
363
|
-
return [4
|
|
345
|
+
if (!storageValue) return [3, 5];
|
|
346
|
+
return [4, updatePersistedValue(key, storageValue, useCookie)];
|
|
364
347
|
case 4:
|
|
365
348
|
_a.sent();
|
|
366
|
-
return [3
|
|
349
|
+
return [3, 7];
|
|
367
350
|
case 5:
|
|
368
|
-
if (!cookieValue) return [3
|
|
369
|
-
return [4
|
|
351
|
+
if (!cookieValue) return [3, 7];
|
|
352
|
+
return [4, updatePersistedValue(key, storageValue, useCookie)];
|
|
370
353
|
case 6:
|
|
371
354
|
_a.sent();
|
|
372
355
|
_a.label = 7;
|
|
373
356
|
case 7:
|
|
374
|
-
return [2
|
|
357
|
+
return [2, urlValue ? urlValue : storageValue ? storageValue : cookieValue ? cookieValue : ""];
|
|
375
358
|
}
|
|
376
359
|
});
|
|
377
360
|
});
|
|
@@ -381,11 +364,11 @@ export var updatePersistedValue = function (key, value, useCookie) {
|
|
|
381
364
|
return __generator(this, function (_a) {
|
|
382
365
|
switch (_a.label) {
|
|
383
366
|
case 0:
|
|
384
|
-
return [4
|
|
367
|
+
return [4, storage.setItem(key, value)];
|
|
385
368
|
case 1:
|
|
386
369
|
_a.sent();
|
|
387
370
|
if (useCookie) setCookie(key, value);
|
|
388
|
-
return [2
|
|
371
|
+
return [2];
|
|
389
372
|
}
|
|
390
373
|
});
|
|
391
374
|
});
|
|
@@ -395,11 +378,11 @@ export var deletePersistedValue = function (item) {
|
|
|
395
378
|
return __generator(this, function (_a) {
|
|
396
379
|
switch (_a.label) {
|
|
397
380
|
case 0:
|
|
398
|
-
return [4
|
|
381
|
+
return [4, storage.removeItem(item)];
|
|
399
382
|
case 1:
|
|
400
383
|
_a.sent();
|
|
401
384
|
deleteCookie(item);
|
|
402
|
-
return [2
|
|
385
|
+
return [2];
|
|
403
386
|
}
|
|
404
387
|
});
|
|
405
388
|
});
|
|
@@ -409,12 +392,12 @@ export var deleteAllPersisted = function () {
|
|
|
409
392
|
return __generator(this, function (_a) {
|
|
410
393
|
switch (_a.label) {
|
|
411
394
|
case 0:
|
|
412
|
-
return [4
|
|
395
|
+
return [4, Promise.all(storedKeys.map(function (item) {
|
|
413
396
|
return deletePersistedValue(item);
|
|
414
397
|
}))];
|
|
415
398
|
case 1:
|
|
416
399
|
_a.sent();
|
|
417
|
-
return [2
|
|
400
|
+
return [2];
|
|
418
401
|
}
|
|
419
402
|
});
|
|
420
403
|
});
|
|
@@ -425,7 +408,7 @@ export var readAndUpdateSessionCount = function (useCookie) {
|
|
|
425
408
|
return __generator(this, function (_a) {
|
|
426
409
|
switch (_a.label) {
|
|
427
410
|
case 0:
|
|
428
|
-
return [4
|
|
411
|
+
return [4, readAndUpdatePersistedValue(PersistKey.SessionCount, useCookie)];
|
|
429
412
|
case 1:
|
|
430
413
|
storedSessionCount = _a.sent();
|
|
431
414
|
sessionCount = 1;
|
|
@@ -433,10 +416,10 @@ export var readAndUpdateSessionCount = function (useCookie) {
|
|
|
433
416
|
sessionCount = parseInt(storedSessionCount);
|
|
434
417
|
sessionCount++;
|
|
435
418
|
}
|
|
436
|
-
return [4
|
|
419
|
+
return [4, updatePersistedValue(PersistKey.SessionCount, sessionCount.toString(), useCookie)];
|
|
437
420
|
case 2:
|
|
438
421
|
_a.sent();
|
|
439
|
-
return [2
|
|
422
|
+
return [2, sessionCount];
|
|
440
423
|
}
|
|
441
424
|
});
|
|
442
425
|
});
|
|
@@ -448,11 +431,11 @@ export var updateLastInstall = function (lastInstallObject, useCookie) {
|
|
|
448
431
|
switch (_a.label) {
|
|
449
432
|
case 0:
|
|
450
433
|
lastInstallStr = JSON.stringify(lastInstallObject);
|
|
451
|
-
return [4
|
|
434
|
+
return [4, storage.setItem(PersistKey.LastInstall, lastInstallStr)];
|
|
452
435
|
case 1:
|
|
453
436
|
_a.sent();
|
|
454
437
|
if (useCookie) setCookie(PersistKey.LastInstall, lastInstallStr);
|
|
455
|
-
return [2
|
|
438
|
+
return [2];
|
|
456
439
|
}
|
|
457
440
|
});
|
|
458
441
|
});
|
|
@@ -463,18 +446,18 @@ export var getLastInstall = function (useCookie) {
|
|
|
463
446
|
return __generator(this, function (_a) {
|
|
464
447
|
switch (_a.label) {
|
|
465
448
|
case 0:
|
|
466
|
-
return [4
|
|
449
|
+
return [4, storage.getItem(PersistKey.LastInstall)];
|
|
467
450
|
case 1:
|
|
468
451
|
lastInstallStr = _a.sent();
|
|
469
452
|
if (lastInstallStr) {
|
|
470
|
-
return [2
|
|
453
|
+
return [2, JSON.parse(lastInstallStr)];
|
|
471
454
|
} else if (useCookie) {
|
|
472
455
|
cookieValue = getCookie(PersistKey.LastInstall);
|
|
473
456
|
if (cookieValue) {
|
|
474
|
-
return [2
|
|
457
|
+
return [2, JSON.parse(cookieValue)];
|
|
475
458
|
}
|
|
476
459
|
}
|
|
477
|
-
return [2
|
|
460
|
+
return [2, undefined];
|
|
478
461
|
}
|
|
479
462
|
});
|
|
480
463
|
});
|
|
@@ -484,13 +467,13 @@ export var updateInstallCount = function (installCount, useCookie) {
|
|
|
484
467
|
return __generator(this, function (_a) {
|
|
485
468
|
switch (_a.label) {
|
|
486
469
|
case 0:
|
|
487
|
-
return [4
|
|
470
|
+
return [4, storage.setItem(PersistKey.InstallCount, installCount.toString())];
|
|
488
471
|
case 1:
|
|
489
472
|
_a.sent();
|
|
490
473
|
if (useCookie) {
|
|
491
474
|
setCookie(PersistKey.InstallCount, installCount.toString());
|
|
492
475
|
}
|
|
493
|
-
return [2
|
|
476
|
+
return [2];
|
|
494
477
|
}
|
|
495
478
|
});
|
|
496
479
|
});
|
|
@@ -502,21 +485,21 @@ export var getItem = function (key) {
|
|
|
502
485
|
switch (_a.label) {
|
|
503
486
|
case 0:
|
|
504
487
|
_a.trys.push([0, 2,, 3]);
|
|
505
|
-
return [4
|
|
488
|
+
return [4, storage.getItem(key)];
|
|
506
489
|
case 1:
|
|
507
490
|
value = _a.sent();
|
|
508
491
|
if (value) {
|
|
509
|
-
return [2
|
|
492
|
+
return [2, value];
|
|
510
493
|
} else {
|
|
511
|
-
return [2
|
|
494
|
+
return [2, null];
|
|
512
495
|
}
|
|
513
|
-
return [3
|
|
496
|
+
return [3, 3];
|
|
514
497
|
case 2:
|
|
515
498
|
error_1 = _a.sent();
|
|
516
499
|
Log.error("Error getting item ".concat(key, " from localStorage:"), error_1);
|
|
517
|
-
return [2
|
|
500
|
+
return [2, null];
|
|
518
501
|
case 3:
|
|
519
|
-
return [2
|
|
502
|
+
return [2];
|
|
520
503
|
}
|
|
521
504
|
});
|
|
522
505
|
});
|
|
@@ -528,16 +511,16 @@ export var setItem = function (key, value) {
|
|
|
528
511
|
switch (_a.label) {
|
|
529
512
|
case 0:
|
|
530
513
|
_a.trys.push([0, 2,, 3]);
|
|
531
|
-
return [4
|
|
514
|
+
return [4, storage.setItem(key, value)];
|
|
532
515
|
case 1:
|
|
533
516
|
_a.sent();
|
|
534
|
-
return [3
|
|
517
|
+
return [3, 3];
|
|
535
518
|
case 2:
|
|
536
519
|
error_2 = _a.sent();
|
|
537
520
|
Log.error("Error setting item ".concat(key, " in localStorage:"), error_2);
|
|
538
|
-
return [3
|
|
521
|
+
return [3, 3];
|
|
539
522
|
case 3:
|
|
540
|
-
return [2
|
|
523
|
+
return [2];
|
|
541
524
|
}
|
|
542
525
|
});
|
|
543
526
|
});
|
|
@@ -548,16 +531,16 @@ export var getSentDeviceIds = function () {
|
|
|
548
531
|
return __generator(this, function (_a) {
|
|
549
532
|
switch (_a.label) {
|
|
550
533
|
case 0:
|
|
551
|
-
return [4
|
|
534
|
+
return [4, storage.getItem(PersistKey.SentDeviceIds)];
|
|
552
535
|
case 1:
|
|
553
536
|
raw = _a.sent();
|
|
554
|
-
if (!raw) return [2
|
|
537
|
+
if (!raw) return [2, {}];
|
|
555
538
|
try {
|
|
556
|
-
return [2
|
|
539
|
+
return [2, JSON.parse(raw)];
|
|
557
540
|
} catch (_b) {
|
|
558
|
-
return [2
|
|
541
|
+
return [2, {}];
|
|
559
542
|
}
|
|
560
|
-
return [2
|
|
543
|
+
return [2];
|
|
561
544
|
}
|
|
562
545
|
});
|
|
563
546
|
});
|
|
@@ -567,10 +550,10 @@ export var persistSentDeviceIds = function (ids) {
|
|
|
567
550
|
return __generator(this, function (_a) {
|
|
568
551
|
switch (_a.label) {
|
|
569
552
|
case 0:
|
|
570
|
-
return [4
|
|
553
|
+
return [4, storage.setItem(PersistKey.SentDeviceIds, JSON.stringify(ids))];
|
|
571
554
|
case 1:
|
|
572
555
|
_a.sent();
|
|
573
|
-
return [2
|
|
556
|
+
return [2];
|
|
574
557
|
}
|
|
575
558
|
});
|
|
576
559
|
});
|
|
@@ -582,11 +565,11 @@ export var checkAndRecordDeviceIdChange = function (name, value) {
|
|
|
582
565
|
return __generator(this, function (_a) {
|
|
583
566
|
switch (_a.label) {
|
|
584
567
|
case 0:
|
|
585
|
-
return [4
|
|
568
|
+
return [4, getSentDeviceIds()];
|
|
586
569
|
case 1:
|
|
587
570
|
sentIds = _a.sent();
|
|
588
|
-
if (sentIds[name] === value) return [2
|
|
589
|
-
if (!(name in sentIds) && !value) return [2
|
|
571
|
+
if (sentIds[name] === value) return [2, false];
|
|
572
|
+
if (!(name in sentIds) && !value) return [2, false];
|
|
590
573
|
if (!(name in sentIds) && value && Object.keys(sentIds).length >= MAX_STORED_DEVICE_IDS) {
|
|
591
574
|
oldestKey = Object.keys(sentIds)[0];
|
|
592
575
|
delete sentIds[oldestKey];
|
|
@@ -597,10 +580,10 @@ export var checkAndRecordDeviceIdChange = function (name, value) {
|
|
|
597
580
|
} else {
|
|
598
581
|
delete sentIds[name];
|
|
599
582
|
}
|
|
600
|
-
return [4
|
|
583
|
+
return [4, persistSentDeviceIds(sentIds)];
|
|
601
584
|
case 2:
|
|
602
585
|
_a.sent();
|
|
603
|
-
return [2
|
|
586
|
+
return [2, true];
|
|
604
587
|
}
|
|
605
588
|
});
|
|
606
589
|
});
|