@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
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import { type EngagementType } from './constants.js';
|
|
1
2
|
import type { TrackingStatus } from '../types.js';
|
|
2
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* DNT counts only when not ignored; while it counts, tracking is NO_TRACKING (opt_in_status).
|
|
5
|
+
* Decided on every visit and never stored: storing it made one visit with DNT on look like the
|
|
6
|
+
* visitor's own choice, so tracking stayed off after DNT was turned off or ignore_do_not_track set.
|
|
7
|
+
*/
|
|
3
8
|
export declare function hasDoNotTrackEnabled(): boolean;
|
|
4
9
|
export declare function opt_in_status(): TrackingStatus;
|
|
5
10
|
export declare function shouldTrackOrSendData(): boolean;
|
|
@@ -8,8 +13,11 @@ export declare function shouldTrackOrSendData(): boolean;
|
|
|
8
13
|
* and consent / server flags allow tracking.
|
|
9
14
|
*/
|
|
10
15
|
export declare function canTrack(caller: string): boolean;
|
|
11
|
-
/**
|
|
12
|
-
|
|
16
|
+
/**
|
|
17
|
+
* canTrack plus the server's flag for this kind of item: getsdkconfig's event (5), api (6),
|
|
18
|
+
* screen (10) and session (11) modules, each switched on its own.
|
|
19
|
+
*/
|
|
20
|
+
export declare function canTrackEngagement(caller: string, type: EngagementType): boolean;
|
|
13
21
|
/**
|
|
14
22
|
* canTrack plus the server's heatmap flag (getsdkconfig module 18).
|
|
15
23
|
*
|
|
@@ -17,7 +25,13 @@ export declare function canTrackEngagement(caller: string): boolean;
|
|
|
17
25
|
* well want events while declining to have every click's coordinates recorded.
|
|
18
26
|
*/
|
|
19
27
|
export declare function canTrackHeatmap(caller: string): boolean;
|
|
20
|
-
/** canTrack plus the server's
|
|
28
|
+
/** canTrack plus the server's js_error module (15) from getsdkconfig. */
|
|
21
29
|
export declare function canTrackErrors(caller: string): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Stores the visitor's tracking status without telling the server. True when it changed.
|
|
32
|
+
* user/register uses this alone: the server learns of the user from that call, so a device/add
|
|
33
|
+
* after it would only repeat a registration the device already has.
|
|
34
|
+
*/
|
|
35
|
+
export declare function recordTrackingStatus(trackingState: TrackingStatus): boolean;
|
|
22
36
|
export declare function setTrackingStatus(trackingState: TrackingStatus): void;
|
|
23
37
|
export declare function getTrackingStatus(): TrackingStatus;
|
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.2 | (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()) {
|
|
@@ -51,13 +53,16 @@ function canTrack(caller) {
|
|
|
51
53
|
}
|
|
52
54
|
return shouldTrackOrSendData();
|
|
53
55
|
}
|
|
54
|
-
/**
|
|
55
|
-
|
|
56
|
+
/**
|
|
57
|
+
* canTrack plus the server's flag for this kind of item: getsdkconfig's event (5), api (6),
|
|
58
|
+
* screen (10) and session (11) modules, each switched on its own.
|
|
59
|
+
*/
|
|
60
|
+
function canTrackEngagement(caller, type) {
|
|
56
61
|
if (!canTrack(caller)) {
|
|
57
62
|
return false;
|
|
58
63
|
}
|
|
59
|
-
if (!state._ZAP._engagementTracking) {
|
|
60
|
-
logger.Console.log('apptics.' + caller + ':
|
|
64
|
+
if (!state._ZAP._engagementTracking[type]) {
|
|
65
|
+
logger.Console.log('apptics.' + caller + ': ' + type + ' tracking is turned off by the server'); // no i18n
|
|
61
66
|
return false;
|
|
62
67
|
}
|
|
63
68
|
return true;
|
|
@@ -78,7 +83,7 @@ function canTrackHeatmap(caller) {
|
|
|
78
83
|
}
|
|
79
84
|
return true;
|
|
80
85
|
}
|
|
81
|
-
/** canTrack plus the server's
|
|
86
|
+
/** canTrack plus the server's js_error module (15) from getsdkconfig. */
|
|
82
87
|
function canTrackErrors(caller) {
|
|
83
88
|
if (!canTrack(caller)) {
|
|
84
89
|
return false;
|
|
@@ -89,17 +94,27 @@ function canTrackErrors(caller) {
|
|
|
89
94
|
}
|
|
90
95
|
return true;
|
|
91
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Stores the visitor's tracking status without telling the server. True when it changed.
|
|
99
|
+
* user/register uses this alone: the server learns of the user from that call, so a device/add
|
|
100
|
+
* after it would only repeat a registration the device already has.
|
|
101
|
+
*/
|
|
102
|
+
function recordTrackingStatus(trackingState) {
|
|
103
|
+
if (storage.tracking_preference.opt_in_status() == trackingState) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
storage.tracking_preference.update_status(trackingState);
|
|
107
|
+
state._ZAP._devicestatus = storage.tracking_preference.opt_in_status();
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
92
110
|
function setTrackingStatus(trackingState) {
|
|
93
111
|
if (utils.isEmpty(trackingState)) {
|
|
94
112
|
logger.Console.warn('setTrackingStatus: trackingStatus is Empty'); // no i18n
|
|
95
113
|
return;
|
|
96
114
|
}
|
|
97
|
-
if (
|
|
115
|
+
if (!recordTrackingStatus(trackingState)) {
|
|
98
116
|
return;
|
|
99
117
|
}
|
|
100
|
-
storage.tracking_preference.update_status(trackingState);
|
|
101
|
-
state._ZAP._devicestatus = storage.tracking_preference.opt_in_status();
|
|
102
|
-
state._ZAP._isanonrequired = storage.tracking_preference.opt_in_status() == constants.AP_TRACKING_STATUS.USAGE_TRACKING_WITH_PII ? false : state._ZAP._isanonrequired;
|
|
103
118
|
if (storage.tracking_preference.opt_in_status() != constants.AP_TRACKING_STATUS.NO_TRACKING) {
|
|
104
119
|
logger.Console.log('setTrackingStatus: Updating device info with new tracking status'); // no i18n
|
|
105
120
|
hooks.hooks.updateDevice(state._ZAP._device_info).then(function (result) {
|
|
@@ -126,5 +141,6 @@ exports.canTrackHeatmap = canTrackHeatmap;
|
|
|
126
141
|
exports.getTrackingStatus = getTrackingStatus;
|
|
127
142
|
exports.hasDoNotTrackEnabled = hasDoNotTrackEnabled;
|
|
128
143
|
exports.opt_in_status = opt_in_status;
|
|
144
|
+
exports.recordTrackingStatus = recordTrackingStatus;
|
|
129
145
|
exports.setTrackingStatus = setTrackingStatus;
|
|
130
146
|
exports.shouldTrackOrSendData = shouldTrackOrSendData;
|
|
@@ -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;
|
|
@@ -18,6 +34,8 @@ export declare const AP_CONSTANTS: Readonly<{
|
|
|
18
34
|
readonly SUCCESS: "success";
|
|
19
35
|
readonly BROWSER: "Browser";
|
|
20
36
|
}>;
|
|
37
|
+
/** The kinds of engagement item, each with its own getsdkconfig module: AP_CONSTANTS' type values. */
|
|
38
|
+
export type EngagementType = 'event' | 'screen' | 'session' | 'api';
|
|
21
39
|
export declare const DEFAULT_API_PATHS: Readonly<{
|
|
22
40
|
readonly addversion: "app/addversion";
|
|
23
41
|
readonly regdevice: "device/add";
|
|
@@ -63,9 +81,13 @@ export declare const SDK_MODULE: Readonly<{
|
|
|
63
81
|
* authority. Where they disagree, getsdkconfig wins.
|
|
64
82
|
*/
|
|
65
83
|
readonly REMOTE_CONFIG: "2";
|
|
84
|
+
readonly EVENT: "5";
|
|
85
|
+
readonly API: "6";
|
|
86
|
+
readonly SCREEN: "10";
|
|
66
87
|
readonly SESSION: "11";
|
|
67
88
|
readonly FEEDBACK: "12";
|
|
68
|
-
|
|
89
|
+
/** Uncaught and reported JavaScript errors: js_error. 13 (crash) and 14 (nonfatal) are the native SDKs'. */
|
|
90
|
+
readonly JS_ERROR: "15";
|
|
69
91
|
readonly REMOTE_LOGGER: "17";
|
|
70
92
|
readonly HEATMAP: "18";
|
|
71
93
|
}>;
|
|
@@ -81,9 +103,10 @@ export declare const LOG_FILENAME_MAX = 100;
|
|
|
81
103
|
*/
|
|
82
104
|
export declare const DEVICE_NAME_MAX = 100;
|
|
83
105
|
/**
|
|
84
|
-
* The `level`
|
|
85
|
-
*
|
|
86
|
-
*
|
|
106
|
+
* The `level` a remote log line goes out with when it has none of its own: 3, Info. Every line an
|
|
107
|
+
* app writes with AppticsLogger carries its level (1 verbose to 5 error, see LOG_LEVEL in
|
|
108
|
+
* remotelog/logger.ts). Only a line an older SDK stored, when the SDK logged its own failures
|
|
109
|
+
* there, has none; it is sent as Info rather than having the batch refused for a missing level.
|
|
87
110
|
*/
|
|
88
111
|
export declare const REMOTE_LOG_LEVEL = 3;
|
|
89
112
|
/**
|
|
@@ -93,31 +116,18 @@ export declare const REMOTE_LOG_LEVEL = 3;
|
|
|
93
116
|
* enough that a tab left open overnight is not still sending every call to its debug twin.
|
|
94
117
|
*/
|
|
95
118
|
export declare const DEBUG_IDLE_MS: number;
|
|
96
|
-
/**
|
|
119
|
+
/** Minutes a tab can be inactive before its session ends. Lives on state, not in _config, but defaults here. */
|
|
97
120
|
export declare const DEFAULT_INACTIVE_MINUTES = 30;
|
|
98
121
|
/** Global defaults. `state._config` holds a mutable copy per init. */
|
|
99
122
|
export declare const AP_CONFIG: Readonly<{
|
|
100
123
|
endpoint: "/sdk/web/";
|
|
101
124
|
method: "POST";
|
|
102
|
-
transport: "XHR";
|
|
103
|
-
track_link_timeout: 300;
|
|
104
|
-
cookie_expiration_days: 365;
|
|
105
|
-
storage_type: "localStorage";
|
|
106
|
-
enable_batch_requests: true;
|
|
107
125
|
batch_size: 50;
|
|
108
126
|
batch_flush_interval: 30000;
|
|
109
127
|
getupdates_interval: 120000;
|
|
110
128
|
batch_request_timeout: 7;
|
|
111
|
-
auto_starts_batch: true;
|
|
112
|
-
mode: 1;
|
|
113
|
-
default_group_name: "default";
|
|
114
|
-
default_optin_status: number;
|
|
115
|
-
enable_pageview_tracking: false;
|
|
116
|
-
save_referrer: true;
|
|
117
129
|
debug: boolean;
|
|
118
|
-
track_by_default: true;
|
|
119
130
|
ignore_do_not_track: boolean;
|
|
120
|
-
remote_log: boolean;
|
|
121
131
|
/**
|
|
122
132
|
* Wrap XHR and fetch to record the app's API calls without it calling startTrackApi(). Off by
|
|
123
133
|
* default: the hostnames and paths of every request an app makes is a wider grant than events
|
|
@@ -130,15 +140,26 @@ export declare const AP_CONFIG: Readonly<{
|
|
|
130
140
|
*/
|
|
131
141
|
track_screen: boolean;
|
|
132
142
|
/**
|
|
133
|
-
*
|
|
134
|
-
*
|
|
143
|
+
* Record uncaught errors and unhandled promise rejections, from the window's `error` and
|
|
144
|
+
* `unhandledrejection` events. On by default; AppticsError.setErrorTracking() switches it later.
|
|
135
145
|
*/
|
|
136
|
-
|
|
146
|
+
track_error: boolean;
|
|
137
147
|
/**
|
|
138
|
-
* Record
|
|
139
|
-
*
|
|
148
|
+
* Record clicks on elements tagged `apeventaction` (or `data-apeventaction`) as events. On by
|
|
149
|
+
* default; AppticsEvent.setClickTracking() switches it later.
|
|
140
150
|
*/
|
|
141
|
-
|
|
151
|
+
track_click: boolean;
|
|
152
|
+
/**
|
|
153
|
+
* How automatic screen tracking names a path, as init() keeps the config's screen_routes: route
|
|
154
|
+
* patterns (`/users/{id}/orders`, each id recorded as a star), exact paths and regular
|
|
155
|
+
* expressions with a name. Tried in order; a path none matches keeps its own name.
|
|
156
|
+
*/
|
|
157
|
+
screen_routes: ScreenRouteRule[];
|
|
158
|
+
/**
|
|
159
|
+
* The feedback form's theme: 'light', 'dark', or 'auto' to follow the visitor's system setting.
|
|
160
|
+
* 'auto' by default.
|
|
161
|
+
*/
|
|
162
|
+
feedback_theme: "light" | "dark" | "auto";
|
|
142
163
|
/**
|
|
143
164
|
* How long a visit must last before its session is stored, in milliseconds. A shorter visit with
|
|
144
165
|
* nothing tracked in it is dropped: a bounce or a crawler is not a session. Anything tracked
|
|
@@ -187,7 +208,13 @@ export type ApConfig = {
|
|
|
187
208
|
* What init() must be given. Everything else the SDK needs — aaid, the portal and project ids that
|
|
188
209
|
* go in every url — comes back from app/addversion, which these four are enough to call.
|
|
189
210
|
*/
|
|
190
|
-
export declare const REQUIRED_CONFIG: readonly ["
|
|
211
|
+
export declare const REQUIRED_CONFIG: readonly ["base_url", "auth_key", "app_domain", "appversion"];
|
|
212
|
+
/**
|
|
213
|
+
* The init() keys and the names the SDK keeps them under inside (and in app_version_info, which
|
|
214
|
+
* already-visited browsers have stored): base_url is the host, auth_key the `zak` header, and
|
|
215
|
+
* app_domain the app's identifier.
|
|
216
|
+
*/
|
|
217
|
+
export declare const CONFIG_KEYS: Readonly<Record<string, string>>;
|
|
191
218
|
/**
|
|
192
219
|
* Paths with a `debug/` twin. The debug endpoints take the same body and answer with a request id
|
|
193
220
|
* and a link to the server-side logs for that request, which is how a payload is traced end to
|
|
@@ -207,6 +234,9 @@ export declare const RETRY_CAPABLE_PATHS: Readonly<Record<string, boolean>>;
|
|
|
207
234
|
* called before those ids are known, so it cannot carry them.
|
|
208
235
|
*/
|
|
209
236
|
export declare const PATHS_WITHOUT_ORG: Readonly<Record<string, boolean>>;
|
|
210
|
-
/**
|
|
211
|
-
|
|
237
|
+
/**
|
|
238
|
+
* Earlier names of the init() keys: 2.0.0-beta's serviceUrl, zak and identifier, and the 1.x
|
|
239
|
+
* console snippet's base_domain and token. Still read, with a warning naming the key to use.
|
|
240
|
+
*/
|
|
241
|
+
export declare const RETIRED_CONFIG_NAMES: Readonly<Record<string, string>>;
|
|
212
242
|
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.2 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
const AP_TRACKING_STATUS = Object.freeze({
|
|
@@ -85,9 +85,13 @@ const SDK_MODULE = Object.freeze({
|
|
|
85
85
|
* authority. Where they disagree, getsdkconfig wins.
|
|
86
86
|
*/
|
|
87
87
|
REMOTE_CONFIG: '2', // no i18n
|
|
88
|
+
EVENT: '5', // no i18n
|
|
89
|
+
API: '6', // no i18n
|
|
90
|
+
SCREEN: '10', // no i18n
|
|
88
91
|
SESSION: '11', // no i18n
|
|
89
92
|
FEEDBACK: '12', // no i18n
|
|
90
|
-
|
|
93
|
+
/** Uncaught and reported JavaScript errors: js_error. 13 (crash) and 14 (nonfatal) are the native SDKs'. */
|
|
94
|
+
JS_ERROR: '15', // no i18n
|
|
91
95
|
REMOTE_LOGGER: '17', // no i18n
|
|
92
96
|
HEATMAP: '18', // no i18n
|
|
93
97
|
});
|
|
@@ -103,9 +107,10 @@ const LOG_FILENAME_MAX = 100;
|
|
|
103
107
|
*/
|
|
104
108
|
const DEVICE_NAME_MAX = 100;
|
|
105
109
|
/**
|
|
106
|
-
* The `level`
|
|
107
|
-
*
|
|
108
|
-
*
|
|
110
|
+
* The `level` a remote log line goes out with when it has none of its own: 3, Info. Every line an
|
|
111
|
+
* app writes with AppticsLogger carries its level (1 verbose to 5 error, see LOG_LEVEL in
|
|
112
|
+
* remotelog/logger.ts). Only a line an older SDK stored, when the SDK logged its own failures
|
|
113
|
+
* there, has none; it is sent as Info rather than having the batch refused for a missing level.
|
|
109
114
|
*/
|
|
110
115
|
const REMOTE_LOG_LEVEL = 3;
|
|
111
116
|
/**
|
|
@@ -115,33 +120,19 @@ const REMOTE_LOG_LEVEL = 3;
|
|
|
115
120
|
* enough that a tab left open overnight is not still sending every call to its debug twin.
|
|
116
121
|
*/
|
|
117
122
|
const DEBUG_IDLE_MS = 60 * 60 * 1000;
|
|
118
|
-
/**
|
|
123
|
+
/** Minutes a tab can be inactive before its session ends. Lives on state, not in _config, but defaults here. */
|
|
119
124
|
const DEFAULT_INACTIVE_MINUTES = 30;
|
|
120
125
|
/** Global defaults. `state._config` holds a mutable copy per init. */
|
|
121
126
|
const AP_CONFIG = Object.freeze({
|
|
122
127
|
// the version is per path (API_VERSIONS); this is only the part before it
|
|
123
128
|
endpoint: '/sdk/web/', // no i18n
|
|
124
129
|
method: 'POST', // no i18n
|
|
125
|
-
transport: 'XHR', // no i18n
|
|
126
|
-
track_link_timeout: 300,
|
|
127
|
-
cookie_expiration_days: 365,
|
|
128
|
-
storage_type: 'localStorage', // no i18n
|
|
129
|
-
enable_batch_requests: true,
|
|
130
130
|
batch_size: 50,
|
|
131
131
|
batch_flush_interval: 30000,
|
|
132
|
-
getupdates_interval: 120000, // 2 minutes in milliseconds
|
|
132
|
+
getupdates_interval: 120000, // 2 minutes in milliseconds, when getsdkconfig gives no next_check_after
|
|
133
133
|
batch_request_timeout: 7,
|
|
134
|
-
auto_starts_batch: true,
|
|
135
|
-
mode: 1,
|
|
136
|
-
default_group_name: 'default', // no i18n
|
|
137
|
-
default_optin_status: AP_TRACKING_STATUS.USAGE_TRACKING_WITHOUT_PII,
|
|
138
|
-
enable_pageview_tracking: false,
|
|
139
|
-
save_referrer: true,
|
|
140
134
|
debug: false,
|
|
141
|
-
track_by_default: true,
|
|
142
135
|
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
136
|
/**
|
|
146
137
|
* Wrap XHR and fetch to record the app's API calls without it calling startTrackApi(). Off by
|
|
147
138
|
* default: the hostnames and paths of every request an app makes is a wider grant than events
|
|
@@ -154,15 +145,26 @@ const AP_CONFIG = Object.freeze({
|
|
|
154
145
|
*/
|
|
155
146
|
track_screen: true,
|
|
156
147
|
/**
|
|
157
|
-
*
|
|
158
|
-
*
|
|
148
|
+
* Record uncaught errors and unhandled promise rejections, from the window's `error` and
|
|
149
|
+
* `unhandledrejection` events. On by default; AppticsError.setErrorTracking() switches it later.
|
|
159
150
|
*/
|
|
160
|
-
|
|
151
|
+
track_error: true,
|
|
161
152
|
/**
|
|
162
|
-
* Record
|
|
163
|
-
*
|
|
153
|
+
* Record clicks on elements tagged `apeventaction` (or `data-apeventaction`) as events. On by
|
|
154
|
+
* default; AppticsEvent.setClickTracking() switches it later.
|
|
164
155
|
*/
|
|
165
|
-
|
|
156
|
+
track_click: true,
|
|
157
|
+
/**
|
|
158
|
+
* How automatic screen tracking names a path, as init() keeps the config's screen_routes: route
|
|
159
|
+
* patterns (`/users/{id}/orders`, each id recorded as a star), exact paths and regular
|
|
160
|
+
* expressions with a name. Tried in order; a path none matches keeps its own name.
|
|
161
|
+
*/
|
|
162
|
+
screen_routes: [],
|
|
163
|
+
/**
|
|
164
|
+
* The feedback form's theme: 'light', 'dark', or 'auto' to follow the visitor's system setting.
|
|
165
|
+
* 'auto' by default.
|
|
166
|
+
*/
|
|
167
|
+
feedback_theme: 'auto',
|
|
166
168
|
/**
|
|
167
169
|
* How long a visit must last before its session is stored, in milliseconds. A shorter visit with
|
|
168
170
|
* nothing tracked in it is dropped: a bounce or a crawler is not a session. Anything tracked
|
|
@@ -208,7 +210,17 @@ const AP_CONFIG = Object.freeze({
|
|
|
208
210
|
* What init() must be given. Everything else the SDK needs — aaid, the portal and project ids that
|
|
209
211
|
* go in every url — comes back from app/addversion, which these four are enough to call.
|
|
210
212
|
*/
|
|
211
|
-
const REQUIRED_CONFIG = Object.freeze(['
|
|
213
|
+
const REQUIRED_CONFIG = Object.freeze(['base_url', 'auth_key', 'app_domain', 'appversion']); // no i18n
|
|
214
|
+
/**
|
|
215
|
+
* The init() keys and the names the SDK keeps them under inside (and in app_version_info, which
|
|
216
|
+
* already-visited browsers have stored): base_url is the host, auth_key the `zak` header, and
|
|
217
|
+
* app_domain the app's identifier.
|
|
218
|
+
*/
|
|
219
|
+
const CONFIG_KEYS = Object.freeze({
|
|
220
|
+
base_url: 'serviceUrl', // no i18n
|
|
221
|
+
auth_key: 'zak', // no i18n
|
|
222
|
+
app_domain: 'identifier', // no i18n
|
|
223
|
+
});
|
|
212
224
|
/**
|
|
213
225
|
* Paths with a `debug/` twin. The debug endpoints take the same body and answer with a request id
|
|
214
226
|
* and a link to the server-side logs for that request, which is how a payload is traced end to
|
|
@@ -243,10 +255,16 @@ const RETRY_CAPABLE_PATHS = Object.freeze({
|
|
|
243
255
|
const PATHS_WITHOUT_ORG = Object.freeze({
|
|
244
256
|
addversion: true, // no i18n
|
|
245
257
|
});
|
|
246
|
-
/**
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
258
|
+
/**
|
|
259
|
+
* Earlier names of the init() keys: 2.0.0-beta's serviceUrl, zak and identifier, and the 1.x
|
|
260
|
+
* console snippet's base_domain and token. Still read, with a warning naming the key to use.
|
|
261
|
+
*/
|
|
262
|
+
const RETIRED_CONFIG_NAMES = Object.freeze({
|
|
263
|
+
serviceUrl: 'base_url', // no i18n
|
|
264
|
+
base_domain: 'base_url', // no i18n
|
|
265
|
+
zak: 'auth_key', // no i18n
|
|
266
|
+
token: 'auth_key', // no i18n
|
|
267
|
+
identifier: 'app_domain', // no i18n
|
|
250
268
|
});
|
|
251
269
|
// crawlers reference
|
|
252
270
|
// https://developers.google.com/search/docs/advanced/crawling/overview-google-crawlers
|
|
@@ -283,7 +301,7 @@ exports.AP_FEEDBACK_TYPE = AP_FEEDBACK_TYPE;
|
|
|
283
301
|
exports.AP_LOG_MODULE = AP_LOG_MODULE;
|
|
284
302
|
exports.AP_TRACKING_STATUS = AP_TRACKING_STATUS;
|
|
285
303
|
exports.BLOCKED_WS = BLOCKED_WS;
|
|
286
|
-
exports.
|
|
304
|
+
exports.CONFIG_KEYS = CONFIG_KEYS;
|
|
287
305
|
exports.CONSOLE_LOG_MAX_BODY = CONSOLE_LOG_MAX_BODY;
|
|
288
306
|
exports.DEBUG_CAPABLE_PATHS = DEBUG_CAPABLE_PATHS;
|
|
289
307
|
exports.DEBUG_IDLE_MS = DEBUG_IDLE_MS;
|
|
@@ -295,5 +313,6 @@ exports.LOG_FUNCTION_MAX = LOG_FUNCTION_MAX;
|
|
|
295
313
|
exports.PATHS_WITHOUT_ORG = PATHS_WITHOUT_ORG;
|
|
296
314
|
exports.REMOTE_LOG_LEVEL = REMOTE_LOG_LEVEL;
|
|
297
315
|
exports.REQUIRED_CONFIG = REQUIRED_CONFIG;
|
|
316
|
+
exports.RETIRED_CONFIG_NAMES = RETIRED_CONFIG_NAMES;
|
|
298
317
|
exports.RETRY_CAPABLE_PATHS = RETRY_CAPABLE_PATHS;
|
|
299
318
|
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;
|