@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,251 @@
|
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
|
+
import { BLOCKED_WS } from './constants.js';
|
|
3
|
+
import { includes } from './utils.js';
|
|
4
|
+
|
|
5
|
+
function isBlockedWS(ua) {
|
|
6
|
+
var i;
|
|
7
|
+
ua = ua.toLowerCase();
|
|
8
|
+
for (i = 0; i < BLOCKED_WS.length; i++) {
|
|
9
|
+
if (ua.indexOf(BLOCKED_WS[i]) !== -1) {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
/** Device RAM as the API wants it ("4 GB"). Chromium only; empty elsewhere. */
|
|
16
|
+
function getRam() {
|
|
17
|
+
var gb = navigator.deviceMemory;
|
|
18
|
+
return typeof gb === 'number' && gb > 0 ? gb + ' GB' : ''; // no i18n
|
|
19
|
+
}
|
|
20
|
+
function getConnectionType() {
|
|
21
|
+
var connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection || {};
|
|
22
|
+
return connection.effectiveType || connection.type || ''; // no i18n
|
|
23
|
+
}
|
|
24
|
+
function getNetworkStatus() {
|
|
25
|
+
return window.navigator.onLine ? 0 : -1;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The battery as a whole percentage, or null where the browser will not say.
|
|
29
|
+
*
|
|
30
|
+
* feedbackWebSDK types `battery` as an int and the console shows it next to a report, which is
|
|
31
|
+
* what makes "it died while I was filling this in" legible. The Battery Status API is behind a
|
|
32
|
+
* promise and is absent in Firefox and Safari entirely, so this answers null rather than 0 -
|
|
33
|
+
* a real 0% and "no answer" are different things, and only one of them belongs in a report.
|
|
34
|
+
*/
|
|
35
|
+
function getBatteryPercent() {
|
|
36
|
+
try {
|
|
37
|
+
var getBattery = navigator.getBattery;
|
|
38
|
+
if (typeof getBattery !== 'function') { // no i18n
|
|
39
|
+
return Promise.resolve(null);
|
|
40
|
+
}
|
|
41
|
+
return getBattery.call(navigator).then(function (battery) {
|
|
42
|
+
var level = battery && typeof battery.level === 'number' ? battery.level : -1; // no i18n
|
|
43
|
+
return level >= 0 && level <= 1 ? Math.round(level * 100) : null;
|
|
44
|
+
}, function () {
|
|
45
|
+
return null;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
return Promise.resolve(null);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function getOrientation() {
|
|
53
|
+
var orientation = (window.screen && window.screen.orientation && window.screen.orientation.type) || ''; // no i18n
|
|
54
|
+
if (includes(orientation, 'portrait-primary')) { // no i18n
|
|
55
|
+
return 0;
|
|
56
|
+
}
|
|
57
|
+
if (includes(orientation, 'landscape-primary')) { // no i18n
|
|
58
|
+
return 1;
|
|
59
|
+
}
|
|
60
|
+
if (includes(orientation, 'landscape-secondary')) { // no i18n
|
|
61
|
+
return 2;
|
|
62
|
+
}
|
|
63
|
+
if (includes(orientation, 'portrait-secondary')) { // no i18n
|
|
64
|
+
return 3;
|
|
65
|
+
}
|
|
66
|
+
return -1;
|
|
67
|
+
}
|
|
68
|
+
function getDevice() {
|
|
69
|
+
var ua = navigator.userAgent;
|
|
70
|
+
if (/Windows/i.test(ua)) {
|
|
71
|
+
return (/Phone/.test(ua) || /WPDesktop/.test(ua)) ? 'Windows Phone' : 'Windows'; // no i18n
|
|
72
|
+
}
|
|
73
|
+
if (/iPad/.test(ua)) {
|
|
74
|
+
return 'iPad'; // no i18n
|
|
75
|
+
}
|
|
76
|
+
if (/iPod/.test(ua)) {
|
|
77
|
+
return 'iPod Touch'; // no i18n
|
|
78
|
+
}
|
|
79
|
+
if (/iPhone/.test(ua)) {
|
|
80
|
+
return 'iPhone'; // no i18n
|
|
81
|
+
}
|
|
82
|
+
if (/(BlackBerry|PlayBook|BB10)/i.test(ua)) {
|
|
83
|
+
return 'BlackBerry'; // no i18n
|
|
84
|
+
}
|
|
85
|
+
if (/Android/.test(ua)) {
|
|
86
|
+
return 'Android'; // no i18n
|
|
87
|
+
}
|
|
88
|
+
if (/Mac/i.test(ua)) {
|
|
89
|
+
return 'Mac'; // no i18n
|
|
90
|
+
}
|
|
91
|
+
if (/Linux/.test(ua)) {
|
|
92
|
+
return 'Linux'; // no i18n
|
|
93
|
+
}
|
|
94
|
+
if (/CrOS/.test(ua)) {
|
|
95
|
+
return 'Chrome'; // no i18n
|
|
96
|
+
}
|
|
97
|
+
return ''; // no i18n
|
|
98
|
+
}
|
|
99
|
+
function getOS() {
|
|
100
|
+
var ua = navigator.userAgent;
|
|
101
|
+
if (/Windows/i.test(ua)) {
|
|
102
|
+
return (/Phone/.test(ua) || /WPDesktop/.test(ua)) ? 'Windows Phone' : 'Windows'; // no i18n
|
|
103
|
+
}
|
|
104
|
+
if (/(iPhone|iPad|iPod)/.test(ua)) {
|
|
105
|
+
return 'iOS'; // no i18n
|
|
106
|
+
}
|
|
107
|
+
if (/Android/.test(ua)) {
|
|
108
|
+
return 'Android'; // no i18n
|
|
109
|
+
}
|
|
110
|
+
if (/(BlackBerry|PlayBook|BB10)/i.test(ua)) {
|
|
111
|
+
return 'BlackBerry'; // no i18n
|
|
112
|
+
}
|
|
113
|
+
if (/Mac/i.test(ua)) {
|
|
114
|
+
return 'Mac OS X'; // no i18n
|
|
115
|
+
}
|
|
116
|
+
if (/Linux/.test(ua)) {
|
|
117
|
+
return 'Linux'; // no i18n
|
|
118
|
+
}
|
|
119
|
+
if (/CrOS/.test(ua)) {
|
|
120
|
+
return 'Chrome OS'; // no i18n
|
|
121
|
+
}
|
|
122
|
+
return ''; // no i18n
|
|
123
|
+
}
|
|
124
|
+
function getBrowser() {
|
|
125
|
+
var ua = navigator.userAgent;
|
|
126
|
+
var vendor = navigator.vendor || ''; // no i18n // vendor is undefined for at least IE9
|
|
127
|
+
var opera = window.opera;
|
|
128
|
+
if (opera || includes(ua, ' OPR/')) { // no i18n
|
|
129
|
+
return (includes(ua, 'Mini')) ? 'Opera Mini' : 'Opera'; // no i18n
|
|
130
|
+
}
|
|
131
|
+
if (/(BlackBerry|PlayBook|BB10)/i.test(ua)) {
|
|
132
|
+
return 'BlackBerry'; // no i18n
|
|
133
|
+
}
|
|
134
|
+
if (includes(ua, 'IEMobile') || includes(ua, 'WPDesktop')) { // no i18n
|
|
135
|
+
return 'Internet Explorer Mobile'; // no i18n
|
|
136
|
+
}
|
|
137
|
+
if (includes(ua, 'SamsungBrowser/')) { // no i18n
|
|
138
|
+
return 'Samsung Internet'; // no i18n
|
|
139
|
+
}
|
|
140
|
+
if (includes(ua, 'Edge') || includes(ua, 'Edg/')) { // no i18n
|
|
141
|
+
return 'Microsoft Edge'; // no i18n
|
|
142
|
+
}
|
|
143
|
+
if (includes(ua, 'FBIOS')) { // no i18n
|
|
144
|
+
return 'Facebook Mobile'; // no i18n
|
|
145
|
+
}
|
|
146
|
+
if (includes(ua, 'Chrome')) { // no i18n
|
|
147
|
+
if (typeof ulaa == 'object') {
|
|
148
|
+
return 'Ulaa'; // no i18n
|
|
149
|
+
}
|
|
150
|
+
else if (window.navigator.brave != undefined && window.navigator.brave.isBrave.name == "isBrave") { // no i18n
|
|
151
|
+
return 'Brave'; // no i18n
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
return 'Chrome'; // no i18n
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (includes(ua, 'CriOS')) { // no i18n
|
|
158
|
+
return 'Chrome iOS'; // no i18n
|
|
159
|
+
}
|
|
160
|
+
if (includes(ua, 'UCWEB') || includes(ua, 'UCBrowser')) { // no i18n
|
|
161
|
+
return 'UC Browser'; // no i18n
|
|
162
|
+
}
|
|
163
|
+
if (includes(ua, 'FxiOS')) { // no i18n
|
|
164
|
+
return 'Firefox iOS'; // no i18n
|
|
165
|
+
}
|
|
166
|
+
if (includes(vendor, 'Apple')) { // no i18n
|
|
167
|
+
return (includes(ua, 'Mobile')) ? 'Mobile Safari' : 'Safari'; // no i18n
|
|
168
|
+
}
|
|
169
|
+
if (includes(ua, 'Android')) { // no i18n
|
|
170
|
+
return 'Android Mobile'; // no i18n
|
|
171
|
+
}
|
|
172
|
+
if (includes(ua, 'Konqueror')) { // no i18n
|
|
173
|
+
return 'Konqueror'; // no i18n
|
|
174
|
+
}
|
|
175
|
+
if (includes(ua, 'Firefox')) { // no i18n
|
|
176
|
+
return 'Firefox'; // no i18n
|
|
177
|
+
}
|
|
178
|
+
if (includes(ua, 'MSIE') || includes(ua, 'Trident/')) { // no i18n
|
|
179
|
+
return 'Internet Explorer'; // no i18n
|
|
180
|
+
}
|
|
181
|
+
if (includes(ua, 'Gecko')) { // no i18n
|
|
182
|
+
return 'Mozilla'; // no i18n
|
|
183
|
+
}
|
|
184
|
+
return ''; // no i18n
|
|
185
|
+
}
|
|
186
|
+
function getBrowserVersion() {
|
|
187
|
+
var browser = getBrowser();
|
|
188
|
+
var ua = navigator.userAgent;
|
|
189
|
+
var versionRegexs = {
|
|
190
|
+
'Internet Explorer Mobile': /rv:(\d+(\.\d+)?)/, // no i18n
|
|
191
|
+
'Microsoft Edge': /Edg\/(\d+(\.\d+)?)/, // no i18n
|
|
192
|
+
'Chrome': /Chrome\/(\d+(\.\d+)?)/, // no i18n
|
|
193
|
+
'Brave': /Chrome\/(\d+(\.\d+)?)/, // no i18n
|
|
194
|
+
'Chrome iOS': /CriOS\/(\d+(\.\d+)?)/, // no i18n
|
|
195
|
+
'UC Browser': /(UCBrowser|UCWEB)\/(\d+(\.\d+)?)/, // no i18n
|
|
196
|
+
'Safari': /Version\/(\d+(\.\d+)?)/, // no i18n
|
|
197
|
+
'Mobile Safari': /Version\/(\d+(\.\d+)?)/, // no i18n
|
|
198
|
+
'Opera': /(Opera|OPR)\/(\d+(\.\d+)?)/, // no i18n
|
|
199
|
+
'Firefox': /Firefox\/(\d+(\.\d+)?)/, // no i18n
|
|
200
|
+
'Firefox iOS': /FxiOS\/(\d+(\.\d+)?)/, // no i18n
|
|
201
|
+
'Konqueror': /Konqueror:(\d+(\.\d+)?)/, // no i18n
|
|
202
|
+
'BlackBerry': /BlackBerry (\d+(\.\d+)?)/, // no i18n
|
|
203
|
+
'Android Mobile': /android\s(\d+(\.\d+)?)/, // no i18n
|
|
204
|
+
'Internet Explorer': /(rv:|MSIE )(\d+(\.\d+)?)/, // no i18n
|
|
205
|
+
'Mozilla': /rv:(\d+(\.\d+)?)/ // no i18n
|
|
206
|
+
};
|
|
207
|
+
// Check for Ulaa browser version
|
|
208
|
+
if (browser === 'Ulaa' && typeof ulaa === 'object') { // no i18n
|
|
209
|
+
return ulaa.getVersion();
|
|
210
|
+
}
|
|
211
|
+
var regex = versionRegexs[browser];
|
|
212
|
+
if (regex === undefined) {
|
|
213
|
+
return ''; // no i18n
|
|
214
|
+
}
|
|
215
|
+
var matches = ua.match(regex);
|
|
216
|
+
if (!matches) {
|
|
217
|
+
return ''; // no i18n
|
|
218
|
+
}
|
|
219
|
+
return parseFloat(matches[matches.length - 2]);
|
|
220
|
+
}
|
|
221
|
+
function getReferringURL() {
|
|
222
|
+
var split = String(window.location.href || '').split(window.location.pathname); // no i18n
|
|
223
|
+
if (split.length >= 2) {
|
|
224
|
+
return split[1].length > 500 ? split[1].substring(0, 500) : split[1];
|
|
225
|
+
}
|
|
226
|
+
return ''; // no i18n
|
|
227
|
+
}
|
|
228
|
+
function getTimeZone() {
|
|
229
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
230
|
+
}
|
|
231
|
+
/** True for crawlers and non-browser environments; the SDK does nothing for them. */
|
|
232
|
+
function is_apptics_disabled() {
|
|
233
|
+
return typeof navigator === 'undefined' || isBlockedWS(navigator.userAgent || ''); // no i18n
|
|
234
|
+
}
|
|
235
|
+
/** Pure DNT check (no side effects). consent.hasDoNotTrackEnabled() applies NO_TRACKING. */
|
|
236
|
+
function isDntOn() {
|
|
237
|
+
var nav = window.navigator || {};
|
|
238
|
+
var dntValues = [true, 1, '1', 'yes']; // no i18n
|
|
239
|
+
return [nav.doNotTrack, nav.msDoNotTrack, window.doNotTrack].some(function (dntValue) {
|
|
240
|
+
return includes(dntValues, dntValue);
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
/** The console snippet's config (window.appticssettings._defaultoptions), if the page defines one. */
|
|
244
|
+
function getSnippetOptions() {
|
|
245
|
+
if (typeof window === 'undefined' || !window.appticssettings) { // no i18n
|
|
246
|
+
return undefined;
|
|
247
|
+
}
|
|
248
|
+
return window.appticssettings._defaultoptions;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export { getBatteryPercent, getBrowser, getBrowserVersion, getConnectionType, getDevice, getNetworkStatus, getOS, getOrientation, getRam, getReferringURL, getSnippetOptions, getTimeZone, isBlockedWS, isDntOn, is_apptics_disabled };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const FRAMEWORK_ID = 6002;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
|
+
// Generated by scripts/register-version.mjs — do not edit by hand.
|
|
3
|
+
// The framework id Apptics issued for this SDK, from POST /sdk/web/v1/framework/addversion
|
|
4
|
+
// (version 2.0.0-beta.1, platform Browser). Regenerated on every npm pack.
|
|
5
|
+
const FRAMEWORK_ID = 6002;
|
|
6
|
+
|
|
7
|
+
export { FRAMEWORK_ID };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Public calls never throw into the host app, and are buffered until start-up finishes. */
|
|
2
|
+
export declare function guard<F extends (...args: any[]) => any>(name: string, fn: F): F;
|
|
3
|
+
/**
|
|
4
|
+
* Hands a public call's own `arguments` to its guarded function, exactly as they were given.
|
|
5
|
+
*
|
|
6
|
+
* guard() returns a wrapper that takes `...args`, so a browser console shows every public call as
|
|
7
|
+
* `(...args)`. Each public call is therefore its own function with named parameters, which is what
|
|
8
|
+
* the console shows, and forwards through this: `arguments` rather than the named parameters, so
|
|
9
|
+
* a call keeps its argument count (addEvent tells its two forms apart by it).
|
|
10
|
+
*/
|
|
11
|
+
export declare function forward<F extends (...args: any[]) => any>(guarded: F, args: IArguments): ReturnType<F>;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
|
+
import { _ZAP } from './state.js';
|
|
3
|
+
import { warnAlways, logFailure } from './logger.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Calls that run immediately while storage is loading. Everything else is buffered and replayed in order.
|
|
7
|
+
* getUser / getTrackingStatus answer from defaults until then; sendFeedback waits for ready() itself.
|
|
8
|
+
* The two log collectors run now so an entry keeps the time it actually happened.
|
|
9
|
+
*/
|
|
10
|
+
const RUN_BEFORE_READY = {
|
|
11
|
+
'Apptics.init': true, 'Apptics.ready': true, 'Apptics.reset': true, 'AppticsUser.getUser': true,
|
|
12
|
+
'AppticsSettings.getTrackingStatus': true, 'AppticsFeedback.sendFeedback': true,
|
|
13
|
+
'AppticsFeedback.addFeedbackLog': true, 'AppticsFeedback.addDiagnosticsInfo': true,
|
|
14
|
+
// a switch, which init() must not undo: it keeps what was set when its config has no theme
|
|
15
|
+
'AppticsFeedback.setFeedbackTheme': true,
|
|
16
|
+
// a switch, and a call that hands back the id endTrackApi needs: neither can wait in a queue
|
|
17
|
+
'AppticsApi.configure': true, 'AppticsApi.startTrackApi': true,
|
|
18
|
+
// these wait for ready() themselves, and a queued call would hand back undefined, not a Promise
|
|
19
|
+
'AppticsRemoteConfig.fetchValue': true, 'AppticsRemoteConfig.fetchValues': true,
|
|
20
|
+
'AppticsRemoteConfig.setCustomConditionValue': true,
|
|
21
|
+
'Apptics.enableDebug': true, 'Apptics.disableDebug': true,
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Calls that record or send something, and so are lost when the SDK hasn't started. Calls that only
|
|
25
|
+
* set a switch or read a value (Apptics.enableDebug, AppticsLogger.enable, AppticsFeedback.addFeedbackLog,
|
|
26
|
+
* AppticsUser.getUser, …)
|
|
27
|
+
* work without Apptics.init() and are not listed.
|
|
28
|
+
*/
|
|
29
|
+
const NEEDS_INIT = {
|
|
30
|
+
'AppticsEvent.addEvent': true, 'AppticsScreen.inScreen': true, 'AppticsScreen.outScreen': true,
|
|
31
|
+
'AppticsApi.endTrackApi': true, 'AppticsError.trackError': true, 'AppticsUser.setUser': true,
|
|
32
|
+
'Apptics.flush': true, AppticsLogger: true, 'AppticsFeedback.sendFeedback': true, 'AppticsRemoteConfig.fetchValue': true,
|
|
33
|
+
'AppticsRemoteConfig.fetchValues': true,
|
|
34
|
+
};
|
|
35
|
+
/** How a call is named in a message: every public call is named after its object, as `AppticsEvent.addEvent`. */
|
|
36
|
+
function publicName(name) {
|
|
37
|
+
return name.indexOf('Apptics') === 0 ? name : 'apptics.' + name; // no i18n
|
|
38
|
+
}
|
|
39
|
+
/** Warned once per page: one line is a clue, a line per call would bury the console. */
|
|
40
|
+
var warnedNotStarted = false;
|
|
41
|
+
/** Public calls never throw into the host app, and are buffered until start-up finishes. */
|
|
42
|
+
function guard(name, fn) {
|
|
43
|
+
const guarded = function (...args) {
|
|
44
|
+
// not started: init() wasn't called, or it refused the config. Say so whether or not
|
|
45
|
+
// console_log is on, since console_log itself is only switched on by init()
|
|
46
|
+
if (!_ZAP._initialised && NEEDS_INIT[name] && !warnedNotStarted) {
|
|
47
|
+
warnedNotStarted = true;
|
|
48
|
+
warnAlways(publicName(name) + ': the SDK has not started, so this call is ignored. Call Apptics.init() first, and check its warnings if you did.'); // no i18n
|
|
49
|
+
}
|
|
50
|
+
if (_ZAP._initialised && !_ZAP._ready && !RUN_BEFORE_READY[name]) {
|
|
51
|
+
_ZAP._pending.push(function () {
|
|
52
|
+
guarded(...args);
|
|
53
|
+
});
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
return fn(...args);
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
// a public call swallowing its own exception into a debug-gated console line is how
|
|
61
|
+
// "the modal does not open" looks from the outside: nothing happens, nothing is said.
|
|
62
|
+
// The app is still shielded - the call returns undefined rather than throwing - but
|
|
63
|
+
// the failure is now visible without debug, and reaches the remote logger
|
|
64
|
+
warnAlways(publicName(name) + ' failed:', err); // no i18n
|
|
65
|
+
logFailure(name, err);
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
return guarded;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Hands a public call's own `arguments` to its guarded function, exactly as they were given.
|
|
73
|
+
*
|
|
74
|
+
* guard() returns a wrapper that takes `...args`, so a browser console shows every public call as
|
|
75
|
+
* `(...args)`. Each public call is therefore its own function with named parameters, which is what
|
|
76
|
+
* the console shows, and forwards through this: `arguments` rather than the named parameters, so
|
|
77
|
+
* a call keeps its argument count (addEvent tells its two forms apart by it).
|
|
78
|
+
*/
|
|
79
|
+
function forward(guarded, args) {
|
|
80
|
+
return guarded.apply(null, Array.prototype.slice.call(args));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export { forward, guard };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { DeviceInfo, ServerResult } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Late-bound calls from lower modules up to the modules above them (see spec §5). device.ts and
|
|
4
|
+
* remotelog/index.ts assign these when they are evaluated; the defaults only run if that module
|
|
5
|
+
* was never imported.
|
|
6
|
+
*/
|
|
7
|
+
export declare const hooks: {
|
|
8
|
+
updateDevice: (deviceInfo: DeviceInfo) => Promise<ServerResult>;
|
|
9
|
+
refreshDeviceInfo: () => void;
|
|
10
|
+
/** Set by remotelog/index.ts. Here, not imported, so the logger doesn't depend on the sender. */
|
|
11
|
+
/**
|
|
12
|
+
* Set by feedback/controls.ts: the user picked in the feedback form, or null for anonymous.
|
|
13
|
+
* Here so transport can read the choice without importing the modal.
|
|
14
|
+
*/
|
|
15
|
+
feedbackUser: () => {
|
|
16
|
+
userid: string;
|
|
17
|
+
groupid: string;
|
|
18
|
+
} | null;
|
|
19
|
+
/**
|
|
20
|
+
* Set by heatmap/send.ts. Here so the scheduler can flush heatmap records without importing
|
|
21
|
+
* the module — an app that never imports the heatmap entry keeps the default no-op.
|
|
22
|
+
*/
|
|
23
|
+
sendHeatmaps: (forget?: boolean) => Promise<void>;
|
|
24
|
+
/** Set by heatmap/track.ts, so init() and reset() can switch capture without importing it. */
|
|
25
|
+
trackHeatmap: (status?: boolean) => void;
|
|
26
|
+
/** Set by heatmap/track.ts: clears what this visit recorded, so the cap starts again. */
|
|
27
|
+
resetHeatmap: () => void;
|
|
28
|
+
/** Set by remoteconfig/fetch.ts, so reset() can forget the rule set without importing it. */
|
|
29
|
+
resetRemoteConfig: () => void;
|
|
30
|
+
/**
|
|
31
|
+
* Set by engagement/auto-screen.ts: the app called inScreen() itself. Here because
|
|
32
|
+
* auto-screen records through track.ts, so track.ts cannot import it back.
|
|
33
|
+
*/
|
|
34
|
+
screenTrackedByApp: () => void;
|
|
35
|
+
/** Set by remoteconfig/fetch.ts: start-up has finished, so remote config fetches its values. */
|
|
36
|
+
remoteConfigStarted: () => void;
|
|
37
|
+
/** Set by remoteconfig/fetch.ts: AppticsUser.setUser changed who this is, so conditions on the user re-apply. */
|
|
38
|
+
remoteConfigUserChanged: () => void;
|
|
39
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
|
+
/**
|
|
3
|
+
* Late-bound calls from lower modules up to the modules above them (see spec §5). device.ts and
|
|
4
|
+
* remotelog/index.ts assign these when they are evaluated; the defaults only run if that module
|
|
5
|
+
* was never imported.
|
|
6
|
+
*/
|
|
7
|
+
const hooks = {
|
|
8
|
+
updateDevice: () => Promise.reject('apptics: device module not loaded'), // no i18n
|
|
9
|
+
refreshDeviceInfo: () => { },
|
|
10
|
+
feedbackUser: () => null,
|
|
11
|
+
sendHeatmaps: () => Promise.resolve(),
|
|
12
|
+
trackHeatmap: () => { },
|
|
13
|
+
resetHeatmap: () => { },
|
|
14
|
+
resetRemoteConfig: () => { },
|
|
15
|
+
screenTrackedByApp: () => { },
|
|
16
|
+
remoteConfigStarted: () => { },
|
|
17
|
+
remoteConfigUserChanged: () => { },
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { hooks };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs `run` while holding the Web Lock `name`, waiting for it if another tab of this site holds
|
|
3
|
+
* it. Locks are shared by every tab of an origin, which is what keeps two tabs from registering
|
|
4
|
+
* the same browser twice or overwriting each other's session.
|
|
5
|
+
*
|
|
6
|
+
* Without the Web Locks API (older browsers), `run` simply runs, as it did before locks were used.
|
|
7
|
+
* Not reentrant: `run` must not ask for the same lock again, or it waits for itself.
|
|
8
|
+
*/
|
|
9
|
+
export declare function withLock<T>(name: string, run: () => Promise<T>): Promise<T>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
|
+
/**
|
|
3
|
+
* Runs `run` while holding the Web Lock `name`, waiting for it if another tab of this site holds
|
|
4
|
+
* it. Locks are shared by every tab of an origin, which is what keeps two tabs from registering
|
|
5
|
+
* the same browser twice or overwriting each other's session.
|
|
6
|
+
*
|
|
7
|
+
* Without the Web Locks API (older browsers), `run` simply runs, as it did before locks were used.
|
|
8
|
+
* Not reentrant: `run` must not ask for the same lock again, or it waits for itself.
|
|
9
|
+
*/
|
|
10
|
+
function withLock(name, run) {
|
|
11
|
+
var locks = typeof navigator !== 'undefined' ? navigator.locks : undefined; // no i18n
|
|
12
|
+
if (!locks || typeof locks.request !== 'function') { // no i18n
|
|
13
|
+
return run();
|
|
14
|
+
}
|
|
15
|
+
return locks.request('apptics-' + name, function () {
|
|
16
|
+
return run();
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { withLock };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const Console: {
|
|
2
|
+
log: (...args: unknown[]) => void;
|
|
3
|
+
warn: (...args: unknown[]) => void;
|
|
4
|
+
error: (...args: unknown[]) => void;
|
|
5
|
+
info: (...args: unknown[]) => void;
|
|
6
|
+
dir(arg: unknown): void;
|
|
7
|
+
};
|
|
8
|
+
/** Warnings the integrator must see even with debug off (e.g. missing required config). */
|
|
9
|
+
export declare function warnAlways(...args: unknown[]): void;
|
|
10
|
+
/**
|
|
11
|
+
* A failure inside one of the SDK's own modules, `module` one of AP_LOG_MODULE's values: said in
|
|
12
|
+
* the browser console in debug mode. Nothing is sent: the Remote Logger page carries only the
|
|
13
|
+
* lines an app logs with AppticsLogger.
|
|
14
|
+
*/
|
|
15
|
+
export declare function logFailure(module: string, ...args: unknown[]): void;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
|
+
import { _ZAP } from './state.js';
|
|
3
|
+
import { each } from './utils.js';
|
|
4
|
+
|
|
5
|
+
const APConsole = typeof console !== 'undefined' ? console : null;
|
|
6
|
+
function gated(method) {
|
|
7
|
+
return function (...args) {
|
|
8
|
+
if (_ZAP._config.debug && APConsole) {
|
|
9
|
+
try {
|
|
10
|
+
APConsole[method].apply(APConsole, args);
|
|
11
|
+
}
|
|
12
|
+
catch (err) {
|
|
13
|
+
each(args, function (arg) {
|
|
14
|
+
APConsole[method](arg);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
// Console override
|
|
21
|
+
const Console = {
|
|
22
|
+
log: gated('log'),
|
|
23
|
+
warn: gated('warn'),
|
|
24
|
+
error: gated('error'),
|
|
25
|
+
info: gated('info'),
|
|
26
|
+
dir(arg) {
|
|
27
|
+
if (_ZAP._config.debug && APConsole) {
|
|
28
|
+
APConsole.dir(arg);
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
/** Warnings the integrator must see even with debug off (e.g. missing required config). */
|
|
33
|
+
function warnAlways(...args) {
|
|
34
|
+
if (APConsole)
|
|
35
|
+
APConsole.warn(...args);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A failure inside one of the SDK's own modules, `module` one of AP_LOG_MODULE's values: said in
|
|
39
|
+
* the browser console in debug mode. Nothing is sent: the Remote Logger page carries only the
|
|
40
|
+
* lines an app logs with AppticsLogger.
|
|
41
|
+
*/
|
|
42
|
+
function logFailure(module, ...args) {
|
|
43
|
+
Console.error.apply(null, args);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { Console, logFailure, warnAlways };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type ApConfig } from './constants.js';
|
|
2
|
+
import type { DeviceInfo, Dict, QuartzSettings, TrackingStatus, UserInfo } from '../types.js';
|
|
3
|
+
/** Runtime state shared by every module (the former `_ZAP` object). */
|
|
4
|
+
export interface State {
|
|
5
|
+
_initialised: boolean;
|
|
6
|
+
/** Start-up finished (storage loaded, session open, timers running). */
|
|
7
|
+
_ready: boolean;
|
|
8
|
+
/** Public calls made after init() and before _ready, replayed in order. */
|
|
9
|
+
_pending: Array<() => void>;
|
|
10
|
+
_readyPromise: Promise<boolean> | null;
|
|
11
|
+
_regDeviceSending: boolean;
|
|
12
|
+
_regDeviceResolve: Array<(value: any) => void>;
|
|
13
|
+
_regDeviceReject: Array<(reason: any) => void>;
|
|
14
|
+
_sending: boolean;
|
|
15
|
+
_deferSendTimer: ReturnType<typeof setTimeout> | null;
|
|
16
|
+
_config: ApConfig;
|
|
17
|
+
_defaultoptions: Dict;
|
|
18
|
+
inactiveduration: number;
|
|
19
|
+
_token: string;
|
|
20
|
+
_frameworkID: number;
|
|
21
|
+
_platform: string;
|
|
22
|
+
_isanonrequired: boolean;
|
|
23
|
+
_devicestatus: TrackingStatus;
|
|
24
|
+
_uuid: string;
|
|
25
|
+
_apid: string;
|
|
26
|
+
_mapid: string;
|
|
27
|
+
_device_info: DeviceInfo;
|
|
28
|
+
_user_info: UserInfo;
|
|
29
|
+
_current_screen: Dict;
|
|
30
|
+
_current_session: Dict;
|
|
31
|
+
_properties: Dict;
|
|
32
|
+
_ignoreDnt: boolean;
|
|
33
|
+
_isGlobalErrorTracking: boolean;
|
|
34
|
+
_shouldTrack: boolean;
|
|
35
|
+
_engagementTracking: boolean;
|
|
36
|
+
_errorTracking: boolean;
|
|
37
|
+
/** getsdkconfig module 18. Heatmap has its own flag in v2; before that it rode engagement. */
|
|
38
|
+
_heatmapTracking: boolean;
|
|
39
|
+
/** getsdkconfig module 17. */
|
|
40
|
+
_remoteLoggerEnabled: boolean;
|
|
41
|
+
/** getsdkconfig's module flag for remote config, which is the authority on whether it runs. */
|
|
42
|
+
_remoteConfigEnabled: boolean;
|
|
43
|
+
/** What the last getupdates answer said, used only to stop asking about a module it reported off. */
|
|
44
|
+
_remoteConfigReported: boolean;
|
|
45
|
+
/** getsdkconfig module 12. */
|
|
46
|
+
_feedbackEnabled: boolean;
|
|
47
|
+
/** getsdkconfig's `quartz` block: screen recording in the feedback form. Off until it says otherwise. */
|
|
48
|
+
_quartz: QuartzSettings;
|
|
49
|
+
/** Epoch ms getsdkconfig asked us to wait until before asking again. 0 means no answer yet. */
|
|
50
|
+
_nextConfigCheck: number;
|
|
51
|
+
/**
|
|
52
|
+
* When debug mode switches itself off, as a timestamp; 0 while it is not running.
|
|
53
|
+
* Every tracked item pushes it back, so it only arrives after a genuinely idle hour.
|
|
54
|
+
*/
|
|
55
|
+
_debugUntil: number;
|
|
56
|
+
_trackinfo: Dict;
|
|
57
|
+
}
|
|
58
|
+
export declare const _ZAP: State;
|
|
59
|
+
/** Restores every field to its default. The object identity is kept, since modules hold a reference to it. */
|
|
60
|
+
export declare function resetState(): void;
|
|
61
|
+
export declare function getConfig<K extends keyof ApConfig>(key: K): ApConfig[K];
|
|
62
|
+
/** The oldest timestamp still worth keeping: now minus batch_request_timeout days. */
|
|
63
|
+
export declare function oldestKeptTime(): number;
|
|
64
|
+
/**
|
|
65
|
+
* True for an item too old (or dated far enough in the future to be nonsense) to be worth
|
|
66
|
+
* sending. Queues use it to drop such items on the way in, and the sender uses it to drop the
|
|
67
|
+
* ones already stored. A minute of slack absorbs clock differences between tabs and machines,
|
|
68
|
+
* so an item a few milliseconds ahead of this clock is still kept.
|
|
69
|
+
*/
|
|
70
|
+
export declare function isExpired(time: unknown): boolean;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
|
+
import { AP_TRACKING_STATUS, AP_CONSTANTS, DEFAULT_INACTIVE_MINUTES, AP_CONFIG } from './constants.js';
|
|
3
|
+
import { nowMs } from './utils.js';
|
|
4
|
+
import { FRAMEWORK_ID } from './framework-id.js';
|
|
5
|
+
|
|
6
|
+
function initialState() {
|
|
7
|
+
return {
|
|
8
|
+
_initialised: false,
|
|
9
|
+
_ready: false,
|
|
10
|
+
_pending: [],
|
|
11
|
+
_readyPromise: null,
|
|
12
|
+
_regDeviceSending: false,
|
|
13
|
+
_regDeviceResolve: [],
|
|
14
|
+
_regDeviceReject: [],
|
|
15
|
+
_sending: false,
|
|
16
|
+
_deferSendTimer: null,
|
|
17
|
+
_config: { ...AP_CONFIG },
|
|
18
|
+
_defaultoptions: {},
|
|
19
|
+
inactiveduration: DEFAULT_INACTIVE_MINUTES,
|
|
20
|
+
_token: '', // no i18n
|
|
21
|
+
// issued by Apptics at pack time; see scripts/register-version.mjs
|
|
22
|
+
_frameworkID: FRAMEWORK_ID,
|
|
23
|
+
_platform: AP_CONSTANTS.BROWSER,
|
|
24
|
+
_isanonrequired: true,
|
|
25
|
+
_devicestatus: AP_TRACKING_STATUS.USAGE_TRACKING_WITHOUT_PII,
|
|
26
|
+
_uuid: '', // no i18n
|
|
27
|
+
_apid: '', // no i18n
|
|
28
|
+
_mapid: '', // no i18n
|
|
29
|
+
_device_info: {},
|
|
30
|
+
_user_info: {},
|
|
31
|
+
_current_screen: {},
|
|
32
|
+
_current_session: {},
|
|
33
|
+
_properties: {},
|
|
34
|
+
_ignoreDnt: false,
|
|
35
|
+
_isGlobalErrorTracking: true,
|
|
36
|
+
_shouldTrack: true,
|
|
37
|
+
_engagementTracking: true,
|
|
38
|
+
_heatmapTracking: true,
|
|
39
|
+
_remoteLoggerEnabled: true,
|
|
40
|
+
_remoteConfigEnabled: true,
|
|
41
|
+
_remoteConfigReported: true,
|
|
42
|
+
_feedbackEnabled: true,
|
|
43
|
+
_nextConfigCheck: 0,
|
|
44
|
+
_debugUntil: 0,
|
|
45
|
+
_errorTracking: true,
|
|
46
|
+
_quartz: { enabled: false, workspace: '', department: '', domain: '', cdnUrl: '' }, // no i18n
|
|
47
|
+
_trackinfo: {},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
const _ZAP = initialState();
|
|
51
|
+
function getConfig(key) {
|
|
52
|
+
return _ZAP._config[key];
|
|
53
|
+
}
|
|
54
|
+
/** The oldest timestamp still worth keeping: now minus batch_request_timeout days. */
|
|
55
|
+
function oldestKeptTime() {
|
|
56
|
+
return nowMs() - getConfig('batch_request_timeout') * 24 * 60 * 60 * 1000; // no i18n
|
|
57
|
+
}
|
|
58
|
+
/** How far ahead of this clock a timestamp may be before it counts as nonsense. */
|
|
59
|
+
const CLOCK_SKEW_MS = 60 * 1000;
|
|
60
|
+
/**
|
|
61
|
+
* True for an item too old (or dated far enough in the future to be nonsense) to be worth
|
|
62
|
+
* sending. Queues use it to drop such items on the way in, and the sender uses it to drop the
|
|
63
|
+
* ones already stored. A minute of slack absorbs clock differences between tabs and machines,
|
|
64
|
+
* so an item a few milliseconds ahead of this clock is still kept.
|
|
65
|
+
*/
|
|
66
|
+
function isExpired(time) {
|
|
67
|
+
if (typeof time !== 'number' || !isFinite(time)) {
|
|
68
|
+
return false; // no usable timestamp: leave it to the caller's own rules
|
|
69
|
+
}
|
|
70
|
+
return time < oldestKeptTime() || time > nowMs() + CLOCK_SKEW_MS;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export { _ZAP, getConfig, isExpired, oldestKeptTime };
|