@zoho_apptics/apptics-js-sdk 2.0.0-beta → 2.0.0-beta.1
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 +111 -5
- package/README.md +399 -300
- 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-VYr43KcB.min.js +3 -0
- package/dist/chunks/lifecycle-VYr43KcB.min.js.map +1 -0
- package/dist/cjs/auto-init.d.ts +3 -3
- package/dist/cjs/auto-init.js +1 -1
- package/dist/cjs/core/attempts.js +1 -1
- package/dist/cjs/core/batch.js +2 -1
- package/dist/cjs/core/callsite.d.ts +6 -0
- package/dist/cjs/core/callsite.js +25 -3
- package/dist/cjs/core/consent.d.ts +5 -1
- package/dist/cjs/core/consent.js +8 -6
- package/dist/cjs/core/constants.d.ts +35 -10
- package/dist/cjs/core/constants.js +31 -15
- 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.js +1 -1
- 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 +2 -4
- package/dist/cjs/core/hooks.js +2 -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 +3 -2
- package/dist/cjs/core/state.js +2 -2
- package/dist/cjs/core/storage.d.ts +20 -5
- package/dist/cjs/core/storage.js +115 -17
- 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 +19 -4
- package/dist/cjs/core/utils.js +1 -1
- package/dist/cjs/core/validate.js +2 -2
- package/dist/cjs/device/appversion.d.ts +1 -6
- package/dist/cjs/device/appversion.js +13 -1
- package/dist/cjs/device/index.d.ts +11 -0
- package/dist/cjs/device/index.js +120 -20
- 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 +6 -1
- package/dist/cjs/engagement/session.d.ts +12 -3
- package/dist/cjs/engagement/session.js +161 -25
- package/dist/cjs/engagement/track.js +45 -20
- package/dist/cjs/errors/send.js +1 -1
- package/dist/cjs/errors/track.d.ts +1 -1
- package/dist/cjs/errors/track.js +46 -6
- package/dist/cjs/feedback/controls.d.ts +6 -0
- package/dist/cjs/feedback/controls.js +31 -1
- package/dist/cjs/feedback/index.d.ts +8 -7
- package/dist/cjs/feedback/index.js +32 -13
- package/dist/cjs/feedback/logs.d.ts +10 -5
- package/dist/cjs/feedback/logs.js +52 -13
- package/dist/cjs/feedback/quartz.d.ts +18 -0
- package/dist/cjs/feedback/quartz.js +105 -0
- package/dist/cjs/feedback/send.d.ts +3 -0
- package/dist/cjs/feedback/send.js +28 -3
- 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 +12 -12
- package/dist/cjs/feedback/ui.d.ts +14 -6
- package/dist/cjs/feedback/ui.js +126 -48
- package/dist/cjs/heatmap/send.js +1 -1
- package/dist/cjs/heatmap/track.d.ts +1 -1
- package/dist/cjs/heatmap/track.js +87 -16
- package/dist/cjs/index.d.ts +17 -63
- package/dist/cjs/index.js +104 -92
- package/dist/cjs/lifecycle.d.ts +8 -1
- package/dist/cjs/lifecycle.js +258 -62
- 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 +3 -3
- package/dist/cjs/remoteconfig/fetch.js +9 -23
- package/dist/cjs/remoteconfig/index.d.ts +10 -8
- package/dist/cjs/remoteconfig/index.js +65 -39
- package/dist/cjs/remoteconfig/store.js +1 -1
- package/dist/cjs/remoteconfig/tz-countries.d.ts +8 -0
- package/dist/cjs/remoteconfig/tz-countries.js +13 -0
- 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 +30 -58
- package/dist/cjs/remotelog/send.js +10 -10
- package/dist/cjs/remotelogger/index.d.ts +12 -0
- package/dist/cjs/remotelogger/index.js +18 -0
- package/dist/cjs/scheduler.js +2 -2
- package/dist/cjs/types.d.ts +155 -82
- package/dist/cjs/user/index.js +11 -6
- package/dist/esm/auto-init.d.ts +3 -3
- package/dist/esm/auto-init.js +1 -1
- package/dist/esm/core/attempts.js +1 -1
- package/dist/esm/core/batch.js +2 -1
- package/dist/esm/core/callsite.d.ts +6 -0
- package/dist/esm/core/callsite.js +25 -4
- package/dist/esm/core/consent.d.ts +5 -1
- package/dist/esm/core/consent.js +9 -7
- package/dist/esm/core/constants.d.ts +35 -10
- package/dist/esm/core/constants.js +30 -15
- 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.js +1 -1
- 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 +2 -4
- package/dist/esm/core/hooks.js +2 -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 +3 -2
- package/dist/esm/core/state.js +2 -2
- package/dist/esm/core/storage.d.ts +20 -5
- package/dist/esm/core/storage.js +113 -18
- 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 +19 -5
- package/dist/esm/core/utils.js +1 -1
- package/dist/esm/core/validate.js +2 -2
- package/dist/esm/device/appversion.d.ts +1 -6
- package/dist/esm/device/appversion.js +13 -2
- package/dist/esm/device/index.d.ts +11 -0
- package/dist/esm/device/index.js +123 -24
- 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 +6 -1
- package/dist/esm/engagement/session.d.ts +12 -3
- package/dist/esm/engagement/session.js +162 -29
- package/dist/esm/engagement/track.js +52 -27
- package/dist/esm/errors/send.js +1 -1
- package/dist/esm/errors/track.d.ts +1 -1
- package/dist/esm/errors/track.js +46 -6
- package/dist/esm/feedback/controls.d.ts +6 -0
- package/dist/esm/feedback/controls.js +31 -2
- package/dist/esm/feedback/index.d.ts +8 -7
- package/dist/esm/feedback/index.js +34 -13
- package/dist/esm/feedback/logs.d.ts +10 -5
- package/dist/esm/feedback/logs.js +54 -15
- package/dist/esm/feedback/quartz.d.ts +18 -0
- package/dist/esm/feedback/quartz.js +99 -0
- package/dist/esm/feedback/send.d.ts +3 -0
- package/dist/esm/feedback/send.js +28 -5
- 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 +12 -12
- package/dist/esm/feedback/ui.d.ts +14 -6
- package/dist/esm/feedback/ui.js +126 -49
- package/dist/esm/heatmap/send.js +1 -1
- package/dist/esm/heatmap/track.d.ts +1 -1
- package/dist/esm/heatmap/track.js +87 -16
- package/dist/esm/index.d.ts +17 -63
- package/dist/esm/index.js +108 -80
- package/dist/esm/lifecycle.d.ts +8 -1
- package/dist/esm/lifecycle.js +266 -71
- 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 +3 -3
- package/dist/esm/remoteconfig/fetch.js +9 -23
- package/dist/esm/remoteconfig/index.d.ts +10 -8
- package/dist/esm/remoteconfig/index.js +66 -40
- package/dist/esm/remoteconfig/store.js +1 -1
- package/dist/esm/remoteconfig/tz-countries.d.ts +8 -0
- package/dist/esm/remoteconfig/tz-countries.js +11 -0
- 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 +32 -60
- package/dist/esm/remotelog/send.js +12 -12
- package/dist/esm/remotelogger/index.d.ts +12 -0
- package/dist/esm/remotelogger/index.js +13 -0
- package/dist/esm/scheduler.js +2 -2
- package/dist/esm/types.d.ts +155 -82
- package/dist/esm/user/index.js +12 -6
- package/dist/feedback.esm.min.js +2 -2
- package/dist/feedback.esm.min.js.map +1 -1
- package/package.json +14 -16
- 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/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/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
|
@@ -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.1 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -10,6 +10,22 @@
|
|
|
10
10
|
* wrapped so a stack we cannot parse costs a line its call site and nothing more.
|
|
11
11
|
*/
|
|
12
12
|
const NO_CALL_SITE = { filename: '', linenumber: 0, fn: '' };
|
|
13
|
+
/**
|
|
14
|
+
* A call typed in the browser's developer console: there is no file, line or function to report,
|
|
15
|
+
* only the console's own placeholder for its input, so the line says plainly that it came from
|
|
16
|
+
* nowhere in the app. file_name and the function field both accept `-`.
|
|
17
|
+
*/
|
|
18
|
+
const CONSOLE_CALL_SITE = { filename: '-', linenumber: 0, fn: '-' };
|
|
19
|
+
/**
|
|
20
|
+
* The frame of code run from the developer console, in each browser:
|
|
21
|
+
* V8 (Chrome, Edge): ` at <anonymous>:1:15` (the file is <anonymous>)
|
|
22
|
+
* Firefox: `@debugger eval code:1:15`
|
|
23
|
+
* Safari: `global code` or `eval code`, with no location at all
|
|
24
|
+
* V8 names a string run through eval or new Function <anonymous> too; it is no file either.
|
|
25
|
+
*/
|
|
26
|
+
const CONSOLE_FILE_V8 = '<anonymous>'; // no i18n
|
|
27
|
+
const CONSOLE_FIREFOX = /debugger eval code/; // no i18n
|
|
28
|
+
const CONSOLE_SAFARI = /^(global|eval) code(@|$)/; // no i18n
|
|
13
29
|
/** logSDK declares max-len="100" on filename. */
|
|
14
30
|
const FILENAME_MAX = 100;
|
|
15
31
|
/**
|
|
@@ -63,14 +79,19 @@ function callSiteFromStack(stack, skip) {
|
|
|
63
79
|
var lines = stack.split('\n');
|
|
64
80
|
var seen = 0;
|
|
65
81
|
for (var i = 0; i < lines.length; i++) {
|
|
66
|
-
var
|
|
82
|
+
var raw = (lines[i] || '').trim(); // no i18n
|
|
83
|
+
var frame = parseFrame(raw);
|
|
67
84
|
if (frame === null) {
|
|
85
|
+
// Safari's console frame has no location, so it is never a frame parseFrame reads
|
|
86
|
+
if (seen === skip && CONSOLE_SAFARI.test(raw)) {
|
|
87
|
+
return CONSOLE_CALL_SITE;
|
|
88
|
+
}
|
|
68
89
|
continue;
|
|
69
90
|
}
|
|
70
91
|
if (seen++ < skip) {
|
|
71
92
|
continue;
|
|
72
93
|
}
|
|
73
|
-
return frame;
|
|
94
|
+
return frame.filename === CONSOLE_FILE_V8 || CONSOLE_FIREFOX.test(raw) ? CONSOLE_CALL_SITE : frame;
|
|
74
95
|
}
|
|
75
96
|
return NO_CALL_SITE;
|
|
76
97
|
}
|
|
@@ -88,6 +109,7 @@ function callSite(skip) {
|
|
|
88
109
|
}
|
|
89
110
|
}
|
|
90
111
|
|
|
112
|
+
exports.CONSOLE_CALL_SITE = CONSOLE_CALL_SITE;
|
|
91
113
|
exports.NO_CALL_SITE = NO_CALL_SITE;
|
|
92
114
|
exports.callSite = callSite;
|
|
93
115
|
exports.callSiteFromStack = callSiteFromStack;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { TrackingStatus } from '../types.js';
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* DNT counts only when not ignored; while it counts, tracking is NO_TRACKING (opt_in_status).
|
|
4
|
+
* Decided on every visit and never stored: storing it made one visit with DNT on look like the
|
|
5
|
+
* visitor's own choice, so tracking stayed off after DNT was turned off or ignore_do_not_track set.
|
|
6
|
+
*/
|
|
3
7
|
export declare function hasDoNotTrackEnabled(): boolean;
|
|
4
8
|
export declare function opt_in_status(): TrackingStatus;
|
|
5
9
|
export declare function shouldTrackOrSendData(): boolean;
|
package/dist/cjs/core/consent.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.1 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var constants = require('./constants.js');
|
|
@@ -9,15 +9,17 @@ var storage = require('./storage.js');
|
|
|
9
9
|
var env = require('./env.js');
|
|
10
10
|
var hooks = require('./hooks.js');
|
|
11
11
|
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* DNT counts only when not ignored; while it counts, tracking is NO_TRACKING (opt_in_status).
|
|
14
|
+
* Decided on every visit and never stored: storing it made one visit with DNT on look like the
|
|
15
|
+
* visitor's own choice, so tracking stayed off after DNT was turned off or ignore_do_not_track set.
|
|
16
|
+
*/
|
|
13
17
|
function hasDoNotTrackEnabled() {
|
|
14
18
|
if (state._ZAP._ignoreDnt) {
|
|
15
19
|
return false;
|
|
16
20
|
}
|
|
17
21
|
if (env.isDntOn()) {
|
|
18
|
-
logger.Console.warn('hasDoNotTrackEnabled: DoNotTrack is enabled'); // no i18n
|
|
19
|
-
setTrackingStatus(constants.AP_TRACKING_STATUS.NO_TRACKING);
|
|
20
|
-
logger.Console.log('hasDoNotTrackEnabled: Setting tracking status to NO_TRACKING'); // no i18n
|
|
22
|
+
logger.Console.warn('hasDoNotTrackEnabled: DoNotTrack is enabled, so nothing is tracked'); // no i18n
|
|
21
23
|
return true;
|
|
22
24
|
}
|
|
23
25
|
return false;
|
|
@@ -43,7 +45,7 @@ function shouldTrackOrSendData() {
|
|
|
43
45
|
*/
|
|
44
46
|
function canTrack(caller) {
|
|
45
47
|
if (!state._ZAP._token) {
|
|
46
|
-
logger.Console.warn('apptics.' + caller + ': You must call
|
|
48
|
+
logger.Console.warn('apptics.' + caller + ': You must call Apptics.init() first'); // no i18n
|
|
47
49
|
return false;
|
|
48
50
|
}
|
|
49
51
|
if (env.is_apptics_disabled()) {
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A screen_routes entry as init() keeps it, ready to match: a route pattern, or an exact path or a
|
|
3
|
+
* regular expression with the name it records.
|
|
4
|
+
*/
|
|
5
|
+
export type ScreenRouteRule = {
|
|
6
|
+
kind: 'pattern';
|
|
7
|
+
pattern: string;
|
|
8
|
+
} | {
|
|
9
|
+
kind: 'equals';
|
|
10
|
+
path: string;
|
|
11
|
+
name: string;
|
|
12
|
+
} | {
|
|
13
|
+
kind: 'regex';
|
|
14
|
+
regex: RegExp;
|
|
15
|
+
name: string;
|
|
16
|
+
};
|
|
1
17
|
export declare const AP_TRACKING_STATUS: Readonly<{
|
|
2
18
|
readonly USAGE_TRACKING_WITH_PII: 1;
|
|
3
19
|
readonly USAGE_TRACKING_WITHOUT_PII: 4;
|
|
@@ -117,7 +133,6 @@ export declare const AP_CONFIG: Readonly<{
|
|
|
117
133
|
debug: boolean;
|
|
118
134
|
track_by_default: true;
|
|
119
135
|
ignore_do_not_track: boolean;
|
|
120
|
-
remote_log: boolean;
|
|
121
136
|
/**
|
|
122
137
|
* Wrap XHR and fetch to record the app's API calls without it calling startTrackApi(). Off by
|
|
123
138
|
* default: the hostnames and paths of every request an app makes is a wider grant than events
|
|
@@ -130,15 +145,16 @@ export declare const AP_CONFIG: Readonly<{
|
|
|
130
145
|
*/
|
|
131
146
|
track_screen: boolean;
|
|
132
147
|
/**
|
|
133
|
-
*
|
|
134
|
-
*
|
|
148
|
+
* How automatic screen tracking names a path, as init() keeps the config's screen_routes: route
|
|
149
|
+
* patterns (`/users/{id}/orders`, each id recorded as a star), exact paths and regular
|
|
150
|
+
* expressions with a name. Tried in order; a path none matches keeps its own name.
|
|
135
151
|
*/
|
|
136
|
-
|
|
152
|
+
screen_routes: ScreenRouteRule[];
|
|
137
153
|
/**
|
|
138
|
-
*
|
|
139
|
-
*
|
|
154
|
+
* The feedback form's theme: 'light', 'dark', or 'auto' to follow the visitor's system setting.
|
|
155
|
+
* 'auto' by default.
|
|
140
156
|
*/
|
|
141
|
-
|
|
157
|
+
feedback_theme: "light" | "dark" | "auto";
|
|
142
158
|
/**
|
|
143
159
|
* How long a visit must last before its session is stored, in milliseconds. A shorter visit with
|
|
144
160
|
* nothing tracked in it is dropped: a bounce or a crawler is not a session. Anything tracked
|
|
@@ -187,7 +203,13 @@ export type ApConfig = {
|
|
|
187
203
|
* What init() must be given. Everything else the SDK needs — aaid, the portal and project ids that
|
|
188
204
|
* go in every url — comes back from app/addversion, which these four are enough to call.
|
|
189
205
|
*/
|
|
190
|
-
export declare const REQUIRED_CONFIG: readonly ["
|
|
206
|
+
export declare const REQUIRED_CONFIG: readonly ["base_url", "auth_key", "app_domain", "appversion"];
|
|
207
|
+
/**
|
|
208
|
+
* The init() keys and the names the SDK keeps them under inside (and in app_version_info, which
|
|
209
|
+
* already-visited browsers have stored): base_url is the host, auth_key the `zak` header, and
|
|
210
|
+
* app_domain the app's identifier.
|
|
211
|
+
*/
|
|
212
|
+
export declare const CONFIG_KEYS: Readonly<Record<string, string>>;
|
|
191
213
|
/**
|
|
192
214
|
* Paths with a `debug/` twin. The debug endpoints take the same body and answer with a request id
|
|
193
215
|
* and a link to the server-side logs for that request, which is how a payload is traced end to
|
|
@@ -207,6 +229,9 @@ export declare const RETRY_CAPABLE_PATHS: Readonly<Record<string, boolean>>;
|
|
|
207
229
|
* called before those ids are known, so it cannot carry them.
|
|
208
230
|
*/
|
|
209
231
|
export declare const PATHS_WITHOUT_ORG: Readonly<Record<string, boolean>>;
|
|
210
|
-
/**
|
|
211
|
-
|
|
232
|
+
/**
|
|
233
|
+
* Earlier names of the init() keys: 2.0.0-beta's serviceUrl, zak and identifier, and the 1.x
|
|
234
|
+
* console snippet's base_domain and token. Still read, with a warning naming the key to use.
|
|
235
|
+
*/
|
|
236
|
+
export declare const RETIRED_CONFIG_NAMES: Readonly<Record<string, string>>;
|
|
212
237
|
export declare const BLOCKED_WS: readonly string[];
|
|
@@ -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.1 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
const AP_TRACKING_STATUS = Object.freeze({
|
|
@@ -140,8 +140,6 @@ const AP_CONFIG = Object.freeze({
|
|
|
140
140
|
debug: false,
|
|
141
141
|
track_by_default: true,
|
|
142
142
|
ignore_do_not_track: false,
|
|
143
|
-
// the SDK's own failure reports to the Remote Logger page: off unless the app passes remote_log: true
|
|
144
|
-
remote_log: false,
|
|
145
143
|
/**
|
|
146
144
|
* Wrap XHR and fetch to record the app's API calls without it calling startTrackApi(). Off by
|
|
147
145
|
* default: the hostnames and paths of every request an app makes is a wider grant than events
|
|
@@ -154,15 +152,16 @@ const AP_CONFIG = Object.freeze({
|
|
|
154
152
|
*/
|
|
155
153
|
track_screen: true,
|
|
156
154
|
/**
|
|
157
|
-
*
|
|
158
|
-
*
|
|
155
|
+
* How automatic screen tracking names a path, as init() keeps the config's screen_routes: route
|
|
156
|
+
* patterns (`/users/{id}/orders`, each id recorded as a star), exact paths and regular
|
|
157
|
+
* expressions with a name. Tried in order; a path none matches keeps its own name.
|
|
159
158
|
*/
|
|
160
|
-
|
|
159
|
+
screen_routes: [],
|
|
161
160
|
/**
|
|
162
|
-
*
|
|
163
|
-
*
|
|
161
|
+
* The feedback form's theme: 'light', 'dark', or 'auto' to follow the visitor's system setting.
|
|
162
|
+
* 'auto' by default.
|
|
164
163
|
*/
|
|
165
|
-
|
|
164
|
+
feedback_theme: 'auto',
|
|
166
165
|
/**
|
|
167
166
|
* How long a visit must last before its session is stored, in milliseconds. A shorter visit with
|
|
168
167
|
* nothing tracked in it is dropped: a bounce or a crawler is not a session. Anything tracked
|
|
@@ -208,7 +207,17 @@ const AP_CONFIG = Object.freeze({
|
|
|
208
207
|
* What init() must be given. Everything else the SDK needs — aaid, the portal and project ids that
|
|
209
208
|
* go in every url — comes back from app/addversion, which these four are enough to call.
|
|
210
209
|
*/
|
|
211
|
-
const REQUIRED_CONFIG = Object.freeze(['
|
|
210
|
+
const REQUIRED_CONFIG = Object.freeze(['base_url', 'auth_key', 'app_domain', 'appversion']); // no i18n
|
|
211
|
+
/**
|
|
212
|
+
* The init() keys and the names the SDK keeps them under inside (and in app_version_info, which
|
|
213
|
+
* already-visited browsers have stored): base_url is the host, auth_key the `zak` header, and
|
|
214
|
+
* app_domain the app's identifier.
|
|
215
|
+
*/
|
|
216
|
+
const CONFIG_KEYS = Object.freeze({
|
|
217
|
+
base_url: 'serviceUrl', // no i18n
|
|
218
|
+
auth_key: 'zak', // no i18n
|
|
219
|
+
app_domain: 'identifier', // no i18n
|
|
220
|
+
});
|
|
212
221
|
/**
|
|
213
222
|
* Paths with a `debug/` twin. The debug endpoints take the same body and answer with a request id
|
|
214
223
|
* and a link to the server-side logs for that request, which is how a payload is traced end to
|
|
@@ -243,10 +252,16 @@ const RETRY_CAPABLE_PATHS = Object.freeze({
|
|
|
243
252
|
const PATHS_WITHOUT_ORG = Object.freeze({
|
|
244
253
|
addversion: true, // no i18n
|
|
245
254
|
});
|
|
246
|
-
/**
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
255
|
+
/**
|
|
256
|
+
* Earlier names of the init() keys: 2.0.0-beta's serviceUrl, zak and identifier, and the 1.x
|
|
257
|
+
* console snippet's base_domain and token. Still read, with a warning naming the key to use.
|
|
258
|
+
*/
|
|
259
|
+
const RETIRED_CONFIG_NAMES = Object.freeze({
|
|
260
|
+
serviceUrl: 'base_url', // no i18n
|
|
261
|
+
base_domain: 'base_url', // no i18n
|
|
262
|
+
zak: 'auth_key', // no i18n
|
|
263
|
+
token: 'auth_key', // no i18n
|
|
264
|
+
identifier: 'app_domain', // no i18n
|
|
250
265
|
});
|
|
251
266
|
// crawlers reference
|
|
252
267
|
// https://developers.google.com/search/docs/advanced/crawling/overview-google-crawlers
|
|
@@ -283,7 +298,7 @@ exports.AP_FEEDBACK_TYPE = AP_FEEDBACK_TYPE;
|
|
|
283
298
|
exports.AP_LOG_MODULE = AP_LOG_MODULE;
|
|
284
299
|
exports.AP_TRACKING_STATUS = AP_TRACKING_STATUS;
|
|
285
300
|
exports.BLOCKED_WS = BLOCKED_WS;
|
|
286
|
-
exports.
|
|
301
|
+
exports.CONFIG_KEYS = CONFIG_KEYS;
|
|
287
302
|
exports.CONSOLE_LOG_MAX_BODY = CONSOLE_LOG_MAX_BODY;
|
|
288
303
|
exports.DEBUG_CAPABLE_PATHS = DEBUG_CAPABLE_PATHS;
|
|
289
304
|
exports.DEBUG_IDLE_MS = DEBUG_IDLE_MS;
|
|
@@ -295,5 +310,6 @@ exports.LOG_FUNCTION_MAX = LOG_FUNCTION_MAX;
|
|
|
295
310
|
exports.PATHS_WITHOUT_ORG = PATHS_WITHOUT_ORG;
|
|
296
311
|
exports.REMOTE_LOG_LEVEL = REMOTE_LOG_LEVEL;
|
|
297
312
|
exports.REQUIRED_CONFIG = REQUIRED_CONFIG;
|
|
313
|
+
exports.RETIRED_CONFIG_NAMES = RETIRED_CONFIG_NAMES;
|
|
298
314
|
exports.RETRY_CAPABLE_PATHS = RETRY_CAPABLE_PATHS;
|
|
299
315
|
exports.SDK_MODULE = SDK_MODULE;
|
package/dist/cjs/core/db.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { Dict, QueueItem } from '../types.js';
|
|
2
|
-
export type QueueName = 'engagements' | 'errors' | '
|
|
2
|
+
export type QueueName = 'engagements' | 'errors' | 'feedbacklogs' | 'remotelogs' | 'heatmaps';
|
|
3
3
|
/** One storage implementation. storage.ts talks only to this interface. */
|
|
4
4
|
export interface Backend {
|
|
5
5
|
readonly kind: 'indexeddb' | 'localstorage';
|
|
6
6
|
loadSettings(): Promise<Dict>;
|
|
7
7
|
putSetting(key: string, value: unknown): Promise<void>;
|
|
8
|
+
/** Removes the key itself, so it is no longer in storage at all. */
|
|
9
|
+
deleteSetting(key: string): Promise<void>;
|
|
8
10
|
clearSettings(): Promise<void>;
|
|
9
11
|
/** Items in insertion order. */
|
|
10
12
|
queueAll(store: QueueName): Promise<QueueItem[]>;
|
|
@@ -16,16 +18,22 @@ export interface Backend {
|
|
|
16
18
|
importAll?(settings: Dict, queues: Record<QueueName, QueueItem[]>): Promise<void>;
|
|
17
19
|
}
|
|
18
20
|
export declare const DB_NAME = "apptics";
|
|
19
|
-
export declare const DB_VERSION =
|
|
20
|
-
/**
|
|
21
|
+
export declare const DB_VERSION = 4;
|
|
22
|
+
/** The types a feedback entry is stored under: an addFeedbackLog() line, an addDiagnosticsInfo() entry. */
|
|
23
|
+
export declare const FEEDBACK_LOG = "feedbacklog";
|
|
24
|
+
export declare const FEEDBACK_DIAGNOSTICS = "feedbackdiagnostics";
|
|
25
|
+
/** A feedback entry from 1.x or 2.0.0-beta, with the type it is stored under now. */
|
|
26
|
+
export declare function renameFeedbackType(item: QueueItem): QueueItem;
|
|
27
|
+
/** 1.x localStorage keys, read once to bring 1.x data into IndexedDB (see migrateLegacy). */
|
|
21
28
|
export declare const LEGACY_KEYS: Readonly<{
|
|
22
29
|
readonly settings: "apptics-device-info";
|
|
23
30
|
readonly engagements: "apptics-engagements-transactions";
|
|
24
31
|
readonly errors: "apptics-errors-transactions";
|
|
25
32
|
readonly logs: "apptics-log-transactions";
|
|
26
33
|
readonly consolelogs: "apptics-consolelog-transactions";
|
|
27
|
-
readonly heatmaps: "apptics-heatmap-transactions";
|
|
28
34
|
}>;
|
|
35
|
+
/** The localStorage backend's layout, for a browser where IndexedDB will not open. */
|
|
36
|
+
export declare const LOCAL_KEYS: Readonly<Record<'settings' | QueueName, string>>;
|
|
29
37
|
/** Shape guards shared by both backends and the 1.x migration. */
|
|
30
38
|
export declare function asList(value: unknown): QueueItem[];
|
|
31
39
|
export declare function asDict(value: unknown): Dict;
|
package/dist/cjs/core/db.js
CHANGED
|
@@ -1,26 +1,73 @@
|
|
|
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.1 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var logger = require('./logger.js');
|
|
5
5
|
var utils = require('./utils.js');
|
|
6
6
|
|
|
7
7
|
const DB_NAME = 'apptics'; // no i18n
|
|
8
|
-
// 3 added the heatmaps store.
|
|
9
|
-
//
|
|
10
|
-
const DB_VERSION =
|
|
8
|
+
// 3 added the heatmaps store. 4 renamed: each record's order key `seq` to `queue`, the logs store
|
|
9
|
+
// to feedbacklogs and consolelogs to remotelogs. Every upgrade keeps what is already queued.
|
|
10
|
+
const DB_VERSION = 4;
|
|
11
11
|
const OPEN_TIMEOUT_MS = 3000;
|
|
12
|
-
const QUEUES = ['engagements', 'errors', '
|
|
13
|
-
/**
|
|
12
|
+
const QUEUES = ['engagements', 'errors', 'feedbacklogs', 'remotelogs', 'heatmaps']; // no i18n
|
|
13
|
+
/** The field, and the index on it, that keeps a queue's records in the order they were added. */
|
|
14
|
+
const QUEUE_KEY = 'queue'; // no i18n
|
|
15
|
+
/** Version 3's names, which the version 4 upgrade moves to the ones above. */
|
|
16
|
+
const OLD_QUEUE_KEY = 'seq'; // no i18n
|
|
17
|
+
const RENAMED_STORES = [['logs', 'feedbacklogs'], ['consolelogs', 'remotelogs']]; // no i18n
|
|
18
|
+
/** The types a feedback entry is stored under: an addFeedbackLog() line, an addDiagnosticsInfo() entry. */
|
|
19
|
+
const FEEDBACK_LOG = 'feedbacklog'; // no i18n
|
|
20
|
+
const FEEDBACK_DIAGNOSTICS = 'feedbackdiagnostics'; // no i18n
|
|
21
|
+
const OLD_FEEDBACK_TYPES = Object.freeze({
|
|
22
|
+
log: FEEDBACK_LOG, // no i18n
|
|
23
|
+
diagnostics: FEEDBACK_DIAGNOSTICS, // no i18n
|
|
24
|
+
});
|
|
25
|
+
/** A feedback entry from 1.x or 2.0.0-beta, with the type it is stored under now. */
|
|
26
|
+
function renameFeedbackType(item) {
|
|
27
|
+
var renamed = item && typeof item.type === 'string' ? OLD_FEEDBACK_TYPES[item.type] : undefined; // no i18n
|
|
28
|
+
return renamed ? { ...item, type: renamed } : item;
|
|
29
|
+
}
|
|
30
|
+
/** 1.x localStorage keys, read once to bring 1.x data into IndexedDB (see migrateLegacy). */
|
|
14
31
|
const LEGACY_KEYS = Object.freeze({
|
|
15
32
|
settings: 'apptics-device-info', // no i18n
|
|
16
33
|
engagements: 'apptics-engagements-transactions', // no i18n
|
|
17
34
|
errors: 'apptics-errors-transactions', // no i18n
|
|
18
35
|
logs: 'apptics-log-transactions', // no i18n
|
|
19
36
|
consolelogs: 'apptics-consolelog-transactions', // no i18n
|
|
20
|
-
|
|
21
|
-
|
|
37
|
+
});
|
|
38
|
+
/** The localStorage backend's layout, for a browser where IndexedDB will not open. */
|
|
39
|
+
const LOCAL_KEYS = Object.freeze({
|
|
40
|
+
settings: LEGACY_KEYS.settings,
|
|
41
|
+
engagements: LEGACY_KEYS.engagements,
|
|
42
|
+
errors: LEGACY_KEYS.errors,
|
|
43
|
+
feedbacklogs: 'apptics-feedbacklog-transactions', // no i18n
|
|
44
|
+
remotelogs: 'apptics-remotelog-transactions', // no i18n
|
|
22
45
|
heatmaps: 'apptics-heatmap-transactions', // no i18n
|
|
23
46
|
});
|
|
47
|
+
/**
|
|
48
|
+
* The localStorage backend once kept these two under the 1.x keys. Moved to the new ones on first
|
|
49
|
+
* use, feedback types renamed on the way, unless something is already there.
|
|
50
|
+
*/
|
|
51
|
+
function moveRenamedLocalKeys() {
|
|
52
|
+
[[LEGACY_KEYS.logs, LOCAL_KEYS.feedbacklogs], [LEGACY_KEYS.consolelogs, LOCAL_KEYS.remotelogs]].forEach(function (pair) {
|
|
53
|
+
try {
|
|
54
|
+
var from = pair[0];
|
|
55
|
+
var to = pair[1];
|
|
56
|
+
var old = localStorage.getItem(from);
|
|
57
|
+
if (old === null) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (localStorage.getItem(to) === null) {
|
|
61
|
+
var items = asList(JSON.parse(old));
|
|
62
|
+
localStorage.setItem(to, JSON.stringify(to === LOCAL_KEYS.feedbacklogs ? items.map(renameFeedbackType) : items));
|
|
63
|
+
}
|
|
64
|
+
localStorage.removeItem(from);
|
|
65
|
+
}
|
|
66
|
+
catch (err) {
|
|
67
|
+
// left where it is; the next load tries again
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
24
71
|
/** Shape guards shared by both backends and the 1.x migration. */
|
|
25
72
|
function asList(value) {
|
|
26
73
|
return Array.isArray(value) ? value : [];
|
|
@@ -48,26 +95,33 @@ function writeJSON(key, value) {
|
|
|
48
95
|
}
|
|
49
96
|
}
|
|
50
97
|
function createLocalStorageBackend() {
|
|
98
|
+
moveRenamedLocalKeys();
|
|
51
99
|
return {
|
|
52
100
|
kind: 'localstorage', // no i18n
|
|
53
101
|
loadSettings() {
|
|
54
|
-
return Promise.resolve(asDict(readJSON(
|
|
102
|
+
return Promise.resolve(asDict(readJSON(LOCAL_KEYS.settings)));
|
|
55
103
|
},
|
|
56
104
|
putSetting(key, value) {
|
|
57
|
-
const all = asDict(readJSON(
|
|
105
|
+
const all = asDict(readJSON(LOCAL_KEYS.settings));
|
|
58
106
|
all[key] = value;
|
|
59
|
-
writeJSON(
|
|
107
|
+
writeJSON(LOCAL_KEYS.settings, all);
|
|
108
|
+
return Promise.resolve();
|
|
109
|
+
},
|
|
110
|
+
deleteSetting(key) {
|
|
111
|
+
const all = asDict(readJSON(LOCAL_KEYS.settings));
|
|
112
|
+
delete all[key];
|
|
113
|
+
writeJSON(LOCAL_KEYS.settings, all);
|
|
60
114
|
return Promise.resolve();
|
|
61
115
|
},
|
|
62
116
|
clearSettings() {
|
|
63
|
-
writeJSON(
|
|
117
|
+
writeJSON(LOCAL_KEYS.settings, {});
|
|
64
118
|
return Promise.resolve();
|
|
65
119
|
},
|
|
66
120
|
queueAll(store) {
|
|
67
|
-
return Promise.resolve(asList(readJSON(
|
|
121
|
+
return Promise.resolve(asList(readJSON(LOCAL_KEYS[store])));
|
|
68
122
|
},
|
|
69
123
|
queuePut(store, items) {
|
|
70
|
-
const list = asList(readJSON(
|
|
124
|
+
const list = asList(readJSON(LOCAL_KEYS[store]));
|
|
71
125
|
items.forEach(function (item) {
|
|
72
126
|
const index = list.findIndex(function (existing) { return existing.id === item.id; });
|
|
73
127
|
if (index === -1) {
|
|
@@ -77,32 +131,32 @@ function createLocalStorageBackend() {
|
|
|
77
131
|
list[index] = item;
|
|
78
132
|
}
|
|
79
133
|
});
|
|
80
|
-
writeJSON(
|
|
134
|
+
writeJSON(LOCAL_KEYS[store], list);
|
|
81
135
|
return Promise.resolve();
|
|
82
136
|
},
|
|
83
137
|
queueDelete(store, ids) {
|
|
84
|
-
const remaining = asList(readJSON(
|
|
138
|
+
const remaining = asList(readJSON(LOCAL_KEYS[store])).filter(function (item) {
|
|
85
139
|
return ids.indexOf(item.id) === -1;
|
|
86
140
|
});
|
|
87
|
-
writeJSON(
|
|
141
|
+
writeJSON(LOCAL_KEYS[store], remaining);
|
|
88
142
|
return Promise.resolve();
|
|
89
143
|
},
|
|
90
144
|
queueClear(store) {
|
|
91
|
-
writeJSON(
|
|
145
|
+
writeJSON(LOCAL_KEYS[store], []);
|
|
92
146
|
return Promise.resolve();
|
|
93
147
|
},
|
|
94
148
|
};
|
|
95
149
|
}
|
|
96
|
-
let
|
|
150
|
+
let lastQueue = 0;
|
|
97
151
|
/**
|
|
98
152
|
* Strictly increasing, and time-based so tabs interleave in roughly the right order.
|
|
99
153
|
* Counting up from the last value rather than a counter that wraps keeps insertion order
|
|
100
154
|
* even when a chatty caller adds more than a thousand items inside one millisecond.
|
|
101
155
|
*/
|
|
102
|
-
function
|
|
156
|
+
function nextQueue() {
|
|
103
157
|
const base = utils.nowMs() * 1000;
|
|
104
|
-
|
|
105
|
-
return
|
|
158
|
+
lastQueue = base > lastQueue ? base : lastQueue + 1;
|
|
159
|
+
return lastQueue;
|
|
106
160
|
}
|
|
107
161
|
function request(req) {
|
|
108
162
|
return new Promise(function (resolve, reject) {
|
|
@@ -117,7 +171,21 @@ function completed(tx) {
|
|
|
117
171
|
tx.onabort = function () { reject(tx.error); };
|
|
118
172
|
});
|
|
119
173
|
}
|
|
120
|
-
/**
|
|
174
|
+
/**
|
|
175
|
+
* The record's `type` for an item with none of its own: heatmap records carry no type, since
|
|
176
|
+
* their payload is the item itself and the server takes no extra field. Never undefined.
|
|
177
|
+
*/
|
|
178
|
+
const STORE_TYPES = Object.freeze({
|
|
179
|
+
engagements: 'engagement', // no i18n
|
|
180
|
+
errors: 'error', // no i18n
|
|
181
|
+
feedbacklogs: FEEDBACK_LOG,
|
|
182
|
+
remotelogs: 'remotelog', // no i18n
|
|
183
|
+
heatmaps: 'heatmap', // no i18n
|
|
184
|
+
});
|
|
185
|
+
function recordType(storeName, item) {
|
|
186
|
+
return item && typeof item.type === 'string' && item.type !== '' ? item.type : (STORE_TYPES[storeName] || storeName); // no i18n
|
|
187
|
+
}
|
|
188
|
+
/** Puts `item` unless it exists (keepExisting) or replaces it keeping its place. Runs inside `store`'s transaction. */
|
|
121
189
|
function putRecord(store, item, keepExisting) {
|
|
122
190
|
const id = String(item.id);
|
|
123
191
|
const lookup = store.get(id);
|
|
@@ -126,7 +194,7 @@ function putRecord(store, item, keepExisting) {
|
|
|
126
194
|
if (existing && keepExisting) {
|
|
127
195
|
return;
|
|
128
196
|
}
|
|
129
|
-
store.put({ id: id,
|
|
197
|
+
store.put({ id: id, queue: existing ? existing.queue : nextQueue(), type: recordType(store.name, item), item: item });
|
|
130
198
|
};
|
|
131
199
|
}
|
|
132
200
|
/** Our stores, as created by onupgradeneeded. */
|
|
@@ -187,15 +255,7 @@ function openOnce(factory, timeoutMs) {
|
|
|
187
255
|
return;
|
|
188
256
|
}
|
|
189
257
|
req.onupgradeneeded = function () {
|
|
190
|
-
|
|
191
|
-
if (!db.objectStoreNames.contains('settings')) { // no i18n
|
|
192
|
-
db.createObjectStore('settings'); // no i18n
|
|
193
|
-
}
|
|
194
|
-
QUEUES.forEach(function (name) {
|
|
195
|
-
if (!db.objectStoreNames.contains(name)) {
|
|
196
|
-
db.createObjectStore(name, { keyPath: 'id' }).createIndex('seq', 'seq'); // no i18n
|
|
197
|
-
}
|
|
198
|
-
});
|
|
258
|
+
upgrade(req.result, req.transaction);
|
|
199
259
|
};
|
|
200
260
|
req.onsuccess = function () {
|
|
201
261
|
if (settled) {
|
|
@@ -226,6 +286,70 @@ function openOnce(factory, timeoutMs) {
|
|
|
226
286
|
};
|
|
227
287
|
});
|
|
228
288
|
}
|
|
289
|
+
/**
|
|
290
|
+
* Creates what is missing and moves version 3's data to version 4's names, inside the upgrade's
|
|
291
|
+
* own transaction: either the whole upgrade lands, or the database stays at the old version with
|
|
292
|
+
* everything still in it.
|
|
293
|
+
*/
|
|
294
|
+
function upgrade(db, tx) {
|
|
295
|
+
if (!db.objectStoreNames.contains('settings')) { // no i18n
|
|
296
|
+
db.createObjectStore('settings'); // no i18n
|
|
297
|
+
}
|
|
298
|
+
QUEUES.forEach(function (name) {
|
|
299
|
+
if (!db.objectStoreNames.contains(name)) {
|
|
300
|
+
db.createObjectStore(name, { keyPath: 'id' }).createIndex(QUEUE_KEY, QUEUE_KEY); // no i18n
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
// kept stores: the order key is renamed on every record, and the index with it
|
|
304
|
+
QUEUES.forEach(function (name) {
|
|
305
|
+
const store = tx.objectStore(name);
|
|
306
|
+
if (!store.indexNames.contains(OLD_QUEUE_KEY)) {
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
store.deleteIndex(OLD_QUEUE_KEY);
|
|
310
|
+
if (!store.indexNames.contains(QUEUE_KEY)) {
|
|
311
|
+
store.createIndex(QUEUE_KEY, QUEUE_KEY);
|
|
312
|
+
}
|
|
313
|
+
eachRecord(store, function (record, cursor) {
|
|
314
|
+
cursor.update(renamedRecord(record, false, name));
|
|
315
|
+
});
|
|
316
|
+
});
|
|
317
|
+
// renamed stores: every record moves to its new store, then the old store goes
|
|
318
|
+
RENAMED_STORES.forEach(function (pair) {
|
|
319
|
+
const from = pair[0];
|
|
320
|
+
const to = pair[1];
|
|
321
|
+
if (!db.objectStoreNames.contains(from)) {
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
const source = tx.objectStore(from);
|
|
325
|
+
const target = tx.objectStore(to);
|
|
326
|
+
eachRecord(source, function (record) {
|
|
327
|
+
target.put(renamedRecord(record, to === 'feedbacklogs', to)); // no i18n
|
|
328
|
+
}, function () {
|
|
329
|
+
db.deleteObjectStore(from);
|
|
330
|
+
});
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
/** Calls `each` for every record of `store`, then `done`, inside the transaction `store` is in. */
|
|
334
|
+
function eachRecord(store, each, done) {
|
|
335
|
+
const req = store.openCursor();
|
|
336
|
+
req.onsuccess = function () {
|
|
337
|
+
const cursor = req.result;
|
|
338
|
+
if (!cursor) {
|
|
339
|
+
if (done)
|
|
340
|
+
done();
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
each(cursor.value, cursor);
|
|
344
|
+
cursor.continue();
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
/** A version 3 record under version 4's names: `queue` for `seq`, and the feedback types renamed. */
|
|
348
|
+
function renamedRecord(record, feedback, storeName) {
|
|
349
|
+
const queue = typeof record[QUEUE_KEY] === 'number' ? record[QUEUE_KEY] : (typeof record[OLD_QUEUE_KEY] === 'number' ? record[OLD_QUEUE_KEY] : nextQueue()); // no i18n
|
|
350
|
+
const item = (feedback ? renameFeedbackType(record.item) : record.item);
|
|
351
|
+
return { id: String(record.id), queue: queue, type: recordType(storeName, item), item: item };
|
|
352
|
+
}
|
|
229
353
|
function createIndexedDBBackend(db) {
|
|
230
354
|
return {
|
|
231
355
|
kind: 'indexeddb', // no i18n
|
|
@@ -244,13 +368,18 @@ function createIndexedDBBackend(db) {
|
|
|
244
368
|
tx.objectStore('settings').put(value, key); // no i18n
|
|
245
369
|
return completed(tx);
|
|
246
370
|
},
|
|
371
|
+
deleteSetting(key) {
|
|
372
|
+
const tx = db.transaction('settings', 'readwrite'); // no i18n
|
|
373
|
+
tx.objectStore('settings').delete(key); // no i18n
|
|
374
|
+
return completed(tx);
|
|
375
|
+
},
|
|
247
376
|
clearSettings() {
|
|
248
377
|
const tx = db.transaction('settings', 'readwrite'); // no i18n
|
|
249
378
|
tx.objectStore('settings').clear(); // no i18n
|
|
250
379
|
return completed(tx);
|
|
251
380
|
},
|
|
252
381
|
queueAll(store) {
|
|
253
|
-
const index = db.transaction(store, 'readonly').objectStore(store).index(
|
|
382
|
+
const index = db.transaction(store, 'readonly').objectStore(store).index(QUEUE_KEY);
|
|
254
383
|
return request(index.getAll()).then(function (records) {
|
|
255
384
|
return records.map(function (record) { return record.item; });
|
|
256
385
|
});
|
|
@@ -325,10 +454,14 @@ function openBackend() {
|
|
|
325
454
|
|
|
326
455
|
exports.DB_NAME = DB_NAME;
|
|
327
456
|
exports.DB_VERSION = DB_VERSION;
|
|
457
|
+
exports.FEEDBACK_DIAGNOSTICS = FEEDBACK_DIAGNOSTICS;
|
|
458
|
+
exports.FEEDBACK_LOG = FEEDBACK_LOG;
|
|
328
459
|
exports.LEGACY_KEYS = LEGACY_KEYS;
|
|
460
|
+
exports.LOCAL_KEYS = LOCAL_KEYS;
|
|
329
461
|
exports.asDict = asDict;
|
|
330
462
|
exports.asList = asList;
|
|
331
463
|
exports.createIndexedDBBackend = createIndexedDBBackend;
|
|
332
464
|
exports.createLocalStorageBackend = createLocalStorageBackend;
|
|
333
465
|
exports.openBackend = openBackend;
|
|
334
466
|
exports.openIndexedDB = openIndexedDB;
|
|
467
|
+
exports.renameFeedbackType = renameFeedbackType;
|
package/dist/cjs/core/debug.js
CHANGED
package/dist/cjs/core/env.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const FRAMEWORK_ID =
|
|
1
|
+
export declare const FRAMEWORK_ID = 6002;
|