@zoho_apptics/apptics-js-sdk 1.0.2 → 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 +193 -0
- package/LICENSE +13 -0
- package/README.md +846 -11
- package/dist/apptics.esm.min.js +3 -0
- package/dist/apptics.esm.min.js.map +1 -0
- package/dist/apptics.min.js +3 -0
- package/dist/apptics.min.js.map +1 -0
- 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 +8 -0
- package/dist/cjs/auto-init.js +32 -0
- package/dist/cjs/core/attempts.d.ts +28 -0
- package/dist/cjs/core/attempts.js +113 -0
- package/dist/cjs/core/batch.d.ts +32 -0
- package/dist/cjs/core/batch.js +116 -0
- package/dist/cjs/core/callsite.d.ts +34 -0
- package/dist/cjs/core/callsite.js +115 -0
- package/dist/cjs/core/consent.d.ts +27 -0
- package/dist/cjs/core/consent.js +132 -0
- package/dist/cjs/core/constants.d.ts +237 -0
- package/dist/cjs/core/constants.js +315 -0
- package/dist/cjs/core/db.d.ts +48 -0
- package/dist/cjs/core/db.js +467 -0
- package/dist/cjs/core/debug.d.ts +22 -0
- package/dist/cjs/core/debug.js +88 -0
- package/dist/cjs/core/env.d.ts +28 -0
- package/dist/cjs/core/env.js +267 -0
- package/dist/cjs/core/framework-id.d.ts +1 -0
- package/dist/cjs/core/framework-id.js +9 -0
- package/dist/cjs/core/guard.d.ts +11 -0
- package/dist/cjs/core/guard.js +86 -0
- package/dist/cjs/core/hooks.d.ts +39 -0
- package/dist/cjs/core/hooks.js +22 -0
- package/dist/cjs/core/locks.d.ts +9 -0
- package/dist/cjs/core/locks.js +22 -0
- package/dist/cjs/core/logger.d.ts +15 -0
- package/dist/cjs/core/logger.js +50 -0
- package/dist/cjs/core/state.d.ts +70 -0
- package/dist/cjs/core/state.js +78 -0
- package/dist/cjs/core/storage.d.ts +61 -0
- package/dist/cjs/core/storage.js +327 -0
- package/dist/cjs/core/stylesheet.d.ts +8 -0
- package/dist/cjs/core/stylesheet.js +29 -0
- package/dist/cjs/core/transport.d.ts +85 -0
- package/dist/cjs/core/transport.js +456 -0
- package/dist/cjs/core/utils.d.ts +26 -0
- package/dist/cjs/core/utils.js +175 -0
- package/dist/cjs/core/validate.d.ts +18 -0
- package/dist/cjs/core/validate.js +233 -0
- package/dist/cjs/device/appversion.d.ts +15 -0
- package/dist/cjs/device/appversion.js +170 -0
- package/dist/cjs/device/index.d.ts +34 -0
- package/dist/cjs/device/index.js +472 -0
- package/dist/cjs/engagement/api-rules.d.ts +49 -0
- package/dist/cjs/engagement/api-rules.js +206 -0
- package/dist/cjs/engagement/auto-api.d.ts +7 -0
- package/dist/cjs/engagement/auto-api.js +200 -0
- package/dist/cjs/engagement/auto-screen.d.ts +18 -0
- package/dist/cjs/engagement/auto-screen.js +305 -0
- package/dist/cjs/engagement/defined-events.d.ts +23 -0
- package/dist/cjs/engagement/defined-events.js +58 -0
- package/dist/cjs/engagement/send.d.ts +6 -0
- package/dist/cjs/engagement/send.js +104 -0
- package/dist/cjs/engagement/session.d.ts +51 -0
- package/dist/cjs/engagement/session.js +463 -0
- package/dist/cjs/engagement/track.d.ts +56 -0
- package/dist/cjs/engagement/track.js +375 -0
- package/dist/cjs/errors/send.d.ts +6 -0
- package/dist/cjs/errors/send.js +73 -0
- package/dist/cjs/errors/track.d.ts +4 -0
- package/dist/cjs/errors/track.js +167 -0
- package/dist/cjs/feedback/controls.d.ts +37 -0
- package/dist/cjs/feedback/controls.js +316 -0
- package/dist/cjs/feedback/index.d.ts +9 -0
- package/dist/cjs/feedback/index.js +56 -0
- package/dist/cjs/feedback/logs.d.ts +45 -0
- package/dist/cjs/feedback/logs.js +241 -0
- package/dist/cjs/feedback/quartz.d.ts +18 -0
- package/dist/cjs/feedback/quartz.js +105 -0
- package/dist/cjs/feedback/send.d.ts +28 -0
- package/dist/cjs/feedback/send.js +203 -0
- package/dist/cjs/feedback/styles.d.ts +10 -0
- package/dist/cjs/feedback/styles.js +8 -0
- package/dist/cjs/feedback/template.d.ts +2 -0
- package/dist/cjs/feedback/template.js +162 -0
- package/dist/cjs/feedback/ui.d.ts +63 -0
- package/dist/cjs/feedback/ui.js +709 -0
- package/dist/cjs/heatmap/send.d.ts +13 -0
- package/dist/cjs/heatmap/send.js +82 -0
- package/dist/cjs/heatmap/track.d.ts +4 -0
- package/dist/cjs/heatmap/track.js +448 -0
- package/dist/cjs/index.d.ts +22 -0
- package/dist/cjs/index.js +162 -0
- package/dist/cjs/lifecycle.d.ts +21 -0
- package/dist/cjs/lifecycle.js +734 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/remoteconfig/country.d.ts +4 -0
- package/dist/cjs/remoteconfig/country.js +73 -0
- package/dist/cjs/remoteconfig/custom.d.ts +10 -0
- package/dist/cjs/remoteconfig/custom.js +58 -0
- package/dist/cjs/remoteconfig/evaluate.d.ts +24 -0
- package/dist/cjs/remoteconfig/evaluate.js +184 -0
- package/dist/cjs/remoteconfig/fetch.d.ts +24 -0
- package/dist/cjs/remoteconfig/fetch.js +200 -0
- package/dist/cjs/remoteconfig/index.d.ts +15 -0
- package/dist/cjs/remoteconfig/index.js +116 -0
- package/dist/cjs/remoteconfig/store.d.ts +18 -0
- package/dist/cjs/remoteconfig/store.js +98 -0
- 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 -0
- package/dist/cjs/remotelog/gate.js +28 -0
- package/dist/cjs/remotelog/index.d.ts +8 -0
- package/dist/cjs/remotelog/logger.d.ts +22 -0
- package/dist/cjs/remotelog/logger.js +111 -0
- package/dist/cjs/remotelog/send.d.ts +13 -0
- package/dist/cjs/remotelog/send.js +153 -0
- package/dist/cjs/remotelogger/index.d.ts +12 -0
- package/dist/cjs/remotelogger/index.js +18 -0
- package/dist/cjs/scheduler.d.ts +8 -0
- package/dist/cjs/scheduler.js +78 -0
- package/dist/cjs/types.d.ts +385 -0
- package/dist/cjs/user/index.d.ts +33 -0
- package/dist/cjs/user/index.js +183 -0
- package/dist/esm/auto-init.d.ts +8 -0
- package/dist/esm/auto-init.js +29 -0
- package/dist/esm/core/attempts.d.ts +28 -0
- package/dist/esm/core/attempts.js +106 -0
- package/dist/esm/core/batch.d.ts +32 -0
- package/dist/esm/core/batch.js +109 -0
- package/dist/esm/core/callsite.d.ts +34 -0
- package/dist/esm/core/callsite.js +110 -0
- package/dist/esm/core/consent.d.ts +27 -0
- package/dist/esm/core/consent.js +122 -0
- package/dist/esm/core/constants.d.ts +237 -0
- package/dist/esm/core/constants.js +292 -0
- package/dist/esm/core/db.d.ts +48 -0
- package/dist/esm/core/db.js +453 -0
- package/dist/esm/core/debug.d.ts +22 -0
- package/dist/esm/core/debug.js +81 -0
- package/dist/esm/core/env.d.ts +28 -0
- package/dist/esm/core/env.js +251 -0
- package/dist/esm/core/framework-id.d.ts +1 -0
- package/dist/esm/core/framework-id.js +7 -0
- package/dist/esm/core/guard.d.ts +11 -0
- package/dist/esm/core/guard.js +83 -0
- package/dist/esm/core/hooks.d.ts +39 -0
- package/dist/esm/core/hooks.js +20 -0
- package/dist/esm/core/locks.d.ts +9 -0
- package/dist/esm/core/locks.js +20 -0
- package/dist/esm/core/logger.d.ts +15 -0
- package/dist/esm/core/logger.js +46 -0
- package/dist/esm/core/state.d.ts +70 -0
- package/dist/esm/core/state.js +73 -0
- package/dist/esm/core/storage.d.ts +61 -0
- package/dist/esm/core/storage.js +314 -0
- package/dist/esm/core/stylesheet.d.ts +8 -0
- package/dist/esm/core/stylesheet.js +27 -0
- package/dist/esm/core/transport.d.ts +85 -0
- package/dist/esm/core/transport.js +439 -0
- package/dist/esm/core/utils.d.ts +26 -0
- package/dist/esm/core/utils.js +161 -0
- package/dist/esm/core/validate.d.ts +18 -0
- package/dist/esm/core/validate.js +226 -0
- package/dist/esm/device/appversion.d.ts +15 -0
- package/dist/esm/device/appversion.js +164 -0
- package/dist/esm/device/index.d.ts +34 -0
- package/dist/esm/device/index.js +461 -0
- package/dist/esm/engagement/api-rules.d.ts +49 -0
- package/dist/esm/engagement/api-rules.js +199 -0
- package/dist/esm/engagement/auto-api.d.ts +7 -0
- package/dist/esm/engagement/auto-api.js +198 -0
- package/dist/esm/engagement/auto-screen.d.ts +18 -0
- package/dist/esm/engagement/auto-screen.js +301 -0
- package/dist/esm/engagement/defined-events.d.ts +23 -0
- package/dist/esm/engagement/defined-events.js +55 -0
- package/dist/esm/engagement/send.d.ts +6 -0
- package/dist/esm/engagement/send.js +101 -0
- package/dist/esm/engagement/session.d.ts +51 -0
- package/dist/esm/engagement/session.js +448 -0
- package/dist/esm/engagement/track.d.ts +56 -0
- package/dist/esm/engagement/track.js +365 -0
- package/dist/esm/errors/send.d.ts +6 -0
- package/dist/esm/errors/send.js +70 -0
- package/dist/esm/errors/track.d.ts +4 -0
- package/dist/esm/errors/track.js +163 -0
- package/dist/esm/feedback/controls.d.ts +37 -0
- package/dist/esm/feedback/controls.js +309 -0
- package/dist/esm/feedback/index.d.ts +9 -0
- package/dist/esm/feedback/index.js +51 -0
- package/dist/esm/feedback/logs.d.ts +45 -0
- package/dist/esm/feedback/logs.js +227 -0
- package/dist/esm/feedback/quartz.d.ts +18 -0
- package/dist/esm/feedback/quartz.js +99 -0
- package/dist/esm/feedback/send.d.ts +28 -0
- package/dist/esm/feedback/send.js +198 -0
- package/dist/esm/feedback/styles.d.ts +10 -0
- package/dist/esm/feedback/styles.js +4 -0
- package/dist/esm/feedback/template.d.ts +2 -0
- package/dist/esm/feedback/template.js +159 -0
- package/dist/esm/feedback/ui.d.ts +63 -0
- package/dist/esm/feedback/ui.js +703 -0
- package/dist/esm/heatmap/send.d.ts +13 -0
- package/dist/esm/heatmap/send.js +79 -0
- package/dist/esm/heatmap/track.d.ts +4 -0
- package/dist/esm/heatmap/track.js +445 -0
- package/dist/esm/index.d.ts +22 -0
- package/dist/esm/index.js +150 -0
- package/dist/esm/lifecycle.d.ts +21 -0
- package/dist/esm/lifecycle.js +729 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/remoteconfig/country.d.ts +4 -0
- package/dist/esm/remoteconfig/country.js +70 -0
- package/dist/esm/remoteconfig/custom.d.ts +10 -0
- package/dist/esm/remoteconfig/custom.js +54 -0
- package/dist/esm/remoteconfig/evaluate.d.ts +24 -0
- package/dist/esm/remoteconfig/evaluate.js +179 -0
- package/dist/esm/remoteconfig/fetch.d.ts +24 -0
- package/dist/esm/remoteconfig/fetch.js +196 -0
- package/dist/esm/remoteconfig/index.d.ts +15 -0
- package/dist/esm/remoteconfig/index.js +111 -0
- package/dist/esm/remoteconfig/store.d.ts +18 -0
- package/dist/esm/remoteconfig/store.js +91 -0
- 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 -0
- package/dist/esm/remotelog/gate.js +26 -0
- package/dist/esm/remotelog/index.d.ts +8 -0
- package/dist/esm/remotelog/logger.d.ts +22 -0
- package/dist/esm/remotelog/logger.js +108 -0
- package/dist/esm/remotelog/send.d.ts +13 -0
- package/dist/esm/remotelog/send.js +149 -0
- package/dist/esm/remotelogger/index.d.ts +12 -0
- package/dist/esm/remotelogger/index.js +13 -0
- package/dist/esm/scheduler.d.ts +8 -0
- package/dist/esm/scheduler.js +74 -0
- package/dist/esm/types.d.ts +385 -0
- package/dist/esm/user/index.d.ts +33 -0
- package/dist/esm/user/index.js +176 -0
- package/dist/feedback.esm.min.js +3 -0
- package/dist/feedback.esm.min.js.map +1 -0
- package/package.json +122 -7
- package/src/appticssdk.js +0 -1
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
|
+
import { AP_TRACKING_STATUS } from './constants.js';
|
|
3
|
+
import { _ZAP } from './state.js';
|
|
4
|
+
import { Console } from './logger.js';
|
|
5
|
+
import { isEmpty, isSuccess } from './utils.js';
|
|
6
|
+
import { tracking_preference } from './storage.js';
|
|
7
|
+
import { is_apptics_disabled, isDntOn } from './env.js';
|
|
8
|
+
import { hooks } from './hooks.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* DNT counts only when not ignored; while it counts, tracking is NO_TRACKING (opt_in_status).
|
|
12
|
+
* Decided on every visit and never stored: storing it made one visit with DNT on look like the
|
|
13
|
+
* visitor's own choice, so tracking stayed off after DNT was turned off or ignore_do_not_track set.
|
|
14
|
+
*/
|
|
15
|
+
function hasDoNotTrackEnabled() {
|
|
16
|
+
if (_ZAP._ignoreDnt) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
if (isDntOn()) {
|
|
20
|
+
Console.warn('hasDoNotTrackEnabled: DoNotTrack is enabled, so nothing is tracked'); // no i18n
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
function opt_in_status() {
|
|
26
|
+
if (hasDoNotTrackEnabled()) {
|
|
27
|
+
Console.warn('opt_in_status: It seems "Do Not Track" is enabled in this browser. Please enable tracking in the browser settings to continue tracking.'); // no i18n
|
|
28
|
+
return AP_TRACKING_STATUS.NO_TRACKING;
|
|
29
|
+
}
|
|
30
|
+
var status = tracking_preference.opt_in_status();
|
|
31
|
+
if (status == -1) {
|
|
32
|
+
Console.warn('opt_in_status: You are opted out of Apptics tracking. This will prevent the our SDK from sending no data to our server.'); // no i18n
|
|
33
|
+
}
|
|
34
|
+
return status;
|
|
35
|
+
}
|
|
36
|
+
function shouldTrackOrSendData() {
|
|
37
|
+
var optInStatus = opt_in_status();
|
|
38
|
+
return optInStatus > -1 && _ZAP._shouldTrack;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The guard every tracking call starts with: init() has run, the client isn't a crawler,
|
|
42
|
+
* and consent / server flags allow tracking.
|
|
43
|
+
*/
|
|
44
|
+
function canTrack(caller) {
|
|
45
|
+
if (!_ZAP._token) {
|
|
46
|
+
Console.warn('apptics.' + caller + ': You must call Apptics.init() first'); // no i18n
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
if (is_apptics_disabled()) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
return shouldTrackOrSendData();
|
|
53
|
+
}
|
|
54
|
+
/** canTrack plus the server's `engagementtracking` flag from getupdates (events, screens, sessions, api calls). */
|
|
55
|
+
function canTrackEngagement(caller) {
|
|
56
|
+
if (!canTrack(caller)) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
if (!_ZAP._engagementTracking) {
|
|
60
|
+
Console.log('apptics.' + caller + ': engagement tracking is turned off by the server'); // no i18n
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* canTrack plus the server's heatmap flag (getsdkconfig module 18).
|
|
67
|
+
*
|
|
68
|
+
* Heatmap rode the engagement flag until v2 gave it one of its own, which matters: an app may
|
|
69
|
+
* well want events while declining to have every click's coordinates recorded.
|
|
70
|
+
*/
|
|
71
|
+
function canTrackHeatmap(caller) {
|
|
72
|
+
if (!canTrack(caller)) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
if (!_ZAP._heatmapTracking) {
|
|
76
|
+
Console.log('apptics.' + caller + ': heatmap tracking is turned off by the server'); // no i18n
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
/** canTrack plus the server's `errortracking` flag from getupdates. */
|
|
82
|
+
function canTrackErrors(caller) {
|
|
83
|
+
if (!canTrack(caller)) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
if (!_ZAP._errorTracking) {
|
|
87
|
+
Console.log('apptics.' + caller + ': error tracking is turned off by the server'); // no i18n
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
function setTrackingStatus(trackingState) {
|
|
93
|
+
if (isEmpty(trackingState)) {
|
|
94
|
+
Console.warn('setTrackingStatus: trackingStatus is Empty'); // no i18n
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (tracking_preference.opt_in_status() == trackingState) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
tracking_preference.update_status(trackingState);
|
|
101
|
+
_ZAP._devicestatus = tracking_preference.opt_in_status();
|
|
102
|
+
_ZAP._isanonrequired = tracking_preference.opt_in_status() == AP_TRACKING_STATUS.USAGE_TRACKING_WITH_PII ? false : _ZAP._isanonrequired;
|
|
103
|
+
if (tracking_preference.opt_in_status() != AP_TRACKING_STATUS.NO_TRACKING) {
|
|
104
|
+
Console.log('setTrackingStatus: Updating device info with new tracking status'); // no i18n
|
|
105
|
+
hooks.updateDevice(_ZAP._device_info).then(function (result) {
|
|
106
|
+
if (isSuccess(result)) {
|
|
107
|
+
Console.log('setTrackingStatus: Device info updated with new tracking status' + JSON.stringify(result.data)); // no i18n
|
|
108
|
+
Console.dir(result.data);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
Console.log('setTrackingStatus: Error updating device info with new tracking status: ' + JSON.stringify(result)); // no i18n
|
|
112
|
+
}
|
|
113
|
+
}).catch(function (err) {
|
|
114
|
+
Console.warn('setTrackingStatus: Error updating device info with new tracking status: ' + JSON.stringify(err)); // no i18n
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function getTrackingStatus() {
|
|
119
|
+
return opt_in_status();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export { canTrack, canTrackEngagement, canTrackErrors, canTrackHeatmap, getTrackingStatus, hasDoNotTrackEnabled, opt_in_status, setTrackingStatus, shouldTrackOrSendData };
|
|
@@ -0,0 +1,237 @@
|
|
|
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
|
+
};
|
|
17
|
+
export declare const AP_TRACKING_STATUS: Readonly<{
|
|
18
|
+
readonly USAGE_TRACKING_WITH_PII: 1;
|
|
19
|
+
readonly USAGE_TRACKING_WITHOUT_PII: 4;
|
|
20
|
+
readonly NO_TRACKING: -1;
|
|
21
|
+
}>;
|
|
22
|
+
export declare const AP_FEEDBACK_TYPE: Readonly<{
|
|
23
|
+
readonly BUG: 0;
|
|
24
|
+
readonly FEEDBACK: 1;
|
|
25
|
+
readonly HELP: 2;
|
|
26
|
+
readonly REPORT: 3;
|
|
27
|
+
}>;
|
|
28
|
+
export declare const AP_CONSTANTS: Readonly<{
|
|
29
|
+
readonly SCREEN: "screen";
|
|
30
|
+
readonly SESSION: "session";
|
|
31
|
+
readonly EVENT: "event";
|
|
32
|
+
readonly API: "api";
|
|
33
|
+
readonly ERROR: "error";
|
|
34
|
+
readonly SUCCESS: "success";
|
|
35
|
+
readonly BROWSER: "Browser";
|
|
36
|
+
}>;
|
|
37
|
+
export declare const DEFAULT_API_PATHS: Readonly<{
|
|
38
|
+
readonly addversion: "app/addversion";
|
|
39
|
+
readonly regdevice: "device/add";
|
|
40
|
+
readonly reguser: "user/register";
|
|
41
|
+
readonly engagement: "engagement/add";
|
|
42
|
+
readonly error: "exception/error";
|
|
43
|
+
readonly feedback: "feedback/add";
|
|
44
|
+
readonly sdkconfig: "getsdkconfig";
|
|
45
|
+
readonly getupdates: "getupdates";
|
|
46
|
+
readonly consolelog: "log/add";
|
|
47
|
+
readonly heatmap: "heatmap/add";
|
|
48
|
+
}>;
|
|
49
|
+
/**
|
|
50
|
+
* Which API version each path lives under.
|
|
51
|
+
*
|
|
52
|
+
* Every path the SDK calls is defined under v2 in the proxy's security-sdk.xml, and four of them —
|
|
53
|
+
* app/addversion, getsdkconfig, heatmap/add and log/add — are defined there *only* under v2: there
|
|
54
|
+
* is no v1 url for them to fall back to, so sending v1 reaches nothing. It stays a per-path map
|
|
55
|
+
* rather than one shared prefix because v1 urls do still exist for the other five, so a path can
|
|
56
|
+
* be moved back on its own if one of them turns out not to be ready.
|
|
57
|
+
*/
|
|
58
|
+
export declare const API_VERSIONS: Readonly<Record<keyof typeof DEFAULT_API_PATHS, string>>;
|
|
59
|
+
/**
|
|
60
|
+
* The SDK subsystem a remote log line is about, as console/addlog's `module` param.
|
|
61
|
+
* These are the server's own names, so they are sent exactly as written here.
|
|
62
|
+
*/
|
|
63
|
+
export declare const AP_LOG_MODULE: Readonly<{
|
|
64
|
+
readonly SESSION: "Session";
|
|
65
|
+
readonly SCREEN: "Screen";
|
|
66
|
+
readonly EVENT: "Event";
|
|
67
|
+
readonly API: "API";
|
|
68
|
+
readonly HEATMAP: "Heatmap";
|
|
69
|
+
readonly PROPERTIES: "Properties";
|
|
70
|
+
}>;
|
|
71
|
+
/**
|
|
72
|
+
* The modules getsdkconfig reports on, by the ids it keys them with. The SDK acts on the ones it
|
|
73
|
+
* has something to switch off; anything else the server sends is stored but unused.
|
|
74
|
+
*/
|
|
75
|
+
export declare const SDK_MODULE: Readonly<{
|
|
76
|
+
/**
|
|
77
|
+
* Remote config. It is the one module both answers report on: getupdates names it in
|
|
78
|
+
* `moduleids` and reports its flag back, and getsdkconfig reports the same flag as the
|
|
79
|
+
* authority. Where they disagree, getsdkconfig wins.
|
|
80
|
+
*/
|
|
81
|
+
readonly REMOTE_CONFIG: "2";
|
|
82
|
+
readonly SESSION: "11";
|
|
83
|
+
readonly FEEDBACK: "12";
|
|
84
|
+
readonly CRASH: "13";
|
|
85
|
+
readonly REMOTE_LOGGER: "17";
|
|
86
|
+
readonly HEATMAP: "18";
|
|
87
|
+
}>;
|
|
88
|
+
/** logSDK declares max-len="10000" on logmessage, so a line is trimmed to fit that. */
|
|
89
|
+
export declare const CONSOLE_LOG_MAX_BODY = 10000;
|
|
90
|
+
/** logSDK caps `function` at 100 characters. */
|
|
91
|
+
export declare const LOG_FUNCTION_MAX = 100;
|
|
92
|
+
/** logSDK caps `filename` at 100 too, which is why a call site carries a basename, not a url. */
|
|
93
|
+
export declare const LOG_FILENAME_MAX = 100;
|
|
94
|
+
/**
|
|
95
|
+
* How much of `devicename` is sent. The url declares no max-len, only safe_string, but this is a
|
|
96
|
+
* label a person reads in a list: anything longer is a paragraph, not a name.
|
|
97
|
+
*/
|
|
98
|
+
export declare const DEVICE_NAME_MAX = 100;
|
|
99
|
+
/**
|
|
100
|
+
* The `level` every line goes out with. Everything the remote logger carries is a failure inside
|
|
101
|
+
* the SDK — logFailure is its only caller — so the level never varies. 3 is what the v2 reference
|
|
102
|
+
* shows in its only example; the scale itself is not documented anywhere we can see.
|
|
103
|
+
*/
|
|
104
|
+
export declare const REMOTE_LOG_LEVEL = 3;
|
|
105
|
+
/**
|
|
106
|
+
* How long debug mode survives with nothing tracked, before switching itself off.
|
|
107
|
+
*
|
|
108
|
+
* An hour is long enough to cover reading a payload, changing the app and reloading, and short
|
|
109
|
+
* enough that a tab left open overnight is not still sending every call to its debug twin.
|
|
110
|
+
*/
|
|
111
|
+
export declare const DEBUG_IDLE_MS: number;
|
|
112
|
+
/** Idle minutes that end a session. Lives on state, not in _config, but defaults here. */
|
|
113
|
+
export declare const DEFAULT_INACTIVE_MINUTES = 30;
|
|
114
|
+
/** Global defaults. `state._config` holds a mutable copy per init. */
|
|
115
|
+
export declare const AP_CONFIG: Readonly<{
|
|
116
|
+
endpoint: "/sdk/web/";
|
|
117
|
+
method: "POST";
|
|
118
|
+
transport: "XHR";
|
|
119
|
+
track_link_timeout: 300;
|
|
120
|
+
cookie_expiration_days: 365;
|
|
121
|
+
storage_type: "localStorage";
|
|
122
|
+
enable_batch_requests: true;
|
|
123
|
+
batch_size: 50;
|
|
124
|
+
batch_flush_interval: 30000;
|
|
125
|
+
getupdates_interval: 120000;
|
|
126
|
+
batch_request_timeout: 7;
|
|
127
|
+
auto_starts_batch: true;
|
|
128
|
+
mode: 1;
|
|
129
|
+
default_group_name: "default";
|
|
130
|
+
default_optin_status: number;
|
|
131
|
+
enable_pageview_tracking: false;
|
|
132
|
+
save_referrer: true;
|
|
133
|
+
debug: boolean;
|
|
134
|
+
track_by_default: true;
|
|
135
|
+
ignore_do_not_track: boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Wrap XHR and fetch to record the app's API calls without it calling startTrackApi(). Off by
|
|
138
|
+
* default: the hostnames and paths of every request an app makes is a wider grant than events
|
|
139
|
+
* and screens, so the app opts in.
|
|
140
|
+
*/
|
|
141
|
+
track_api: boolean;
|
|
142
|
+
/**
|
|
143
|
+
* Record a screen view for the first page and every navigation after it, from the url. On by
|
|
144
|
+
* default; the app's own inScreen() during a navigation replaces that navigation's view.
|
|
145
|
+
*/
|
|
146
|
+
track_screen: boolean;
|
|
147
|
+
/**
|
|
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.
|
|
151
|
+
*/
|
|
152
|
+
screen_routes: ScreenRouteRule[];
|
|
153
|
+
/**
|
|
154
|
+
* The feedback form's theme: 'light', 'dark', or 'auto' to follow the visitor's system setting.
|
|
155
|
+
* 'auto' by default.
|
|
156
|
+
*/
|
|
157
|
+
feedback_theme: "light" | "dark" | "auto";
|
|
158
|
+
/**
|
|
159
|
+
* How long a visit must last before its session is stored, in milliseconds. A shorter visit with
|
|
160
|
+
* nothing tracked in it is dropped: a bounce or a crawler is not a session. Anything tracked
|
|
161
|
+
* inside the window writes the session immediately, keeping its original start time. 0 disables
|
|
162
|
+
* the wait and stores every session as it starts.
|
|
163
|
+
*/
|
|
164
|
+
min_session_duration: number;
|
|
165
|
+
/**
|
|
166
|
+
* Record where people click and how far they scroll, for the console's heatmaps. Off by default:
|
|
167
|
+
* coordinates and element labels are a wider grant than events and screens, so the app opts in.
|
|
168
|
+
*/
|
|
169
|
+
track_heatmap: boolean;
|
|
170
|
+
/**
|
|
171
|
+
* Send engagement, exception and log payloads to their `debug/` twins, which answer with a
|
|
172
|
+
* request id and a link to the server's own logs for that request. For tracing a payload that
|
|
173
|
+
* is not showing up in the console; off in normal use, and it does not change what is sent.
|
|
174
|
+
*/
|
|
175
|
+
debug_api: boolean;
|
|
176
|
+
/**
|
|
177
|
+
* What to call this device in the debug stream. Engagement, exception and log are the three
|
|
178
|
+
* urls that declare `devicename`, and it is what tells one tester's browser from another's
|
|
179
|
+
* when several are tracing the same build. Empty by default: it rides on every one of those
|
|
180
|
+
* calls, so an app that is not tracing should not pay for it. With `debug_api` on and nothing
|
|
181
|
+
* set here, a label is derived from the browser and OS instead, since an unnamed row in the
|
|
182
|
+
* debug stream is no use to whoever is reading it.
|
|
183
|
+
*/
|
|
184
|
+
device_name: string;
|
|
185
|
+
/**
|
|
186
|
+
* Most heatmap records one visit may produce. Clicks are cheap, but a page that scrolls a lot
|
|
187
|
+
* can produce them faster than they are sent, and an unbounded queue is a memory leak on a tab
|
|
188
|
+
* left open for a day. Reached, capture stops for the rest of the session.
|
|
189
|
+
*/
|
|
190
|
+
heatmap_max_per_session: number;
|
|
191
|
+
}>;
|
|
192
|
+
export type ApConfig = {
|
|
193
|
+
-readonly [K in keyof typeof AP_CONFIG]: (typeof AP_CONFIG)[K];
|
|
194
|
+
};
|
|
195
|
+
/**
|
|
196
|
+
* Config keys `init()` refuses to start without (after the snippet aliases are resolved).
|
|
197
|
+
*
|
|
198
|
+
* `appversion` is here rather than defaulted on purpose. Every error, every device registration
|
|
199
|
+
* and every uploaded source map is only meaningful against the build it came from, and a default
|
|
200
|
+
* would answer that question wrongly and silently for every app that forgot to set it.
|
|
201
|
+
*/
|
|
202
|
+
/**
|
|
203
|
+
* What init() must be given. Everything else the SDK needs — aaid, the portal and project ids that
|
|
204
|
+
* go in every url — comes back from app/addversion, which these four are enough to call.
|
|
205
|
+
*/
|
|
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>>;
|
|
213
|
+
/**
|
|
214
|
+
* Paths with a `debug/` twin. The debug endpoints take the same body and answer with a request id
|
|
215
|
+
* and a link to the server-side logs for that request, which is how a payload is traced end to
|
|
216
|
+
* end when the console does not show what was expected.
|
|
217
|
+
*/
|
|
218
|
+
export declare const DEBUG_CAPABLE_PATHS: Readonly<Record<string, boolean>>;
|
|
219
|
+
/**
|
|
220
|
+
* Paths that declare `attempt`, `firstattempttime` and `lst`.
|
|
221
|
+
*
|
|
222
|
+
* Every url that carries data declares all three. app/addversion and getsdkconfig declare none:
|
|
223
|
+
* they are start-up calls whose answers the SDK needs, not payloads it is pushing, and sending
|
|
224
|
+
* an undeclared param is refused outright as EXTRA_PARAM_FOUND.
|
|
225
|
+
*/
|
|
226
|
+
export declare const RETRY_CAPABLE_PATHS: Readonly<Record<string, boolean>>;
|
|
227
|
+
/**
|
|
228
|
+
* Paths that live directly under the version, with no org and project segments. app/addversion is
|
|
229
|
+
* called before those ids are known, so it cannot carry them.
|
|
230
|
+
*/
|
|
231
|
+
export declare const PATHS_WITHOUT_ORG: Readonly<Record<string, boolean>>;
|
|
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>>;
|
|
237
|
+
export declare const BLOCKED_WS: readonly string[];
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
|
+
const AP_TRACKING_STATUS = Object.freeze({
|
|
3
|
+
USAGE_TRACKING_WITH_PII: 1,
|
|
4
|
+
USAGE_TRACKING_WITHOUT_PII: 4,
|
|
5
|
+
NO_TRACKING: -1,
|
|
6
|
+
});
|
|
7
|
+
const AP_FEEDBACK_TYPE = Object.freeze({
|
|
8
|
+
BUG: 0,
|
|
9
|
+
FEEDBACK: 1,
|
|
10
|
+
HELP: 2,
|
|
11
|
+
REPORT: 3,
|
|
12
|
+
});
|
|
13
|
+
const AP_CONSTANTS = Object.freeze({
|
|
14
|
+
SCREEN: 'screen', // no i18n
|
|
15
|
+
SESSION: 'session', // no i18n
|
|
16
|
+
EVENT: 'event', // no i18n
|
|
17
|
+
API: 'api', // no i18n
|
|
18
|
+
ERROR: 'error', // no i18n
|
|
19
|
+
SUCCESS: 'success', // no i18n
|
|
20
|
+
BROWSER: 'Browser', // no i18n
|
|
21
|
+
});
|
|
22
|
+
const DEFAULT_API_PATHS = Object.freeze({
|
|
23
|
+
// the first call: registers the build and answers with the ids every later call needs
|
|
24
|
+
addversion: 'app/addversion', // no i18n
|
|
25
|
+
regdevice: 'device/add', // no i18n
|
|
26
|
+
reguser: 'user/register', // no i18n
|
|
27
|
+
engagement: 'engagement/add', // no i18n
|
|
28
|
+
// the exception group is part of the path, and the proxy matches it with [a-z]+ — no
|
|
29
|
+
// underscore, so js_error cannot route. 'error' is in the accepted set and is what we send
|
|
30
|
+
error: 'exception/error', // no i18n
|
|
31
|
+
feedback: 'feedback/add', // no i18n
|
|
32
|
+
// the source of truth for which modules are on. v2 replaced the old getupdates answer: it is
|
|
33
|
+
// per-module flags keyed by id now, not loose booleans
|
|
34
|
+
sdkconfig: 'getsdkconfig', // no i18n
|
|
35
|
+
// still its own endpoint, and not a synonym for the one above: it takes a body naming the
|
|
36
|
+
// modules being asked about, and answers with their payloads - remote config among them
|
|
37
|
+
getupdates: 'getupdates', // no i18n
|
|
38
|
+
// v2 replaced console/addlog: one call now carries a batch of lines, not one line
|
|
39
|
+
consolelog: 'log/add', // no i18n
|
|
40
|
+
heatmap: 'heatmap/add', // no i18n
|
|
41
|
+
});
|
|
42
|
+
/**
|
|
43
|
+
* Which API version each path lives under.
|
|
44
|
+
*
|
|
45
|
+
* Every path the SDK calls is defined under v2 in the proxy's security-sdk.xml, and four of them —
|
|
46
|
+
* app/addversion, getsdkconfig, heatmap/add and log/add — are defined there *only* under v2: there
|
|
47
|
+
* is no v1 url for them to fall back to, so sending v1 reaches nothing. It stays a per-path map
|
|
48
|
+
* rather than one shared prefix because v1 urls do still exist for the other five, so a path can
|
|
49
|
+
* be moved back on its own if one of them turns out not to be ready.
|
|
50
|
+
*/
|
|
51
|
+
const API_VERSIONS = Object.freeze({
|
|
52
|
+
addversion: 'v2', // no i18n
|
|
53
|
+
regdevice: 'v2', // no i18n
|
|
54
|
+
engagement: 'v2', // no i18n
|
|
55
|
+
error: 'v2', // no i18n
|
|
56
|
+
reguser: 'v2', // no i18n
|
|
57
|
+
feedback: 'v2', // no i18n
|
|
58
|
+
sdkconfig: 'v2', // no i18n
|
|
59
|
+
getupdates: 'v2', // no i18n
|
|
60
|
+
consolelog: 'v2', // no i18n
|
|
61
|
+
heatmap: 'v2', // no i18n
|
|
62
|
+
});
|
|
63
|
+
/**
|
|
64
|
+
* The SDK subsystem a remote log line is about, as console/addlog's `module` param.
|
|
65
|
+
* These are the server's own names, so they are sent exactly as written here.
|
|
66
|
+
*/
|
|
67
|
+
const AP_LOG_MODULE = Object.freeze({
|
|
68
|
+
SESSION: 'Session', // no i18n
|
|
69
|
+
SCREEN: 'Screen', // no i18n
|
|
70
|
+
EVENT: 'Event', // no i18n
|
|
71
|
+
API: 'API', // no i18n
|
|
72
|
+
HEATMAP: 'Heatmap', // no i18n
|
|
73
|
+
PROPERTIES: 'Properties', // no i18n
|
|
74
|
+
});
|
|
75
|
+
/**
|
|
76
|
+
* The modules getsdkconfig reports on, by the ids it keys them with. The SDK acts on the ones it
|
|
77
|
+
* has something to switch off; anything else the server sends is stored but unused.
|
|
78
|
+
*/
|
|
79
|
+
const SDK_MODULE = Object.freeze({
|
|
80
|
+
/**
|
|
81
|
+
* Remote config. It is the one module both answers report on: getupdates names it in
|
|
82
|
+
* `moduleids` and reports its flag back, and getsdkconfig reports the same flag as the
|
|
83
|
+
* authority. Where they disagree, getsdkconfig wins.
|
|
84
|
+
*/
|
|
85
|
+
REMOTE_CONFIG: '2', // no i18n
|
|
86
|
+
SESSION: '11', // no i18n
|
|
87
|
+
FEEDBACK: '12', // no i18n
|
|
88
|
+
CRASH: '13', // no i18n
|
|
89
|
+
REMOTE_LOGGER: '17', // no i18n
|
|
90
|
+
HEATMAP: '18', // no i18n
|
|
91
|
+
});
|
|
92
|
+
/** logSDK declares max-len="10000" on logmessage, so a line is trimmed to fit that. */
|
|
93
|
+
const CONSOLE_LOG_MAX_BODY = 10000;
|
|
94
|
+
/** logSDK caps `function` at 100 characters. */
|
|
95
|
+
const LOG_FUNCTION_MAX = 100;
|
|
96
|
+
/** logSDK caps `filename` at 100 too, which is why a call site carries a basename, not a url. */
|
|
97
|
+
const LOG_FILENAME_MAX = 100;
|
|
98
|
+
/**
|
|
99
|
+
* How much of `devicename` is sent. The url declares no max-len, only safe_string, but this is a
|
|
100
|
+
* label a person reads in a list: anything longer is a paragraph, not a name.
|
|
101
|
+
*/
|
|
102
|
+
const DEVICE_NAME_MAX = 100;
|
|
103
|
+
/**
|
|
104
|
+
* The `level` every line goes out with. Everything the remote logger carries is a failure inside
|
|
105
|
+
* the SDK — logFailure is its only caller — so the level never varies. 3 is what the v2 reference
|
|
106
|
+
* shows in its only example; the scale itself is not documented anywhere we can see.
|
|
107
|
+
*/
|
|
108
|
+
const REMOTE_LOG_LEVEL = 3;
|
|
109
|
+
/**
|
|
110
|
+
* How long debug mode survives with nothing tracked, before switching itself off.
|
|
111
|
+
*
|
|
112
|
+
* An hour is long enough to cover reading a payload, changing the app and reloading, and short
|
|
113
|
+
* enough that a tab left open overnight is not still sending every call to its debug twin.
|
|
114
|
+
*/
|
|
115
|
+
const DEBUG_IDLE_MS = 60 * 60 * 1000;
|
|
116
|
+
/** Idle minutes that end a session. Lives on state, not in _config, but defaults here. */
|
|
117
|
+
const DEFAULT_INACTIVE_MINUTES = 30;
|
|
118
|
+
/** Global defaults. `state._config` holds a mutable copy per init. */
|
|
119
|
+
const AP_CONFIG = Object.freeze({
|
|
120
|
+
// the version is per path (API_VERSIONS); this is only the part before it
|
|
121
|
+
endpoint: '/sdk/web/', // no i18n
|
|
122
|
+
method: 'POST', // no i18n
|
|
123
|
+
transport: 'XHR', // no i18n
|
|
124
|
+
track_link_timeout: 300,
|
|
125
|
+
cookie_expiration_days: 365,
|
|
126
|
+
storage_type: 'localStorage', // no i18n
|
|
127
|
+
enable_batch_requests: true,
|
|
128
|
+
batch_size: 50,
|
|
129
|
+
batch_flush_interval: 30000,
|
|
130
|
+
getupdates_interval: 120000, // 2 minutes in milliseconds
|
|
131
|
+
batch_request_timeout: 7,
|
|
132
|
+
auto_starts_batch: true,
|
|
133
|
+
mode: 1,
|
|
134
|
+
default_group_name: 'default', // no i18n
|
|
135
|
+
default_optin_status: AP_TRACKING_STATUS.USAGE_TRACKING_WITHOUT_PII,
|
|
136
|
+
enable_pageview_tracking: false,
|
|
137
|
+
save_referrer: true,
|
|
138
|
+
debug: false,
|
|
139
|
+
track_by_default: true,
|
|
140
|
+
ignore_do_not_track: false,
|
|
141
|
+
/**
|
|
142
|
+
* Wrap XHR and fetch to record the app's API calls without it calling startTrackApi(). Off by
|
|
143
|
+
* default: the hostnames and paths of every request an app makes is a wider grant than events
|
|
144
|
+
* and screens, so the app opts in.
|
|
145
|
+
*/
|
|
146
|
+
track_api: false,
|
|
147
|
+
/**
|
|
148
|
+
* Record a screen view for the first page and every navigation after it, from the url. On by
|
|
149
|
+
* default; the app's own inScreen() during a navigation replaces that navigation's view.
|
|
150
|
+
*/
|
|
151
|
+
track_screen: true,
|
|
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: [],
|
|
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: 'auto',
|
|
163
|
+
/**
|
|
164
|
+
* How long a visit must last before its session is stored, in milliseconds. A shorter visit with
|
|
165
|
+
* nothing tracked in it is dropped: a bounce or a crawler is not a session. Anything tracked
|
|
166
|
+
* inside the window writes the session immediately, keeping its original start time. 0 disables
|
|
167
|
+
* the wait and stores every session as it starts.
|
|
168
|
+
*/
|
|
169
|
+
min_session_duration: 5000,
|
|
170
|
+
/**
|
|
171
|
+
* Record where people click and how far they scroll, for the console's heatmaps. Off by default:
|
|
172
|
+
* coordinates and element labels are a wider grant than events and screens, so the app opts in.
|
|
173
|
+
*/
|
|
174
|
+
track_heatmap: false,
|
|
175
|
+
/**
|
|
176
|
+
* Send engagement, exception and log payloads to their `debug/` twins, which answer with a
|
|
177
|
+
* request id and a link to the server's own logs for that request. For tracing a payload that
|
|
178
|
+
* is not showing up in the console; off in normal use, and it does not change what is sent.
|
|
179
|
+
*/
|
|
180
|
+
debug_api: false,
|
|
181
|
+
/**
|
|
182
|
+
* What to call this device in the debug stream. Engagement, exception and log are the three
|
|
183
|
+
* urls that declare `devicename`, and it is what tells one tester's browser from another's
|
|
184
|
+
* when several are tracing the same build. Empty by default: it rides on every one of those
|
|
185
|
+
* calls, so an app that is not tracing should not pay for it. With `debug_api` on and nothing
|
|
186
|
+
* set here, a label is derived from the browser and OS instead, since an unnamed row in the
|
|
187
|
+
* debug stream is no use to whoever is reading it.
|
|
188
|
+
*/
|
|
189
|
+
device_name: '',
|
|
190
|
+
/**
|
|
191
|
+
* Most heatmap records one visit may produce. Clicks are cheap, but a page that scrolls a lot
|
|
192
|
+
* can produce them faster than they are sent, and an unbounded queue is a memory leak on a tab
|
|
193
|
+
* left open for a day. Reached, capture stops for the rest of the session.
|
|
194
|
+
*/
|
|
195
|
+
heatmap_max_per_session: 500,
|
|
196
|
+
});
|
|
197
|
+
/**
|
|
198
|
+
* Config keys `init()` refuses to start without (after the snippet aliases are resolved).
|
|
199
|
+
*
|
|
200
|
+
* `appversion` is here rather than defaulted on purpose. Every error, every device registration
|
|
201
|
+
* and every uploaded source map is only meaningful against the build it came from, and a default
|
|
202
|
+
* would answer that question wrongly and silently for every app that forgot to set it.
|
|
203
|
+
*/
|
|
204
|
+
/**
|
|
205
|
+
* What init() must be given. Everything else the SDK needs — aaid, the portal and project ids that
|
|
206
|
+
* go in every url — comes back from app/addversion, which these four are enough to call.
|
|
207
|
+
*/
|
|
208
|
+
const REQUIRED_CONFIG = Object.freeze(['base_url', 'auth_key', 'app_domain', 'appversion']); // no i18n
|
|
209
|
+
/**
|
|
210
|
+
* The init() keys and the names the SDK keeps them under inside (and in app_version_info, which
|
|
211
|
+
* already-visited browsers have stored): base_url is the host, auth_key the `zak` header, and
|
|
212
|
+
* app_domain the app's identifier.
|
|
213
|
+
*/
|
|
214
|
+
const CONFIG_KEYS = Object.freeze({
|
|
215
|
+
base_url: 'serviceUrl', // no i18n
|
|
216
|
+
auth_key: 'zak', // no i18n
|
|
217
|
+
app_domain: 'identifier', // no i18n
|
|
218
|
+
});
|
|
219
|
+
/**
|
|
220
|
+
* Paths with a `debug/` twin. The debug endpoints take the same body and answer with a request id
|
|
221
|
+
* and a link to the server-side logs for that request, which is how a payload is traced end to
|
|
222
|
+
* end when the console does not show what was expected.
|
|
223
|
+
*/
|
|
224
|
+
const DEBUG_CAPABLE_PATHS = Object.freeze({
|
|
225
|
+
engagement: true, // no i18n
|
|
226
|
+
error: true, // no i18n
|
|
227
|
+
consolelog: true, // no i18n
|
|
228
|
+
});
|
|
229
|
+
/**
|
|
230
|
+
* Paths that declare `attempt`, `firstattempttime` and `lst`.
|
|
231
|
+
*
|
|
232
|
+
* Every url that carries data declares all three. app/addversion and getsdkconfig declare none:
|
|
233
|
+
* they are start-up calls whose answers the SDK needs, not payloads it is pushing, and sending
|
|
234
|
+
* an undeclared param is refused outright as EXTRA_PARAM_FOUND.
|
|
235
|
+
*/
|
|
236
|
+
const RETRY_CAPABLE_PATHS = Object.freeze({
|
|
237
|
+
regdevice: true, // no i18n
|
|
238
|
+
reguser: true, // no i18n
|
|
239
|
+
engagement: true, // no i18n
|
|
240
|
+
error: true, // no i18n
|
|
241
|
+
heatmap: true, // no i18n
|
|
242
|
+
consolelog: true, // no i18n
|
|
243
|
+
feedback: true, // no i18n
|
|
244
|
+
getupdates: true, // no i18n
|
|
245
|
+
});
|
|
246
|
+
/**
|
|
247
|
+
* Paths that live directly under the version, with no org and project segments. app/addversion is
|
|
248
|
+
* called before those ids are known, so it cannot carry them.
|
|
249
|
+
*/
|
|
250
|
+
const PATHS_WITHOUT_ORG = Object.freeze({
|
|
251
|
+
addversion: true, // no i18n
|
|
252
|
+
});
|
|
253
|
+
/**
|
|
254
|
+
* Earlier names of the init() keys: 2.0.0-beta's serviceUrl, zak and identifier, and the 1.x
|
|
255
|
+
* console snippet's base_domain and token. Still read, with a warning naming the key to use.
|
|
256
|
+
*/
|
|
257
|
+
const RETIRED_CONFIG_NAMES = Object.freeze({
|
|
258
|
+
serviceUrl: 'base_url', // no i18n
|
|
259
|
+
base_domain: 'base_url', // no i18n
|
|
260
|
+
zak: 'auth_key', // no i18n
|
|
261
|
+
token: 'auth_key', // no i18n
|
|
262
|
+
identifier: 'app_domain', // no i18n
|
|
263
|
+
});
|
|
264
|
+
// crawlers reference
|
|
265
|
+
// https://developers.google.com/search/docs/advanced/crawling/overview-google-crawlers
|
|
266
|
+
const BLOCKED_WS = Object.freeze([
|
|
267
|
+
'ahrefsbot', // no i18n
|
|
268
|
+
'ahrefssiteaudit', // no i18n
|
|
269
|
+
'baiduspider', // no i18n
|
|
270
|
+
'bingbot', // no i18n
|
|
271
|
+
'bingpreview', // no i18n
|
|
272
|
+
'chrome-lighthouse', // no i18n
|
|
273
|
+
'facebookexternal', // no i18n
|
|
274
|
+
'petalbot', // no i18n
|
|
275
|
+
'pinterest', // no i18n
|
|
276
|
+
'screaming frog', // no i18n
|
|
277
|
+
'yahoo! slurp', // no i18n
|
|
278
|
+
'yandexbot', // no i18n
|
|
279
|
+
'adsbot-google', // no i18n
|
|
280
|
+
'apis-google', // no i18n
|
|
281
|
+
'duplexweb-google', // no i18n
|
|
282
|
+
'feedfetcher-google', // no i18n
|
|
283
|
+
'google favicon', // no i18n
|
|
284
|
+
'google web preview', // no i18n
|
|
285
|
+
'google-read-aloud', // no i18n
|
|
286
|
+
'googlebot', // no i18n
|
|
287
|
+
'googleweblight', // no i18n
|
|
288
|
+
'mediapartners-google', // no i18n
|
|
289
|
+
'storebot-google', // no i18n
|
|
290
|
+
]);
|
|
291
|
+
|
|
292
|
+
export { API_VERSIONS, AP_CONFIG, AP_CONSTANTS, AP_FEEDBACK_TYPE, AP_LOG_MODULE, AP_TRACKING_STATUS, BLOCKED_WS, CONFIG_KEYS, CONSOLE_LOG_MAX_BODY, DEBUG_CAPABLE_PATHS, DEBUG_IDLE_MS, DEFAULT_API_PATHS, DEFAULT_INACTIVE_MINUTES, DEVICE_NAME_MAX, LOG_FILENAME_MAX, LOG_FUNCTION_MAX, PATHS_WITHOUT_ORG, REMOTE_LOG_LEVEL, REQUIRED_CONFIG, RETIRED_CONFIG_NAMES, RETRY_CAPABLE_PATHS, SDK_MODULE };
|