@zoho_apptics/apptics-js-sdk 2.0.0-beta.2 → 2.0.0
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 +47 -0
- package/README.md +229 -174
- package/dist/apptics-pn-sw.js +3 -0
- package/dist/apptics-pn-sw.js.map +1 -0
- 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/batch-Axq9sTzR.min.js +3 -0
- package/dist/chunks/batch-Axq9sTzR.min.js.map +1 -0
- package/dist/chunks/lifecycle-Cvg78jN_.min.js +3 -0
- package/dist/chunks/lifecycle-Cvg78jN_.min.js.map +1 -0
- package/dist/chunks/send-DBpesydB.min.js +3 -0
- package/dist/chunks/send-DBpesydB.min.js.map +1 -0
- package/dist/chunks/transport-B21X39p4.min.js +3 -0
- package/dist/chunks/transport-B21X39p4.min.js.map +1 -0
- package/dist/cjs/core/attempts.js +1 -1
- package/dist/cjs/core/batch.js +4 -3
- package/dist/cjs/core/consent.d.ts +9 -6
- package/dist/cjs/core/consent.js +63 -10
- package/dist/cjs/core/console-call.d.ts +23 -0
- package/dist/cjs/core/console-call.js +63 -0
- package/dist/cjs/core/constants.d.ts +44 -0
- package/dist/cjs/core/constants.js +55 -1
- package/dist/cjs/core/db.js +31 -7
- package/dist/cjs/core/debug.d.ts +6 -4
- package/dist/cjs/core/debug.js +36 -12
- 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.js +19 -4
- package/dist/cjs/core/hooks.d.ts +25 -1
- package/dist/cjs/core/hooks.js +11 -1
- package/dist/cjs/core/locks.js +1 -1
- package/dist/cjs/core/logger.js +1 -1
- package/dist/cjs/core/shield.d.ts +31 -0
- package/dist/cjs/core/shield.js +129 -0
- package/dist/cjs/core/state.d.ts +5 -1
- package/dist/cjs/core/state.js +3 -1
- package/dist/cjs/core/storage.d.ts +7 -0
- package/dist/cjs/core/storage.js +28 -6
- package/dist/cjs/core/stylesheet.js +1 -1
- package/dist/cjs/core/transport.d.ts +15 -4
- package/dist/cjs/core/transport.js +63 -13
- package/dist/cjs/core/utils.js +1 -1
- package/dist/cjs/core/validate.js +6 -5
- package/dist/cjs/device/appversion.js +1 -1
- package/dist/cjs/device/index.js +63 -15
- package/dist/cjs/engagement/api-rules.js +1 -1
- package/dist/cjs/engagement/auto-api.js +4 -3
- package/dist/cjs/engagement/auto-screen.js +10 -6
- package/dist/cjs/engagement/defined-events.d.ts +2 -3
- package/dist/cjs/engagement/defined-events.js +10 -16
- package/dist/cjs/engagement/send.js +1 -1
- package/dist/cjs/engagement/session.js +77 -37
- package/dist/cjs/engagement/track.js +9 -6
- package/dist/cjs/errors/send.js +1 -1
- package/dist/cjs/errors/track.js +3 -2
- package/dist/cjs/feedback/controls.d.ts +30 -4
- package/dist/cjs/feedback/controls.js +237 -51
- package/dist/cjs/feedback/i18n/index.d.ts +31 -0
- package/dist/cjs/feedback/i18n/index.js +187 -0
- package/dist/cjs/feedback/i18n/strings.d.ts +9 -0
- package/dist/cjs/feedback/i18n/strings.js +8 -0
- package/dist/cjs/feedback/index.js +1 -1
- package/dist/cjs/feedback/logs.js +5 -4
- package/dist/cjs/feedback/quartz.js +5 -2
- package/dist/cjs/feedback/send.d.ts +4 -1
- package/dist/cjs/feedback/send.js +56 -15
- package/dist/cjs/feedback/styles.js +2 -2
- package/dist/cjs/feedback/template.d.ts +4 -2
- package/dist/cjs/feedback/template.js +67 -46
- package/dist/cjs/feedback/ui.d.ts +40 -4
- package/dist/cjs/feedback/ui.js +208 -89
- package/dist/cjs/heatmap/send.js +1 -1
- package/dist/cjs/heatmap/track.js +13 -9
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/lifecycle.js +119 -72
- package/dist/cjs/pushnotification/display.d.ts +65 -0
- package/dist/cjs/pushnotification/display.js +112 -0
- package/dist/cjs/pushnotification/index.d.ts +20 -0
- package/dist/cjs/pushnotification/index.js +96 -0
- package/dist/cjs/pushnotification/kept-opens.d.ts +23 -0
- package/dist/cjs/pushnotification/kept-opens.js +64 -0
- package/dist/cjs/pushnotification/notify.d.ts +45 -0
- package/dist/cjs/pushnotification/notify.js +476 -0
- package/dist/cjs/pushnotification/payload.d.ts +65 -0
- package/dist/cjs/pushnotification/payload.js +279 -0
- package/dist/cjs/pushnotification/session.d.ts +46 -0
- package/dist/cjs/pushnotification/session.js +413 -0
- package/dist/cjs/pushnotification/stats.d.ts +45 -0
- package/dist/cjs/pushnotification/stats.js +244 -0
- package/dist/cjs/pushnotification/wms.d.ts +30 -0
- package/dist/cjs/pushnotification/wms.js +374 -0
- package/dist/cjs/remoteconfig/country.js +1 -1
- package/dist/cjs/remoteconfig/custom.js +4 -3
- package/dist/cjs/remoteconfig/evaluate.js +1 -1
- package/dist/cjs/remoteconfig/fetch.js +27 -8
- package/dist/cjs/remoteconfig/index.d.ts +1 -6
- package/dist/cjs/remoteconfig/index.js +4 -28
- package/dist/cjs/remoteconfig/store.js +1 -1
- package/dist/cjs/remoteconfig/tz-countries.js +1 -1
- package/dist/cjs/remotelog/callsite.js +1 -1
- package/dist/cjs/remotelog/gate.js +1 -1
- package/dist/cjs/remotelog/logger.js +1 -1
- package/dist/cjs/remotelog/send.js +5 -4
- package/dist/cjs/remotelogger/index.js +1 -1
- package/dist/cjs/scheduler.js +11 -5
- package/dist/cjs/sw/apptics-pn-sw.d.ts +83 -0
- package/dist/cjs/sw/timers.d.ts +44 -0
- package/dist/cjs/types.d.ts +31 -15
- package/dist/cjs/user/index.d.ts +7 -0
- package/dist/cjs/user/index.js +25 -7
- package/dist/esm/core/attempts.js +1 -1
- package/dist/esm/core/batch.js +4 -3
- package/dist/esm/core/consent.d.ts +9 -6
- package/dist/esm/core/consent.js +67 -16
- package/dist/esm/core/console-call.d.ts +23 -0
- package/dist/esm/core/console-call.js +60 -0
- package/dist/esm/core/constants.d.ts +44 -0
- package/dist/esm/core/constants.js +52 -2
- package/dist/esm/core/db.js +31 -7
- package/dist/esm/core/debug.d.ts +6 -4
- package/dist/esm/core/debug.js +37 -13
- 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.js +19 -4
- package/dist/esm/core/hooks.d.ts +25 -1
- package/dist/esm/core/hooks.js +11 -1
- package/dist/esm/core/locks.js +1 -1
- package/dist/esm/core/logger.js +1 -1
- package/dist/esm/core/shield.d.ts +31 -0
- package/dist/esm/core/shield.js +119 -0
- package/dist/esm/core/state.d.ts +5 -1
- package/dist/esm/core/state.js +3 -1
- package/dist/esm/core/storage.d.ts +7 -0
- package/dist/esm/core/storage.js +28 -8
- package/dist/esm/core/stylesheet.js +1 -1
- package/dist/esm/core/transport.d.ts +15 -4
- package/dist/esm/core/transport.js +64 -16
- package/dist/esm/core/utils.js +1 -1
- package/dist/esm/core/validate.js +6 -5
- package/dist/esm/device/appversion.js +1 -1
- package/dist/esm/device/index.js +67 -19
- package/dist/esm/engagement/api-rules.js +1 -1
- package/dist/esm/engagement/auto-api.js +4 -3
- package/dist/esm/engagement/auto-screen.js +10 -6
- package/dist/esm/engagement/defined-events.d.ts +2 -3
- package/dist/esm/engagement/defined-events.js +10 -16
- package/dist/esm/engagement/send.js +1 -1
- package/dist/esm/engagement/session.js +77 -37
- package/dist/esm/engagement/track.js +9 -6
- package/dist/esm/errors/send.js +1 -1
- package/dist/esm/errors/track.js +3 -2
- package/dist/esm/feedback/controls.d.ts +30 -4
- package/dist/esm/feedback/controls.js +234 -52
- package/dist/esm/feedback/i18n/index.d.ts +31 -0
- package/dist/esm/feedback/i18n/index.js +178 -0
- package/dist/esm/feedback/i18n/strings.d.ts +9 -0
- package/dist/esm/feedback/i18n/strings.js +4 -0
- package/dist/esm/feedback/index.js +1 -1
- package/dist/esm/feedback/logs.js +5 -4
- package/dist/esm/feedback/quartz.js +5 -2
- package/dist/esm/feedback/send.d.ts +4 -1
- package/dist/esm/feedback/send.js +56 -16
- package/dist/esm/feedback/styles.js +2 -2
- package/dist/esm/feedback/template.d.ts +4 -2
- package/dist/esm/feedback/template.js +67 -46
- package/dist/esm/feedback/ui.d.ts +40 -4
- package/dist/esm/feedback/ui.js +210 -91
- package/dist/esm/heatmap/send.js +1 -1
- package/dist/esm/heatmap/track.js +13 -9
- package/dist/esm/index.js +2 -2
- package/dist/esm/lifecycle.js +120 -73
- package/dist/esm/pushnotification/display.d.ts +65 -0
- package/dist/esm/pushnotification/display.js +95 -0
- package/dist/esm/pushnotification/index.d.ts +20 -0
- package/dist/esm/pushnotification/index.js +91 -0
- package/dist/esm/pushnotification/kept-opens.d.ts +23 -0
- package/dist/esm/pushnotification/kept-opens.js +62 -0
- package/dist/esm/pushnotification/notify.d.ts +45 -0
- package/dist/esm/pushnotification/notify.js +469 -0
- package/dist/esm/pushnotification/payload.d.ts +65 -0
- package/dist/esm/pushnotification/payload.js +272 -0
- package/dist/esm/pushnotification/session.d.ts +46 -0
- package/dist/esm/pushnotification/session.js +402 -0
- package/dist/esm/pushnotification/stats.d.ts +45 -0
- package/dist/esm/pushnotification/stats.js +238 -0
- package/dist/esm/pushnotification/wms.d.ts +30 -0
- package/dist/esm/pushnotification/wms.js +368 -0
- package/dist/esm/remoteconfig/country.js +1 -1
- package/dist/esm/remoteconfig/custom.js +4 -3
- package/dist/esm/remoteconfig/evaluate.js +1 -1
- package/dist/esm/remoteconfig/fetch.js +27 -8
- package/dist/esm/remoteconfig/index.d.ts +1 -6
- package/dist/esm/remoteconfig/index.js +4 -28
- package/dist/esm/remoteconfig/store.js +1 -1
- package/dist/esm/remoteconfig/tz-countries.js +1 -1
- package/dist/esm/remotelog/callsite.js +1 -1
- package/dist/esm/remotelog/gate.js +1 -1
- package/dist/esm/remotelog/logger.js +1 -1
- package/dist/esm/remotelog/send.js +5 -4
- package/dist/esm/remotelogger/index.js +1 -1
- package/dist/esm/scheduler.js +11 -5
- package/dist/esm/sw/apptics-pn-sw.d.ts +83 -0
- package/dist/esm/sw/timers.d.ts +44 -0
- package/dist/esm/types.d.ts +31 -15
- package/dist/esm/user/index.d.ts +7 -0
- package/dist/esm/user/index.js +26 -9
- package/dist/feedback.esm.min.js +2 -2
- package/dist/feedback.esm.min.js.map +1 -1
- package/dist/pushnotification.esm.min.js +3 -0
- package/dist/pushnotification.esm.min.js.map +1 -0
- package/dist/remoteconfig.esm.min.js +2 -2
- package/dist/remoteconfig.esm.min.js.map +1 -1
- package/dist/remotelogger.esm.min.js +2 -2
- package/dist/remotelogger.esm.min.js.map +1 -1
- package/package.json +15 -2
- package/dist/chunks/lifecycle-C6m1W7jo.min.js +0 -3
- package/dist/chunks/lifecycle-C6m1W7jo.min.js.map +0 -1
- package/dist/chunks/send-CgUO82ne.min.js +0 -3
- package/dist/chunks/send-CgUO82ne.min.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @zoho_apptics/apptics-js-sdk v2.0.0
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
2
|
import { _ZAP } from '../core/state.js';
|
|
3
3
|
import { Console, warnAlways } from '../core/logger.js';
|
|
4
4
|
import { isEmpty, isSuccess } from '../core/utils.js';
|
package/dist/esm/device/index.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
/*! @zoho_apptics/apptics-js-sdk v2.0.0
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
2
|
import { SDK_MODULE } from '../core/constants.js';
|
|
3
3
|
import { _ZAP, getConfig } from '../core/state.js';
|
|
4
|
-
import { Console } from '../core/logger.js';
|
|
4
|
+
import { Console, warnAlways } from '../core/logger.js';
|
|
5
5
|
import { isEmpty, nowMs, getNewUUID, isSuccess, compareTwoObjects } from '../core/utils.js';
|
|
6
|
-
import { user_defaults, getKeyFromDeviceInfo, setDeviceInfoKey, storedTrackingStatus,
|
|
6
|
+
import { user_defaults, reloadSettings, getKeyFromDeviceInfo, setDeviceInfoKey, storedTrackingStatus, trackingStatusCode } from '../core/storage.js';
|
|
7
7
|
import { withLock } from '../core/locks.js';
|
|
8
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';
|
|
9
|
+
import { isAnonymous, hasDoNotTrackEnabled } from '../core/consent.js';
|
|
10
|
+
import { rejectIfDisabled, rejectIfOffline, apiHeaders, getHeaderParams, postToApptics, hasDeviceId, hasSendIds, rejectIfNoDeviceIds } from '../core/transport.js';
|
|
11
11
|
import { hooks } from '../core/hooks.js';
|
|
12
|
+
import { quietly, shield } from '../core/shield.js';
|
|
12
13
|
import { applyStoredAppVersion } from './appversion.js';
|
|
13
14
|
|
|
14
15
|
/** Server-assigned ids, never sent back in device payloads. */
|
|
@@ -107,12 +108,13 @@ function checkAndUpdateDeviceInfo() {
|
|
|
107
108
|
addOrUpdateDeviceID(_ZAP._device_info, previous);
|
|
108
109
|
}
|
|
109
110
|
/**
|
|
110
|
-
* Whether device/add has registered this device: it has a deviceid
|
|
111
|
-
*
|
|
112
|
-
*
|
|
111
|
+
* Whether device/add has registered this device: it has a deviceid, and while tracking is
|
|
112
|
+
* anonymous the anonymousid its data goes out by. Outside anonymous tracking the anonymousid is
|
|
113
|
+
* not required: nothing else sends it, and requiring it had a server that leaves it out register
|
|
114
|
+
* the same device again on every page load.
|
|
113
115
|
*/
|
|
114
116
|
function isRegistered(info) {
|
|
115
|
-
return !!info && !isEmpty(info.deviceid);
|
|
117
|
+
return !!info && !isEmpty(info.deviceid) && (!isAnonymous() || !isEmpty(info.anonymousid));
|
|
116
118
|
}
|
|
117
119
|
function addOrUpdateDeviceID(device_info, previous) {
|
|
118
120
|
var old_device_info = previous !== undefined ? previous : user_defaults.item('device_info') || {}; // no i18n
|
|
@@ -154,6 +156,20 @@ function addOrUpdateDeviceID(device_info, previous) {
|
|
|
154
156
|
* out as an empty header.
|
|
155
157
|
*/
|
|
156
158
|
const DEVICE_RESPONSE_KEYS = ['deviceid', 'anonymousid', 'aaid', 'apid', 'mapid', 'appversionid', 'osversionid', 'timezoneid', 'platformid', 'devicetypeid', 'modelid']; // no i18n
|
|
159
|
+
/** Whether this page has said the server left the anonymousid out; said once, not per call. */
|
|
160
|
+
var missingAnonymousIdSaid = false;
|
|
161
|
+
/**
|
|
162
|
+
* An anonymous browser's data waits for the anonymousid, so an answer to its device/add without
|
|
163
|
+
* one is said out loud, debug or not: otherwise the data sits in storage with no sign of why, and
|
|
164
|
+
* expires after batch_request_timeout.
|
|
165
|
+
*/
|
|
166
|
+
function noteMissingAnonymousId(data) {
|
|
167
|
+
if (missingAnonymousIdSaid || !isAnonymous() || !isEmpty(data.anonymousid) || !isEmpty(_ZAP._device_info.anonymousid)) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
missingAnonymousIdSaid = true;
|
|
171
|
+
warnAlways('apptics: device/add answered with no anonymousid for anonymous tracking, so anonymous data is kept, and anonymous feedback not sent, until it does'); // no i18n
|
|
172
|
+
}
|
|
157
173
|
/** Copies server-assigned ids into state and persists device info; resolves once it is stored. */
|
|
158
174
|
function applyDeviceResponse(data) {
|
|
159
175
|
DEVICE_RESPONSE_KEYS.forEach(function (key) {
|
|
@@ -171,7 +187,10 @@ function applyDeviceResponse(data) {
|
|
|
171
187
|
_ZAP._mapid = data.mapid;
|
|
172
188
|
}
|
|
173
189
|
// stored before the registration counts as done, so another tab waiting to register reads it
|
|
174
|
-
return user_defaults.save('device_info', _ZAP._device_info)
|
|
190
|
+
return user_defaults.save('device_info', _ZAP._device_info).then(function () {
|
|
191
|
+
// push registers by these ids, and may have been waiting for the anonymousid
|
|
192
|
+
hooks.pushDeviceIdsChanged();
|
|
193
|
+
});
|
|
175
194
|
}
|
|
176
195
|
/**
|
|
177
196
|
* The browser's uuid: the one in storage, or a new one stored now. Every tab of the site uses the
|
|
@@ -244,7 +263,7 @@ function prepareDevice() {
|
|
|
244
263
|
function needsDevice() {
|
|
245
264
|
// the app ids from app/addversion, and the deviceid from device/add: either missing, and the
|
|
246
265
|
// device is registered before anything stored is sent
|
|
247
|
-
return (isEmpty(getHeaderParams('apid')) && isEmpty(getHeaderParams('mapid'))) || !
|
|
266
|
+
return (isEmpty(getHeaderParams('apid')) && isEmpty(getHeaderParams('mapid'))) || !hasSendIds(); // no i18n
|
|
248
267
|
}
|
|
249
268
|
/**
|
|
250
269
|
* Resolves once a registration that is in flight has settled, succeeded or not, and right away
|
|
@@ -305,6 +324,7 @@ function registerDeviceWithApptics() {
|
|
|
305
324
|
// the time registration runs, so the first call can carry them like every later one.
|
|
306
325
|
var headers = { zak: getHeaderParams('zak'), uuid: getHeaderParams('uuid'), ...apiHeaders() }; // no i18n
|
|
307
326
|
return postToApptics('regdevice', payload, headers, label).then(function (result) {
|
|
327
|
+
noteMissingAnonymousId(result.data || {});
|
|
308
328
|
return applyDeviceResponse(result.data || {}).then(function () {
|
|
309
329
|
return result;
|
|
310
330
|
});
|
|
@@ -332,14 +352,15 @@ function updateDeviceWithApptics(device_info) {
|
|
|
332
352
|
var payload = deviceBody(device_info);
|
|
333
353
|
var headers = { zak: getHeaderParams('zak'), uuid: getHeaderParams('uuid'), ...apiHeaders() }; // no i18n
|
|
334
354
|
return postToApptics('regdevice', payload, headers, label).then(function (result) {
|
|
335
|
-
|
|
355
|
+
noteMissingAnonymousId(result.data || {});
|
|
356
|
+
quietly('device/add', applyDeviceResponse(result.data || {})); // no i18n
|
|
336
357
|
return result;
|
|
337
358
|
});
|
|
338
359
|
}
|
|
339
360
|
// Function to get updates from the server
|
|
340
361
|
function getUpdatesFromServer() {
|
|
341
362
|
var label = 'getUpdatesFromServer'; // no i18n
|
|
342
|
-
var blocked = rejectIfOffline(label) || rejectIfNoDeviceIds(label);
|
|
363
|
+
var blocked = rejectIfOffline(label) || rejectIfNoDeviceIds(label, 'sdkconfig');
|
|
343
364
|
if (blocked) {
|
|
344
365
|
return blocked;
|
|
345
366
|
}
|
|
@@ -355,7 +376,7 @@ function getUpdatesFromServer() {
|
|
|
355
376
|
}
|
|
356
377
|
// the visitor's tracking status lives in trackinfo too, and is not the server's to replace
|
|
357
378
|
var saved = storedTrackingStatus();
|
|
358
|
-
user_defaults.add('trackinfo', saved === undefined ? _ZAP._trackinfo : Object.assign({}, _ZAP._trackinfo, { tracking_status: saved })); // no i18n
|
|
379
|
+
user_defaults.add('trackinfo', saved === undefined ? _ZAP._trackinfo : Object.assign({}, _ZAP._trackinfo, { tracking_status: trackingStatusCode(saved) })); // no i18n
|
|
359
380
|
Console.log('getUpdatesFromServer: ' + JSON.stringify(_ZAP._trackinfo)); // no i18n
|
|
360
381
|
return data;
|
|
361
382
|
});
|
|
@@ -434,6 +455,13 @@ function applyServerFlags(data) {
|
|
|
434
455
|
_ZAP._remoteLoggerEnabled = flagOn('remotelogger', 'remoteloggerenabled'); // no i18n
|
|
435
456
|
_ZAP._feedbackEnabled = flagOn('feedback', 'feedbackenabled'); // no i18n
|
|
436
457
|
}
|
|
458
|
+
// push notification: module 16 and the wms block it comes with. Live, the module flag decides;
|
|
459
|
+
// restored, the flag this SDK saved; with neither, the block itself, which the server sends
|
|
460
|
+
// only when push is on. Either way it is off without a usable wms block
|
|
461
|
+
_ZAP._wmsConfig = wmsConfigFrom(data.wms);
|
|
462
|
+
var pushFlag = hasModules ? moduleEnabled(status, SDK_MODULE.PUSH_NOTIFICATION)
|
|
463
|
+
: (data.hasOwnProperty('push') ? data.push === true : true); // no i18n
|
|
464
|
+
_ZAP._pushEnabled = pushFlag && _ZAP._wmsConfig !== null;
|
|
437
465
|
// screen recording, set up in the console: everything the form needs comes from here
|
|
438
466
|
var quartz = (data.quartz && typeof data.quartz === 'object' ? data.quartz : {});
|
|
439
467
|
var text = function (value) {
|
|
@@ -464,7 +492,27 @@ function applyServerFlags(data) {
|
|
|
464
492
|
quartz_cdn_url: _ZAP._quartz.cdnUrl,
|
|
465
493
|
},
|
|
466
494
|
shouldtrack: _ZAP._shouldTrack,
|
|
467
|
-
next_check_after: _ZAP._nextConfigCheck
|
|
495
|
+
next_check_after: _ZAP._nextConfigCheck,
|
|
496
|
+
push: _ZAP._pushEnabled,
|
|
497
|
+
wms: _ZAP._wmsConfig,
|
|
498
|
+
};
|
|
499
|
+
// a no-op unless the push entry was imported, which sets the hook
|
|
500
|
+
hooks.pushConfigChanged();
|
|
501
|
+
}
|
|
502
|
+
/** getsdkconfig's wms block, or null when it has no wms_js_url to load. */
|
|
503
|
+
function wmsConfigFrom(value) {
|
|
504
|
+
if (!value || typeof value !== 'object') { // no i18n
|
|
505
|
+
return null;
|
|
506
|
+
}
|
|
507
|
+
var wms = value;
|
|
508
|
+
if (typeof wms.wms_js_url !== 'string' || wms.wms_js_url.trim() === '') { // no i18n
|
|
509
|
+
return null;
|
|
510
|
+
}
|
|
511
|
+
var sriValues = wms.wms_sri_values && typeof wms.wms_sri_values === 'object' ? wms.wms_sri_values : null; // no i18n
|
|
512
|
+
return {
|
|
513
|
+
wms_js_url: wms.wms_js_url.trim(),
|
|
514
|
+
wms_sri: typeof wms.wms_sri === 'string' ? wms.wms_sri : '', // no i18n
|
|
515
|
+
wms_sri_values: sriValues,
|
|
468
516
|
};
|
|
469
517
|
}
|
|
470
518
|
/**
|
|
@@ -527,7 +575,7 @@ function refreshServerSettings() {
|
|
|
527
575
|
markTabAsked();
|
|
528
576
|
var round = configRound;
|
|
529
577
|
var askedAt = nowMs();
|
|
530
|
-
getUpdatesFromServer().catch(function (err) {
|
|
578
|
+
quietly('getsdkconfig', getUpdatesFromServer().catch(function (err) {
|
|
531
579
|
Console.log(err);
|
|
532
580
|
}).then(function () {
|
|
533
581
|
if (round !== configRound) {
|
|
@@ -543,7 +591,7 @@ function refreshServerSettings() {
|
|
|
543
591
|
// an answer without a usable next_check_after, or a failed call, waits getupdates_interval
|
|
544
592
|
configDueAt = _ZAP._nextConfigCheck > nowMs() ? _ZAP._nextConfigCheck : askedAt + getConfig('getupdates_interval'); // no i18n
|
|
545
593
|
scheduleServerSettingCheck();
|
|
546
|
-
});
|
|
594
|
+
}));
|
|
547
595
|
}
|
|
548
596
|
/**
|
|
549
597
|
* getsdkconfig now, not at the next check: setUser registered a user, or getupdates reported a
|
|
@@ -602,10 +650,10 @@ function scheduleServerSettingCheck() {
|
|
|
602
650
|
}
|
|
603
651
|
var wait = Math.min(Math.max(configDueAt - nowMs(), 0), MAX_TIMEOUT);
|
|
604
652
|
Console.log('getsdkconfig: next check in ' + wait + ' ms'); // no i18n
|
|
605
|
-
configTimer = setTimeout(function () {
|
|
653
|
+
configTimer = setTimeout(shield('getsdkconfig', function () {
|
|
606
654
|
configTimer = null;
|
|
607
655
|
refreshServerSettings();
|
|
608
|
-
}, wait);
|
|
656
|
+
}), wait);
|
|
609
657
|
}
|
|
610
658
|
/** reset(): no more checks, and the next init() asks again straight away. */
|
|
611
659
|
function stopServerSettingChecks() {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
/*! @zoho_apptics/apptics-js-sdk v2.0.0
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
2
|
import { _ZAP, getConfig } from '../core/state.js';
|
|
3
3
|
import { Console } from '../core/logger.js';
|
|
4
4
|
import { nowMs, isEmpty } from '../core/utils.js';
|
|
5
5
|
import { trackApi } from './track.js';
|
|
6
6
|
import { urlTracked } from './api-rules.js';
|
|
7
|
+
import { shield } from '../core/shield.js';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Automatic API tracking: wraps XMLHttpRequest and fetch so calls the app makes are recorded
|
|
@@ -129,10 +130,10 @@ function installXhr() {
|
|
|
129
130
|
tracked.starttime = nowMs();
|
|
130
131
|
// loadend fires for success, error, abort and timeout alike, so one listener covers
|
|
131
132
|
// every ending; status 0 is how a network failure arrives here
|
|
132
|
-
this.addEventListener('loadend', function () {
|
|
133
|
+
this.addEventListener('loadend', shield('automatic api tracking', function () {
|
|
133
134
|
var message = this.status === 0 ? 'Network Error' : (this.statusText || '-'); // no i18n
|
|
134
135
|
record(tracked.method, tracked.url, tracked.starttime, this.status, message);
|
|
135
|
-
});
|
|
136
|
+
}));
|
|
136
137
|
}
|
|
137
138
|
return originalSend.apply(this, arguments);
|
|
138
139
|
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
/*! @zoho_apptics/apptics-js-sdk v2.0.0
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
2
|
import { Console } from '../core/logger.js';
|
|
3
3
|
import { hooks } from '../core/hooks.js';
|
|
4
4
|
import { _ZAP } from '../core/state.js';
|
|
5
5
|
import { nowMs } from '../core/utils.js';
|
|
6
6
|
import { recordScreen } from './track.js';
|
|
7
|
+
import { shield } from '../core/shield.js';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Automatic screen tracking: a screen view for the page the SDK starts on, and one for every
|
|
@@ -163,7 +164,7 @@ function check() {
|
|
|
163
164
|
_ZAP._current_screen = Object.assign({}, _ZAP._current_screen, { screen: name });
|
|
164
165
|
pendingName = name;
|
|
165
166
|
pendingAt = nowMs();
|
|
166
|
-
settleTimer = setTimeout(settle, settleMs);
|
|
167
|
+
settleTimer = setTimeout(shield('automatic screen tracking', settle), settleMs); // no i18n
|
|
167
168
|
}
|
|
168
169
|
function settle() {
|
|
169
170
|
settleTimer = null;
|
|
@@ -198,7 +199,10 @@ function cancelPending() {
|
|
|
198
199
|
* that followed found the url already seen and recorded nothing: the page went untracked and the
|
|
199
200
|
* view before it was never ended.
|
|
200
201
|
*/
|
|
201
|
-
|
|
202
|
+
const checkShielded = shield('automatic screen tracking', check); // no i18n
|
|
203
|
+
// shielded: it runs inside the app's own history.pushState and replaceState calls, and a throw
|
|
204
|
+
// here would reach the app's code
|
|
205
|
+
const navigated = shield('automatic screen tracking', function () {
|
|
202
206
|
var name = currentName();
|
|
203
207
|
if (name !== '' && (name === pendingName || (pendingName === '' && name === lastName))) { // no i18n
|
|
204
208
|
return;
|
|
@@ -206,9 +210,9 @@ function navigated() {
|
|
|
206
210
|
if (timer === null) {
|
|
207
211
|
claimed = false;
|
|
208
212
|
cancelPending();
|
|
209
|
-
timer = setTimeout(
|
|
213
|
+
timer = setTimeout(checkShielded, 0);
|
|
210
214
|
}
|
|
211
|
-
}
|
|
215
|
+
});
|
|
212
216
|
/** The app recorded a screen itself; the automatic view of this navigation gives way to it. */
|
|
213
217
|
function screenTrackedByApp() {
|
|
214
218
|
claimed = true;
|
|
@@ -270,7 +274,7 @@ function enableScreenTracking(enabled, wait) {
|
|
|
270
274
|
// the page the SDK starts on. Not through navigated(): a inScreen() the app made during
|
|
271
275
|
// start-up was replayed just before this, and it is this screen's, so its claim stands
|
|
272
276
|
if (timer === null) {
|
|
273
|
-
timer = setTimeout(
|
|
277
|
+
timer = setTimeout(checkShielded, 0);
|
|
274
278
|
}
|
|
275
279
|
return;
|
|
276
280
|
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Apptics' defined events
|
|
2
|
+
* Apptics' defined events for the browser: ready-made names in reserved `AP_` groups,
|
|
3
3
|
* logged with trackEvent like any other event and never tracked automatically.
|
|
4
4
|
*
|
|
5
5
|
* trackEvent(DefinedEvents.AP_USER_LOGIN);
|
|
6
6
|
* trackEvent(DefinedEvents.AP_SEARCH, { query_length: 12 });
|
|
7
7
|
*
|
|
8
8
|
* They are the only events allowed the `ap_` prefix: an app's own event, group or property may
|
|
9
|
-
* not start with it.
|
|
10
|
-
* some (battery, OS update, uninstall) have no meaning in a browser and are simply never sent.
|
|
9
|
+
* not start with it.
|
|
11
10
|
*/
|
|
12
11
|
/** One defined event: the name and the group it is sent under. */
|
|
13
12
|
export interface DefinedEvent {
|
|
@@ -1,33 +1,27 @@
|
|
|
1
|
-
/*! @zoho_apptics/apptics-js-sdk v2.0.0
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
2
|
/**
|
|
3
|
-
* Apptics' defined events
|
|
3
|
+
* Apptics' defined events for the browser: ready-made names in reserved `AP_` groups,
|
|
4
4
|
* logged with trackEvent like any other event and never tracked automatically.
|
|
5
5
|
*
|
|
6
6
|
* trackEvent(DefinedEvents.AP_USER_LOGIN);
|
|
7
7
|
* trackEvent(DefinedEvents.AP_SEARCH, { query_length: 12 });
|
|
8
8
|
*
|
|
9
9
|
* They are the only events allowed the `ap_` prefix: an app's own event, group or property may
|
|
10
|
-
* not start with it.
|
|
11
|
-
* some (battery, OS update, uninstall) have no meaning in a browser and are simply never sent.
|
|
10
|
+
* not start with it.
|
|
12
11
|
*/
|
|
13
12
|
const GROUPS = {
|
|
14
|
-
AP_APP_LIFE_CYCLE: [
|
|
15
|
-
'AP_APP_INSTALL', 'AP_APP_UNINSTALL', 'AP_APP_UPDATE', 'AP_APP_CRACKED', 'AP_APP_OPEN', 'AP_APP_CLEAR_DATA', // no i18n
|
|
16
|
-
'AP_APP_FOREGROUND', 'AP_APP_BACKGROUND', 'AP_APP_OUT_OF_MEMORY', 'AP_APP_FIRST_OPEN', 'AP_APP_LAUNCHING', // no i18n
|
|
17
|
-
'AP_APP_RESIGN_ACTIVE', 'AP_APP_WILL_CONNECT', // no i18n
|
|
18
|
-
],
|
|
19
13
|
AP_USER_LIFE_CYCLE: ['AP_USER_SIGNUP', 'AP_USER_LOGIN', 'AP_USER_LOGOUT'], // no i18n
|
|
14
|
+
AP_PAGE_LIFE_CYCLE: ['AP_PAGE_LOAD', 'AP_PAGE_VISIBLE', 'AP_PAGE_HIDDEN', 'AP_PAGE_UNLOAD', 'AP_PAGE_PRINT'], // no i18n
|
|
20
15
|
AP_APPLICATION: [
|
|
21
|
-
'
|
|
22
|
-
'AP_NOTIFICATION_RECEIVE', 'AP_NOTIFICATION_OPEN', 'AP_NOTIFICATION_DISMISS',
|
|
23
|
-
'
|
|
16
|
+
'AP_PWA_INSTALL', 'AP_PWA_LAUNCH', 'AP_PURCHASE', 'AP_SEARCH', 'AP_SHARE', 'AP_FILE_DOWNLOAD', 'AP_COPY', // no i18n
|
|
17
|
+
'AP_NOTIFICATION_RECEIVE', 'AP_NOTIFICATION_OPEN', 'AP_NOTIFICATION_DISMISS', // no i18n
|
|
18
|
+
'AP_NOTIFICATION_PERMISSION_GRANTED', 'AP_NOTIFICATION_PERMISSION_DENIED', // no i18n
|
|
24
19
|
],
|
|
25
20
|
AP_OTHERS: [
|
|
26
|
-
'
|
|
27
|
-
'
|
|
28
|
-
'AP_SWITCH_ORIENTATION_PORTRAIT', // no i18n
|
|
21
|
+
'AP_NETWORK_ONLINE', 'AP_NETWORK_OFFLINE', 'AP_SWITCH_THEME_LIGHT', 'AP_SWITCH_THEME_DARK', // no i18n
|
|
22
|
+
'AP_SWITCH_THEME_CUSTOM', 'AP_SWITCH_LANGUAGE', 'AP_FULLSCREEN_ENTER', 'AP_FULLSCREEN_EXIT', // no i18n
|
|
29
23
|
],
|
|
30
|
-
|
|
24
|
+
AP_BROWSER: ['AP_BROWSER_UPDATE', 'AP_BROWSER_UNSUPPORTED'], // no i18n
|
|
31
25
|
};
|
|
32
26
|
function build() {
|
|
33
27
|
var out = {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @zoho_apptics/apptics-js-sdk v2.0.0
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
2
|
import { AP_LOG_MODULE, AP_CONSTANTS } from '../core/constants.js';
|
|
3
3
|
import { _ZAP } from '../core/state.js';
|
|
4
4
|
import { Console, logFailure, warnAlways } from '../core/logger.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @zoho_apptics/apptics-js-sdk v2.0.0
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
2
|
import { AP_CONSTANTS, AP_LOG_MODULE } from '../core/constants.js';
|
|
3
3
|
import { _ZAP, getConfig } from '../core/state.js';
|
|
4
4
|
import { logFailure, Console } from '../core/logger.js';
|
|
@@ -7,6 +7,7 @@ import { engagement_transactions, getKeyFromDeviceInfo, setDeviceInfoKey } from
|
|
|
7
7
|
import { is_apptics_disabled, getNetworkStatus, getOrientation, getConnectionType, getRam } from '../core/env.js';
|
|
8
8
|
import { canTrackEngagement } from '../core/consent.js';
|
|
9
9
|
import { withLock } from '../core/locks.js';
|
|
10
|
+
import { shield, quietly } from '../core/shield.js';
|
|
10
11
|
|
|
11
12
|
/** The most recently started item of `type` that is still open (endtime 0). */
|
|
12
13
|
function latestOpen(type, items) {
|
|
@@ -149,13 +150,12 @@ function holdTabLock() {
|
|
|
149
150
|
holdingTabLock = false;
|
|
150
151
|
});
|
|
151
152
|
}
|
|
152
|
-
/**
|
|
153
|
-
function
|
|
153
|
+
/** The ids of tabs whose lock is held or waiting, or null without Web Locks (or if asking fails). */
|
|
154
|
+
function liveTabIds() {
|
|
154
155
|
var locks = tabLocks();
|
|
155
156
|
if (!locks) {
|
|
156
|
-
return Promise.resolve();
|
|
157
|
+
return Promise.resolve(null);
|
|
157
158
|
}
|
|
158
|
-
var mine = tabId();
|
|
159
159
|
return locks.query().then(function (state) {
|
|
160
160
|
var alive = {};
|
|
161
161
|
(state.held || []).concat(state.pending || []).forEach(function (lock) {
|
|
@@ -163,6 +163,42 @@ function closeScreensOfGoneTabs() {
|
|
|
163
163
|
alive[lock.name.slice(TAB_LOCK_PREFIX.length)] = true;
|
|
164
164
|
}
|
|
165
165
|
});
|
|
166
|
+
return alive;
|
|
167
|
+
}, function () {
|
|
168
|
+
return null;
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* The other tabs still on a session. A tab that reloaded or closed before its leave was written
|
|
173
|
+
* stays listed, and would keep the session open for good: with Web Locks, a listed tab counts only
|
|
174
|
+
* while its lock is held. Without them every listed tab counts, as before.
|
|
175
|
+
*/
|
|
176
|
+
function otherLiveTabs(session) {
|
|
177
|
+
var others = tabsOf(session).filter(function (tab) { return tab !== tabId(); });
|
|
178
|
+
if (!others.length) {
|
|
179
|
+
return Promise.resolve(others);
|
|
180
|
+
}
|
|
181
|
+
return liveTabIds().then(function (alive) {
|
|
182
|
+
if (!alive) {
|
|
183
|
+
return others;
|
|
184
|
+
}
|
|
185
|
+
var live = others.filter(function (tab) { return alive[tab] === true; });
|
|
186
|
+
if (live.length < others.length) {
|
|
187
|
+
Console.log('session: ' + (others.length - live.length) + ' tab(s) listed on it are gone'); // no i18n
|
|
188
|
+
}
|
|
189
|
+
return live;
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
/** Ends the open screen views of tabs that are gone. Resolves right away without Web Locks. */
|
|
193
|
+
function closeScreensOfGoneTabs() {
|
|
194
|
+
if (!tabLocks()) {
|
|
195
|
+
return Promise.resolve();
|
|
196
|
+
}
|
|
197
|
+
var mine = tabId();
|
|
198
|
+
return liveTabIds().then(function (alive) {
|
|
199
|
+
if (!alive) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
166
202
|
var now = nowMs();
|
|
167
203
|
return engagement_transactions.all().then(function (items) {
|
|
168
204
|
var gone = items.filter(function (item) {
|
|
@@ -305,10 +341,10 @@ function startNewSession(time) {
|
|
|
305
341
|
// held, not stored: see pendingSession above
|
|
306
342
|
pendingSession = _ZAP._current_session;
|
|
307
343
|
clearPendingTimer();
|
|
308
|
-
pendingTimer = setTimeout(function () {
|
|
344
|
+
pendingTimer = setTimeout(shield('session', function () {
|
|
309
345
|
pendingTimer = null;
|
|
310
|
-
commitPendingSession();
|
|
311
|
-
}, minimum);
|
|
346
|
+
quietly('session', commitPendingSession()); // no i18n
|
|
347
|
+
}), minimum);
|
|
312
348
|
return Promise.resolve();
|
|
313
349
|
}
|
|
314
350
|
/** The un-deferred path, for a minimum of 0. */
|
|
@@ -333,14 +369,14 @@ function markTabInactive(onEnded) {
|
|
|
333
369
|
if (inactivityTimer !== null) {
|
|
334
370
|
clearTimeout(inactivityTimer);
|
|
335
371
|
}
|
|
336
|
-
inactivityTimer = setTimeout(function () {
|
|
372
|
+
inactivityTimer = setTimeout(shield('inactive session', function () {
|
|
337
373
|
inactivityTimer = null;
|
|
338
|
-
endInactiveSession().then(function (ended) {
|
|
374
|
+
quietly('inactive session', endInactiveSession().then(function (ended) {
|
|
339
375
|
if (ended) {
|
|
340
376
|
onEnded();
|
|
341
377
|
}
|
|
342
|
-
});
|
|
343
|
-
}, _ZAP.inactiveduration * 60 * 1000 + 1000);
|
|
378
|
+
}));
|
|
379
|
+
}), _ZAP.inactiveduration * 60 * 1000 + 1000);
|
|
344
380
|
return first ? updateLastActiveTimeOfSession() : Promise.resolve();
|
|
345
381
|
}
|
|
346
382
|
/**
|
|
@@ -378,19 +414,21 @@ function endInactiveSession() {
|
|
|
378
414
|
if (nowMs() - lastActive < _ZAP.inactiveduration * 60 * 1000) {
|
|
379
415
|
return;
|
|
380
416
|
}
|
|
381
|
-
var
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
return
|
|
417
|
+
var session = _currentSession;
|
|
418
|
+
return otherLiveTabs(session).then(function (others) {
|
|
419
|
+
if (others.length > 0) {
|
|
420
|
+
var left = Object.assign({}, session, { tabs: others });
|
|
421
|
+
_ZAP._current_session = left;
|
|
422
|
+
return engagement_transactions.update(left);
|
|
423
|
+
}
|
|
424
|
+
var endAt = Math.max(lastActive, Number(session.starttime) || lastActive);
|
|
425
|
+
var closed = Object.assign({}, session, { endtime: endAt, tabs: [] });
|
|
426
|
+
_ZAP._current_session = closed;
|
|
427
|
+
ended = true;
|
|
428
|
+
Console.log('session: inactive for ' + _ZAP.inactiveduration + ' minutes, so it ends when the user left, ' + endAt); // no i18n
|
|
429
|
+
return engagement_transactions.update(closed).then(function () {
|
|
430
|
+
return closeScreensOf(closed, endAt);
|
|
431
|
+
});
|
|
394
432
|
});
|
|
395
433
|
});
|
|
396
434
|
}).then(function () {
|
|
@@ -426,18 +464,20 @@ function closeOrLeaveSession(now, wasInactive) {
|
|
|
426
464
|
var time = wasInactive && lastActive > 0
|
|
427
465
|
? Math.max(Math.min(lastActive, now), Number(_currentSession.starttime) || 0)
|
|
428
466
|
: now;
|
|
429
|
-
var
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
return
|
|
467
|
+
var session = _currentSession;
|
|
468
|
+
return otherLiveTabs(session).then(function (others) {
|
|
469
|
+
if (others.length > 0) {
|
|
470
|
+
var left = Object.assign({}, session, { tabs: others, lastactivetime: time });
|
|
471
|
+
_ZAP._current_session = left;
|
|
472
|
+
Console.log('endCurrentSession: ' + others.length + ' other tab(s) still on this session, so it stays open'); // no i18n
|
|
473
|
+
return engagement_transactions.update(left);
|
|
474
|
+
}
|
|
475
|
+
var closed = Object.assign({}, session, { endtime: time, lastactivetime: time, tabs: [] });
|
|
476
|
+
_ZAP._current_session = closed;
|
|
477
|
+
Console.log('endCurrentSession: closing the session opened at ' + closed.starttime); // no i18n
|
|
478
|
+
return engagement_transactions.update(closed).then(function () {
|
|
479
|
+
return closeScreensOf(closed, time);
|
|
480
|
+
});
|
|
441
481
|
});
|
|
442
482
|
});
|
|
443
483
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @zoho_apptics/apptics-js-sdk v2.0.0
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
2
|
import { AP_LOG_MODULE, AP_CONSTANTS } from '../core/constants.js';
|
|
3
3
|
import { _ZAP } from '../core/state.js';
|
|
4
4
|
import { logFailure, Console, warnAlways } from '../core/logger.js';
|
|
@@ -13,6 +13,7 @@ import { hooks } from '../core/hooks.js';
|
|
|
13
13
|
import { urlTracked, normalizeApiPath } from './api-rules.js';
|
|
14
14
|
import { asDefinedEvent } from './defined-events.js';
|
|
15
15
|
import { automaticScreenName } from './auto-screen.js';
|
|
16
|
+
import { quietly } from '../core/shield.js';
|
|
16
17
|
|
|
17
18
|
/** Messages already printed, so a name refused in a loop says so once. */
|
|
18
19
|
var refusedSaid = {};
|
|
@@ -82,9 +83,11 @@ function trackEvent(eventName, groupName, jsonObj) {
|
|
|
82
83
|
};
|
|
83
84
|
// save the event
|
|
84
85
|
// the session may still be waiting out its minimum; this event is what earns it
|
|
85
|
-
commitPendingSession();
|
|
86
|
+
quietly('session', commitPendingSession()); // no i18n
|
|
86
87
|
noteDebugActivity();
|
|
87
88
|
engagement_transactions.add(eventData);
|
|
89
|
+
// a push notification opened earlier may count this event as its conversion
|
|
90
|
+
hooks.pushEventTracked(String(eventName), String(groupName));
|
|
88
91
|
Console.log('AppticsEvent.addEvent(\'' + eventName + '\',' + '\'' + groupName + '\'' + ',' + JSON.stringify(_jsonObj || {}) + ')'); // no i18n
|
|
89
92
|
Console.dir(eventData);
|
|
90
93
|
}
|
|
@@ -108,7 +111,7 @@ function outScreenAt(id, endedAt) {
|
|
|
108
111
|
logFailure(AP_LOG_MODULE.SCREEN, 'AppticsScreen.outScreen: no screen id given'); // no i18n
|
|
109
112
|
return;
|
|
110
113
|
}
|
|
111
|
-
closeScreen(id, endedAt);
|
|
114
|
+
quietly('screen', closeScreen(id, endedAt)); // no i18n
|
|
112
115
|
}
|
|
113
116
|
/**
|
|
114
117
|
* Queues a screen view and makes it the current screen.
|
|
@@ -147,9 +150,9 @@ function recordScreen(screenName, jsonObj, id, startedAt, implicit) {
|
|
|
147
150
|
// the screen being left ends where this one starts
|
|
148
151
|
var previous = _ZAP._current_screen && _ZAP._current_screen.id;
|
|
149
152
|
if (previous && previous !== screenData.id) {
|
|
150
|
-
closeScreen(previous, time);
|
|
153
|
+
quietly('screen', closeScreen(previous, time)); // no i18n
|
|
151
154
|
}
|
|
152
|
-
commitPendingSession();
|
|
155
|
+
quietly('session', commitPendingSession()); // no i18n
|
|
153
156
|
noteDebugActivity();
|
|
154
157
|
engagement_transactions.add(screenData);
|
|
155
158
|
// `implicit`: a view recorded only so a heatmap record has one to belong to. Kept on the
|
|
@@ -319,7 +322,7 @@ function trackApi(jsonObj) {
|
|
|
319
322
|
edge: _ZAP._device_info.connectionType || getConnectionType()
|
|
320
323
|
};
|
|
321
324
|
// save the api
|
|
322
|
-
commitPendingSession();
|
|
325
|
+
quietly('session', commitPendingSession()); // no i18n
|
|
323
326
|
noteDebugActivity();
|
|
324
327
|
engagement_transactions.add(apiData);
|
|
325
328
|
Console.log('AppticsApi(\'' + method + ' ' + scheme + '://' + hostname + path + '\')'); // no i18n
|
package/dist/esm/errors/send.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @zoho_apptics/apptics-js-sdk v2.0.0
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
2
|
import { _ZAP } from '../core/state.js';
|
|
3
3
|
import { Console, warnAlways } from '../core/logger.js';
|
|
4
4
|
import { cloneObject } from '../core/utils.js';
|
package/dist/esm/errors/track.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @zoho_apptics/apptics-js-sdk v2.0.0
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
2
|
import { AP_CONSTANTS } from '../core/constants.js';
|
|
3
3
|
import { _ZAP } from '../core/state.js';
|
|
4
4
|
import { Console } from '../core/logger.js';
|
|
@@ -9,6 +9,7 @@ import { getConnectionType, getNetworkStatus } from '../core/env.js';
|
|
|
9
9
|
import { canTrackErrors } from '../core/consent.js';
|
|
10
10
|
import { validateJSON } from '../core/validate.js';
|
|
11
11
|
import { noteDebugActivity } from '../core/debug.js';
|
|
12
|
+
import { quietly } from '../core/shield.js';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* The stack to report. Three sources, in order of how much they tell us:
|
|
@@ -111,7 +112,7 @@ function trackError(errorEvent, jsonObj) {
|
|
|
111
112
|
};
|
|
112
113
|
// save the error
|
|
113
114
|
// an error is worth a session even in the first seconds of a visit
|
|
114
|
-
commitPendingSession();
|
|
115
|
+
quietly('session', commitPendingSession()); // no i18n
|
|
115
116
|
noteDebugActivity();
|
|
116
117
|
error_transactions.add(errorData);
|
|
117
118
|
Console.log('AppticsError.trackError(\'' + issuetype + '\',\'' + message + '\',' + JSON.stringify(_jsonObj || {}) + ')'); // no i18n
|