@zoho_apptics/apptics-js-sdk 2.0.0-beta.1 → 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 +127 -16
- package/README.md +357 -215
- 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 -4
- package/dist/cjs/core/consent.d.ts +17 -4
- package/dist/cjs/core/consent.js +81 -14
- 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 +66 -17
- package/dist/cjs/core/constants.js +76 -19
- 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.d.ts +0 -3
- package/dist/cjs/core/env.js +1 -9
- package/dist/cjs/core/framework-id.d.ts +1 -1
- package/dist/cjs/core/framework-id.js +3 -3
- package/dist/cjs/core/guard.js +19 -4
- package/dist/cjs/core/hooks.d.ts +29 -0
- package/dist/cjs/core/hooks.js +12 -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 +11 -5
- package/dist/cjs/core/state.js +4 -4
- package/dist/cjs/core/storage.d.ts +7 -0
- package/dist/cjs/core/storage.js +28 -9
- package/dist/cjs/core/stylesheet.js +1 -1
- package/dist/cjs/core/transport.d.ts +15 -4
- package/dist/cjs/core/transport.js +72 -25
- package/dist/cjs/core/utils.js +1 -1
- package/dist/cjs/core/validate.js +6 -5
- package/dist/cjs/device/appversion.d.ts +10 -1
- package/dist/cjs/device/appversion.js +26 -3
- package/dist/cjs/device/index.d.ts +17 -2
- package/dist/cjs/device/index.js +251 -35
- 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 +7 -3
- package/dist/cjs/engagement/session.d.ts +17 -0
- package/dist/cjs/engagement/session.js +154 -23
- package/dist/cjs/engagement/track.d.ts +4 -4
- package/dist/cjs/engagement/track.js +23 -17
- package/dist/cjs/errors/send.js +2 -2
- package/dist/cjs/errors/track.d.ts +2 -1
- package/dist/cjs/errors/track.js +8 -5
- package/dist/cjs/feedback/controls.d.ts +36 -4
- package/dist/cjs/feedback/controls.js +302 -67
- 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.d.ts +3 -6
- package/dist/cjs/feedback/logs.js +12 -21
- package/dist/cjs/feedback/quartz.js +5 -2
- package/dist/cjs/feedback/send.d.ts +6 -3
- package/dist/cjs/feedback/send.js +59 -41
- package/dist/cjs/feedback/styles.js +2 -2
- package/dist/cjs/feedback/template.d.ts +4 -2
- package/dist/cjs/feedback/template.js +73 -44
- package/dist/cjs/feedback/ui.d.ts +47 -4
- package/dist/cjs/feedback/ui.js +351 -97
- package/dist/cjs/heatmap/send.d.ts +2 -0
- package/dist/cjs/heatmap/send.js +3 -5
- package/dist/cjs/heatmap/track.js +13 -9
- package/dist/cjs/index.d.ts +1 -2
- package/dist/cjs/index.js +55 -18
- package/dist/cjs/lifecycle.d.ts +13 -2
- package/dist/cjs/lifecycle.js +233 -118
- 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.d.ts +17 -10
- package/dist/cjs/remoteconfig/fetch.js +146 -32
- package/dist/cjs/remoteconfig/index.d.ts +9 -5
- package/dist/cjs/remoteconfig/index.js +24 -32
- package/dist/cjs/remoteconfig/store.d.ts +15 -7
- package/dist/cjs/remoteconfig/store.js +68 -35
- package/dist/cjs/remoteconfig/tz-countries.js +1 -1
- package/dist/cjs/{core → remotelog}/callsite.d.ts +5 -4
- package/dist/cjs/{core → remotelog}/callsite.js +6 -5
- package/dist/cjs/remotelog/gate.js +1 -1
- package/dist/cjs/remotelog/logger.js +2 -2
- package/dist/cjs/remotelog/send.js +6 -5
- package/dist/cjs/remotelogger/index.js +1 -1
- package/dist/cjs/scheduler.d.ts +3 -1
- package/dist/cjs/scheduler.js +34 -25
- 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 +90 -29
- package/dist/cjs/user/index.d.ts +7 -0
- package/dist/cjs/user/index.js +25 -3
- package/dist/esm/core/attempts.js +1 -1
- package/dist/esm/core/batch.js +4 -4
- package/dist/esm/core/consent.d.ts +17 -4
- package/dist/esm/core/consent.js +84 -20
- 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 +66 -17
- package/dist/esm/core/constants.js +73 -20
- 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.d.ts +0 -3
- package/dist/esm/core/env.js +2 -9
- package/dist/esm/core/framework-id.d.ts +1 -1
- package/dist/esm/core/framework-id.js +3 -3
- package/dist/esm/core/guard.js +19 -4
- package/dist/esm/core/hooks.d.ts +29 -0
- package/dist/esm/core/hooks.js +12 -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 +11 -5
- package/dist/esm/core/state.js +4 -4
- package/dist/esm/core/storage.d.ts +7 -0
- package/dist/esm/core/storage.js +28 -11
- package/dist/esm/core/stylesheet.js +1 -1
- package/dist/esm/core/transport.d.ts +15 -4
- package/dist/esm/core/transport.js +73 -28
- package/dist/esm/core/utils.js +1 -1
- package/dist/esm/core/validate.js +6 -5
- package/dist/esm/device/appversion.d.ts +10 -1
- package/dist/esm/device/appversion.js +26 -4
- package/dist/esm/device/index.d.ts +17 -2
- package/dist/esm/device/index.js +255 -42
- 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 +7 -3
- package/dist/esm/engagement/session.d.ts +17 -0
- package/dist/esm/engagement/session.js +152 -24
- package/dist/esm/engagement/track.d.ts +4 -4
- package/dist/esm/engagement/track.js +24 -18
- package/dist/esm/errors/send.js +2 -2
- package/dist/esm/errors/track.d.ts +2 -1
- package/dist/esm/errors/track.js +8 -5
- package/dist/esm/feedback/controls.d.ts +36 -4
- package/dist/esm/feedback/controls.js +298 -68
- 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.d.ts +3 -6
- package/dist/esm/feedback/logs.js +12 -21
- package/dist/esm/feedback/quartz.js +5 -2
- package/dist/esm/feedback/send.d.ts +6 -3
- package/dist/esm/feedback/send.js +61 -44
- package/dist/esm/feedback/styles.js +2 -2
- package/dist/esm/feedback/template.d.ts +4 -2
- package/dist/esm/feedback/template.js +73 -44
- package/dist/esm/feedback/ui.d.ts +47 -4
- package/dist/esm/feedback/ui.js +353 -99
- package/dist/esm/heatmap/send.d.ts +2 -0
- package/dist/esm/heatmap/send.js +3 -5
- package/dist/esm/heatmap/track.js +13 -9
- package/dist/esm/index.d.ts +1 -2
- package/dist/esm/index.js +58 -21
- package/dist/esm/lifecycle.d.ts +13 -2
- package/dist/esm/lifecycle.js +238 -125
- 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.d.ts +17 -10
- package/dist/esm/remoteconfig/fetch.js +147 -33
- package/dist/esm/remoteconfig/index.d.ts +9 -5
- package/dist/esm/remoteconfig/index.js +24 -32
- package/dist/esm/remoteconfig/store.d.ts +15 -7
- package/dist/esm/remoteconfig/store.js +68 -36
- package/dist/esm/remoteconfig/tz-countries.js +1 -1
- package/dist/esm/{core → remotelog}/callsite.d.ts +5 -4
- package/dist/esm/{core → remotelog}/callsite.js +6 -5
- package/dist/esm/remotelog/gate.js +1 -1
- package/dist/esm/remotelog/logger.js +2 -2
- package/dist/esm/remotelog/send.js +6 -5
- package/dist/esm/remotelogger/index.js +1 -1
- package/dist/esm/scheduler.d.ts +3 -1
- package/dist/esm/scheduler.js +35 -27
- 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 +90 -29
- package/dist/esm/user/index.d.ts +7 -0
- package/dist/esm/user/index.js +26 -5
- 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 +3 -0
- package/dist/remoteconfig.esm.min.js.map +1 -0
- package/dist/remotelogger.esm.min.js +3 -0
- package/dist/remotelogger.esm.min.js.map +1 -0
- package/package.json +17 -3
- package/dist/chunks/lifecycle-VYr43KcB.min.js +0 -3
- package/dist/chunks/lifecycle-VYr43KcB.min.js.map +0 -1
- package/dist/cjs/auto-init.d.ts +0 -8
- package/dist/cjs/auto-init.js +0 -32
- package/dist/esm/auto-init.d.ts +0 -8
- package/dist/esm/auto-init.js +0 -29
|
@@ -1,6 +1,6 @@
|
|
|
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 { LOG_FUNCTION_MAX } from '../core/constants.js';
|
|
3
|
-
import { callSite } from '
|
|
3
|
+
import { callSite } from './callsite.js';
|
|
4
4
|
import { remotelog_transactions } from '../core/storage.js';
|
|
5
5
|
import { guard } from '../core/guard.js';
|
|
6
6
|
import { nowMs } from '../core/utils.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 { LOG_FUNCTION_MAX, CONSOLE_LOG_MAX_BODY, REMOTE_LOG_LEVEL, LOG_FILENAME_MAX } from '../core/constants.js';
|
|
3
3
|
import { _ZAP } from '../core/state.js';
|
|
4
4
|
import { warnAlways, Console } from '../core/logger.js';
|
|
@@ -6,6 +6,7 @@ import { nowMs, isEmpty } from '../core/utils.js';
|
|
|
6
6
|
import { remotelog_transactions } from '../core/storage.js';
|
|
7
7
|
import { postToApptics, apiHeaders, isPermanentRefusal, getMetaObj, postKeepalive } from '../core/transport.js';
|
|
8
8
|
import { remoteLoggerReachable } from './gate.js';
|
|
9
|
+
import { shield, quietly } from '../core/shield.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Delivery for the remote logger.
|
|
@@ -40,7 +41,7 @@ function entryFor(item) {
|
|
|
40
41
|
var entry = {
|
|
41
42
|
sessionstarttime: _ZAP._current_session.starttime || item.happenedat || nowMs(),
|
|
42
43
|
logtime: item.happenedat || nowMs(),
|
|
43
|
-
// an app's line carries the level it was logged at;
|
|
44
|
+
// an app's line carries the level it was logged at; only a line an older SDK stored has none
|
|
44
45
|
level: Number(item.level) || REMOTE_LOG_LEVEL,
|
|
45
46
|
logmessage: String(item.exceptionlog).slice(0, CONSOLE_LOG_MAX_BODY),
|
|
46
47
|
function: String(item.module || 'SDK').slice(0, LOG_FUNCTION_MAX), // no i18n
|
|
@@ -65,10 +66,10 @@ function scheduleSend() {
|
|
|
65
66
|
return;
|
|
66
67
|
}
|
|
67
68
|
sendScheduled = true;
|
|
68
|
-
setTimeout(function () {
|
|
69
|
+
setTimeout(shield(LABEL, function () {
|
|
69
70
|
sendScheduled = false;
|
|
70
|
-
sendStoredLogs();
|
|
71
|
-
}, SEND_DELAY_MS);
|
|
71
|
+
quietly(LABEL, sendStoredLogs());
|
|
72
|
+
}), SEND_DELAY_MS);
|
|
72
73
|
}
|
|
73
74
|
/** Drops the oldest lines once the queue is over MAX_STORED_BYTES, keeping the newest that fit. */
|
|
74
75
|
function trim(items) {
|
package/dist/esm/scheduler.d.ts
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* response (page hide), so they survive the page going away.
|
|
4
4
|
*/
|
|
5
5
|
export declare function flush(forget?: boolean): Promise<void>;
|
|
6
|
-
/**
|
|
6
|
+
/** Apptics.flush(): flush(), at most once every CALLED_FLUSH_GAP_MS. A call sooner sends nothing. */
|
|
7
|
+
export declare function calledFlush(): Promise<void>;
|
|
8
|
+
/** Starts the flush interval once; later calls do nothing until stopTimers(). */
|
|
7
9
|
export declare function startTimers(): void;
|
|
8
10
|
export declare function stopTimers(): void;
|
package/dist/esm/scheduler.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 { _ZAP, getConfig } from './core/state.js';
|
|
3
|
-
import { nowMs } from './core/utils.js';
|
|
4
3
|
import { Console } from './core/logger.js';
|
|
4
|
+
import { nowMs } from './core/utils.js';
|
|
5
5
|
import { canTrack } from './core/consent.js';
|
|
6
6
|
import { clearDefer } from './core/batch.js';
|
|
7
7
|
import { sendEngagementData } from './engagement/send.js';
|
|
8
8
|
import { sendErrorData } from './errors/send.js';
|
|
9
9
|
import { hooks } from './core/hooks.js';
|
|
10
|
-
import {
|
|
10
|
+
import { stopServerSettingChecks } from './device/index.js';
|
|
11
11
|
import { expireDebugIfIdle } from './core/debug.js';
|
|
12
|
+
import { shield, quietly } from './core/shield.js';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Sends everything queued now. With `forget`, the requests are sent without waiting for a
|
|
@@ -25,50 +26,57 @@ function flush(forget) {
|
|
|
25
26
|
}).then(function () {
|
|
26
27
|
// the hook heatmap/send.ts sets
|
|
27
28
|
return hooks.sendHeatmaps(forget);
|
|
29
|
+
}).then(function () {
|
|
30
|
+
// and the one pushnotification/stats.ts sets
|
|
31
|
+
return hooks.sendPushStats(forget);
|
|
28
32
|
});
|
|
29
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* How often Apptics.flush() sends when it is called by hand, from the console or the app's own
|
|
36
|
+
* code: once every 15 seconds, however often it is called. The SDK's own sends (the flush
|
|
37
|
+
* interval, page hide and close, back online) call flush() directly and are not held to it.
|
|
38
|
+
*/
|
|
39
|
+
const CALLED_FLUSH_GAP_MS = 15 * 1000;
|
|
40
|
+
/** When Apptics.flush() last sent; 0 until it has. */
|
|
41
|
+
var calledFlushAt = 0;
|
|
42
|
+
/** Apptics.flush(): flush(), at most once every CALLED_FLUSH_GAP_MS. A call sooner sends nothing. */
|
|
43
|
+
function calledFlush() {
|
|
44
|
+
var now = nowMs();
|
|
45
|
+
if (calledFlushAt > 0 && now - calledFlushAt < CALLED_FLUSH_GAP_MS) {
|
|
46
|
+
Console.log('Apptics.flush: sent ' + (now - calledFlushAt) + ' ms ago; it sends at most once every ' + CALLED_FLUSH_GAP_MS + ' ms, and the timer sends the rest'); // no i18n
|
|
47
|
+
return Promise.resolve();
|
|
48
|
+
}
|
|
49
|
+
calledFlushAt = now;
|
|
50
|
+
return flush();
|
|
51
|
+
}
|
|
30
52
|
var sendingInterval = null;
|
|
31
|
-
|
|
32
|
-
/** Starts the flush and getupdates intervals once; later calls do nothing until stopTimers(). */
|
|
53
|
+
/** Starts the flush interval once; later calls do nothing until stopTimers(). */
|
|
33
54
|
function startTimers() {
|
|
34
55
|
if (sendingInterval === null) {
|
|
35
|
-
sendingInterval = setInterval(function () {
|
|
56
|
+
sendingInterval = setInterval(shield('scheduled send', function () {
|
|
36
57
|
// the only tick that happens whether or not anything is being tracked, which is
|
|
37
58
|
// exactly the case debug mode has to expire in
|
|
38
59
|
expireDebugIfIdle();
|
|
39
60
|
Console.log('scheduleToSendDataToServer: Scheduling to send engagement data to the server after sometime'); // no i18n
|
|
40
61
|
// one after the other, as flush() does: run together, the second and third find the
|
|
41
62
|
// first still sending and are deferred, and the third's retry replaces the second's
|
|
42
|
-
sendEngagementData().then(function () {
|
|
63
|
+
quietly('scheduled send', sendEngagementData().then(function () {
|
|
43
64
|
return sendErrorData();
|
|
44
65
|
}).then(function () {
|
|
45
66
|
return hooks.sendHeatmaps();
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
// the interval is the floor, not the schedule: getsdkconfig answers with next_check_after,
|
|
51
|
-
// and asking again before then is a call the server has already told us it will not answer
|
|
52
|
-
// differently. The timer still ticks so a server that sends no hint behaves as before.
|
|
53
|
-
getUpdatesInterval = setInterval(function () {
|
|
54
|
-
if (_ZAP._nextConfigCheck > 0 && nowMs() < _ZAP._nextConfigCheck) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
Console.log('scheduleToGetUpdatesFromServer: asking the server for its config'); // no i18n
|
|
58
|
-
getUpdatesFromServer().catch(function (err) {
|
|
59
|
-
Console.log(err);
|
|
60
|
-
});
|
|
61
|
-
}, getConfig('getupdates_interval')); // no i18n
|
|
67
|
+
}).then(function () {
|
|
68
|
+
return hooks.sendPushStats();
|
|
69
|
+
}));
|
|
70
|
+
}), getConfig('batch_flush_interval')); // no i18n
|
|
62
71
|
}
|
|
63
72
|
}
|
|
64
73
|
function stopTimers() {
|
|
65
74
|
if (sendingInterval !== null)
|
|
66
75
|
clearInterval(sendingInterval);
|
|
67
|
-
if (getUpdatesInterval !== null)
|
|
68
|
-
clearInterval(getUpdatesInterval);
|
|
69
76
|
sendingInterval = null;
|
|
70
|
-
getUpdatesInterval = null;
|
|
71
77
|
clearDefer();
|
|
78
|
+
stopServerSettingChecks();
|
|
79
|
+
calledFlushAt = 0;
|
|
72
80
|
}
|
|
73
81
|
|
|
74
|
-
export { flush, startTimers, stopTimers };
|
|
82
|
+
export { calledFlush, flush, startTimers, stopTimers };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { CLICK_MESSAGE, CLOSE_MESSAGE, STEP_MESSAGE } from '../pushnotification/display.js';
|
|
2
|
+
/**
|
|
3
|
+
* The Apptics service worker: the part of push notifications that runs without the page. The
|
|
4
|
+
* site hosts a one-line worker of its own,
|
|
5
|
+
*
|
|
6
|
+
* importScripts('https://static.zohocdn.com/apptics-js-sdk/<version>/apptics-pn-sw.js');
|
|
7
|
+
*
|
|
8
|
+
* or adds that line to the worker it already has. It handles the clicks on the notifications the
|
|
9
|
+
* SDK showed: Prev / Next step a carousel in place, a button or the body opens its URL, and the
|
|
10
|
+
* click is posted to the site's open tabs for the app's onNotificationClick. Notifications that
|
|
11
|
+
* aren't the SDK's (data.apptics !== 1) are left to the site's own code.
|
|
12
|
+
*
|
|
13
|
+
* Timed parts (auto-scroll, the countdown, auto-dismiss) run here too, once the tab that showed
|
|
14
|
+
* the notification hands them over (timers.ts): they go on while that tab is in the background or
|
|
15
|
+
* closed. An event keeps the worker alive for a few minutes only, so what is still running after
|
|
16
|
+
* that goes back to an open tab.
|
|
17
|
+
*/
|
|
18
|
+
interface ClientLike {
|
|
19
|
+
url: string;
|
|
20
|
+
focus?: () => Promise<unknown>;
|
|
21
|
+
postMessage: (message: unknown) => void;
|
|
22
|
+
}
|
|
23
|
+
/** What the handlers use of the worker's global scope; tests pass their own. */
|
|
24
|
+
export interface WorkerScope {
|
|
25
|
+
/** The site's origin (the worker's own); a tab of it gets the click report. */
|
|
26
|
+
origin?: string;
|
|
27
|
+
registration: {
|
|
28
|
+
showNotification: (title: string, options: NotificationOptions) => Promise<void>;
|
|
29
|
+
getNotifications?: (filter: {
|
|
30
|
+
tag: string;
|
|
31
|
+
}) => Promise<ReadonlyArray<{
|
|
32
|
+
close: () => void;
|
|
33
|
+
}>>;
|
|
34
|
+
};
|
|
35
|
+
clients: {
|
|
36
|
+
matchAll: (options: {
|
|
37
|
+
type: string;
|
|
38
|
+
includeUncontrolled: boolean;
|
|
39
|
+
}) => Promise<ReadonlyArray<ClientLike>>;
|
|
40
|
+
openWindow: (url: string) => Promise<unknown>;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
interface NotificationEventLike {
|
|
44
|
+
action?: string;
|
|
45
|
+
notification: {
|
|
46
|
+
data?: unknown;
|
|
47
|
+
close: () => void;
|
|
48
|
+
};
|
|
49
|
+
waitUntil: (promise: Promise<unknown>) => void;
|
|
50
|
+
}
|
|
51
|
+
export { CLICK_MESSAGE, CLOSE_MESSAGE, STEP_MESSAGE };
|
|
52
|
+
export declare function onNotificationClick(event: NotificationEventLike, scope: WorkerScope): void;
|
|
53
|
+
export declare function onNotificationClose(event: NotificationEventLike, scope: WorkerScope): void;
|
|
54
|
+
interface MessageEventLike {
|
|
55
|
+
data?: unknown;
|
|
56
|
+
ports?: ReadonlyArray<{
|
|
57
|
+
postMessage: (message: unknown) => void;
|
|
58
|
+
}>;
|
|
59
|
+
waitUntil?: (promise: Promise<unknown>) => void;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* What a tab of the site posts: run a notification's timers here (answered on the port it came
|
|
63
|
+
* with, so the tab knows not to run them itself), or stop them, one tag or all.
|
|
64
|
+
*/
|
|
65
|
+
export declare function onMessage(event: MessageEventLike, scope: WorkerScope): void;
|
|
66
|
+
interface TakeOverScope {
|
|
67
|
+
location?: {
|
|
68
|
+
pathname?: string;
|
|
69
|
+
};
|
|
70
|
+
skipWaiting: () => Promise<void>;
|
|
71
|
+
clients: {
|
|
72
|
+
claim: () => Promise<void>;
|
|
73
|
+
};
|
|
74
|
+
addEventListener: (type: string, fn: (e: {
|
|
75
|
+
waitUntil: (p: Promise<unknown>) => void;
|
|
76
|
+
}) => void) => void;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* As the site's own /apptics-pn-sw.js, a new version takes over at once, and the open tabs with
|
|
80
|
+
* it, rather than waiting until every tab of the site is closed. Inside a site's own worker it
|
|
81
|
+
* leaves that worker's updates as the site set them up.
|
|
82
|
+
*/
|
|
83
|
+
export declare function takeOverWhenOwn(g: TakeOverScope): void;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { ShownNotification } from '../pushnotification/display.js';
|
|
2
|
+
/**
|
|
3
|
+
* A notification's timed parts, run by the service worker: auto-scroll steps the carousel, the
|
|
4
|
+
* countdown ticks every second, and auto-dismiss closes it. They run in the worker, so they go on
|
|
5
|
+
* while the tab that received the message is in the background, frozen or closed.
|
|
6
|
+
*
|
|
7
|
+
* A browser stops a worker once the event keeping it alive has run for about 5 minutes. So the
|
|
8
|
+
* worker runs them for at most RUN_BUDGET_MS, and gives what is left to one open tab of the site,
|
|
9
|
+
* which runs the rest as it did before the worker took them over.
|
|
10
|
+
*/
|
|
11
|
+
/** How long the worker runs a notification's timers before handing what is left to a tab. */
|
|
12
|
+
export declare const RUN_BUDGET_MS: number;
|
|
13
|
+
interface ClientLike {
|
|
14
|
+
url: string;
|
|
15
|
+
postMessage: (message: unknown) => void;
|
|
16
|
+
}
|
|
17
|
+
/** What the timers use of the worker's global scope; tests pass their own. */
|
|
18
|
+
export interface TimerScope {
|
|
19
|
+
origin?: string;
|
|
20
|
+
registration: {
|
|
21
|
+
showNotification: (title: string, options: NotificationOptions) => Promise<void>;
|
|
22
|
+
getNotifications?: (filter: {
|
|
23
|
+
tag: string;
|
|
24
|
+
}) => Promise<ReadonlyArray<{
|
|
25
|
+
close: () => void;
|
|
26
|
+
}>>;
|
|
27
|
+
};
|
|
28
|
+
clients: {
|
|
29
|
+
matchAll: (options: {
|
|
30
|
+
type: string;
|
|
31
|
+
includeUncontrolled: boolean;
|
|
32
|
+
}) => Promise<ReadonlyArray<ClientLike>>;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/** Stops the timers of `tag`, or of every notification without one. */
|
|
36
|
+
export declare function stopTimers(tag?: string): void;
|
|
37
|
+
/** Prev / Next: the visitor took over the carousel, so auto-scroll stops; the countdown keeps their slide. */
|
|
38
|
+
export declare function stepTimers(tag: string, index: number): void;
|
|
39
|
+
/**
|
|
40
|
+
* Runs the timers of `shown`, already on screen, replacing any it had. Resolves once they end:
|
|
41
|
+
* dismissed, closed or clicked by the visitor, stopped, all done, or handed to a tab.
|
|
42
|
+
*/
|
|
43
|
+
export declare function runTimers(shown: ShownNotification, scope: TimerScope): Promise<void>;
|
|
44
|
+
export {};
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -26,6 +26,8 @@ export interface UserInfo {
|
|
|
26
26
|
userid?: string;
|
|
27
27
|
groupid?: string;
|
|
28
28
|
status?: number;
|
|
29
|
+
/** user/register's answer: false when the user's customer group is not tracked. */
|
|
30
|
+
customergrouptracking?: boolean;
|
|
29
31
|
[key: string]: any;
|
|
30
32
|
}
|
|
31
33
|
export interface ServerResult<T = Dict> {
|
|
@@ -37,7 +39,7 @@ export interface ServerResult<T = Dict> {
|
|
|
37
39
|
export type TrackingStatus = (typeof AP_TRACKING_STATUS)[keyof typeof AP_TRACKING_STATUS];
|
|
38
40
|
export type FeedbackType = (typeof AP_FEEDBACK_TYPE)[keyof typeof AP_FEEDBACK_TYPE];
|
|
39
41
|
export type Properties = Record<string, unknown>;
|
|
40
|
-
/** The config init() requires.
|
|
42
|
+
/** The config init() requires. */
|
|
41
43
|
export interface AppticsConfig {
|
|
42
44
|
/** Apptics host every request goes to, e.g. https://apptics.zoho.com (a trailing slash is ignored). Was `serviceUrl`. */
|
|
43
45
|
base_url: string;
|
|
@@ -65,12 +67,6 @@ export interface AppticsConfig {
|
|
|
65
67
|
base_domain?: string;
|
|
66
68
|
/** @deprecated 1.x console-snippet name for auth_key: still read, with a warning */
|
|
67
69
|
token?: string;
|
|
68
|
-
/**
|
|
69
|
-
* Debug mode: send engagement, exception and log payloads to their `debug/` twins, which answer
|
|
70
|
-
* with a request id and a link to the server's own logs, for following in the Apptics web
|
|
71
|
-
* console. Off by default; it does not change what is sent. Same as calling enableDebug().
|
|
72
|
-
*/
|
|
73
|
-
debug?: boolean;
|
|
74
70
|
/** Log the SDK's own activity to the browser console. Off by default. */
|
|
75
71
|
console_log?: boolean;
|
|
76
72
|
ignore_do_not_track?: boolean;
|
|
@@ -87,6 +83,18 @@ export interface AppticsConfig {
|
|
|
87
83
|
* navigation replaces its automatic view; set this false to track only the app's own calls.
|
|
88
84
|
*/
|
|
89
85
|
track_screen?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Record uncaught errors and unhandled promise rejections automatically. On by default; set this
|
|
88
|
+
* false to record only the errors the app hands to AppticsError.trackError(). Switched later with
|
|
89
|
+
* AppticsError.setErrorTracking().
|
|
90
|
+
*/
|
|
91
|
+
track_error?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Record clicks on elements tagged `apeventaction` (or `data-apeventaction`) as events, in the
|
|
94
|
+
* group of the nearest `apgroupaction` around them. On by default; switched later with
|
|
95
|
+
* AppticsEvent.setClickTracking().
|
|
96
|
+
*/
|
|
97
|
+
track_click?: boolean;
|
|
90
98
|
/**
|
|
91
99
|
* How automatic screen tracking names a path, tried in order; the first that matches wins, and a
|
|
92
100
|
* path none matches keeps its own name. Each entry is one of:
|
|
@@ -105,29 +113,41 @@ export interface AppticsConfig {
|
|
|
105
113
|
feedback_theme?: 'light' | 'dark' | 'auto';
|
|
106
114
|
/** How often queued data is sent, in milliseconds. Default 30000, at least 1000. */
|
|
107
115
|
batch_flush_interval?: number;
|
|
108
|
-
/**
|
|
116
|
+
/**
|
|
117
|
+
* How long to wait before reading the server's tracking settings again, in milliseconds, when its
|
|
118
|
+
* answer gives no time for the next check (next_check_after). Default 120000, at least 10000.
|
|
119
|
+
*/
|
|
109
120
|
getupdates_interval?: number;
|
|
110
121
|
/** Most items in one batch. Default 50, between 1 and 500. */
|
|
111
122
|
batch_size?: number;
|
|
112
123
|
/** Days an unsent item is kept before it is dropped. Default 7, between 1 and 30. */
|
|
113
124
|
batch_request_timeout?: number;
|
|
114
|
-
/**
|
|
125
|
+
/**
|
|
126
|
+
* How long a tab can be inactive (hidden, minimised, in the background) before its session
|
|
127
|
+
* ends, in milliseconds, counted from the moment the tab went inactive; the session then ends at
|
|
128
|
+
* that moment. Default 1800000 (30 minutes), between 5000 (5 seconds) and 1800000. A value
|
|
129
|
+
* outside that is ignored with a warning and the default is kept.
|
|
130
|
+
*/
|
|
131
|
+
max_session_duration?: number;
|
|
132
|
+
/**
|
|
133
|
+
* @deprecated Use max_session_duration, in milliseconds. Still read, in minutes, when
|
|
134
|
+
* max_session_duration is not given, with a warning; held to the same 5 seconds to 30 minutes.
|
|
135
|
+
*/
|
|
115
136
|
inactiveduration?: number;
|
|
116
137
|
/**
|
|
117
|
-
* How long a visit must last before its session is recorded, in milliseconds. Default 5000,
|
|
118
|
-
*
|
|
119
|
-
*
|
|
138
|
+
* How long a visit must last before its session is recorded, in milliseconds. Default 5000,
|
|
139
|
+
* between 5000 (5 seconds) and 1800000 (30 minutes); a value outside that, 0 included, is ignored
|
|
140
|
+
* with a warning and 5000 is kept. A shorter visit with nothing tracked in it is not reported at
|
|
141
|
+
* all; anything tracked inside the window records the session at once, with its real start time.
|
|
120
142
|
*/
|
|
121
143
|
min_session_duration?: number;
|
|
122
144
|
/**
|
|
123
|
-
* Record where people click and how far they scroll. Off by default;
|
|
124
|
-
* switches it later.
|
|
145
|
+
* Record where people click and how far they scroll. Off by default;
|
|
146
|
+
* AppticsHeatmap.setHeatmapTracking() switches it later.
|
|
125
147
|
*/
|
|
126
148
|
track_heatmap?: boolean;
|
|
127
149
|
/** Most heatmap records one visit may produce. Default 500; capture pauses past it. */
|
|
128
150
|
heatmap_max_per_session?: number;
|
|
129
|
-
/** @deprecated the earlier name for `debug` (debug mode); `debug` wins when both are given */
|
|
130
|
-
debug_api?: boolean;
|
|
131
151
|
/**
|
|
132
152
|
* What to call this device in the debug stream, e.g. 'QA iPad 3'. Sent on engagement,
|
|
133
153
|
* exception and log, the three endpoints that declare it. Unset, nothing is sent unless
|
|
@@ -175,8 +195,9 @@ export interface QuartzApi {
|
|
|
175
195
|
quartzBranding: boolean;
|
|
176
196
|
}): void;
|
|
177
197
|
clearFeedback(): void;
|
|
178
|
-
|
|
179
|
-
|
|
198
|
+
/** Resolves once the recording has ended and is stored; Quartz's own build returns a Promise. */
|
|
199
|
+
endRecording(): Promise<unknown> | void;
|
|
200
|
+
setVideoContent(element: Element | null): Promise<unknown> | void;
|
|
180
201
|
submitRecording(details: {
|
|
181
202
|
email: string;
|
|
182
203
|
subject: string;
|
|
@@ -256,7 +277,7 @@ export interface SendFeedbackOptions {
|
|
|
256
277
|
attachments?: FileList | File[] | null;
|
|
257
278
|
/** Log files of the app's own to send along. */
|
|
258
279
|
logFiles?: FileList | File[] | null;
|
|
259
|
-
/** The addDiagnosticsInfo() entries
|
|
280
|
+
/** The addDiagnosticsInfo() entries: unset sends them when there are any, false never does. */
|
|
260
281
|
includeDiagnostics?: boolean;
|
|
261
282
|
/** The addFeedbackLog() lines: unset sends them when there are any, false never does. */
|
|
262
283
|
includeLog?: boolean;
|
|
@@ -305,31 +326,41 @@ export interface AppticsFeedbackApi {
|
|
|
305
326
|
export interface AppticsSdk {
|
|
306
327
|
/** Android's Apptics: starting the SDK, and what applies to all of it. */
|
|
307
328
|
Apptics: {
|
|
308
|
-
/** Starts the SDK
|
|
329
|
+
/** Starts the SDK with the app's config object, which is required. */
|
|
309
330
|
init(config: AppticsConfig): boolean;
|
|
310
331
|
/** Resolves true once start-up (storage load, device, session) has finished; false if it can't start. */
|
|
311
332
|
ready(): Promise<boolean>;
|
|
312
|
-
/**
|
|
333
|
+
/**
|
|
334
|
+
* Sends stored engagements, errors and heatmap records now; resolves once they have gone out.
|
|
335
|
+
* At most once every 15 seconds: a call sooner than that sends nothing and resolves at once,
|
|
336
|
+
* and what is queued goes with the next timed send.
|
|
337
|
+
*/
|
|
313
338
|
flush(): Promise<void>;
|
|
314
339
|
/** Clears stored identity, queued data and remote config values, then starts again. */
|
|
315
340
|
reset(): void;
|
|
316
341
|
/**
|
|
317
342
|
* Turns debug mode on, before or after Apptics.init(). Engagement, exception and log then go to
|
|
318
343
|
* their `debug/` twins, whose answers carry a request id and a link into the server's own logs. It
|
|
319
|
-
* switches itself off after an hour with nothing tracked.
|
|
344
|
+
* switches itself off after an hour with nothing tracked. Works only when typed in the browser
|
|
345
|
+
* console: a call from the page's code is ignored, with a warning, so an app can't ship with it on.
|
|
320
346
|
*/
|
|
321
347
|
enableDebug(): void;
|
|
322
|
-
/** Turns debug mode off, before or after Apptics.init()
|
|
348
|
+
/** Turns debug mode off, before or after Apptics.init(). Like enableDebug(), only from the browser console. */
|
|
323
349
|
disableDebug(): void;
|
|
324
350
|
};
|
|
325
351
|
/** Android's AppticsEvents. */
|
|
326
352
|
AppticsEvent: {
|
|
327
353
|
/** Apptics' defined events, as Android's DefinedEvents, to log with addEvent. */
|
|
328
354
|
DefinedEvents: typeof DefinedEvents;
|
|
329
|
-
/** An event.
|
|
330
|
-
addEvent(eventName: string, groupName
|
|
355
|
+
/** An event. The group is required: an event without one, or with an invalid name or group, is not logged, and the console says why. */
|
|
356
|
+
addEvent(eventName: string, groupName: string, properties?: Properties): void;
|
|
331
357
|
/** A defined event (AppticsEvent.DefinedEvents.AP_USER_LOGIN, …), which brings its own group. */
|
|
332
358
|
addEvent(definedEvent: DefinedEvent, properties?: Properties): void;
|
|
359
|
+
/**
|
|
360
|
+
* Turns click tracking from markup (`apeventaction`) on or off after Apptics.init(); `enabled`
|
|
361
|
+
* defaults to true. The `track_click` config flag sets it at start-up.
|
|
362
|
+
*/
|
|
363
|
+
setClickTracking(enabled?: boolean): void;
|
|
333
364
|
};
|
|
334
365
|
/** Android's AppticsScreenTracker. */
|
|
335
366
|
AppticsScreen: {
|
|
@@ -337,6 +368,11 @@ export interface AppticsSdk {
|
|
|
337
368
|
inScreen(screenName: string, properties?: Properties): string;
|
|
338
369
|
/** Ends the screen view inScreen began, before the next screen would. */
|
|
339
370
|
outScreen(id: string): void;
|
|
371
|
+
/**
|
|
372
|
+
* Turns automatic screen tracking on or off after Apptics.init(); `enabled` defaults to true.
|
|
373
|
+
* The `track_screen` config flag sets it at start-up. inScreen() records either way.
|
|
374
|
+
*/
|
|
375
|
+
setScreenTracking(enabled?: boolean): void;
|
|
340
376
|
};
|
|
341
377
|
/** Android's AppticsApiTracker. */
|
|
342
378
|
AppticsApi: {
|
|
@@ -349,16 +385,23 @@ export interface AppticsSdk {
|
|
|
349
385
|
/** The rules API tracking records by, from ApiTrackingBuilder. Works before Apptics.init(). */
|
|
350
386
|
configure(config: ApiTrackingConfig | ApiTrackingBuilder): void;
|
|
351
387
|
/**
|
|
352
|
-
* Turns automatic API tracking on or off after Apptics.init()
|
|
353
|
-
* config flag
|
|
388
|
+
* Turns automatic API tracking on or off after Apptics.init(); `enabled` defaults to true.
|
|
389
|
+
* The `track_api` config flag sets it at start-up.
|
|
354
390
|
*/
|
|
391
|
+
setApiTracking(enabled?: boolean): void;
|
|
392
|
+
/** @deprecated renamed setApiTracking; this name still works, with a console warning */
|
|
355
393
|
enableApiTracking(enabled?: boolean): void;
|
|
356
394
|
};
|
|
357
395
|
/** Errors the app caught, and the switch for tracking uncaught ones. */
|
|
358
396
|
AppticsError: {
|
|
359
397
|
/** Reports an error the app caught, or an `error` / `unhandledrejection` event. */
|
|
360
398
|
trackError(error: ErrorLike, properties?: Properties): void;
|
|
361
|
-
/**
|
|
399
|
+
/**
|
|
400
|
+
* Turns the automatic tracking of uncaught errors and unhandled rejections on or off after
|
|
401
|
+
* Apptics.init(); `enabled` defaults to true. The `track_error` config flag sets it at start-up.
|
|
402
|
+
*/
|
|
403
|
+
setErrorTracking(enabled?: boolean): void;
|
|
404
|
+
/** @deprecated renamed setErrorTracking; this name still works, with a console warning */
|
|
362
405
|
trackGlobalErrorHandler(enabled?: boolean): void;
|
|
363
406
|
};
|
|
364
407
|
/** Android's AppticsUser. */
|
|
@@ -372,14 +415,32 @@ export interface AppticsSdk {
|
|
|
372
415
|
};
|
|
373
416
|
/** Click and scroll capture for the console's heatmaps. */
|
|
374
417
|
AppticsHeatmap: {
|
|
375
|
-
/**
|
|
418
|
+
/**
|
|
419
|
+
* Starts or stops recording clicks and scrolls; `enabled` defaults to true. The
|
|
420
|
+
* `track_heatmap` config flag sets it at start-up.
|
|
421
|
+
*/
|
|
422
|
+
setHeatmapTracking(enabled?: boolean): void;
|
|
423
|
+
/** @deprecated renamed setHeatmapTracking; this name still works, with a console warning */
|
|
376
424
|
trackHeatmap(on?: boolean): void;
|
|
377
425
|
};
|
|
378
426
|
/** Android's AppticsSettings: what the SDK may track for this visitor. */
|
|
379
427
|
AppticsSettings: {
|
|
380
428
|
/** The states setTrackingStatus takes. */
|
|
381
429
|
AP_TRACKING_STATUS: typeof AP_TRACKING_STATUS;
|
|
430
|
+
/** One of AP_TRACKING_STATUS, as AppticsSettings.AP_TRACKING_STATUS.ANONYMOUS. */
|
|
382
431
|
setTrackingStatus(status: TrackingStatus): void;
|
|
432
|
+
/** @deprecated pass AP_TRACKING_STATUS.<name>; the number (1, 4, 7, -1) still works, with a console warning */
|
|
433
|
+
setTrackingStatus(status: number): void;
|
|
434
|
+
/** One of AP_TRACKING_STATUS, as 'USAGE_TRACKING_WITH_PII'. */
|
|
383
435
|
getTrackingStatus(): TrackingStatus;
|
|
384
436
|
};
|
|
385
437
|
}
|
|
438
|
+
/**
|
|
439
|
+
* getsdkconfig's `wms` block: where wmsliteapi.js loads from, its subresource-integrity hash, and
|
|
440
|
+
* the hashes wmsliteapi.js checks the scripts it loads itself against.
|
|
441
|
+
*/
|
|
442
|
+
export interface WmsConfig {
|
|
443
|
+
wms_js_url: string;
|
|
444
|
+
wms_sri: string;
|
|
445
|
+
wms_sri_values: Record<string, unknown> | null;
|
|
446
|
+
}
|
package/dist/esm/user/index.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import type { Dict, Properties, UserInfo, UserValidationResult } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Whether the active user's customer group is not tracked, as user/register last answered for them
|
|
4
|
+
* (user_info's customergrouptracking). A user registered before it was kept has none, and counts as
|
|
5
|
+
* tracked. Only a user getsdkconfig is asked about can be one: the status decides whether it
|
|
6
|
+
* carries their userid.
|
|
7
|
+
*/
|
|
8
|
+
export declare function activeUserGroupUntracked(): boolean;
|
|
2
9
|
export declare function getUser(): UserInfo;
|
|
3
10
|
export declare function setUser(userid?: string, groupid?: string, jsonObj?: Properties | UserValidationResult): void;
|
|
4
11
|
export declare function addOrUpdateUser(user_info: Dict): void;
|
package/dist/esm/user/index.js
CHANGED
|
@@ -1,14 +1,24 @@
|
|
|
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_TRACKING_STATUS } from '../core/constants.js';
|
|
3
3
|
import { _ZAP } from '../core/state.js';
|
|
4
4
|
import { logFailure, Console } from '../core/logger.js';
|
|
5
5
|
import { isEmpty, nowMs, isEmptyObj, cloneMapExcludingKeys } from '../core/utils.js';
|
|
6
6
|
import { user_defaults } from '../core/storage.js';
|
|
7
|
-
import { canTrack,
|
|
7
|
+
import { canTrack, opt_in_status } from '../core/consent.js';
|
|
8
8
|
import { rejectIfDisabled, rejectIfOffline, rejectIfNoDeviceIds, postToApptics, apiHeaders } from '../core/transport.js';
|
|
9
9
|
import { userValidateJSON } from '../core/validate.js';
|
|
10
10
|
import { hooks } from '../core/hooks.js';
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Whether the active user's customer group is not tracked, as user/register last answered for them
|
|
14
|
+
* (user_info's customergrouptracking). A user registered before it was kept has none, and counts as
|
|
15
|
+
* tracked. Only a user getsdkconfig is asked about can be one: the status decides whether it
|
|
16
|
+
* carries their userid.
|
|
17
|
+
*/
|
|
18
|
+
function activeUserGroupUntracked() {
|
|
19
|
+
var user = _ZAP._user_info;
|
|
20
|
+
return !!user && !isEmpty(user.userid) && user.customergrouptracking === false;
|
|
21
|
+
}
|
|
12
22
|
function getUser() {
|
|
13
23
|
return _ZAP._user_info || {}; // no i18n
|
|
14
24
|
}
|
|
@@ -93,7 +103,7 @@ function registerUserWithApptics(user_info) {
|
|
|
93
103
|
if (isEmptyObj(user_info)) {
|
|
94
104
|
return Promise.reject(label + ': nothing to register'); // no i18n
|
|
95
105
|
}
|
|
96
|
-
var missing = rejectIfNoDeviceIds(label);
|
|
106
|
+
var missing = rejectIfNoDeviceIds(label, 'reguser');
|
|
97
107
|
if (missing) {
|
|
98
108
|
return missing;
|
|
99
109
|
}
|
|
@@ -102,11 +112,21 @@ function registerUserWithApptics(user_info) {
|
|
|
102
112
|
var data = result.data || {};
|
|
103
113
|
user_info.userid = data.userid;
|
|
104
114
|
user_info.groupid = data.customergroupid;
|
|
105
|
-
setTrackingStatus
|
|
115
|
+
// whether a change of tracking status asks getsdkconfig again depends on it (see setTrackingStatus)
|
|
116
|
+
user_info.customergrouptracking = data.customergrouptracking !== false;
|
|
117
|
+
// the tracking status is left as it is: registering a user is not consent to attach them to
|
|
118
|
+
// the data. Only AppticsSettings.setTrackingStatus changes it
|
|
106
119
|
addOrUpdateUser(user_info);
|
|
107
120
|
getUserInfo();
|
|
108
121
|
// the user and their customer group are known now: remote config conditions on them re-apply
|
|
109
122
|
hooks.remoteConfigUserChanged();
|
|
123
|
+
// a user whose customer group is not tracked (customergrouptracking: false) gets every
|
|
124
|
+
// module off from getsdkconfig, so it is asked again for them now; for any other user the
|
|
125
|
+
// current answer stands. Only with PII does getsdkconfig carry the userid: anonymous, or
|
|
126
|
+
// without PII, it answers for the device alone, and the customer group does not apply
|
|
127
|
+
if (data.customergrouptracking === false && opt_in_status() === AP_TRACKING_STATUS.USAGE_TRACKING_WITH_PII) {
|
|
128
|
+
hooks.askServerSettings();
|
|
129
|
+
}
|
|
110
130
|
return data;
|
|
111
131
|
});
|
|
112
132
|
}
|
|
@@ -172,5 +192,6 @@ class UserBuilder {
|
|
|
172
192
|
return userValidateJSON(user);
|
|
173
193
|
}
|
|
174
194
|
}
|
|
195
|
+
hooks.activeUserGroupUntracked = activeUserGroupUntracked;
|
|
175
196
|
|
|
176
|
-
export { UserBuilder, addOrUpdateUser, getUser, getUserInfo, registerUserWithApptics, setUser };
|
|
197
|
+
export { UserBuilder, activeUserGroupUntracked, addOrUpdateUser, getUser, getUserInfo, registerUserWithApptics, setUser };
|