@zoho_apptics/apptics-js-sdk 2.0.0-beta → 2.0.0-beta.2
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/CHANGELOG.md +191 -21
- package/README.md +519 -333
- package/dist/apptics.esm.min.js +2 -2
- package/dist/apptics.esm.min.js.map +1 -1
- package/dist/apptics.min.js +2 -2
- package/dist/apptics.min.js.map +1 -1
- package/dist/chunks/lifecycle-C6m1W7jo.min.js +3 -0
- package/dist/chunks/lifecycle-C6m1W7jo.min.js.map +1 -0
- package/dist/chunks/send-CgUO82ne.min.js +3 -0
- package/dist/chunks/send-CgUO82ne.min.js.map +1 -0
- package/dist/cjs/core/attempts.js +1 -1
- package/dist/cjs/core/batch.js +2 -2
- package/dist/cjs/core/consent.d.ts +18 -4
- package/dist/cjs/core/consent.js +31 -15
- package/dist/cjs/core/constants.d.ts +57 -27
- package/dist/cjs/core/constants.js +52 -33
- package/dist/cjs/core/db.d.ts +12 -4
- package/dist/cjs/core/db.js +167 -34
- package/dist/cjs/core/debug.js +1 -1
- package/dist/cjs/core/env.d.ts +0 -3
- package/dist/cjs/core/env.js +1 -9
- package/dist/cjs/core/framework-id.d.ts +1 -1
- package/dist/cjs/core/framework-id.js +3 -3
- package/dist/cjs/core/guard.d.ts +9 -0
- package/dist/cjs/core/guard.js +27 -13
- package/dist/cjs/core/hooks.d.ts +7 -4
- package/dist/cjs/core/hooks.js +3 -3
- package/dist/cjs/core/locks.d.ts +9 -0
- package/dist/cjs/core/locks.js +22 -0
- package/dist/cjs/core/logger.d.ts +3 -4
- package/dist/cjs/core/logger.js +4 -40
- package/dist/cjs/core/state.d.ts +9 -6
- package/dist/cjs/core/state.js +3 -5
- package/dist/cjs/core/storage.d.ts +20 -5
- package/dist/cjs/core/storage.js +115 -20
- package/dist/cjs/core/stylesheet.d.ts +8 -0
- package/dist/cjs/core/stylesheet.js +29 -0
- package/dist/cjs/core/transport.d.ts +2 -0
- package/dist/cjs/core/transport.js +30 -18
- package/dist/cjs/core/utils.js +1 -1
- package/dist/cjs/core/validate.js +2 -2
- package/dist/cjs/device/appversion.d.ts +10 -6
- package/dist/cjs/device/appversion.js +38 -3
- package/dist/cjs/device/index.d.ts +28 -2
- package/dist/cjs/device/index.js +312 -44
- package/dist/cjs/engagement/api-rules.d.ts +32 -67
- package/dist/cjs/engagement/api-rules.js +144 -157
- package/dist/cjs/engagement/auto-api.js +2 -2
- package/dist/cjs/engagement/auto-screen.d.ts +2 -0
- package/dist/cjs/engagement/auto-screen.js +67 -3
- package/dist/cjs/engagement/defined-events.js +1 -1
- package/dist/cjs/engagement/send.js +12 -3
- package/dist/cjs/engagement/session.d.ts +29 -3
- package/dist/cjs/engagement/session.js +253 -26
- package/dist/cjs/engagement/track.d.ts +4 -4
- package/dist/cjs/engagement/track.js +58 -30
- package/dist/cjs/errors/send.js +2 -2
- package/dist/cjs/errors/track.d.ts +2 -1
- package/dist/cjs/errors/track.js +49 -7
- package/dist/cjs/feedback/controls.d.ts +12 -0
- package/dist/cjs/feedback/controls.js +104 -25
- package/dist/cjs/feedback/index.d.ts +8 -7
- package/dist/cjs/feedback/index.js +32 -13
- package/dist/cjs/feedback/logs.d.ts +13 -11
- package/dist/cjs/feedback/logs.js +57 -28
- package/dist/cjs/feedback/quartz.d.ts +18 -0
- package/dist/cjs/feedback/quartz.js +105 -0
- package/dist/cjs/feedback/send.d.ts +5 -2
- package/dist/cjs/feedback/send.js +30 -28
- package/dist/cjs/feedback/styles.d.ts +10 -0
- package/dist/cjs/feedback/styles.js +8 -0
- package/dist/cjs/feedback/template.d.ts +1 -1
- package/dist/cjs/feedback/template.js +20 -12
- package/dist/cjs/feedback/ui.d.ts +21 -6
- package/dist/cjs/feedback/ui.js +283 -70
- package/dist/cjs/heatmap/send.d.ts +2 -0
- package/dist/cjs/heatmap/send.js +3 -5
- package/dist/cjs/heatmap/track.d.ts +1 -1
- package/dist/cjs/heatmap/track.js +87 -16
- package/dist/cjs/index.d.ts +16 -63
- package/dist/cjs/index.js +144 -95
- package/dist/cjs/lifecycle.d.ts +21 -3
- package/dist/cjs/lifecycle.js +353 -89
- package/dist/cjs/remoteconfig/country.d.ts +4 -0
- package/dist/cjs/remoteconfig/country.js +73 -0
- package/dist/cjs/remoteconfig/custom.d.ts +7 -7
- package/dist/cjs/remoteconfig/custom.js +31 -51
- package/dist/cjs/remoteconfig/evaluate.d.ts +3 -3
- package/dist/cjs/remoteconfig/evaluate.js +56 -43
- package/dist/cjs/remoteconfig/fetch.d.ts +16 -9
- package/dist/cjs/remoteconfig/fetch.js +120 -39
- package/dist/cjs/remoteconfig/index.d.ts +19 -8
- package/dist/cjs/remoteconfig/index.js +81 -39
- package/dist/cjs/remoteconfig/store.d.ts +15 -7
- package/dist/cjs/remoteconfig/store.js +68 -35
- package/dist/cjs/remoteconfig/tz-countries.d.ts +8 -0
- package/dist/cjs/remoteconfig/tz-countries.js +13 -0
- package/dist/{esm/core → cjs/remotelog}/callsite.d.ts +11 -4
- package/dist/cjs/{core → remotelog}/callsite.js +30 -7
- package/dist/cjs/remotelog/gate.d.ts +2 -11
- package/dist/cjs/remotelog/gate.js +9 -35
- package/dist/cjs/remotelog/index.d.ts +4 -21
- package/dist/cjs/remotelog/logger.d.ts +11 -17
- package/dist/cjs/remotelog/logger.js +31 -59
- package/dist/cjs/remotelog/send.js +11 -11
- package/dist/cjs/remotelogger/index.d.ts +12 -0
- package/dist/cjs/remotelogger/index.js +18 -0
- package/dist/cjs/scheduler.d.ts +3 -1
- package/dist/cjs/scheduler.js +25 -22
- package/dist/cjs/types.d.ts +208 -90
- package/dist/cjs/user/index.js +16 -7
- package/dist/esm/core/attempts.js +1 -1
- package/dist/esm/core/batch.js +2 -2
- package/dist/esm/core/consent.d.ts +18 -4
- package/dist/esm/core/consent.js +32 -17
- package/dist/esm/core/constants.d.ts +57 -27
- package/dist/esm/core/constants.js +51 -33
- package/dist/esm/core/db.d.ts +12 -4
- package/dist/esm/core/db.js +164 -35
- package/dist/esm/core/debug.js +1 -1
- package/dist/esm/core/env.d.ts +0 -3
- package/dist/esm/core/env.js +2 -9
- package/dist/esm/core/framework-id.d.ts +1 -1
- package/dist/esm/core/framework-id.js +3 -3
- package/dist/esm/core/guard.d.ts +9 -0
- package/dist/esm/core/guard.js +27 -14
- package/dist/esm/core/hooks.d.ts +7 -4
- package/dist/esm/core/hooks.js +3 -3
- package/dist/esm/core/locks.d.ts +9 -0
- package/dist/esm/core/locks.js +20 -0
- package/dist/esm/core/logger.d.ts +3 -4
- package/dist/esm/core/logger.js +4 -40
- package/dist/esm/core/state.d.ts +9 -6
- package/dist/esm/core/state.js +3 -5
- package/dist/esm/core/storage.d.ts +20 -5
- package/dist/esm/core/storage.js +113 -21
- package/dist/esm/core/stylesheet.d.ts +8 -0
- package/dist/esm/core/stylesheet.js +27 -0
- package/dist/esm/core/transport.d.ts +2 -0
- package/dist/esm/core/transport.js +30 -19
- package/dist/esm/core/utils.js +1 -1
- package/dist/esm/core/validate.js +2 -2
- package/dist/esm/device/appversion.d.ts +10 -6
- package/dist/esm/device/appversion.js +37 -4
- package/dist/esm/device/index.d.ts +28 -2
- package/dist/esm/device/index.js +313 -49
- package/dist/esm/engagement/api-rules.d.ts +32 -67
- package/dist/esm/engagement/api-rules.js +143 -155
- package/dist/esm/engagement/auto-api.js +3 -3
- package/dist/esm/engagement/auto-screen.d.ts +2 -0
- package/dist/esm/engagement/auto-screen.js +67 -4
- package/dist/esm/engagement/defined-events.js +1 -1
- package/dist/esm/engagement/send.js +12 -3
- package/dist/esm/engagement/session.d.ts +29 -3
- package/dist/esm/engagement/session.js +251 -30
- package/dist/esm/engagement/track.d.ts +4 -4
- package/dist/esm/engagement/track.js +65 -37
- package/dist/esm/errors/send.js +2 -2
- package/dist/esm/errors/track.d.ts +2 -1
- package/dist/esm/errors/track.js +49 -7
- package/dist/esm/feedback/controls.d.ts +12 -0
- package/dist/esm/feedback/controls.js +103 -26
- package/dist/esm/feedback/index.d.ts +8 -7
- package/dist/esm/feedback/index.js +34 -13
- package/dist/esm/feedback/logs.d.ts +13 -11
- package/dist/esm/feedback/logs.js +59 -30
- package/dist/esm/feedback/quartz.d.ts +18 -0
- package/dist/esm/feedback/quartz.js +99 -0
- package/dist/esm/feedback/send.d.ts +5 -2
- package/dist/esm/feedback/send.js +31 -31
- package/dist/esm/feedback/styles.d.ts +10 -0
- package/dist/esm/feedback/styles.js +4 -0
- package/dist/esm/feedback/template.d.ts +1 -1
- package/dist/esm/feedback/template.js +20 -12
- package/dist/esm/feedback/ui.d.ts +21 -6
- package/dist/esm/feedback/ui.js +283 -71
- package/dist/esm/heatmap/send.d.ts +2 -0
- package/dist/esm/heatmap/send.js +3 -5
- package/dist/esm/heatmap/track.d.ts +1 -1
- package/dist/esm/heatmap/track.js +87 -16
- package/dist/esm/index.d.ts +16 -63
- package/dist/esm/index.js +148 -83
- package/dist/esm/lifecycle.d.ts +21 -3
- package/dist/esm/lifecycle.js +359 -98
- package/dist/esm/remoteconfig/country.d.ts +4 -0
- package/dist/esm/remoteconfig/country.js +70 -0
- package/dist/esm/remoteconfig/custom.d.ts +7 -7
- package/dist/esm/remoteconfig/custom.js +32 -52
- package/dist/esm/remoteconfig/evaluate.d.ts +3 -3
- package/dist/esm/remoteconfig/evaluate.js +57 -44
- package/dist/esm/remoteconfig/fetch.d.ts +16 -9
- package/dist/esm/remoteconfig/fetch.js +120 -39
- package/dist/esm/remoteconfig/index.d.ts +19 -8
- package/dist/esm/remoteconfig/index.js +82 -40
- package/dist/esm/remoteconfig/store.d.ts +15 -7
- package/dist/esm/remoteconfig/store.js +68 -36
- package/dist/esm/remoteconfig/tz-countries.d.ts +8 -0
- package/dist/esm/remoteconfig/tz-countries.js +11 -0
- package/dist/{cjs/core → esm/remotelog}/callsite.d.ts +11 -4
- package/dist/esm/{core → remotelog}/callsite.js +30 -8
- package/dist/esm/remotelog/gate.d.ts +2 -11
- package/dist/esm/remotelog/gate.js +10 -32
- package/dist/esm/remotelog/index.d.ts +4 -21
- package/dist/esm/remotelog/logger.d.ts +11 -17
- package/dist/esm/remotelog/logger.js +33 -61
- package/dist/esm/remotelog/send.js +13 -13
- package/dist/esm/remotelogger/index.d.ts +12 -0
- package/dist/esm/remotelogger/index.js +13 -0
- package/dist/esm/scheduler.d.ts +3 -1
- package/dist/esm/scheduler.js +26 -24
- package/dist/esm/types.d.ts +208 -90
- package/dist/esm/user/index.js +18 -8
- package/dist/feedback.esm.min.js +2 -2
- package/dist/feedback.esm.min.js.map +1 -1
- package/dist/remoteconfig.esm.min.js +3 -0
- package/dist/remoteconfig.esm.min.js.map +1 -0
- package/dist/remotelogger.esm.min.js +3 -0
- package/dist/remotelogger.esm.min.js.map +1 -0
- package/package.json +16 -17
- package/dist/chunks/batch-BU_mTpm1.min.js +0 -3
- package/dist/chunks/batch-BU_mTpm1.min.js.map +0 -1
- package/dist/chunks/logs-Bea5zUW_.min.js +0 -3
- package/dist/chunks/logs-Bea5zUW_.min.js.map +0 -1
- package/dist/cjs/auto-init.d.ts +0 -8
- package/dist/cjs/auto-init.js +0 -32
- package/dist/cjs/heatmap/index.d.ts +0 -16
- package/dist/cjs/heatmap/index.js +0 -22
- package/dist/cjs/remotelog/index.js +0 -55
- package/dist/esm/auto-init.d.ts +0 -8
- package/dist/esm/auto-init.js +0 -29
- package/dist/esm/heatmap/index.d.ts +0 -16
- package/dist/esm/heatmap/index.js +0 -17
- package/dist/esm/remotelog/index.js +0 -51
- package/dist/heatmap.esm.min.js +0 -3
- package/dist/heatmap.esm.min.js.map +0 -1
- package/dist/style.css +0 -1
package/dist/esm/core/state.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
2
|
import { AP_TRACKING_STATUS, AP_CONSTANTS, DEFAULT_INACTIVE_MINUTES, AP_CONFIG } from './constants.js';
|
|
3
3
|
import { nowMs } from './utils.js';
|
|
4
4
|
import { FRAMEWORK_ID } from './framework-id.js';
|
|
@@ -21,7 +21,6 @@ function initialState() {
|
|
|
21
21
|
// issued by Apptics at pack time; see scripts/register-version.mjs
|
|
22
22
|
_frameworkID: FRAMEWORK_ID,
|
|
23
23
|
_platform: AP_CONSTANTS.BROWSER,
|
|
24
|
-
_isanonrequired: true,
|
|
25
24
|
_devicestatus: AP_TRACKING_STATUS.USAGE_TRACKING_WITHOUT_PII,
|
|
26
25
|
_uuid: '', // no i18n
|
|
27
26
|
_apid: '', // no i18n
|
|
@@ -32,9 +31,8 @@ function initialState() {
|
|
|
32
31
|
_current_session: {},
|
|
33
32
|
_properties: {},
|
|
34
33
|
_ignoreDnt: false,
|
|
35
|
-
_isGlobalErrorTracking: true,
|
|
36
34
|
_shouldTrack: true,
|
|
37
|
-
_engagementTracking: true,
|
|
35
|
+
_engagementTracking: { event: true, screen: true, session: true, api: true },
|
|
38
36
|
_heatmapTracking: true,
|
|
39
37
|
_remoteLoggerEnabled: true,
|
|
40
38
|
_remoteConfigEnabled: true,
|
|
@@ -43,7 +41,7 @@ function initialState() {
|
|
|
43
41
|
_nextConfigCheck: 0,
|
|
44
42
|
_debugUntil: 0,
|
|
45
43
|
_errorTracking: true,
|
|
46
|
-
|
|
44
|
+
_quartz: { enabled: false, workspace: '', department: '', domain: '', cdnUrl: '' }, // no i18n
|
|
47
45
|
_trackinfo: {},
|
|
48
46
|
};
|
|
49
47
|
}
|
|
@@ -20,23 +20,38 @@ export declare const error_transactions: Queue;
|
|
|
20
20
|
* These are not sent on their own: feedback/logs.ts renders them into the files that
|
|
21
21
|
* feedback/add carries, and removes the ones a submission took with it.
|
|
22
22
|
*/
|
|
23
|
-
export declare const
|
|
23
|
+
export declare const feedbacklog_transactions: Queue;
|
|
24
24
|
/** Clicks and scrolls waiting for heatmap/add. */
|
|
25
25
|
export declare const heatmap_transactions: Queue;
|
|
26
26
|
/**
|
|
27
|
-
* Remote log lines waiting for
|
|
27
|
+
* Remote log lines waiting for log/add. Stored rather than sent straight out because the
|
|
28
28
|
* endpoint takes one line per call and counts retries (`attempt`), so a line has to outlive a
|
|
29
29
|
* failed send — and a reload.
|
|
30
30
|
*/
|
|
31
|
-
export declare const
|
|
32
|
-
/**
|
|
31
|
+
export declare const remotelog_transactions: Queue;
|
|
32
|
+
/**
|
|
33
|
+
* Sets one key of the stored device_info, and of this tab's copy: the uuid the device is
|
|
34
|
+
* registered under, whether it has had a session. Its other keys stay as they are.
|
|
35
|
+
*/
|
|
36
|
+
export declare function setDeviceInfoKey(key: string, value: unknown): void;
|
|
37
|
+
/** device_info (uuid included), app_version_info, trackinfo (tracking_status included), users, user_info, and the rest. */
|
|
33
38
|
export declare const user_defaults: {
|
|
34
39
|
all(): Dict;
|
|
35
40
|
item(key: string): any;
|
|
36
41
|
add(key: string, value: unknown): void;
|
|
42
|
+
/** As add(), and resolves once the value is in storage, where other tabs can read it. */
|
|
43
|
+
save(key: string, value: unknown): Promise<void>;
|
|
37
44
|
clear(): void;
|
|
38
45
|
};
|
|
39
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* Re-reads `keys` from storage. Settings are loaded into memory once, when a tab starts, so a value
|
|
48
|
+
* another tab of this site wrote since then — the device ids it registered — is only in storage.
|
|
49
|
+
* A key storage doesn't hold keeps this tab's value.
|
|
50
|
+
*/
|
|
51
|
+
export declare function reloadSettings(keys: string[]): Promise<void>;
|
|
52
|
+
/** The visitor's tracking status, stored in trackinfo as tracking_status. */
|
|
53
|
+
export declare function storedTrackingStatus(): TrackingStatus | undefined;
|
|
54
|
+
/** Opt-in status, stored in the trackinfo setting as tracking_status. */
|
|
40
55
|
export declare const tracking_preference: {
|
|
41
56
|
_tracking_status: string;
|
|
42
57
|
all(): Dict;
|
package/dist/esm/core/storage.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
2
|
import { AP_TRACKING_STATUS } from './constants.js';
|
|
3
3
|
import { _ZAP, isExpired, getConfig } from './state.js';
|
|
4
4
|
import { Console } from './logger.js';
|
|
5
|
-
import { cloneObject, getNewUUID, sizeof } from './utils.js';
|
|
6
|
-
import { openBackend, LEGACY_KEYS, asList, asDict } from './db.js';
|
|
5
|
+
import { cloneObject, getNewUUID, isEmpty, sizeof } from './utils.js';
|
|
6
|
+
import { openBackend, LEGACY_KEYS, asList, renameFeedbackType, asDict } from './db.js';
|
|
7
7
|
|
|
8
8
|
var readyPromise = null;
|
|
9
9
|
var settings = {};
|
|
@@ -28,8 +28,6 @@ function migrateLegacy(b) {
|
|
|
28
28
|
errors: localStorage.getItem(LEGACY_KEYS.errors),
|
|
29
29
|
logs: localStorage.getItem(LEGACY_KEYS.logs),
|
|
30
30
|
consolelogs: localStorage.getItem(LEGACY_KEYS.consolelogs),
|
|
31
|
-
// read for completeness of the shape only: 1.x never wrote this key
|
|
32
|
-
heatmaps: null,
|
|
33
31
|
};
|
|
34
32
|
}
|
|
35
33
|
catch (err) {
|
|
@@ -47,15 +45,17 @@ function migrateLegacy(b) {
|
|
|
47
45
|
return null;
|
|
48
46
|
}
|
|
49
47
|
};
|
|
48
|
+
// 1.x's keys are logs and consolelogs; they are feedbacklogs and remotelogs now, and a
|
|
49
|
+
// feedback entry's type is feedbacklog or feedbackdiagnostics instead of log or diagnostics
|
|
50
50
|
var queues = {
|
|
51
51
|
engagements: asList(parse(raw.engagements)),
|
|
52
52
|
errors: asList(parse(raw.errors)),
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
feedbacklogs: asList(parse(raw.logs)).map(renameFeedbackType),
|
|
54
|
+
remotelogs: asList(parse(raw.consolelogs)),
|
|
55
55
|
// nothing to migrate: 1.x had no heatmaps
|
|
56
56
|
heatmaps: [],
|
|
57
57
|
};
|
|
58
|
-
queues.engagements.concat(queues.errors, queues.
|
|
58
|
+
queues.engagements.concat(queues.errors, queues.feedbacklogs, queues.remotelogs).forEach(function (item) {
|
|
59
59
|
if (!item.id)
|
|
60
60
|
item.id = getNewUUID();
|
|
61
61
|
});
|
|
@@ -89,6 +89,7 @@ function storageReady() {
|
|
|
89
89
|
}).then(function (loaded) {
|
|
90
90
|
// writes made before loading finished win over stored values
|
|
91
91
|
settings = Object.assign({}, loaded, settings);
|
|
92
|
+
moveRetiredSettings();
|
|
92
93
|
return b;
|
|
93
94
|
});
|
|
94
95
|
}).catch(function (err) {
|
|
@@ -159,21 +160,75 @@ const error_transactions = createQueue('errors'); // no i18n
|
|
|
159
160
|
* These are not sent on their own: feedback/logs.ts renders them into the files that
|
|
160
161
|
* feedback/add carries, and removes the ones a submission took with it.
|
|
161
162
|
*/
|
|
162
|
-
const
|
|
163
|
+
const feedbacklog_transactions = createQueue('feedbacklogs'); // no i18n
|
|
163
164
|
/** Clicks and scrolls waiting for heatmap/add. */
|
|
164
165
|
const heatmap_transactions = createQueue('heatmaps'); // no i18n
|
|
165
166
|
/**
|
|
166
|
-
* Remote log lines waiting for
|
|
167
|
+
* Remote log lines waiting for log/add. Stored rather than sent straight out because the
|
|
167
168
|
* endpoint takes one line per call and counts retries (`attempt`), so a line has to outlive a
|
|
168
169
|
* failed send — and a reload.
|
|
169
170
|
*/
|
|
170
|
-
const
|
|
171
|
+
const remotelog_transactions = createQueue('remotelogs'); // no i18n
|
|
171
172
|
/* ---------------- settings (sync reads, background writes) ---------------- */
|
|
173
|
+
/** Writes `key`, or removes it from storage altogether when `value` is undefined. */
|
|
174
|
+
function writeSetting(b, key) {
|
|
175
|
+
return settings[key] === undefined ? b.deleteSetting(key) : b.putSetting(key, settings[key]);
|
|
176
|
+
}
|
|
172
177
|
function setSetting(key, value) {
|
|
173
|
-
|
|
174
|
-
|
|
178
|
+
if (value === undefined) {
|
|
179
|
+
delete settings[key];
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
settings[key] = cloneObject(value);
|
|
183
|
+
}
|
|
184
|
+
withBackend('save ' + key, undefined, function (b) { return writeSetting(b, key); }); // no i18n
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Settings 2.0.0-beta kept as keys of their own, now kept inside device_info and trackinfo.
|
|
188
|
+
* Moved once, on the first load after an upgrade, before anything reads them: the uuid is the one
|
|
189
|
+
* the device is registered under, and the tracking status is the visitor's own choice, so losing
|
|
190
|
+
* either would register a new device or forget a consent. token was never read, and goes.
|
|
191
|
+
* appkey and appversion are read and removed by init(), which compares them with this visit's app.
|
|
192
|
+
*/
|
|
193
|
+
function moveRetiredSettings() {
|
|
194
|
+
var device = settings.device_info && typeof settings.device_info === 'object' ? settings.device_info : null; // no i18n
|
|
195
|
+
if (settings.uuid !== undefined || settings.hadsession !== undefined) {
|
|
196
|
+
device = Object.assign({}, device || {});
|
|
197
|
+
if (isEmpty(device.uuid) && !isEmpty(settings.uuid)) {
|
|
198
|
+
device.uuid = settings.uuid;
|
|
199
|
+
}
|
|
200
|
+
if (settings.hadsession === true) {
|
|
201
|
+
device.hadsession = true;
|
|
202
|
+
}
|
|
203
|
+
setSetting('device_info', device); // no i18n
|
|
204
|
+
setSetting('uuid', undefined); // no i18n
|
|
205
|
+
setSetting('hadsession', undefined); // no i18n
|
|
206
|
+
}
|
|
207
|
+
if (settings.tracking_status !== undefined) {
|
|
208
|
+
var track = Object.assign({}, settings.trackinfo && typeof settings.trackinfo === 'object' ? settings.trackinfo : {}); // no i18n
|
|
209
|
+
if (track.tracking_status === undefined) {
|
|
210
|
+
track.tracking_status = settings.tracking_status;
|
|
211
|
+
}
|
|
212
|
+
setSetting('trackinfo', track); // no i18n
|
|
213
|
+
setSetting('tracking_status', undefined); // no i18n
|
|
214
|
+
}
|
|
215
|
+
if (settings.token !== undefined) {
|
|
216
|
+
setSetting('token', undefined); // no i18n
|
|
217
|
+
}
|
|
175
218
|
}
|
|
176
|
-
/**
|
|
219
|
+
/**
|
|
220
|
+
* Sets one key of the stored device_info, and of this tab's copy: the uuid the device is
|
|
221
|
+
* registered under, whether it has had a session. Its other keys stay as they are.
|
|
222
|
+
*/
|
|
223
|
+
function setDeviceInfoKey(key, value) {
|
|
224
|
+
var device = Object.assign({}, settings.device_info && typeof settings.device_info === 'object' ? settings.device_info : {}); // no i18n
|
|
225
|
+
device[key] = value;
|
|
226
|
+
if (_ZAP._device_info && typeof _ZAP._device_info === 'object') { // no i18n
|
|
227
|
+
_ZAP._device_info[key] = value;
|
|
228
|
+
}
|
|
229
|
+
setSetting('device_info', device); // no i18n
|
|
230
|
+
}
|
|
231
|
+
/** device_info (uuid included), app_version_info, trackinfo (tracking_status included), users, user_info, and the rest. */
|
|
177
232
|
const user_defaults = {
|
|
178
233
|
all() {
|
|
179
234
|
return cloneObject(settings);
|
|
@@ -185,26 +240,63 @@ const user_defaults = {
|
|
|
185
240
|
add(key, value) {
|
|
186
241
|
setSetting(key, value);
|
|
187
242
|
},
|
|
243
|
+
/** As add(), and resolves once the value is in storage, where other tabs can read it. */
|
|
244
|
+
save(key, value) {
|
|
245
|
+
if (value === undefined) {
|
|
246
|
+
delete settings[key];
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
settings[key] = cloneObject(value);
|
|
250
|
+
}
|
|
251
|
+
return withBackend('save ' + key, undefined, function (b) { return writeSetting(b, key); }); // no i18n
|
|
252
|
+
},
|
|
188
253
|
clear() {
|
|
189
254
|
settings = {};
|
|
190
255
|
withBackend('clear settings', undefined, function (b) { return b.clearSettings(); }); // no i18n
|
|
191
256
|
},
|
|
192
257
|
};
|
|
193
|
-
/**
|
|
258
|
+
/**
|
|
259
|
+
* Re-reads `keys` from storage. Settings are loaded into memory once, when a tab starts, so a value
|
|
260
|
+
* another tab of this site wrote since then — the device ids it registered — is only in storage.
|
|
261
|
+
* A key storage doesn't hold keeps this tab's value.
|
|
262
|
+
*/
|
|
263
|
+
function reloadSettings(keys) {
|
|
264
|
+
return withBackend('reload settings', undefined, function (b) {
|
|
265
|
+
return b.loadSettings().then(function (loaded) {
|
|
266
|
+
keys.forEach(function (key) {
|
|
267
|
+
if (loaded[key] !== undefined) {
|
|
268
|
+
settings[key] = loaded[key];
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
/** The visitor's tracking status, stored in trackinfo as tracking_status. */
|
|
275
|
+
function storedTrackingStatus() {
|
|
276
|
+
var track = settings.trackinfo;
|
|
277
|
+
var status = track && typeof track === 'object' ? track.tracking_status : undefined; // no i18n
|
|
278
|
+
// a status only: getsdkconfig's own answer uses the same key for its per-module flags, and
|
|
279
|
+
// one stored by mistake must not read as a consent and stop all tracking
|
|
280
|
+
return status === AP_TRACKING_STATUS.USAGE_TRACKING_WITH_PII || status === AP_TRACKING_STATUS.USAGE_TRACKING_WITHOUT_PII
|
|
281
|
+
|| status === AP_TRACKING_STATUS.NO_TRACKING ? status : undefined;
|
|
282
|
+
}
|
|
283
|
+
/** Opt-in status, stored in the trackinfo setting as tracking_status. */
|
|
194
284
|
const tracking_preference = {
|
|
195
285
|
_tracking_status: 'tracking_status', // no i18n
|
|
196
286
|
all() {
|
|
197
287
|
return user_defaults.all();
|
|
198
288
|
},
|
|
199
289
|
opt_in_status() {
|
|
200
|
-
return (
|
|
290
|
+
return (storedTrackingStatus() || AP_TRACKING_STATUS.USAGE_TRACKING_WITHOUT_PII);
|
|
201
291
|
},
|
|
202
292
|
update_status(tracking_status) {
|
|
203
293
|
_ZAP._devicestatus = tracking_status;
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
294
|
+
var track = Object.assign({}, settings.trackinfo && typeof settings.trackinfo === 'object' ? settings.trackinfo : {}); // no i18n
|
|
295
|
+
track.tracking_status = tracking_status;
|
|
296
|
+
if (_ZAP._trackinfo && typeof _ZAP._trackinfo === 'object') { // no i18n
|
|
297
|
+
_ZAP._trackinfo.tracking_status = tracking_status;
|
|
298
|
+
}
|
|
299
|
+
setSetting('trackinfo', track); // no i18n
|
|
208
300
|
},
|
|
209
301
|
};
|
|
210
302
|
function getKeyFromDeviceInfo(key) {
|
|
@@ -216,4 +308,4 @@ function getKeyFromDeviceInfo(key) {
|
|
|
216
308
|
return null;
|
|
217
309
|
}
|
|
218
310
|
|
|
219
|
-
export {
|
|
311
|
+
export { engagement_transactions, error_transactions, feedbacklog_transactions, getKeyFromDeviceInfo, heatmap_transactions, reloadSettings, remotelog_transactions, setDeviceInfoKey, storageReady, storedTrackingStatus, tracking_preference, user_defaults };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adds the feedback form's styles to the page, once, as a <style> element, so no app imports or
|
|
3
|
+
* links a stylesheet: the css is carried in the JavaScript, for npm and the CDN builds alike.
|
|
4
|
+
*
|
|
5
|
+
* Nothing happens when `css` is empty (running from source, as the tests do) or when the page
|
|
6
|
+
* already has the styles (the element is marked data-apptics="style"). Never throws.
|
|
7
|
+
*/
|
|
8
|
+
export declare function injectStylesheet(css: string): void;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
|
+
/**
|
|
3
|
+
* Adds the feedback form's styles to the page, once, as a <style> element, so no app imports or
|
|
4
|
+
* links a stylesheet: the css is carried in the JavaScript, for npm and the CDN builds alike.
|
|
5
|
+
*
|
|
6
|
+
* Nothing happens when `css` is empty (running from source, as the tests do) or when the page
|
|
7
|
+
* already has the styles (the element is marked data-apptics="style"). Never throws.
|
|
8
|
+
*/
|
|
9
|
+
function injectStylesheet(css) {
|
|
10
|
+
try {
|
|
11
|
+
if (!css || typeof document === 'undefined') { // no i18n
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (document.querySelector('[data-apptics="style"]')) { // no i18n
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
var style = document.createElement('style'); // no i18n
|
|
18
|
+
style.setAttribute('data-apptics', 'style'); // no i18n
|
|
19
|
+
style.textContent = css;
|
|
20
|
+
(document.head || document.documentElement).appendChild(style);
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
// the form still works unstyled; the app must not break over a stylesheet
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { injectStylesheet };
|
|
@@ -81,3 +81,5 @@ export declare function getMetaObj(): Dict;
|
|
|
81
81
|
* and feedback (P11).
|
|
82
82
|
*/
|
|
83
83
|
export declare function rejectIfNoDeviceIds(label: string): Promise<never> | null;
|
|
84
|
+
/** Whether device/add has given this browser its deviceid. */
|
|
85
|
+
export declare function hasDeviceId(): boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
2
|
import { API_VERSIONS, PATHS_WITHOUT_ORG, DEFAULT_API_PATHS, DEBUG_CAPABLE_PATHS, AP_TRACKING_STATUS, DEVICE_NAME_MAX } from './constants.js';
|
|
3
3
|
import { getConfig, _ZAP } from './state.js';
|
|
4
4
|
import { Console } from './logger.js';
|
|
@@ -139,19 +139,17 @@ function getParameters(path) {
|
|
|
139
139
|
// v2 device/add declares neither identifier, platform nor appversion: the build is already
|
|
140
140
|
// known from app/addversion, and sending an undeclared param is refused as EXTRA_PARAM_FOUND.
|
|
141
141
|
// What it does declare as mandatory is appversionid, which v1 treated as optional.
|
|
142
|
+
// isanonrequired is always false: the web SDK has no anonymous mode, only the tracking
|
|
143
|
+
// statuses (with PII, without PII, none), which devicestatus carries.
|
|
142
144
|
if (path == 'regdevice') { // no i18n
|
|
143
|
-
returnVal = '?isanonrequired=
|
|
145
|
+
returnVal = '?isanonrequired=false&devicestatus=' + _ZAP._devicestatus; // no i18n
|
|
144
146
|
if (!isEmpty(_ZAP._device_info.deviceid)) {
|
|
145
147
|
returnVal += '&deviceid=' + encodeURIComponent(String(_ZAP._device_info.deviceid)); // no i18n
|
|
146
148
|
}
|
|
147
149
|
return returnVal + mandatoryParams(returnVal);
|
|
148
150
|
}
|
|
149
|
-
// getsdkconfig
|
|
150
|
-
|
|
151
|
-
// with NOT_AUTHENTICATED. getupdates declares the same param with plain paramdecrypt, so it
|
|
152
|
-
// does carry one. It still needs appversionid and frameworkid, added at the end.
|
|
153
|
-
var identifiesDevice = path != 'sdkconfig'; // no i18n
|
|
154
|
-
if (identifiesDevice) {
|
|
151
|
+
// getsdkconfig carries no deviceid: the user's ids below are what it answers for
|
|
152
|
+
if (path != 'sdkconfig') { // no i18n
|
|
155
153
|
if (isEmpty(_ZAP._device_info.deviceid)) {
|
|
156
154
|
hooks.refreshDeviceInfo();
|
|
157
155
|
// the device is missing, but appversionid and frameworkid are mandatory regardless:
|
|
@@ -172,15 +170,17 @@ function getParameters(path) {
|
|
|
172
170
|
}
|
|
173
171
|
return returnVal + mandatoryParams(returnVal);
|
|
174
172
|
}
|
|
175
|
-
// add userid and groupid if opt_in_status is USAGE_TRACKING_WITH_PII
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
173
|
+
// add userid and groupid if opt_in_status is USAGE_TRACKING_WITH_PII. getupdates doesn't declare
|
|
174
|
+
// them, and refuses userid as EXTRA_PARAM_FOUND; it has no use for them either, since remote
|
|
175
|
+
// config conditions on the user are evaluated here, against the rule set it answers with
|
|
176
|
+
var carriesUser = path != 'reguser' && path != 'getupdates'; // no i18n
|
|
177
|
+
if (carriesUser && opt_in_status() == AP_TRACKING_STATUS.USAGE_TRACKING_WITH_PII) {
|
|
178
|
+
if (_ZAP._user_info.hasOwnProperty('userid') && !isEmpty(_ZAP._user_info.userid)) { // no i18n
|
|
179
|
+
// getsdkconfig has no deviceid before it, so its userid starts the query
|
|
180
|
+
returnVal += (returnVal === '' ? '?' : '&') + 'userid=' + encodeURIComponent(String(_ZAP._user_info.userid)); // no i18n
|
|
181
|
+
}
|
|
182
|
+
if (_ZAP._user_info.hasOwnProperty('groupid') && !isEmpty(_ZAP._user_info.groupid)) { // no i18n
|
|
183
|
+
returnVal += (returnVal === '' ? '?' : '&') + 'customergroupid=' + encodeURIComponent(String(_ZAP._user_info.groupid)); // no i18n
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
186
|
returnVal += deviceNameParam(path, returnVal);
|
|
@@ -417,9 +417,20 @@ function getMetaObj() {
|
|
|
417
417
|
function rejectIfNoDeviceIds(label) {
|
|
418
418
|
if (isEmpty(getHeaderParams('apid')) && isEmpty(getHeaderParams('mapid'))) { // no i18n
|
|
419
419
|
hooks.refreshDeviceInfo();
|
|
420
|
-
return Promise.reject(label + ': You must call
|
|
420
|
+
return Promise.reject(label + ': You must call Apptics.init() first'); // no i18n
|
|
421
|
+
}
|
|
422
|
+
// app/addversion has answered, device/add not yet (offline, or it failed): what is stored waits
|
|
423
|
+
// for the device it belongs to rather than going out without a deviceid. The refresh registers
|
|
424
|
+
// the device, joining a registration already in flight
|
|
425
|
+
if (!hasDeviceId()) {
|
|
426
|
+
hooks.refreshDeviceInfo();
|
|
427
|
+
return Promise.reject(label + ': the device is not registered yet, kept for the next send'); // no i18n
|
|
421
428
|
}
|
|
422
429
|
return null;
|
|
423
430
|
}
|
|
431
|
+
/** Whether device/add has given this browser its deviceid. */
|
|
432
|
+
function hasDeviceId() {
|
|
433
|
+
return !isEmpty(_ZAP._device_info && _ZAP._device_info.deviceid) || !isEmpty(getKeyFromDeviceInfo('deviceid')); // no i18n
|
|
434
|
+
}
|
|
424
435
|
|
|
425
|
-
export { KEEPALIVE_BUDGET, REQUEST_TIMEOUT_MS, apiHeaders, getHeaderParams, getMetaObj, getParameters, getUrlWithParams, isPermanentRefusal, makeRequest, postKeepalive, postToApptics, rejectIfDisabled, rejectIfNoDeviceIds, rejectIfOffline, usesDebugApi };
|
|
436
|
+
export { KEEPALIVE_BUDGET, REQUEST_TIMEOUT_MS, apiHeaders, getHeaderParams, getMetaObj, getParameters, getUrlWithParams, hasDeviceId, isPermanentRefusal, makeRequest, postKeepalive, postToApptics, rejectIfDisabled, rejectIfNoDeviceIds, rejectIfOffline, usesDebugApi };
|
package/dist/esm/core/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
2
|
import { AP_CONSTANTS } from './constants.js';
|
|
3
3
|
|
|
4
4
|
/** Returned from an `each` iterator to stop iterating objects and array-likes. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
2
|
import { Console } from './logger.js';
|
|
3
3
|
import { isEmpty, isEmptyObj } from './utils.js';
|
|
4
4
|
|
|
@@ -218,7 +218,7 @@ function validateScreenName(str) {
|
|
|
218
218
|
}
|
|
219
219
|
// Define the regular expression pattern
|
|
220
220
|
//^[a-zA-Z][\\w\\s]{1,100}$
|
|
221
|
-
const pattern = /^[\w\s.\-_
|
|
221
|
+
const pattern = /^[\w\s.\-_&/:*]{0,99}$/;
|
|
222
222
|
// Test if the string matches the pattern
|
|
223
223
|
return pattern.test(str);
|
|
224
224
|
}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
/** Whether we already hold usable ids for the app and version running now. */
|
|
2
|
-
export declare function hasAppVersion(): boolean;
|
|
3
1
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* rather than carrying on to calls that would be refused for missing them.
|
|
2
|
+
* A fingerprint of the auth key, which is what is stored to tell one key from another: enough to
|
|
3
|
+
* notice that init() was given a different one, without keeping a second copy of the key itself.
|
|
4
|
+
* FNV-1a, 32 bits, as hex; '' for no key.
|
|
8
5
|
*/
|
|
6
|
+
export declare function keyFingerprint(key: unknown): string;
|
|
7
|
+
/**
|
|
8
|
+
* Whether we already hold usable ids for the app, auth key and version running now. Ids stored by
|
|
9
|
+
* a build that kept no key fingerprint register again once, and the answer then records it.
|
|
10
|
+
*/
|
|
11
|
+
export declare function hasAppVersion(): boolean;
|
|
12
|
+
export declare function appVersionFailedForNetwork(): boolean;
|
|
9
13
|
export declare function registerAppVersion(): Promise<boolean>;
|
|
10
14
|
/**
|
|
11
15
|
* Puts the stored ids back on `_ZAP._device_info`.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
2
|
import { _ZAP } from '../core/state.js';
|
|
3
3
|
import { Console, warnAlways } from '../core/logger.js';
|
|
4
4
|
import { isEmpty, isSuccess } from '../core/utils.js';
|
|
@@ -37,13 +37,34 @@ const REQUIRED_KEYS = ['aaid', 'portalid', 'projectid', 'apid', 'mapid', 'appver
|
|
|
37
37
|
function missingKeys(data) {
|
|
38
38
|
return REQUIRED_KEYS.filter(function (key) { return isEmpty(data[key]); });
|
|
39
39
|
}
|
|
40
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* A fingerprint of the auth key, which is what is stored to tell one key from another: enough to
|
|
42
|
+
* notice that init() was given a different one, without keeping a second copy of the key itself.
|
|
43
|
+
* FNV-1a, 32 bits, as hex; '' for no key.
|
|
44
|
+
*/
|
|
45
|
+
function keyFingerprint(key) {
|
|
46
|
+
var text = isEmpty(key) ? '' : String(key); // no i18n
|
|
47
|
+
if (text === '') { // no i18n
|
|
48
|
+
return ''; // no i18n
|
|
49
|
+
}
|
|
50
|
+
var hash = 0x811c9dc5;
|
|
51
|
+
for (var i = 0; i < text.length; i++) {
|
|
52
|
+
hash ^= text.charCodeAt(i);
|
|
53
|
+
hash = Math.imul(hash, 0x01000193) >>> 0;
|
|
54
|
+
}
|
|
55
|
+
return ('0000000' + hash.toString(16)).slice(-8); // no i18n
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Whether we already hold usable ids for the app, auth key and version running now. Ids stored by
|
|
59
|
+
* a build that kept no key fingerprint register again once, and the answer then records it.
|
|
60
|
+
*/
|
|
41
61
|
function hasAppVersion() {
|
|
42
62
|
var saved = stored();
|
|
43
63
|
return missingKeys(saved).length === 0
|
|
44
64
|
&& saved.appversion === _ZAP._defaultoptions.appversion
|
|
45
65
|
&& saved.identifier === _ZAP._defaultoptions.identifier
|
|
46
|
-
&& saved.serviceUrl === _ZAP._defaultoptions.serviceUrl
|
|
66
|
+
&& saved.serviceUrl === _ZAP._defaultoptions.serviceUrl
|
|
67
|
+
&& saved.zakhash === keyFingerprint(_ZAP._defaultoptions.zak);
|
|
47
68
|
}
|
|
48
69
|
/** Puts the ids where the rest of the SDK reads them from. */
|
|
49
70
|
function apply(data) {
|
|
@@ -78,7 +99,16 @@ function apply(data) {
|
|
|
78
99
|
* Resolves true when the ids are in place, false when they are not — the caller stops there
|
|
79
100
|
* rather than carrying on to calls that would be refused for missing them.
|
|
80
101
|
*/
|
|
102
|
+
/**
|
|
103
|
+
* Whether the last registration failed for want of a network (offline, a dropped connection, a
|
|
104
|
+
* timeout) rather than because the server answered no. Only the first is worth trying again.
|
|
105
|
+
*/
|
|
106
|
+
var failedForNetwork = false;
|
|
107
|
+
function appVersionFailedForNetwork() {
|
|
108
|
+
return failedForNetwork;
|
|
109
|
+
}
|
|
81
110
|
function registerAppVersion() {
|
|
111
|
+
failedForNetwork = false;
|
|
82
112
|
if (hasAppVersion()) {
|
|
83
113
|
apply(stored());
|
|
84
114
|
Console.log(LABEL + ': reusing the ids stored for ' + _ZAP._defaultoptions.appversion); // no i18n
|
|
@@ -115,6 +145,7 @@ function registerAppVersion() {
|
|
|
115
145
|
appversion: _ZAP._defaultoptions.appversion,
|
|
116
146
|
identifier: _ZAP._defaultoptions.identifier,
|
|
117
147
|
serviceUrl: _ZAP._defaultoptions.serviceUrl,
|
|
148
|
+
zakhash: keyFingerprint(_ZAP._defaultoptions.zak),
|
|
118
149
|
};
|
|
119
150
|
RESULT_KEYS.forEach(function (key) {
|
|
120
151
|
if (!isEmpty(data[key])) {
|
|
@@ -126,6 +157,8 @@ function registerAppVersion() {
|
|
|
126
157
|
return true;
|
|
127
158
|
})
|
|
128
159
|
.catch(function (err) {
|
|
160
|
+
// a server answer carries serverResult; a request that never got one does not
|
|
161
|
+
failedForNetwork = !(err && err.serverResult) || navigator.onLine === false;
|
|
129
162
|
warnAlways(LABEL + ': could not register this app version: ' + String(err && err.message ? err.message : err)); // no i18n
|
|
130
163
|
return false;
|
|
131
164
|
})
|
|
@@ -150,4 +183,4 @@ function clearAppVersion() {
|
|
|
150
183
|
user_defaults.add(STORE_KEY, undefined);
|
|
151
184
|
}
|
|
152
185
|
|
|
153
|
-
export { applyStoredAppVersion, clearAppVersion, hasAppVersion, registerAppVersion };
|
|
186
|
+
export { appVersionFailedForNetwork, applyStoredAppVersion, clearAppVersion, hasAppVersion, keyFingerprint, registerAppVersion };
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import type { DeviceInfo, Dict, ServerResult } from '../types.js';
|
|
2
2
|
export declare function checkAndUpdateDeviceInfo(): void;
|
|
3
3
|
export declare function addOrUpdateDeviceID(device_info: DeviceInfo, previous?: DeviceInfo): void;
|
|
4
|
+
/**
|
|
5
|
+
* Sets up this browser's device at start-up: the uuid, the device info, and a registration when
|
|
6
|
+
* the browser has none.
|
|
7
|
+
*
|
|
8
|
+
* Settings are this tab's own copy, loaded when it started. On a browser with no device yet, two
|
|
9
|
+
* tabs started together would each register it and store two devices, so the first visit runs
|
|
10
|
+
* under a lock shared by every tab of the site: the tab that gets it re-reads storage, registers
|
|
11
|
+
* only when no other tab has, and keeps the lock until the new ids are stored. The next tab then
|
|
12
|
+
* finds them. Start-up goes on as soon as the device info is set, without waiting for the server.
|
|
13
|
+
*/
|
|
14
|
+
export declare function prepareDevice(): Promise<void>;
|
|
4
15
|
/** True while the device has no server ids, so nothing can be sent yet. */
|
|
5
16
|
export declare function needsDevice(): boolean;
|
|
6
17
|
/**
|
|
@@ -17,7 +28,22 @@ export declare function getUpdatesFromServer(): Promise<Dict>;
|
|
|
17
28
|
*/
|
|
18
29
|
export declare function restoreServerSettings(): void;
|
|
19
30
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
31
|
+
* next_check_after as a time: the server's value is milliseconds, either a timestamp or a wait
|
|
32
|
+
* from now. Anything below 1e12 (2001 as a timestamp) can only be a wait.
|
|
33
|
+
*/
|
|
34
|
+
export declare function nextCheckTime(value: unknown, now: number): number;
|
|
35
|
+
/**
|
|
36
|
+
* Asks for the server settings now if the device is registered, then schedules the next ask
|
|
37
|
+
* for the time the answer gave in next_check_after. On a first visit the ids don't exist yet;
|
|
38
|
+
* registerDeviceWithApptics calls this as soon as device/add succeeds.
|
|
22
39
|
*/
|
|
23
40
|
export declare function refreshServerSettings(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Start-up's getsdkconfig. Asked on a first visit and on the first page load in each tab; any
|
|
43
|
+
* other load (a reload, a link to another page of the site, back/forward) uses the saved answer
|
|
44
|
+
* and waits for its next_check_after, unless that has already passed. Nothing happens if one has
|
|
45
|
+
* gone out already on this load (after device/add).
|
|
46
|
+
*/
|
|
47
|
+
export declare function startServerSettingChecks(): void;
|
|
48
|
+
/** reset(): no more checks, and the next init() asks again straight away. */
|
|
49
|
+
export declare function stopServerSettingChecks(): void;
|