@zoho_apptics/apptics-js-sdk 2.0.0-beta.1 → 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 +80 -16
- package/README.md +187 -100
- 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 +1 -2
- package/dist/cjs/core/consent.d.ts +13 -3
- package/dist/cjs/core/consent.js +24 -10
- package/dist/cjs/core/constants.d.ts +22 -17
- package/dist/cjs/core/constants.js +22 -19
- package/dist/cjs/core/db.js +1 -1
- 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.js +1 -1
- package/dist/cjs/core/hooks.d.ts +5 -0
- package/dist/cjs/core/hooks.js +2 -1
- package/dist/cjs/core/locks.js +1 -1
- package/dist/cjs/core/logger.js +1 -1
- package/dist/cjs/core/state.d.ts +6 -4
- package/dist/cjs/core/state.js +2 -4
- package/dist/cjs/core/storage.js +1 -4
- package/dist/cjs/core/stylesheet.js +1 -1
- package/dist/cjs/core/transport.js +13 -16
- package/dist/cjs/core/utils.js +1 -1
- package/dist/cjs/core/validate.js +1 -1
- package/dist/cjs/device/appversion.d.ts +10 -1
- package/dist/cjs/device/appversion.js +26 -3
- package/dist/cjs/device/index.d.ts +17 -2
- package/dist/cjs/device/index.js +195 -27
- package/dist/cjs/engagement/api-rules.js +1 -1
- package/dist/cjs/engagement/auto-api.js +1 -1
- package/dist/cjs/engagement/auto-screen.js +1 -1
- package/dist/cjs/engagement/defined-events.js +1 -1
- package/dist/cjs/engagement/send.js +7 -3
- package/dist/cjs/engagement/session.d.ts +17 -0
- package/dist/cjs/engagement/session.js +95 -4
- package/dist/cjs/engagement/track.d.ts +4 -4
- package/dist/cjs/engagement/track.js +15 -12
- package/dist/cjs/errors/send.js +2 -2
- package/dist/cjs/errors/track.d.ts +2 -1
- package/dist/cjs/errors/track.js +6 -4
- package/dist/cjs/feedback/controls.d.ts +6 -0
- package/dist/cjs/feedback/controls.js +74 -25
- package/dist/cjs/feedback/index.js +1 -1
- package/dist/cjs/feedback/logs.d.ts +3 -6
- package/dist/cjs/feedback/logs.js +8 -18
- package/dist/cjs/feedback/quartz.js +1 -1
- package/dist/cjs/feedback/send.d.ts +2 -2
- package/dist/cjs/feedback/send.js +4 -27
- package/dist/cjs/feedback/styles.js +2 -2
- package/dist/cjs/feedback/template.d.ts +1 -1
- package/dist/cjs/feedback/template.js +9 -1
- package/dist/cjs/feedback/ui.d.ts +7 -0
- package/dist/cjs/feedback/ui.js +160 -25
- package/dist/cjs/heatmap/send.d.ts +2 -0
- package/dist/cjs/heatmap/send.js +3 -5
- package/dist/cjs/heatmap/track.js +1 -1
- package/dist/cjs/index.d.ts +1 -2
- package/dist/cjs/index.js +54 -17
- package/dist/cjs/lifecycle.d.ts +13 -2
- package/dist/cjs/lifecycle.js +122 -54
- package/dist/cjs/remoteconfig/country.js +1 -1
- package/dist/cjs/remoteconfig/custom.js +1 -1
- package/dist/cjs/remoteconfig/evaluate.js +1 -1
- package/dist/cjs/remoteconfig/fetch.d.ts +17 -10
- package/dist/cjs/remoteconfig/fetch.js +126 -31
- package/dist/cjs/remoteconfig/index.d.ts +13 -4
- package/dist/cjs/remoteconfig/index.js +36 -20
- package/dist/cjs/remoteconfig/store.d.ts +15 -7
- package/dist/cjs/remoteconfig/store.js +68 -35
- package/dist/cjs/remoteconfig/tz-countries.js +1 -1
- package/dist/cjs/{core → remotelog}/callsite.d.ts +5 -4
- package/dist/cjs/{core → remotelog}/callsite.js +6 -5
- package/dist/cjs/remotelog/gate.js +1 -1
- package/dist/cjs/remotelog/logger.js +2 -2
- package/dist/cjs/remotelog/send.js +2 -2
- package/dist/cjs/remotelogger/index.js +1 -1
- package/dist/cjs/scheduler.d.ts +3 -1
- package/dist/cjs/scheduler.js +24 -21
- package/dist/cjs/types.d.ts +61 -16
- package/dist/cjs/user/index.js +6 -2
- package/dist/esm/core/attempts.js +1 -1
- package/dist/esm/core/batch.js +1 -2
- package/dist/esm/core/consent.d.ts +13 -3
- package/dist/esm/core/consent.js +24 -11
- package/dist/esm/core/constants.d.ts +22 -17
- package/dist/esm/core/constants.js +22 -19
- package/dist/esm/core/db.js +1 -1
- 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.js +1 -1
- package/dist/esm/core/hooks.d.ts +5 -0
- package/dist/esm/core/hooks.js +2 -1
- package/dist/esm/core/locks.js +1 -1
- package/dist/esm/core/logger.js +1 -1
- package/dist/esm/core/state.d.ts +6 -4
- package/dist/esm/core/state.js +2 -4
- package/dist/esm/core/storage.js +1 -4
- package/dist/esm/core/stylesheet.js +1 -1
- package/dist/esm/core/transport.js +13 -16
- package/dist/esm/core/utils.js +1 -1
- package/dist/esm/core/validate.js +1 -1
- package/dist/esm/device/appversion.d.ts +10 -1
- package/dist/esm/device/appversion.js +26 -4
- package/dist/esm/device/index.d.ts +17 -2
- package/dist/esm/device/index.js +195 -30
- package/dist/esm/engagement/api-rules.js +1 -1
- package/dist/esm/engagement/auto-api.js +1 -1
- package/dist/esm/engagement/auto-screen.js +1 -1
- package/dist/esm/engagement/defined-events.js +1 -1
- package/dist/esm/engagement/send.js +7 -3
- package/dist/esm/engagement/session.d.ts +17 -0
- package/dist/esm/engagement/session.js +93 -5
- package/dist/esm/engagement/track.d.ts +4 -4
- package/dist/esm/engagement/track.js +16 -13
- package/dist/esm/errors/send.js +2 -2
- package/dist/esm/errors/track.d.ts +2 -1
- package/dist/esm/errors/track.js +6 -4
- package/dist/esm/feedback/controls.d.ts +6 -0
- package/dist/esm/feedback/controls.js +74 -26
- package/dist/esm/feedback/index.js +1 -1
- package/dist/esm/feedback/logs.d.ts +3 -6
- package/dist/esm/feedback/logs.js +8 -18
- package/dist/esm/feedback/quartz.js +1 -1
- package/dist/esm/feedback/send.d.ts +2 -2
- package/dist/esm/feedback/send.js +6 -29
- package/dist/esm/feedback/styles.js +2 -2
- package/dist/esm/feedback/template.d.ts +1 -1
- package/dist/esm/feedback/template.js +9 -1
- package/dist/esm/feedback/ui.d.ts +7 -0
- package/dist/esm/feedback/ui.js +161 -26
- package/dist/esm/heatmap/send.d.ts +2 -0
- package/dist/esm/heatmap/send.js +3 -5
- package/dist/esm/heatmap/track.js +1 -1
- package/dist/esm/index.d.ts +1 -2
- package/dist/esm/index.js +57 -20
- package/dist/esm/lifecycle.d.ts +13 -2
- package/dist/esm/lifecycle.js +126 -60
- package/dist/esm/remoteconfig/country.js +1 -1
- package/dist/esm/remoteconfig/custom.js +1 -1
- package/dist/esm/remoteconfig/evaluate.js +1 -1
- package/dist/esm/remoteconfig/fetch.d.ts +17 -10
- package/dist/esm/remoteconfig/fetch.js +127 -32
- package/dist/esm/remoteconfig/index.d.ts +13 -4
- package/dist/esm/remoteconfig/index.js +36 -20
- package/dist/esm/remoteconfig/store.d.ts +15 -7
- package/dist/esm/remoteconfig/store.js +68 -36
- package/dist/esm/remoteconfig/tz-countries.js +1 -1
- package/dist/esm/{core → remotelog}/callsite.d.ts +5 -4
- package/dist/esm/{core → remotelog}/callsite.js +6 -5
- package/dist/esm/remotelog/gate.js +1 -1
- package/dist/esm/remotelog/logger.js +2 -2
- package/dist/esm/remotelog/send.js +2 -2
- package/dist/esm/remotelogger/index.js +1 -1
- package/dist/esm/scheduler.d.ts +3 -1
- package/dist/esm/scheduler.js +25 -23
- package/dist/esm/types.d.ts +61 -16
- package/dist/esm/user/index.js +7 -3
- 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 +3 -2
- package/dist/chunks/lifecycle-VYr43KcB.min.js +0 -3
- package/dist/chunks/lifecycle-VYr43KcB.min.js.map +0 -1
- package/dist/cjs/auto-init.d.ts +0 -8
- package/dist/cjs/auto-init.js +0 -32
- package/dist/esm/auto-init.d.ts +0 -8
- package/dist/esm/auto-init.js +0 -29
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type EngagementType } from './constants.js';
|
|
1
2
|
import type { TrackingStatus } from '../types.js';
|
|
2
3
|
/**
|
|
3
4
|
* DNT counts only when not ignored; while it counts, tracking is NO_TRACKING (opt_in_status).
|
|
@@ -12,8 +13,11 @@ export declare function shouldTrackOrSendData(): boolean;
|
|
|
12
13
|
* and consent / server flags allow tracking.
|
|
13
14
|
*/
|
|
14
15
|
export declare function canTrack(caller: string): boolean;
|
|
15
|
-
/**
|
|
16
|
-
|
|
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;
|
|
17
21
|
/**
|
|
18
22
|
* canTrack plus the server's heatmap flag (getsdkconfig module 18).
|
|
19
23
|
*
|
|
@@ -21,7 +25,13 @@ export declare function canTrackEngagement(caller: string): boolean;
|
|
|
21
25
|
* well want events while declining to have every click's coordinates recorded.
|
|
22
26
|
*/
|
|
23
27
|
export declare function canTrackHeatmap(caller: string): boolean;
|
|
24
|
-
/** canTrack plus the server's
|
|
28
|
+
/** canTrack plus the server's js_error module (15) from getsdkconfig. */
|
|
25
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;
|
|
26
36
|
export declare function setTrackingStatus(trackingState: TrackingStatus): void;
|
|
27
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.
|
|
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');
|
|
@@ -53,13 +53,16 @@ function canTrack(caller) {
|
|
|
53
53
|
}
|
|
54
54
|
return shouldTrackOrSendData();
|
|
55
55
|
}
|
|
56
|
-
/**
|
|
57
|
-
|
|
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) {
|
|
58
61
|
if (!canTrack(caller)) {
|
|
59
62
|
return false;
|
|
60
63
|
}
|
|
61
|
-
if (!state._ZAP._engagementTracking) {
|
|
62
|
-
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
|
|
63
66
|
return false;
|
|
64
67
|
}
|
|
65
68
|
return true;
|
|
@@ -80,7 +83,7 @@ function canTrackHeatmap(caller) {
|
|
|
80
83
|
}
|
|
81
84
|
return true;
|
|
82
85
|
}
|
|
83
|
-
/** canTrack plus the server's
|
|
86
|
+
/** canTrack plus the server's js_error module (15) from getsdkconfig. */
|
|
84
87
|
function canTrackErrors(caller) {
|
|
85
88
|
if (!canTrack(caller)) {
|
|
86
89
|
return false;
|
|
@@ -91,17 +94,27 @@ function canTrackErrors(caller) {
|
|
|
91
94
|
}
|
|
92
95
|
return true;
|
|
93
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
|
+
}
|
|
94
110
|
function setTrackingStatus(trackingState) {
|
|
95
111
|
if (utils.isEmpty(trackingState)) {
|
|
96
112
|
logger.Console.warn('setTrackingStatus: trackingStatus is Empty'); // no i18n
|
|
97
113
|
return;
|
|
98
114
|
}
|
|
99
|
-
if (
|
|
115
|
+
if (!recordTrackingStatus(trackingState)) {
|
|
100
116
|
return;
|
|
101
117
|
}
|
|
102
|
-
storage.tracking_preference.update_status(trackingState);
|
|
103
|
-
state._ZAP._devicestatus = storage.tracking_preference.opt_in_status();
|
|
104
|
-
state._ZAP._isanonrequired = storage.tracking_preference.opt_in_status() == constants.AP_TRACKING_STATUS.USAGE_TRACKING_WITH_PII ? false : state._ZAP._isanonrequired;
|
|
105
118
|
if (storage.tracking_preference.opt_in_status() != constants.AP_TRACKING_STATUS.NO_TRACKING) {
|
|
106
119
|
logger.Console.log('setTrackingStatus: Updating device info with new tracking status'); // no i18n
|
|
107
120
|
hooks.hooks.updateDevice(state._ZAP._device_info).then(function (result) {
|
|
@@ -128,5 +141,6 @@ exports.canTrackHeatmap = canTrackHeatmap;
|
|
|
128
141
|
exports.getTrackingStatus = getTrackingStatus;
|
|
129
142
|
exports.hasDoNotTrackEnabled = hasDoNotTrackEnabled;
|
|
130
143
|
exports.opt_in_status = opt_in_status;
|
|
144
|
+
exports.recordTrackingStatus = recordTrackingStatus;
|
|
131
145
|
exports.setTrackingStatus = setTrackingStatus;
|
|
132
146
|
exports.shouldTrackOrSendData = shouldTrackOrSendData;
|
|
@@ -34,6 +34,8 @@ export declare const AP_CONSTANTS: Readonly<{
|
|
|
34
34
|
readonly SUCCESS: "success";
|
|
35
35
|
readonly BROWSER: "Browser";
|
|
36
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';
|
|
37
39
|
export declare const DEFAULT_API_PATHS: Readonly<{
|
|
38
40
|
readonly addversion: "app/addversion";
|
|
39
41
|
readonly regdevice: "device/add";
|
|
@@ -79,9 +81,13 @@ export declare const SDK_MODULE: Readonly<{
|
|
|
79
81
|
* authority. Where they disagree, getsdkconfig wins.
|
|
80
82
|
*/
|
|
81
83
|
readonly REMOTE_CONFIG: "2";
|
|
84
|
+
readonly EVENT: "5";
|
|
85
|
+
readonly API: "6";
|
|
86
|
+
readonly SCREEN: "10";
|
|
82
87
|
readonly SESSION: "11";
|
|
83
88
|
readonly FEEDBACK: "12";
|
|
84
|
-
|
|
89
|
+
/** Uncaught and reported JavaScript errors: js_error. 13 (crash) and 14 (nonfatal) are the native SDKs'. */
|
|
90
|
+
readonly JS_ERROR: "15";
|
|
85
91
|
readonly REMOTE_LOGGER: "17";
|
|
86
92
|
readonly HEATMAP: "18";
|
|
87
93
|
}>;
|
|
@@ -97,9 +103,10 @@ export declare const LOG_FILENAME_MAX = 100;
|
|
|
97
103
|
*/
|
|
98
104
|
export declare const DEVICE_NAME_MAX = 100;
|
|
99
105
|
/**
|
|
100
|
-
* The `level`
|
|
101
|
-
*
|
|
102
|
-
*
|
|
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.
|
|
103
110
|
*/
|
|
104
111
|
export declare const REMOTE_LOG_LEVEL = 3;
|
|
105
112
|
/**
|
|
@@ -109,29 +116,17 @@ export declare const REMOTE_LOG_LEVEL = 3;
|
|
|
109
116
|
* enough that a tab left open overnight is not still sending every call to its debug twin.
|
|
110
117
|
*/
|
|
111
118
|
export declare const DEBUG_IDLE_MS: number;
|
|
112
|
-
/**
|
|
119
|
+
/** Minutes a tab can be inactive before its session ends. Lives on state, not in _config, but defaults here. */
|
|
113
120
|
export declare const DEFAULT_INACTIVE_MINUTES = 30;
|
|
114
121
|
/** Global defaults. `state._config` holds a mutable copy per init. */
|
|
115
122
|
export declare const AP_CONFIG: Readonly<{
|
|
116
123
|
endpoint: "/sdk/web/";
|
|
117
124
|
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
125
|
batch_size: 50;
|
|
124
126
|
batch_flush_interval: 30000;
|
|
125
127
|
getupdates_interval: 120000;
|
|
126
128
|
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
129
|
debug: boolean;
|
|
134
|
-
track_by_default: true;
|
|
135
130
|
ignore_do_not_track: boolean;
|
|
136
131
|
/**
|
|
137
132
|
* Wrap XHR and fetch to record the app's API calls without it calling startTrackApi(). Off by
|
|
@@ -144,6 +139,16 @@ export declare const AP_CONFIG: Readonly<{
|
|
|
144
139
|
* default; the app's own inScreen() during a navigation replaces that navigation's view.
|
|
145
140
|
*/
|
|
146
141
|
track_screen: boolean;
|
|
142
|
+
/**
|
|
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.
|
|
145
|
+
*/
|
|
146
|
+
track_error: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Record clicks on elements tagged `apeventaction` (or `data-apeventaction`) as events. On by
|
|
149
|
+
* default; AppticsEvent.setClickTracking() switches it later.
|
|
150
|
+
*/
|
|
151
|
+
track_click: boolean;
|
|
147
152
|
/**
|
|
148
153
|
* How automatic screen tracking names a path, as init() keeps the config's screen_routes: route
|
|
149
154
|
* patterns (`/users/{id}/orders`, each id recorded as a star), exact paths and regular
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.
|
|
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,30 +120,18 @@ 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
136
|
/**
|
|
144
137
|
* Wrap XHR and fetch to record the app's API calls without it calling startTrackApi(). Off by
|
|
@@ -151,6 +144,16 @@ const AP_CONFIG = Object.freeze({
|
|
|
151
144
|
* default; the app's own inScreen() during a navigation replaces that navigation's view.
|
|
152
145
|
*/
|
|
153
146
|
track_screen: true,
|
|
147
|
+
/**
|
|
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.
|
|
150
|
+
*/
|
|
151
|
+
track_error: true,
|
|
152
|
+
/**
|
|
153
|
+
* Record clicks on elements tagged `apeventaction` (or `data-apeventaction`) as events. On by
|
|
154
|
+
* default; AppticsEvent.setClickTracking() switches it later.
|
|
155
|
+
*/
|
|
156
|
+
track_click: true,
|
|
154
157
|
/**
|
|
155
158
|
* How automatic screen tracking names a path, as init() keeps the config's screen_routes: route
|
|
156
159
|
* patterns (`/users/{id}/orders`, each id recorded as a star), exact paths and regular
|
package/dist/cjs/core/db.js
CHANGED
package/dist/cjs/core/debug.js
CHANGED
package/dist/cjs/core/env.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { AppticsConfig } from '../types.js';
|
|
2
1
|
export declare function isBlockedWS(ua: string): boolean;
|
|
3
2
|
/** Device RAM as the API wants it ("4 GB"). Chromium only; empty elsewhere. */
|
|
4
3
|
export declare function getRam(): string;
|
|
@@ -24,5 +23,3 @@ export declare function getTimeZone(): string;
|
|
|
24
23
|
export declare function is_apptics_disabled(): boolean;
|
|
25
24
|
/** Pure DNT check (no side effects). consent.hasDoNotTrackEnabled() applies NO_TRACKING. */
|
|
26
25
|
export declare function isDntOn(): boolean;
|
|
27
|
-
/** The console snippet's config (window.appticssettings._defaultoptions), if the page defines one. */
|
|
28
|
-
export declare function getSnippetOptions(): AppticsConfig | undefined;
|
package/dist/cjs/core/env.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.
|
|
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');
|
|
@@ -242,13 +242,6 @@ function isDntOn() {
|
|
|
242
242
|
return utils.includes(dntValues, dntValue);
|
|
243
243
|
});
|
|
244
244
|
}
|
|
245
|
-
/** The console snippet's config (window.appticssettings._defaultoptions), if the page defines one. */
|
|
246
|
-
function getSnippetOptions() {
|
|
247
|
-
if (typeof window === 'undefined' || !window.appticssettings) { // no i18n
|
|
248
|
-
return undefined;
|
|
249
|
-
}
|
|
250
|
-
return window.appticssettings._defaultoptions;
|
|
251
|
-
}
|
|
252
245
|
|
|
253
246
|
exports.getBatteryPercent = getBatteryPercent;
|
|
254
247
|
exports.getBrowser = getBrowser;
|
|
@@ -260,7 +253,6 @@ exports.getOS = getOS;
|
|
|
260
253
|
exports.getOrientation = getOrientation;
|
|
261
254
|
exports.getRam = getRam;
|
|
262
255
|
exports.getReferringURL = getReferringURL;
|
|
263
|
-
exports.getSnippetOptions = getSnippetOptions;
|
|
264
256
|
exports.getTimeZone = getTimeZone;
|
|
265
257
|
exports.isBlockedWS = isBlockedWS;
|
|
266
258
|
exports.isDntOn = isDntOn;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const FRAMEWORK_ID =
|
|
1
|
+
export declare const FRAMEWORK_ID = 6003;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.
|
|
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
|
// Generated by scripts/register-version.mjs — do not edit by hand.
|
|
5
5
|
// The framework id Apptics issued for this SDK, from POST /sdk/web/v1/framework/addversion
|
|
6
|
-
// (version 2.0.0-beta.
|
|
7
|
-
const FRAMEWORK_ID =
|
|
6
|
+
// (version 2.0.0-beta.2, platform Browser). Regenerated on every npm pack.
|
|
7
|
+
const FRAMEWORK_ID = 6003;
|
|
8
8
|
|
|
9
9
|
exports.FRAMEWORK_ID = FRAMEWORK_ID;
|
package/dist/cjs/core/guard.js
CHANGED
package/dist/cjs/core/hooks.d.ts
CHANGED
|
@@ -36,4 +36,9 @@ export declare const hooks: {
|
|
|
36
36
|
remoteConfigStarted: () => void;
|
|
37
37
|
/** Set by remoteconfig/fetch.ts: AppticsUser.setUser changed who this is, so conditions on the user re-apply. */
|
|
38
38
|
remoteConfigUserChanged: () => void;
|
|
39
|
+
/**
|
|
40
|
+
* Set by device/index.ts: getsdkconfig is asked now, outside its next_check_after. setUser calls
|
|
41
|
+
* it once a user is registered, and remote config when getupdates reports a module changed.
|
|
42
|
+
*/
|
|
43
|
+
askServerSettings: () => void;
|
|
39
44
|
};
|
package/dist/cjs/core/hooks.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.
|
|
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
|
/**
|
|
@@ -17,6 +17,7 @@ const hooks = {
|
|
|
17
17
|
screenTrackedByApp: () => { },
|
|
18
18
|
remoteConfigStarted: () => { },
|
|
19
19
|
remoteConfigUserChanged: () => { },
|
|
20
|
+
askServerSettings: () => { },
|
|
20
21
|
};
|
|
21
22
|
|
|
22
23
|
exports.hooks = hooks;
|
package/dist/cjs/core/locks.js
CHANGED
package/dist/cjs/core/logger.js
CHANGED
package/dist/cjs/core/state.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ApConfig } from './constants.js';
|
|
1
|
+
import { type ApConfig, type EngagementType } from './constants.js';
|
|
2
2
|
import type { DeviceInfo, Dict, QuartzSettings, TrackingStatus, UserInfo } from '../types.js';
|
|
3
3
|
/** Runtime state shared by every module (the former `_ZAP` object). */
|
|
4
4
|
export interface State {
|
|
@@ -19,7 +19,6 @@ export interface State {
|
|
|
19
19
|
_token: string;
|
|
20
20
|
_frameworkID: number;
|
|
21
21
|
_platform: string;
|
|
22
|
-
_isanonrequired: boolean;
|
|
23
22
|
_devicestatus: TrackingStatus;
|
|
24
23
|
_uuid: string;
|
|
25
24
|
_apid: string;
|
|
@@ -30,9 +29,12 @@ export interface State {
|
|
|
30
29
|
_current_session: Dict;
|
|
31
30
|
_properties: Dict;
|
|
32
31
|
_ignoreDnt: boolean;
|
|
33
|
-
_isGlobalErrorTracking: boolean;
|
|
34
32
|
_shouldTrack: boolean;
|
|
35
|
-
|
|
33
|
+
/**
|
|
34
|
+
* getsdkconfig's engagement modules, one per kind of item, keyed by the item's type: event (5),
|
|
35
|
+
* api (6), screen (10) and session (11).
|
|
36
|
+
*/
|
|
37
|
+
_engagementTracking: Record<EngagementType, boolean>;
|
|
36
38
|
_errorTracking: boolean;
|
|
37
39
|
/** getsdkconfig module 18. Heatmap has its own flag in v2; before that it rode engagement. */
|
|
38
40
|
_heatmapTracking: boolean;
|
package/dist/cjs/core/state.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.
|
|
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');
|
|
@@ -23,7 +23,6 @@ function initialState() {
|
|
|
23
23
|
// issued by Apptics at pack time; see scripts/register-version.mjs
|
|
24
24
|
_frameworkID: frameworkId.FRAMEWORK_ID,
|
|
25
25
|
_platform: constants.AP_CONSTANTS.BROWSER,
|
|
26
|
-
_isanonrequired: true,
|
|
27
26
|
_devicestatus: constants.AP_TRACKING_STATUS.USAGE_TRACKING_WITHOUT_PII,
|
|
28
27
|
_uuid: '', // no i18n
|
|
29
28
|
_apid: '', // no i18n
|
|
@@ -34,9 +33,8 @@ function initialState() {
|
|
|
34
33
|
_current_session: {},
|
|
35
34
|
_properties: {},
|
|
36
35
|
_ignoreDnt: false,
|
|
37
|
-
_isGlobalErrorTracking: true,
|
|
38
36
|
_shouldTrack: true,
|
|
39
|
-
_engagementTracking: true,
|
|
37
|
+
_engagementTracking: { event: true, screen: true, session: true, api: true },
|
|
40
38
|
_heatmapTracking: true,
|
|
41
39
|
_remoteLoggerEnabled: true,
|
|
42
40
|
_remoteConfigEnabled: true,
|
package/dist/cjs/core/storage.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.
|
|
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');
|
|
@@ -293,9 +293,6 @@ const tracking_preference = {
|
|
|
293
293
|
},
|
|
294
294
|
update_status(tracking_status) {
|
|
295
295
|
state._ZAP._devicestatus = tracking_status;
|
|
296
|
-
// Legacy order kept: this reads the status *before* the write below (setTrackingStatus recomputes it after).
|
|
297
|
-
state._ZAP._isanonrequired =
|
|
298
|
-
tracking_preference.opt_in_status() == constants.AP_TRACKING_STATUS.USAGE_TRACKING_WITH_PII ? false : state._ZAP._isanonrequired;
|
|
299
296
|
var track = Object.assign({}, settings.trackinfo && typeof settings.trackinfo === 'object' ? settings.trackinfo : {}); // no i18n
|
|
300
297
|
track.tracking_status = tracking_status;
|
|
301
298
|
if (state._ZAP._trackinfo && typeof state._ZAP._trackinfo === 'object') { // no i18n
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.
|
|
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');
|
|
@@ -141,19 +141,17 @@ function getParameters(path) {
|
|
|
141
141
|
// v2 device/add declares neither identifier, platform nor appversion: the build is already
|
|
142
142
|
// known from app/addversion, and sending an undeclared param is refused as EXTRA_PARAM_FOUND.
|
|
143
143
|
// What it does declare as mandatory is appversionid, which v1 treated as optional.
|
|
144
|
+
// isanonrequired is always false: the web SDK has no anonymous mode, only the tracking
|
|
145
|
+
// statuses (with PII, without PII, none), which devicestatus carries.
|
|
144
146
|
if (path == 'regdevice') { // no i18n
|
|
145
|
-
returnVal = '?isanonrequired=
|
|
147
|
+
returnVal = '?isanonrequired=false&devicestatus=' + state._ZAP._devicestatus; // no i18n
|
|
146
148
|
if (!utils.isEmpty(state._ZAP._device_info.deviceid)) {
|
|
147
149
|
returnVal += '&deviceid=' + encodeURIComponent(String(state._ZAP._device_info.deviceid)); // no i18n
|
|
148
150
|
}
|
|
149
151
|
return returnVal + mandatoryParams(returnVal);
|
|
150
152
|
}
|
|
151
|
-
// getsdkconfig
|
|
152
|
-
|
|
153
|
-
// with NOT_AUTHENTICATED. getupdates declares the same param with plain paramdecrypt, so it
|
|
154
|
-
// does carry one. It still needs appversionid and frameworkid, added at the end.
|
|
155
|
-
var identifiesDevice = path != 'sdkconfig'; // no i18n
|
|
156
|
-
if (identifiesDevice) {
|
|
153
|
+
// getsdkconfig carries no deviceid: the user's ids below are what it answers for
|
|
154
|
+
if (path != 'sdkconfig') { // no i18n
|
|
157
155
|
if (utils.isEmpty(state._ZAP._device_info.deviceid)) {
|
|
158
156
|
hooks.hooks.refreshDeviceInfo();
|
|
159
157
|
// the device is missing, but appversionid and frameworkid are mandatory regardless:
|
|
@@ -178,14 +176,13 @@ function getParameters(path) {
|
|
|
178
176
|
// them, and refuses userid as EXTRA_PARAM_FOUND; it has no use for them either, since remote
|
|
179
177
|
// config conditions on the user are evaluated here, against the rule set it answers with
|
|
180
178
|
var carriesUser = path != 'reguser' && path != 'getupdates'; // no i18n
|
|
181
|
-
if (carriesUser &&
|
|
182
|
-
if (
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}
|
|
179
|
+
if (carriesUser && consent.opt_in_status() == constants.AP_TRACKING_STATUS.USAGE_TRACKING_WITH_PII) {
|
|
180
|
+
if (state._ZAP._user_info.hasOwnProperty('userid') && !utils.isEmpty(state._ZAP._user_info.userid)) { // no i18n
|
|
181
|
+
// getsdkconfig has no deviceid before it, so its userid starts the query
|
|
182
|
+
returnVal += (returnVal === '' ? '?' : '&') + 'userid=' + encodeURIComponent(String(state._ZAP._user_info.userid)); // no i18n
|
|
183
|
+
}
|
|
184
|
+
if (state._ZAP._user_info.hasOwnProperty('groupid') && !utils.isEmpty(state._ZAP._user_info.groupid)) { // no i18n
|
|
185
|
+
returnVal += (returnVal === '' ? '?' : '&') + 'customergroupid=' + encodeURIComponent(String(state._ZAP._user_info.groupid)); // no i18n
|
|
189
186
|
}
|
|
190
187
|
}
|
|
191
188
|
returnVal += deviceNameParam(path, returnVal);
|
package/dist/cjs/core/utils.js
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* A fingerprint of the auth key, which is what is stored to tell one key from another: enough to
|
|
3
|
+
* notice that init() was given a different one, without keeping a second copy of the key itself.
|
|
4
|
+
* FNV-1a, 32 bits, as hex; '' for no key.
|
|
5
|
+
*/
|
|
6
|
+
export declare function keyFingerprint(key: unknown): string;
|
|
7
|
+
/**
|
|
8
|
+
* Whether we already hold usable ids for the app, auth key and version running now. Ids stored by
|
|
9
|
+
* a build that kept no key fingerprint register again once, and the answer then records it.
|
|
10
|
+
*/
|
|
2
11
|
export declare function hasAppVersion(): boolean;
|
|
3
12
|
export declare function appVersionFailedForNetwork(): boolean;
|
|
4
13
|
export declare function registerAppVersion(): Promise<boolean>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.
|
|
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 state = require('../core/state.js');
|
|
@@ -39,13 +39,34 @@ const REQUIRED_KEYS = ['aaid', 'portalid', 'projectid', 'apid', 'mapid', 'appver
|
|
|
39
39
|
function missingKeys(data) {
|
|
40
40
|
return REQUIRED_KEYS.filter(function (key) { return utils.isEmpty(data[key]); });
|
|
41
41
|
}
|
|
42
|
-
/**
|
|
42
|
+
/**
|
|
43
|
+
* A fingerprint of the auth key, which is what is stored to tell one key from another: enough to
|
|
44
|
+
* notice that init() was given a different one, without keeping a second copy of the key itself.
|
|
45
|
+
* FNV-1a, 32 bits, as hex; '' for no key.
|
|
46
|
+
*/
|
|
47
|
+
function keyFingerprint(key) {
|
|
48
|
+
var text = utils.isEmpty(key) ? '' : String(key); // no i18n
|
|
49
|
+
if (text === '') { // no i18n
|
|
50
|
+
return ''; // no i18n
|
|
51
|
+
}
|
|
52
|
+
var hash = 0x811c9dc5;
|
|
53
|
+
for (var i = 0; i < text.length; i++) {
|
|
54
|
+
hash ^= text.charCodeAt(i);
|
|
55
|
+
hash = Math.imul(hash, 0x01000193) >>> 0;
|
|
56
|
+
}
|
|
57
|
+
return ('0000000' + hash.toString(16)).slice(-8); // no i18n
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Whether we already hold usable ids for the app, auth key and version running now. Ids stored by
|
|
61
|
+
* a build that kept no key fingerprint register again once, and the answer then records it.
|
|
62
|
+
*/
|
|
43
63
|
function hasAppVersion() {
|
|
44
64
|
var saved = stored();
|
|
45
65
|
return missingKeys(saved).length === 0
|
|
46
66
|
&& saved.appversion === state._ZAP._defaultoptions.appversion
|
|
47
67
|
&& saved.identifier === state._ZAP._defaultoptions.identifier
|
|
48
|
-
&& saved.serviceUrl === state._ZAP._defaultoptions.serviceUrl
|
|
68
|
+
&& saved.serviceUrl === state._ZAP._defaultoptions.serviceUrl
|
|
69
|
+
&& saved.zakhash === keyFingerprint(state._ZAP._defaultoptions.zak);
|
|
49
70
|
}
|
|
50
71
|
/** Puts the ids where the rest of the SDK reads them from. */
|
|
51
72
|
function apply(data) {
|
|
@@ -126,6 +147,7 @@ function registerAppVersion() {
|
|
|
126
147
|
appversion: state._ZAP._defaultoptions.appversion,
|
|
127
148
|
identifier: state._ZAP._defaultoptions.identifier,
|
|
128
149
|
serviceUrl: state._ZAP._defaultoptions.serviceUrl,
|
|
150
|
+
zakhash: keyFingerprint(state._ZAP._defaultoptions.zak),
|
|
129
151
|
};
|
|
130
152
|
RESULT_KEYS.forEach(function (key) {
|
|
131
153
|
if (!utils.isEmpty(data[key])) {
|
|
@@ -167,4 +189,5 @@ exports.appVersionFailedForNetwork = appVersionFailedForNetwork;
|
|
|
167
189
|
exports.applyStoredAppVersion = applyStoredAppVersion;
|
|
168
190
|
exports.clearAppVersion = clearAppVersion;
|
|
169
191
|
exports.hasAppVersion = hasAppVersion;
|
|
192
|
+
exports.keyFingerprint = keyFingerprint;
|
|
170
193
|
exports.registerAppVersion = registerAppVersion;
|