@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,461 @@
|
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
|
+
import { SDK_MODULE } from '../core/constants.js';
|
|
3
|
+
import { _ZAP } from '../core/state.js';
|
|
4
|
+
import { Console } from '../core/logger.js';
|
|
5
|
+
import { isEmpty, getNewUUID, isSuccess, compareTwoObjects } from '../core/utils.js';
|
|
6
|
+
import { user_defaults, getKeyFromDeviceInfo, setDeviceInfoKey, storedTrackingStatus, reloadSettings } from '../core/storage.js';
|
|
7
|
+
import { withLock } from '../core/locks.js';
|
|
8
|
+
import { getTimeZone, getConnectionType, getReferringURL, getDevice, getBrowserVersion, getBrowser, getOS } from '../core/env.js';
|
|
9
|
+
import { hasDoNotTrackEnabled } from '../core/consent.js';
|
|
10
|
+
import { rejectIfDisabled, rejectIfOffline, apiHeaders, getHeaderParams, postToApptics, hasDeviceId, rejectIfNoDeviceIds } from '../core/transport.js';
|
|
11
|
+
import { hooks } from '../core/hooks.js';
|
|
12
|
+
import { applyStoredAppVersion } from './appversion.js';
|
|
13
|
+
|
|
14
|
+
/** Server-assigned ids, never sent back in device payloads. */
|
|
15
|
+
/**
|
|
16
|
+
* Exactly the keys deviceInfoWebSDKV2 declares, which is exactly what device/add accepts.
|
|
17
|
+
*
|
|
18
|
+
* An allow-list rather than an exclusion list: the template is a closed set of eleven mandatory
|
|
19
|
+
* keys, so anything else on device_info is refused as EXTRA_PARAM_FOUND and takes the whole
|
|
20
|
+
* registration with it. v1 carried `frameworkid` in the body; v2 moved it to a query param, and
|
|
21
|
+
* `platformid` — which v1 left out — became mandatory here. It comes from app/addversion, which
|
|
22
|
+
* is why that call has to land first.
|
|
23
|
+
*/
|
|
24
|
+
const DEVICE_BODY_KEYS = ['devicetype', 'osversion', 'timezone', 'screenheight', 'screenwidth', 'referrer', 'referringdomain', 'browser', 'browserversion', 'donottrackenabled', 'platformid']; // no i18n
|
|
25
|
+
/** The ones the template types as int, so an empty value has to become 0 rather than ''. */
|
|
26
|
+
const DEVICE_BODY_NUMERIC = ['screenheight', 'screenwidth', 'donottrackenabled', 'platformid']; // no i18n
|
|
27
|
+
/**
|
|
28
|
+
* The device/add body: all eleven declared keys, always.
|
|
29
|
+
*
|
|
30
|
+
* Every one is min-occurrences="1", so a key is sent even when its value is empty — `referrer` is
|
|
31
|
+
* empty on any direct visit, and leaving it out would refuse the registration over a blank the
|
|
32
|
+
* server is happy to receive.
|
|
33
|
+
*/
|
|
34
|
+
function deviceBody(info) {
|
|
35
|
+
var out = {};
|
|
36
|
+
DEVICE_BODY_KEYS.forEach(function (key) {
|
|
37
|
+
var value = info[key];
|
|
38
|
+
var numeric = DEVICE_BODY_NUMERIC.indexOf(key) !== -1;
|
|
39
|
+
out[key] = isEmpty(value) ? (numeric ? 0 : '') : value; // no i18n
|
|
40
|
+
});
|
|
41
|
+
return JSON.stringify(out);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The fields that describe the device itself, and so the only ones worth a device/add when they
|
|
45
|
+
* change: a browser or OS upgrade, a new screen, a move between timezones, a do-not-track switch.
|
|
46
|
+
*
|
|
47
|
+
* `referrer` and `connectionType` are deliberately absent. Both change constantly — the referrer on
|
|
48
|
+
* most navigations, the connection on every network switch — so including them would send a
|
|
49
|
+
* device/add on nearly every page load. The server-assigned ids are absent for the opposite reason:
|
|
50
|
+
* they arrive from the server, so comparing them would report a change the moment registration
|
|
51
|
+
* fills them in.
|
|
52
|
+
*/
|
|
53
|
+
const DEVICE_IDENTITY_KEYS = ['osversion', 'browser', 'browserversion', 'devicetype', 'screenheight', 'screenwidth', 'timezone', 'donottrackenabled',
|
|
54
|
+
// the SDK build this device runs: an upgrade to a new SDK version is a change the server is told about
|
|
55
|
+
'frameworkid']; // no i18n
|
|
56
|
+
/** The identity fields alone, for comparing one stored device_info against a fresh one. */
|
|
57
|
+
function deviceIdentity(info) {
|
|
58
|
+
var identity = {};
|
|
59
|
+
DEVICE_IDENTITY_KEYS.forEach(function (key) {
|
|
60
|
+
identity[key] = info ? info[key] : undefined;
|
|
61
|
+
});
|
|
62
|
+
return identity;
|
|
63
|
+
}
|
|
64
|
+
function checkAndUpdateDeviceInfo() {
|
|
65
|
+
// read the stored info before it is overwritten below: addOrUpdateDeviceID compares the two to
|
|
66
|
+
// decide whether the server needs telling, and cannot do that once the new info has replaced it
|
|
67
|
+
var previous = user_defaults.item('device_info'); // no i18n
|
|
68
|
+
// params -> https://help.apptics.com/hc/en-us/articles/115004613766-Default-Properties-Collected-by-apptics
|
|
69
|
+
_ZAP._device_info = {
|
|
70
|
+
osversion: getOS(),
|
|
71
|
+
browser: getBrowser(),
|
|
72
|
+
browserversion: String(getBrowserVersion()),
|
|
73
|
+
donottrackenabled: hasDoNotTrackEnabled() ? 1 : 0, // no i18n
|
|
74
|
+
devicetype: getDevice(),
|
|
75
|
+
screenheight: screen.height,
|
|
76
|
+
screenwidth: screen.width,
|
|
77
|
+
referrer: getReferringURL(),
|
|
78
|
+
connectionType: getConnectionType(),
|
|
79
|
+
referringdomain: window.location.hostname || '', // no i18n
|
|
80
|
+
deviceid: getKeyFromDeviceInfo('deviceid'), // no i18n
|
|
81
|
+
anonymousid: getKeyFromDeviceInfo('anonymousid'), // no i18n
|
|
82
|
+
// the id of the SDK build running now, never the stored one: a stored id is the build this
|
|
83
|
+
// device first registered with, and every later SDK version would go on reporting it
|
|
84
|
+
frameworkid: _ZAP._frameworkID,
|
|
85
|
+
mapid: getKeyFromDeviceInfo('mapid'), // no i18n
|
|
86
|
+
aaid: getKeyFromDeviceInfo('aaid'), // no i18n
|
|
87
|
+
apid: getKeyFromDeviceInfo('apid'), // no i18n
|
|
88
|
+
appversionid: getKeyFromDeviceInfo('appversionid'), // no i18n
|
|
89
|
+
platformid: getKeyFromDeviceInfo('platformid'), // no i18n
|
|
90
|
+
devicetypeid: getKeyFromDeviceInfo('devicetypeid'), // no i18n
|
|
91
|
+
osversionid: getKeyFromDeviceInfo('osversionid'), // no i18n
|
|
92
|
+
timezoneid: getKeyFromDeviceInfo('timezoneid'), // no i18n
|
|
93
|
+
// metaWebSDKV2 needs both of these on every call: modelid comes from device/add,
|
|
94
|
+
// appreleaseversionid from app/addversion
|
|
95
|
+
modelid: getKeyFromDeviceInfo('modelid'), // no i18n
|
|
96
|
+
appreleaseversionid: getKeyFromDeviceInfo('appreleaseversionid'), // no i18n
|
|
97
|
+
timezone: getTimeZone(),
|
|
98
|
+
// kept here rather than as keys of their own: the id the browser is registered under, and
|
|
99
|
+
// whether it has had a session (a session's firstsession says so)
|
|
100
|
+
uuid: _ZAP._uuid || getKeyFromDeviceInfo('uuid'), // no i18n
|
|
101
|
+
hadsession: getKeyFromDeviceInfo('hadsession') === true ? true : undefined, // no i18n
|
|
102
|
+
};
|
|
103
|
+
// the rebuild above starts from browser facts, so the ids app/addversion returned are put
|
|
104
|
+
// back before anything is stored or compared
|
|
105
|
+
applyStoredAppVersion();
|
|
106
|
+
user_defaults.add('device_info', _ZAP._device_info); // no i18n
|
|
107
|
+
addOrUpdateDeviceID(_ZAP._device_info, previous);
|
|
108
|
+
}
|
|
109
|
+
function addOrUpdateDeviceID(device_info, previous) {
|
|
110
|
+
var old_device_info = previous !== undefined ? previous : user_defaults.item('device_info') || {}; // no i18n
|
|
111
|
+
// Compare the old and new device infos and update the server if anything changed in the new.
|
|
112
|
+
if (device_info.deviceid == null || device_info.frameworkid == null || device_info.anonymousid == null) {
|
|
113
|
+
device_info.frameworkid = _ZAP._frameworkID;
|
|
114
|
+
Console.log('addOrUpdateDeviceID: Initiated register the device'); // no i18n
|
|
115
|
+
registerDeviceWithApptics().then(function (result_device_info) {
|
|
116
|
+
if (isSuccess(result_device_info)) {
|
|
117
|
+
Console.log('addOrUpdateDeviceID: Success register the device ' + JSON.stringify(result_device_info.data)); // no i18n
|
|
118
|
+
Console.dir(result_device_info.data);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
Console.log('addOrUpdateDeviceID: Error registering the device: ' + result_device_info); // no i18n
|
|
122
|
+
}
|
|
123
|
+
}).catch(function (err) {
|
|
124
|
+
Console.log('addOrUpdateDeviceID: Error registering the device: ' + err); // no i18n
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
else if (!isEmpty(old_device_info) && !compareTwoObjects(deviceIdentity(device_info), deviceIdentity(old_device_info))) {
|
|
128
|
+
// the device itself changed — a browser or OS upgrade, a new screen, a different timezone.
|
|
129
|
+
// The update carries the stored deviceid as a param and the stored uuid as a header, so the
|
|
130
|
+
// server amends this device rather than creating another one: same device, new details
|
|
131
|
+
Console.log('addOrUpdateDeviceID: Device info changed, so updating new changes'); // no i18n
|
|
132
|
+
Console.dir(deviceIdentity(device_info));
|
|
133
|
+
updateDeviceWithApptics(device_info).catch(function (err) {
|
|
134
|
+
Console.log('addOrUpdateDeviceID: Error updating the device: ' + err); // no i18n
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* The ids device/add is allowed to set. Each is taken only when the answer actually carries it.
|
|
140
|
+
*
|
|
141
|
+
* device/add is not the only source of these: app/addversion runs first and is the *only* source
|
|
142
|
+
* of aaid, mapid, appversionid and appreleaseversionid. Its answer is already on _device_info by
|
|
143
|
+
* the time registration replies, and v2's device/add does not repeat all of it - it answers about
|
|
144
|
+
* the device, not the build. Assigning every key unconditionally therefore overwrote ids we had
|
|
145
|
+
* with undefined, which is how aaid and appversionid reached metaWebSDKV2 as null and mapid went
|
|
146
|
+
* out as an empty header.
|
|
147
|
+
*/
|
|
148
|
+
const DEVICE_RESPONSE_KEYS = ['deviceid', 'anonymousid', 'aaid', 'apid', 'mapid', 'appversionid', 'osversionid', 'timezoneid', 'platformid', 'devicetypeid', 'modelid']; // no i18n
|
|
149
|
+
/** Copies server-assigned ids into state and persists device info; resolves once it is stored. */
|
|
150
|
+
function applyDeviceResponse(data) {
|
|
151
|
+
DEVICE_RESPONSE_KEYS.forEach(function (key) {
|
|
152
|
+
// an id the answer does not mention is one we already hold, or one we never had:
|
|
153
|
+
// either way what is on _device_info is better than undefined
|
|
154
|
+
if (!isEmpty(data[key])) {
|
|
155
|
+
_ZAP._device_info[key] = data[key];
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
// apid and mapid are also read straight off state for the request headers
|
|
159
|
+
if (!isEmpty(data.apid)) {
|
|
160
|
+
_ZAP._apid = data.apid;
|
|
161
|
+
}
|
|
162
|
+
if (!isEmpty(data.mapid)) {
|
|
163
|
+
_ZAP._mapid = data.mapid;
|
|
164
|
+
}
|
|
165
|
+
// stored before the registration counts as done, so another tab waiting to register reads it
|
|
166
|
+
return user_defaults.save('device_info', _ZAP._device_info); // no i18n
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* The browser's uuid: the one in storage, or a new one stored now. Every tab of the site uses the
|
|
170
|
+
* same one, because the device is registered under it.
|
|
171
|
+
*/
|
|
172
|
+
function useStoredUuid() {
|
|
173
|
+
// kept in device_info: it is the id this browser is registered under
|
|
174
|
+
var uuid = getKeyFromDeviceInfo('uuid'); // no i18n
|
|
175
|
+
if (isEmpty(uuid)) {
|
|
176
|
+
uuid = getNewUUID();
|
|
177
|
+
setDeviceInfoKey('uuid', uuid); // no i18n
|
|
178
|
+
}
|
|
179
|
+
_ZAP._uuid = uuid;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* The ids another tab of this site registered after this one loaded its settings: those are in
|
|
183
|
+
* storage but not in this tab's copy. Resolves with them, applied to this tab, or null when the
|
|
184
|
+
* browser is still unregistered and this tab has to register it.
|
|
185
|
+
*/
|
|
186
|
+
function adoptRegisteredDevice() {
|
|
187
|
+
return reloadSettings(['device_info']).then(function () {
|
|
188
|
+
var stored = user_defaults.item('device_info') || {}; // no i18n
|
|
189
|
+
if (isEmpty(stored.deviceid) || isEmpty(stored.anonymousid)) {
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
// the device is registered under the uuid the other tab sent
|
|
193
|
+
if (!isEmpty(stored.uuid)) {
|
|
194
|
+
_ZAP._uuid = stored.uuid;
|
|
195
|
+
}
|
|
196
|
+
Console.log('registerDeviceWithApptics: another tab registered this browser, using its device ' + stored.deviceid); // no i18n
|
|
197
|
+
return applyDeviceResponse(stored).then(function () {
|
|
198
|
+
return { result: 'success', data: stored }; // no i18n
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Sets up this browser's device at start-up: the uuid, the device info, and a registration when
|
|
204
|
+
* the browser has none.
|
|
205
|
+
*
|
|
206
|
+
* Settings are this tab's own copy, loaded when it started. On a browser with no device yet, two
|
|
207
|
+
* tabs started together would each register it and store two devices, so the first visit runs
|
|
208
|
+
* under a lock shared by every tab of the site: the tab that gets it re-reads storage, registers
|
|
209
|
+
* only when no other tab has, and keeps the lock until the new ids are stored. The next tab then
|
|
210
|
+
* finds them. Start-up goes on as soon as the device info is set, without waiting for the server.
|
|
211
|
+
*/
|
|
212
|
+
function prepareDevice() {
|
|
213
|
+
var cached = user_defaults.item('device_info') || {}; // no i18n
|
|
214
|
+
if (!isEmpty(cached.deviceid) && !isEmpty(cached.anonymousid)) {
|
|
215
|
+
useStoredUuid();
|
|
216
|
+
checkAndUpdateDeviceInfo();
|
|
217
|
+
return Promise.resolve();
|
|
218
|
+
}
|
|
219
|
+
return new Promise(function (resolve) {
|
|
220
|
+
withLock('device', function () {
|
|
221
|
+
return reloadSettings(['device_info']).then(function () {
|
|
222
|
+
useStoredUuid();
|
|
223
|
+
checkAndUpdateDeviceInfo();
|
|
224
|
+
resolve();
|
|
225
|
+
// held until a registration this started is stored, or has failed
|
|
226
|
+
return deviceReady();
|
|
227
|
+
});
|
|
228
|
+
}).catch(function (err) {
|
|
229
|
+
Console.log('prepareDevice: ' + err); // no i18n
|
|
230
|
+
}).then(function () {
|
|
231
|
+
resolve();
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
/** True while the device has no server ids, so nothing can be sent yet. */
|
|
236
|
+
function needsDevice() {
|
|
237
|
+
// the app ids from app/addversion, and the deviceid from device/add: either missing, and the
|
|
238
|
+
// device is registered before anything stored is sent
|
|
239
|
+
return (isEmpty(getHeaderParams('apid')) && isEmpty(getHeaderParams('mapid'))) || !hasDeviceId(); // no i18n
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Resolves once a registration that is in flight has settled, succeeded or not, and right away
|
|
243
|
+
* when none is running. Callers use it to wait for the ids rather than poll for them.
|
|
244
|
+
*/
|
|
245
|
+
function deviceReady() {
|
|
246
|
+
if (!_ZAP._regDeviceSending) {
|
|
247
|
+
return Promise.resolve();
|
|
248
|
+
}
|
|
249
|
+
return new Promise(function (resolve) {
|
|
250
|
+
_ZAP._regDeviceResolve.push(function () { resolve(); });
|
|
251
|
+
_ZAP._regDeviceReject.push(function () { resolve(); });
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
/** Ends an in-flight registration: clears the flag and settles every caller that waited on it. */
|
|
255
|
+
function settleRegistration(ok, value) {
|
|
256
|
+
var waiters = ok ? _ZAP._regDeviceResolve : _ZAP._regDeviceReject;
|
|
257
|
+
_ZAP._regDeviceSending = false;
|
|
258
|
+
_ZAP._regDeviceResolve = [];
|
|
259
|
+
_ZAP._regDeviceReject = [];
|
|
260
|
+
waiters.forEach(function (fn) {
|
|
261
|
+
fn(value);
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
// Function to register the device
|
|
265
|
+
function registerDeviceWithApptics() {
|
|
266
|
+
var label = 'registerDeviceWithApptics'; // no i18n
|
|
267
|
+
var blocked = rejectIfDisabled(label);
|
|
268
|
+
if (blocked) {
|
|
269
|
+
return blocked;
|
|
270
|
+
}
|
|
271
|
+
if (!_ZAP._token) {
|
|
272
|
+
Console.warn(label + ': You must call Apptics.init() first'); // no i18n
|
|
273
|
+
return Promise.reject(label + ': You must call Apptics.init() first'); // no i18n
|
|
274
|
+
}
|
|
275
|
+
var offline = rejectIfOffline(label);
|
|
276
|
+
if (offline) {
|
|
277
|
+
return offline;
|
|
278
|
+
}
|
|
279
|
+
if (_ZAP._device_info.deviceid && _ZAP._device_info.anonymousid) {
|
|
280
|
+
return Promise.resolve(_ZAP._device_info);
|
|
281
|
+
}
|
|
282
|
+
return new Promise((resolve, reject) => {
|
|
283
|
+
if (_ZAP._regDeviceSending) {
|
|
284
|
+
// a registration is already in flight; settle together with it
|
|
285
|
+
_ZAP._regDeviceResolve.push(resolve);
|
|
286
|
+
_ZAP._regDeviceReject.push(reject);
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
_ZAP._regDeviceSending = true;
|
|
290
|
+
adoptRegisteredDevice().then(function (adopted) {
|
|
291
|
+
if (adopted) {
|
|
292
|
+
return adopted;
|
|
293
|
+
}
|
|
294
|
+
var payload = deviceBody(_ZAP._device_info);
|
|
295
|
+
// device/add is the one url that allows all four: zak and uuid identify the caller,
|
|
296
|
+
// apid and mapid the app. app/addversion has already answered with apid and mapid by
|
|
297
|
+
// the time registration runs, so the first call can carry them like every later one.
|
|
298
|
+
var headers = { zak: getHeaderParams('zak'), uuid: getHeaderParams('uuid'), ...apiHeaders() }; // no i18n
|
|
299
|
+
return postToApptics('regdevice', payload, headers, label).then(function (result) {
|
|
300
|
+
return applyDeviceResponse(result.data || {}).then(function () {
|
|
301
|
+
return result;
|
|
302
|
+
});
|
|
303
|
+
});
|
|
304
|
+
}).then(function (result) {
|
|
305
|
+
settleRegistration(true, result);
|
|
306
|
+
resolve(result);
|
|
307
|
+
// first visit: the ids exist now, so fetch the server settings right away
|
|
308
|
+
refreshServerSettings();
|
|
309
|
+
}).catch(function (err) {
|
|
310
|
+
settleRegistration(false, err);
|
|
311
|
+
reject(err);
|
|
312
|
+
});
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
// Function to update the device
|
|
316
|
+
function updateDeviceWithApptics(device_info) {
|
|
317
|
+
var label = 'updateDeviceWithApptics'; // no i18n
|
|
318
|
+
var blocked = rejectIfDisabled(label) || rejectIfOffline(label);
|
|
319
|
+
if (blocked) {
|
|
320
|
+
return blocked;
|
|
321
|
+
}
|
|
322
|
+
var payload = deviceBody(device_info);
|
|
323
|
+
var headers = { zak: getHeaderParams('zak'), uuid: getHeaderParams('uuid'), ...apiHeaders() }; // no i18n
|
|
324
|
+
return postToApptics('regdevice', payload, headers, label).then(function (result) {
|
|
325
|
+
applyDeviceResponse(result.data || {});
|
|
326
|
+
return result;
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
// Function to get updates from the server
|
|
330
|
+
function getUpdatesFromServer() {
|
|
331
|
+
var label = 'getUpdatesFromServer'; // no i18n
|
|
332
|
+
var blocked = rejectIfOffline(label) || rejectIfNoDeviceIds(label);
|
|
333
|
+
if (blocked) {
|
|
334
|
+
return blocked;
|
|
335
|
+
}
|
|
336
|
+
// getsdkconfig takes no body: the ids it needs are parameters
|
|
337
|
+
return postToApptics('sdkconfig', '', apiHeaders(), label).then(function (result) {
|
|
338
|
+
var data = result.data || {};
|
|
339
|
+
applyServerFlags(data);
|
|
340
|
+
// the visitor's tracking status lives in trackinfo too, and is not the server's to replace
|
|
341
|
+
var saved = storedTrackingStatus();
|
|
342
|
+
user_defaults.add('trackinfo', saved === undefined ? _ZAP._trackinfo : Object.assign({}, _ZAP._trackinfo, { tracking_status: saved })); // no i18n
|
|
343
|
+
Console.log('getUpdatesFromServer: ' + JSON.stringify(_ZAP._trackinfo)); // no i18n
|
|
344
|
+
return data;
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Whether getsdkconfig says a module is on.
|
|
349
|
+
*
|
|
350
|
+
* Absent means on: a server that does not report a module has not turned it off, and an SDK that
|
|
351
|
+
* went quiet because of a key it had never heard of would be impossible to diagnose.
|
|
352
|
+
*/
|
|
353
|
+
function moduleEnabled(status, id) {
|
|
354
|
+
var entry = status[id];
|
|
355
|
+
if (!entry || typeof entry !== 'object') {
|
|
356
|
+
return true;
|
|
357
|
+
}
|
|
358
|
+
return entry.enabled !== false;
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Applies the server's tracking flags, from a getsdkconfig response or the saved trackinfo.
|
|
362
|
+
*
|
|
363
|
+
* v2 reports a flag per module, keyed by a numeric id, rather than the loose booleans getupdates
|
|
364
|
+
* answered with. Both shapes are read: the stored trackinfo from a previous version of this SDK
|
|
365
|
+
* is in the old shape, and discarding it would mean a visit tracking things the server had
|
|
366
|
+
* already said to stop.
|
|
367
|
+
*/
|
|
368
|
+
function applyServerFlags(data) {
|
|
369
|
+
var status = (data.tracking_status && typeof data.tracking_status === 'object'
|
|
370
|
+
? data.tracking_status : {});
|
|
371
|
+
var hasModules = Object.keys(status).length > 0;
|
|
372
|
+
if (data.hasOwnProperty('tracking_enabled')) { // no i18n
|
|
373
|
+
_ZAP._shouldTrack = data.tracking_enabled !== false;
|
|
374
|
+
}
|
|
375
|
+
else {
|
|
376
|
+
// the old shape: archived versions and untracked customer groups
|
|
377
|
+
var versionArchived = !data.hasOwnProperty('versionarchivestatus') || isEmpty(data.versionarchivestatus)
|
|
378
|
+
? true : data.versionarchivestatus;
|
|
379
|
+
var customerGroupTracking = !data.hasOwnProperty('customergrouptracking') || isEmpty(data.customergrouptracking)
|
|
380
|
+
? true : data.customergrouptracking;
|
|
381
|
+
_ZAP._shouldTrack = versionArchived || !customerGroupTracking;
|
|
382
|
+
}
|
|
383
|
+
if (hasModules) {
|
|
384
|
+
// sessions carry screens, events and api calls, so module 11 gates all of engagement
|
|
385
|
+
_ZAP._engagementTracking = moduleEnabled(status, SDK_MODULE.SESSION);
|
|
386
|
+
_ZAP._errorTracking = moduleEnabled(status, SDK_MODULE.CRASH);
|
|
387
|
+
_ZAP._heatmapTracking = moduleEnabled(status, SDK_MODULE.HEATMAP);
|
|
388
|
+
_ZAP._remoteLoggerEnabled = moduleEnabled(status, SDK_MODULE.REMOTE_LOGGER);
|
|
389
|
+
_ZAP._feedbackEnabled = moduleEnabled(status, SDK_MODULE.FEEDBACK);
|
|
390
|
+
// getsdkconfig is the authority on this one: getupdates reports it too and the two can
|
|
391
|
+
// disagree while both are in flight, so what is read here wins
|
|
392
|
+
_ZAP._remoteConfigEnabled = moduleEnabled(status, SDK_MODULE.REMOTE_CONFIG);
|
|
393
|
+
}
|
|
394
|
+
else {
|
|
395
|
+
_ZAP._engagementTracking = data.engagementtracking !== false;
|
|
396
|
+
_ZAP._errorTracking = data.errortracking !== false;
|
|
397
|
+
_ZAP._heatmapTracking = data.heatmaptracking !== false;
|
|
398
|
+
_ZAP._remoteLoggerEnabled = data.remoteloggerenabled !== false;
|
|
399
|
+
_ZAP._feedbackEnabled = data.feedbackenabled !== false;
|
|
400
|
+
}
|
|
401
|
+
// screen recording, set up in the console: everything the form needs comes from here
|
|
402
|
+
var quartz = (data.quartz && typeof data.quartz === 'object' ? data.quartz : {});
|
|
403
|
+
var text = function (value) {
|
|
404
|
+
return typeof value === 'string' ? value.trim() : ''; // no i18n
|
|
405
|
+
};
|
|
406
|
+
_ZAP._quartz = {
|
|
407
|
+
enabled: quartz.hasOwnProperty('quartz_enabled') ? quartz.quartz_enabled === true : data.quartzenabled === true, // no i18n
|
|
408
|
+
workspace: text(quartz.quartz_workspace),
|
|
409
|
+
department: text(quartz.quartz_department),
|
|
410
|
+
domain: text(quartz.quartz_domain),
|
|
411
|
+
cdnUrl: text(quartz.quartz_cdn_url),
|
|
412
|
+
};
|
|
413
|
+
// when to ask again, which replaces polling on a fixed interval
|
|
414
|
+
if (typeof data.next_check_after === 'number' && data.next_check_after > 0) {
|
|
415
|
+
_ZAP._nextConfigCheck = data.next_check_after;
|
|
416
|
+
}
|
|
417
|
+
_ZAP._trackinfo = {
|
|
418
|
+
engagementtracking: _ZAP._engagementTracking,
|
|
419
|
+
errortracking: _ZAP._errorTracking,
|
|
420
|
+
heatmaptracking: _ZAP._heatmapTracking,
|
|
421
|
+
remoteloggerenabled: _ZAP._remoteLoggerEnabled,
|
|
422
|
+
feedbackenabled: _ZAP._feedbackEnabled,
|
|
423
|
+
// in the server's own shape, so restoring it on the next visit reads it the same way
|
|
424
|
+
quartz: {
|
|
425
|
+
quartz_enabled: _ZAP._quartz.enabled,
|
|
426
|
+
quartz_workspace: _ZAP._quartz.workspace,
|
|
427
|
+
quartz_department: _ZAP._quartz.department,
|
|
428
|
+
quartz_domain: _ZAP._quartz.domain,
|
|
429
|
+
quartz_cdn_url: _ZAP._quartz.cdnUrl,
|
|
430
|
+
},
|
|
431
|
+
shouldtrack: _ZAP._shouldTrack,
|
|
432
|
+
next_check_after: _ZAP._nextConfigCheck
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Start-up: applies the server settings saved by the last getupdates, so a "stop tracking"
|
|
437
|
+
* answer holds across page loads instead of resetting to "on" until the next check.
|
|
438
|
+
*/
|
|
439
|
+
function restoreServerSettings() {
|
|
440
|
+
var saved = user_defaults.item('trackinfo'); // no i18n
|
|
441
|
+
if (saved && typeof saved === 'object') { // no i18n
|
|
442
|
+
applyServerFlags(saved);
|
|
443
|
+
Console.log('restoreServerSettings: ' + JSON.stringify(_ZAP._trackinfo)); // no i18n
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Fetches the server settings now if the device is registered. On a first visit the ids don't
|
|
448
|
+
* exist yet; registerDeviceWithApptics calls this as soon as device/add succeeds.
|
|
449
|
+
*/
|
|
450
|
+
function refreshServerSettings() {
|
|
451
|
+
if (isEmpty(getHeaderParams('apid')) && isEmpty(getHeaderParams('mapid'))) { // no i18n
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
getUpdatesFromServer().catch(function (err) {
|
|
455
|
+
Console.log(err);
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
hooks.updateDevice = updateDeviceWithApptics;
|
|
459
|
+
hooks.refreshDeviceInfo = checkAndUpdateDeviceInfo;
|
|
460
|
+
|
|
461
|
+
export { addOrUpdateDeviceID, checkAndUpdateDeviceInfo, deviceReady, getUpdatesFromServer, needsDevice, prepareDevice, refreshServerSettings, registerDeviceWithApptics, restoreServerSettings, updateDeviceWithApptics };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** The rules, as ApiTrackingBuilder.build() returns them. Every list may be empty. */
|
|
2
|
+
export interface ApiTrackingConfig {
|
|
3
|
+
/** URLs recorded, exactly; with any allow rule, only calls matching one are recorded. */
|
|
4
|
+
allowEquals: string[];
|
|
5
|
+
/** URLs never recorded, exactly. */
|
|
6
|
+
ignoreEquals: string[];
|
|
7
|
+
/** Regular expressions a recorded URL may match; with any allow rule, it must match one. */
|
|
8
|
+
allowRegex: RegExp[];
|
|
9
|
+
/** Regular expressions whose URLs are never recorded. */
|
|
10
|
+
ignoreRegex: RegExp[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A URL as the rules compare it: `scheme://host[:port]/path`, the scheme and host lower-cased,
|
|
14
|
+
* the default port dropped, the query, fragment and a trailing slash removed. '' when it is not
|
|
15
|
+
* an absolute http(s) URL.
|
|
16
|
+
*/
|
|
17
|
+
export declare function ruleUrl(raw: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Builds the rules configure takes. Each method may be called more than once, and takes any number
|
|
20
|
+
* of values: `new ApiTrackingBuilder().allowEquals(a, b).ignoreRegex(/x/).build()`.
|
|
21
|
+
*/
|
|
22
|
+
export declare class ApiTrackingBuilder {
|
|
23
|
+
private rules;
|
|
24
|
+
/** Records only these URLs (and those any allowRegex matches): `https://api.example.com/orders`. */
|
|
25
|
+
allowEquals(...urls: string[]): this;
|
|
26
|
+
/** Never records these URLs: `https://api.example.com/health`. */
|
|
27
|
+
ignoreEquals(...urls: string[]): this;
|
|
28
|
+
/** Records only URLs these match (and those any allowEquals names): `/^https:\/\/api\.example\.com\//`. */
|
|
29
|
+
allowRegex(...patterns: Array<RegExp | string>): this;
|
|
30
|
+
/** Never records URLs these match: `/\/internal\//`. */
|
|
31
|
+
ignoreRegex(...patterns: Array<RegExp | string>): this;
|
|
32
|
+
build(): ApiTrackingConfig;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Applies the rules, replacing any given before. Takes what build() returned, or the builder
|
|
36
|
+
* itself. Call it once, before the requests it should cover; it works before init().
|
|
37
|
+
*/
|
|
38
|
+
export declare function configureApiTracking(config: ApiTrackingConfig | ApiTrackingBuilder): void;
|
|
39
|
+
/** The rules in force, for tests and the playground. */
|
|
40
|
+
export declare function apiTrackingConfig(): ApiTrackingConfig;
|
|
41
|
+
/**
|
|
42
|
+
* Whether a call to `url` is recorded. Ignore rules are tried first and always win; then, when
|
|
43
|
+
* there are allow rules, the URL must match one. A URL that cannot be read is not recorded.
|
|
44
|
+
*/
|
|
45
|
+
export declare function urlTracked(url: string): boolean;
|
|
46
|
+
/** The path without its query string or fragment, which is where ids and tokens travel. */
|
|
47
|
+
export declare function withoutQuery(path: string): string;
|
|
48
|
+
/** The path a call is recorded under: the query goes, and numeric ids, UUIDs and JWTs become `*`. */
|
|
49
|
+
export declare function normalizeApiPath(path: string): string;
|