@zoho_apptics/apptics-js-sdk 2.0.0-beta → 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 +111 -5
- package/README.md +399 -300
- 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-VYr43KcB.min.js +3 -0
- package/dist/chunks/lifecycle-VYr43KcB.min.js.map +1 -0
- package/dist/cjs/auto-init.d.ts +3 -3
- package/dist/cjs/auto-init.js +1 -1
- package/dist/cjs/core/attempts.js +1 -1
- package/dist/cjs/core/batch.js +2 -1
- package/dist/cjs/core/callsite.d.ts +6 -0
- package/dist/cjs/core/callsite.js +25 -3
- package/dist/cjs/core/consent.d.ts +5 -1
- package/dist/cjs/core/consent.js +8 -6
- package/dist/cjs/core/constants.d.ts +35 -10
- package/dist/cjs/core/constants.js +31 -15
- package/dist/cjs/core/db.d.ts +12 -4
- package/dist/cjs/core/db.js +167 -34
- package/dist/cjs/core/debug.js +1 -1
- package/dist/cjs/core/env.js +1 -1
- package/dist/cjs/core/framework-id.d.ts +1 -1
- package/dist/cjs/core/framework-id.js +3 -3
- package/dist/cjs/core/guard.d.ts +9 -0
- package/dist/cjs/core/guard.js +27 -13
- package/dist/cjs/core/hooks.d.ts +2 -4
- package/dist/cjs/core/hooks.js +2 -3
- package/dist/cjs/core/locks.d.ts +9 -0
- package/dist/cjs/core/locks.js +22 -0
- package/dist/cjs/core/logger.d.ts +3 -4
- package/dist/cjs/core/logger.js +4 -40
- package/dist/cjs/core/state.d.ts +3 -2
- package/dist/cjs/core/state.js +2 -2
- package/dist/cjs/core/storage.d.ts +20 -5
- package/dist/cjs/core/storage.js +115 -17
- package/dist/cjs/core/stylesheet.d.ts +8 -0
- package/dist/cjs/core/stylesheet.js +29 -0
- package/dist/cjs/core/transport.d.ts +2 -0
- package/dist/cjs/core/transport.js +19 -4
- package/dist/cjs/core/utils.js +1 -1
- package/dist/cjs/core/validate.js +2 -2
- package/dist/cjs/device/appversion.d.ts +1 -6
- package/dist/cjs/device/appversion.js +13 -1
- package/dist/cjs/device/index.d.ts +11 -0
- package/dist/cjs/device/index.js +120 -20
- package/dist/cjs/engagement/api-rules.d.ts +32 -67
- package/dist/cjs/engagement/api-rules.js +144 -157
- package/dist/cjs/engagement/auto-api.js +2 -2
- package/dist/cjs/engagement/auto-screen.d.ts +2 -0
- package/dist/cjs/engagement/auto-screen.js +67 -3
- package/dist/cjs/engagement/defined-events.js +1 -1
- package/dist/cjs/engagement/send.js +6 -1
- package/dist/cjs/engagement/session.d.ts +12 -3
- package/dist/cjs/engagement/session.js +161 -25
- package/dist/cjs/engagement/track.js +45 -20
- package/dist/cjs/errors/send.js +1 -1
- package/dist/cjs/errors/track.d.ts +1 -1
- package/dist/cjs/errors/track.js +46 -6
- package/dist/cjs/feedback/controls.d.ts +6 -0
- package/dist/cjs/feedback/controls.js +31 -1
- package/dist/cjs/feedback/index.d.ts +8 -7
- package/dist/cjs/feedback/index.js +32 -13
- package/dist/cjs/feedback/logs.d.ts +10 -5
- package/dist/cjs/feedback/logs.js +52 -13
- package/dist/cjs/feedback/quartz.d.ts +18 -0
- package/dist/cjs/feedback/quartz.js +105 -0
- package/dist/cjs/feedback/send.d.ts +3 -0
- package/dist/cjs/feedback/send.js +28 -3
- package/dist/cjs/feedback/styles.d.ts +10 -0
- package/dist/cjs/feedback/styles.js +8 -0
- package/dist/cjs/feedback/template.d.ts +1 -1
- package/dist/cjs/feedback/template.js +12 -12
- package/dist/cjs/feedback/ui.d.ts +14 -6
- package/dist/cjs/feedback/ui.js +126 -48
- package/dist/cjs/heatmap/send.js +1 -1
- package/dist/cjs/heatmap/track.d.ts +1 -1
- package/dist/cjs/heatmap/track.js +87 -16
- package/dist/cjs/index.d.ts +17 -63
- package/dist/cjs/index.js +104 -92
- package/dist/cjs/lifecycle.d.ts +8 -1
- package/dist/cjs/lifecycle.js +258 -62
- package/dist/cjs/remoteconfig/country.d.ts +4 -0
- package/dist/cjs/remoteconfig/country.js +73 -0
- package/dist/cjs/remoteconfig/custom.d.ts +7 -7
- package/dist/cjs/remoteconfig/custom.js +31 -51
- package/dist/cjs/remoteconfig/evaluate.d.ts +3 -3
- package/dist/cjs/remoteconfig/evaluate.js +56 -43
- package/dist/cjs/remoteconfig/fetch.d.ts +3 -3
- package/dist/cjs/remoteconfig/fetch.js +9 -23
- package/dist/cjs/remoteconfig/index.d.ts +10 -8
- package/dist/cjs/remoteconfig/index.js +65 -39
- package/dist/cjs/remoteconfig/store.js +1 -1
- 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 -11
- package/dist/cjs/remotelog/gate.js +9 -35
- package/dist/cjs/remotelog/index.d.ts +4 -21
- package/dist/cjs/remotelog/logger.d.ts +11 -17
- package/dist/cjs/remotelog/logger.js +30 -58
- package/dist/cjs/remotelog/send.js +10 -10
- package/dist/cjs/remotelogger/index.d.ts +12 -0
- package/dist/cjs/remotelogger/index.js +18 -0
- package/dist/cjs/scheduler.js +2 -2
- package/dist/cjs/types.d.ts +155 -82
- package/dist/cjs/user/index.js +11 -6
- package/dist/esm/auto-init.d.ts +3 -3
- package/dist/esm/auto-init.js +1 -1
- package/dist/esm/core/attempts.js +1 -1
- package/dist/esm/core/batch.js +2 -1
- package/dist/esm/core/callsite.d.ts +6 -0
- package/dist/esm/core/callsite.js +25 -4
- package/dist/esm/core/consent.d.ts +5 -1
- package/dist/esm/core/consent.js +9 -7
- package/dist/esm/core/constants.d.ts +35 -10
- package/dist/esm/core/constants.js +30 -15
- package/dist/esm/core/db.d.ts +12 -4
- package/dist/esm/core/db.js +164 -35
- package/dist/esm/core/debug.js +1 -1
- package/dist/esm/core/env.js +1 -1
- package/dist/esm/core/framework-id.d.ts +1 -1
- package/dist/esm/core/framework-id.js +3 -3
- package/dist/esm/core/guard.d.ts +9 -0
- package/dist/esm/core/guard.js +27 -14
- package/dist/esm/core/hooks.d.ts +2 -4
- package/dist/esm/core/hooks.js +2 -3
- package/dist/esm/core/locks.d.ts +9 -0
- package/dist/esm/core/locks.js +20 -0
- package/dist/esm/core/logger.d.ts +3 -4
- package/dist/esm/core/logger.js +4 -40
- package/dist/esm/core/state.d.ts +3 -2
- package/dist/esm/core/state.js +2 -2
- package/dist/esm/core/storage.d.ts +20 -5
- package/dist/esm/core/storage.js +113 -18
- package/dist/esm/core/stylesheet.d.ts +8 -0
- package/dist/esm/core/stylesheet.js +27 -0
- package/dist/esm/core/transport.d.ts +2 -0
- package/dist/esm/core/transport.js +19 -5
- package/dist/esm/core/utils.js +1 -1
- package/dist/esm/core/validate.js +2 -2
- package/dist/esm/device/appversion.d.ts +1 -6
- package/dist/esm/device/appversion.js +13 -2
- package/dist/esm/device/index.d.ts +11 -0
- package/dist/esm/device/index.js +123 -24
- package/dist/esm/engagement/api-rules.d.ts +32 -67
- package/dist/esm/engagement/api-rules.js +143 -155
- package/dist/esm/engagement/auto-api.js +3 -3
- package/dist/esm/engagement/auto-screen.d.ts +2 -0
- package/dist/esm/engagement/auto-screen.js +67 -4
- package/dist/esm/engagement/defined-events.js +1 -1
- package/dist/esm/engagement/send.js +6 -1
- package/dist/esm/engagement/session.d.ts +12 -3
- package/dist/esm/engagement/session.js +162 -29
- package/dist/esm/engagement/track.js +52 -27
- package/dist/esm/errors/send.js +1 -1
- package/dist/esm/errors/track.d.ts +1 -1
- package/dist/esm/errors/track.js +46 -6
- package/dist/esm/feedback/controls.d.ts +6 -0
- package/dist/esm/feedback/controls.js +31 -2
- package/dist/esm/feedback/index.d.ts +8 -7
- package/dist/esm/feedback/index.js +34 -13
- package/dist/esm/feedback/logs.d.ts +10 -5
- package/dist/esm/feedback/logs.js +54 -15
- package/dist/esm/feedback/quartz.d.ts +18 -0
- package/dist/esm/feedback/quartz.js +99 -0
- package/dist/esm/feedback/send.d.ts +3 -0
- package/dist/esm/feedback/send.js +28 -5
- package/dist/esm/feedback/styles.d.ts +10 -0
- package/dist/esm/feedback/styles.js +4 -0
- package/dist/esm/feedback/template.d.ts +1 -1
- package/dist/esm/feedback/template.js +12 -12
- package/dist/esm/feedback/ui.d.ts +14 -6
- package/dist/esm/feedback/ui.js +126 -49
- package/dist/esm/heatmap/send.js +1 -1
- package/dist/esm/heatmap/track.d.ts +1 -1
- package/dist/esm/heatmap/track.js +87 -16
- package/dist/esm/index.d.ts +17 -63
- package/dist/esm/index.js +108 -80
- package/dist/esm/lifecycle.d.ts +8 -1
- package/dist/esm/lifecycle.js +266 -71
- package/dist/esm/remoteconfig/country.d.ts +4 -0
- package/dist/esm/remoteconfig/country.js +70 -0
- package/dist/esm/remoteconfig/custom.d.ts +7 -7
- package/dist/esm/remoteconfig/custom.js +32 -52
- package/dist/esm/remoteconfig/evaluate.d.ts +3 -3
- package/dist/esm/remoteconfig/evaluate.js +57 -44
- package/dist/esm/remoteconfig/fetch.d.ts +3 -3
- package/dist/esm/remoteconfig/fetch.js +9 -23
- package/dist/esm/remoteconfig/index.d.ts +10 -8
- package/dist/esm/remoteconfig/index.js +66 -40
- package/dist/esm/remoteconfig/store.js +1 -1
- 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 -11
- package/dist/esm/remotelog/gate.js +10 -32
- package/dist/esm/remotelog/index.d.ts +4 -21
- package/dist/esm/remotelog/logger.d.ts +11 -17
- package/dist/esm/remotelog/logger.js +32 -60
- package/dist/esm/remotelog/send.js +12 -12
- package/dist/esm/remotelogger/index.d.ts +12 -0
- package/dist/esm/remotelogger/index.js +13 -0
- package/dist/esm/scheduler.js +2 -2
- package/dist/esm/types.d.ts +155 -82
- package/dist/esm/user/index.js +12 -6
- package/dist/feedback.esm.min.js +2 -2
- package/dist/feedback.esm.min.js.map +1 -1
- package/package.json +14 -16
- package/dist/chunks/batch-BU_mTpm1.min.js +0 -3
- package/dist/chunks/batch-BU_mTpm1.min.js.map +0 -1
- package/dist/chunks/logs-Bea5zUW_.min.js +0 -3
- package/dist/chunks/logs-Bea5zUW_.min.js.map +0 -1
- package/dist/cjs/heatmap/index.d.ts +0 -16
- package/dist/cjs/heatmap/index.js +0 -22
- package/dist/cjs/remotelog/index.js +0 -55
- package/dist/esm/heatmap/index.d.ts +0 -16
- package/dist/esm/heatmap/index.js +0 -17
- package/dist/esm/remotelog/index.js +0 -51
- package/dist/heatmap.esm.min.js +0 -3
- package/dist/heatmap.esm.min.js.map +0 -1
- package/dist/style.css +0 -1
package/dist/esm/device/index.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
2
|
import { SDK_MODULE } from '../core/constants.js';
|
|
3
3
|
import { _ZAP } from '../core/state.js';
|
|
4
4
|
import { Console } from '../core/logger.js';
|
|
5
|
-
import { isEmpty, isSuccess, compareTwoObjects } from '../core/utils.js';
|
|
6
|
-
import { user_defaults, getKeyFromDeviceInfo } from '../core/storage.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';
|
|
7
8
|
import { getTimeZone, getConnectionType, getReferringURL, getDevice, getBrowserVersion, getBrowser, getOS } from '../core/env.js';
|
|
8
9
|
import { hasDoNotTrackEnabled } from '../core/consent.js';
|
|
9
|
-
import {
|
|
10
|
+
import { rejectIfDisabled, rejectIfOffline, apiHeaders, getHeaderParams, postToApptics, hasDeviceId, rejectIfNoDeviceIds } from '../core/transport.js';
|
|
10
11
|
import { hooks } from '../core/hooks.js';
|
|
11
12
|
import { applyStoredAppVersion } from './appversion.js';
|
|
12
13
|
|
|
@@ -93,7 +94,11 @@ function checkAndUpdateDeviceInfo() {
|
|
|
93
94
|
// appreleaseversionid from app/addversion
|
|
94
95
|
modelid: getKeyFromDeviceInfo('modelid'), // no i18n
|
|
95
96
|
appreleaseversionid: getKeyFromDeviceInfo('appreleaseversionid'), // no i18n
|
|
96
|
-
timezone: getTimeZone()
|
|
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
|
|
97
102
|
};
|
|
98
103
|
// the rebuild above starts from browser facts, so the ids app/addversion returned are put
|
|
99
104
|
// back before anything is stored or compared
|
|
@@ -141,7 +146,7 @@ function addOrUpdateDeviceID(device_info, previous) {
|
|
|
141
146
|
* out as an empty header.
|
|
142
147
|
*/
|
|
143
148
|
const DEVICE_RESPONSE_KEYS = ['deviceid', 'anonymousid', 'aaid', 'apid', 'mapid', 'appversionid', 'osversionid', 'timezoneid', 'platformid', 'devicetypeid', 'modelid']; // no i18n
|
|
144
|
-
/** Copies server-assigned ids into state and persists device info. */
|
|
149
|
+
/** Copies server-assigned ids into state and persists device info; resolves once it is stored. */
|
|
145
150
|
function applyDeviceResponse(data) {
|
|
146
151
|
DEVICE_RESPONSE_KEYS.forEach(function (key) {
|
|
147
152
|
// an id the answer does not mention is one we already hold, or one we never had:
|
|
@@ -157,12 +162,81 @@ function applyDeviceResponse(data) {
|
|
|
157
162
|
if (!isEmpty(data.mapid)) {
|
|
158
163
|
_ZAP._mapid = data.mapid;
|
|
159
164
|
}
|
|
160
|
-
//
|
|
161
|
-
user_defaults.
|
|
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
|
+
});
|
|
162
234
|
}
|
|
163
235
|
/** True while the device has no server ids, so nothing can be sent yet. */
|
|
164
236
|
function needsDevice() {
|
|
165
|
-
|
|
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
|
|
166
240
|
}
|
|
167
241
|
/**
|
|
168
242
|
* Resolves once a registration that is in flight has settled, succeeded or not, and right away
|
|
@@ -195,8 +269,8 @@ function registerDeviceWithApptics() {
|
|
|
195
269
|
return blocked;
|
|
196
270
|
}
|
|
197
271
|
if (!_ZAP._token) {
|
|
198
|
-
Console.warn(label + ': You must call
|
|
199
|
-
return Promise.reject(label + ': You must call
|
|
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
|
|
200
274
|
}
|
|
201
275
|
var offline = rejectIfOffline(label);
|
|
202
276
|
if (offline) {
|
|
@@ -213,13 +287,21 @@ function registerDeviceWithApptics() {
|
|
|
213
287
|
return;
|
|
214
288
|
}
|
|
215
289
|
_ZAP._regDeviceSending = true;
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
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) {
|
|
223
305
|
settleRegistration(true, result);
|
|
224
306
|
resolve(result);
|
|
225
307
|
// first visit: the ids exist now, so fetch the server settings right away
|
|
@@ -255,7 +337,9 @@ function getUpdatesFromServer() {
|
|
|
255
337
|
return postToApptics('sdkconfig', '', apiHeaders(), label).then(function (result) {
|
|
256
338
|
var data = result.data || {};
|
|
257
339
|
applyServerFlags(data);
|
|
258
|
-
|
|
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
|
|
259
343
|
Console.log('getUpdatesFromServer: ' + JSON.stringify(_ZAP._trackinfo)); // no i18n
|
|
260
344
|
return data;
|
|
261
345
|
});
|
|
@@ -314,10 +398,18 @@ function applyServerFlags(data) {
|
|
|
314
398
|
_ZAP._remoteLoggerEnabled = data.remoteloggerenabled !== false;
|
|
315
399
|
_ZAP._feedbackEnabled = data.feedbackenabled !== false;
|
|
316
400
|
}
|
|
401
|
+
// screen recording, set up in the console: everything the form needs comes from here
|
|
317
402
|
var quartz = (data.quartz && typeof data.quartz === 'object' ? data.quartz : {});
|
|
318
|
-
|
|
319
|
-
?
|
|
320
|
-
|
|
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
|
+
};
|
|
321
413
|
// when to ask again, which replaces polling on a fixed interval
|
|
322
414
|
if (typeof data.next_check_after === 'number' && data.next_check_after > 0) {
|
|
323
415
|
_ZAP._nextConfigCheck = data.next_check_after;
|
|
@@ -328,7 +420,14 @@ function applyServerFlags(data) {
|
|
|
328
420
|
heatmaptracking: _ZAP._heatmapTracking,
|
|
329
421
|
remoteloggerenabled: _ZAP._remoteLoggerEnabled,
|
|
330
422
|
feedbackenabled: _ZAP._feedbackEnabled,
|
|
331
|
-
|
|
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
|
+
},
|
|
332
431
|
shouldtrack: _ZAP._shouldTrack,
|
|
333
432
|
next_check_after: _ZAP._nextConfigCheck
|
|
334
433
|
};
|
|
@@ -359,4 +458,4 @@ function refreshServerSettings() {
|
|
|
359
458
|
hooks.updateDevice = updateDeviceWithApptics;
|
|
360
459
|
hooks.refreshDeviceInfo = checkAndUpdateDeviceInfo;
|
|
361
460
|
|
|
362
|
-
export { addOrUpdateDeviceID, checkAndUpdateDeviceInfo, deviceReady, getUpdatesFromServer, needsDevice, refreshServerSettings, registerDeviceWithApptics, restoreServerSettings, updateDeviceWithApptics };
|
|
461
|
+
export { addOrUpdateDeviceID, checkAndUpdateDeviceInfo, deviceReady, getUpdatesFromServer, needsDevice, prepareDevice, refreshServerSettings, registerDeviceWithApptics, restoreServerSettings, updateDeviceWithApptics };
|
|
@@ -1,62 +1,34 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* What API tracking records, and under what name — Android's AppticsApiTracker.configure, built
|
|
3
|
-
* with ApiTrackingBuilder the way user properties are built with UserBuilder:
|
|
4
|
-
*
|
|
5
|
-
* configureApiTracking(new ApiTrackingBuilder()
|
|
6
|
-
* .allowOnlyDomains('api.zylker.com', 'api.zylker.in')
|
|
7
|
-
* .groupDomains('api.zylker.*')
|
|
8
|
-
* .ignoreEndpoint('/health', '/internal/**')
|
|
9
|
-
* .addPattern('/v2/catalog/{categoryId}/items/{itemId}')
|
|
10
|
-
* .build());
|
|
11
|
-
*
|
|
12
|
-
* Two jobs. Filtering decides whether a call is recorded at all: ignore rules first, and they
|
|
13
|
-
* always win, then the allow lists. Normalization decides the path it is recorded under, so that
|
|
14
|
-
* `/users/42/orders` and `/users/43/orders` are one endpoint on the console rather than two: the
|
|
15
|
-
* query string goes, an explicit pattern is used when one matches, and otherwise numeric ids,
|
|
16
|
-
* UUIDs and JWTs become `*`.
|
|
17
|
-
*
|
|
18
|
-
* Both apply to every call, the ones the fetch/XHR wrappers catch and the ones the app reports
|
|
19
|
-
* with trackApi() or startTrackApi(), so one set of rules decides what the API page shows.
|
|
20
|
-
*/
|
|
21
1
|
/** The rules, as ApiTrackingBuilder.build() returns them. Every list may be empty. */
|
|
22
2
|
export interface ApiTrackingConfig {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
patterns: string[];
|
|
32
|
-
preserveSegments: string[];
|
|
33
|
-
autoDetection: boolean;
|
|
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[];
|
|
34
11
|
}
|
|
35
|
-
/**
|
|
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
|
+
*/
|
|
36
22
|
export declare class ApiTrackingBuilder {
|
|
37
23
|
private rules;
|
|
38
|
-
/**
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
|
|
42
|
-
/** Records only
|
|
43
|
-
|
|
44
|
-
/** Never records
|
|
45
|
-
|
|
46
|
-
/** Never records hosts starting with these, e.g. `dev.`. */
|
|
47
|
-
ignoreDomainPrefixes(...prefixes: string[]): this;
|
|
48
|
-
/** Never records hosts ending with these, e.g. `.cdn.net`. */
|
|
49
|
-
ignoreDomainSuffixes(...suffixes: string[]): this;
|
|
50
|
-
/** Records the hosts a pattern such as `api.myapp.*` matches under that one name. */
|
|
51
|
-
groupDomains(...patterns: string[]): this;
|
|
52
|
-
/** Never records these paths: exact, `*` or `{name}` for one segment, `**` at the end for a prefix. */
|
|
53
|
-
ignoreEndpoint(...paths: string[]): this;
|
|
54
|
-
/** Records a path this pattern matches as the pattern, with each `{name}` as `*`. Tried before auto-detection. */
|
|
55
|
-
addPattern(...patterns: string[]): this;
|
|
56
|
-
/** Segments never turned into `*`, e.g. `v1` or `404`. */
|
|
57
|
-
preserveSegments(...segments: string[]): this;
|
|
58
|
-
/** `false`: only addPattern paths are normalized; every other path is recorded as it is. */
|
|
59
|
-
autoDetection(enabled: boolean): this;
|
|
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;
|
|
60
32
|
build(): ApiTrackingConfig;
|
|
61
33
|
}
|
|
62
34
|
/**
|
|
@@ -66,19 +38,12 @@ export declare class ApiTrackingBuilder {
|
|
|
66
38
|
export declare function configureApiTracking(config: ApiTrackingConfig | ApiTrackingBuilder): void;
|
|
67
39
|
/** The rules in force, for tests and the playground. */
|
|
68
40
|
export declare function apiTrackingConfig(): ApiTrackingConfig;
|
|
69
|
-
/** Whether calls to this host are recorded. Ignore rules are checked first and always win. */
|
|
70
|
-
export declare function hostAllowed(hostname: string): boolean;
|
|
71
|
-
/** The name a host is recorded under: the first groupDomains pattern it matches, or itself. */
|
|
72
|
-
export declare function groupedHost(hostname: string): string;
|
|
73
|
-
/** Whether a host is one of the groupDomains names, which carry a `*` no real host has. */
|
|
74
|
-
export declare function isGroupedHost(hostname: string): boolean;
|
|
75
|
-
/** The path without its query string or fragment, which is where ids and tokens travel. */
|
|
76
|
-
export declare function withoutQuery(path: string): string;
|
|
77
|
-
/** Whether ignoreEndpoint leaves this path out. Matched on the path as called, query removed. */
|
|
78
|
-
export declare function endpointIgnored(path: string): boolean;
|
|
79
41
|
/**
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
* autoDetection on, numeric ids, UUIDs and JWTs become `*`, except preserveSegments.
|
|
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.
|
|
83
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 `*`. */
|
|
84
49
|
export declare function normalizeApiPath(path: string): string;
|