@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 { 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.
|
|
@@ -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.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, getConfig } from './core/state.js';
|
|
3
3
|
import { Console } from './core/logger.js';
|
|
4
4
|
import { nowMs } from './core/utils.js';
|
|
@@ -9,6 +9,7 @@ import { sendErrorData } from './errors/send.js';
|
|
|
9
9
|
import { hooks } from './core/hooks.js';
|
|
10
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,6 +26,9 @@ 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
|
}
|
|
30
34
|
/**
|
|
@@ -49,19 +53,21 @@ var sendingInterval = null;
|
|
|
49
53
|
/** Starts the flush interval once; later calls do nothing until stopTimers(). */
|
|
50
54
|
function startTimers() {
|
|
51
55
|
if (sendingInterval === null) {
|
|
52
|
-
sendingInterval = setInterval(function () {
|
|
56
|
+
sendingInterval = setInterval(shield('scheduled send', function () {
|
|
53
57
|
// the only tick that happens whether or not anything is being tracked, which is
|
|
54
58
|
// exactly the case debug mode has to expire in
|
|
55
59
|
expireDebugIfIdle();
|
|
56
60
|
Console.log('scheduleToSendDataToServer: Scheduling to send engagement data to the server after sometime'); // no i18n
|
|
57
61
|
// one after the other, as flush() does: run together, the second and third find the
|
|
58
62
|
// first still sending and are deferred, and the third's retry replaces the second's
|
|
59
|
-
sendEngagementData().then(function () {
|
|
63
|
+
quietly('scheduled send', sendEngagementData().then(function () {
|
|
60
64
|
return sendErrorData();
|
|
61
65
|
}).then(function () {
|
|
62
66
|
return hooks.sendHeatmaps();
|
|
63
|
-
})
|
|
64
|
-
|
|
67
|
+
}).then(function () {
|
|
68
|
+
return hooks.sendPushStats();
|
|
69
|
+
}));
|
|
70
|
+
}), getConfig('batch_flush_interval')); // no i18n
|
|
65
71
|
}
|
|
66
72
|
}
|
|
67
73
|
function 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> {
|
|
@@ -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;
|
|
@@ -127,14 +123,22 @@ export interface AppticsConfig {
|
|
|
127
123
|
/** Days an unsent item is kept before it is dropped. Default 7, between 1 and 30. */
|
|
128
124
|
batch_request_timeout?: number;
|
|
129
125
|
/**
|
|
130
|
-
*
|
|
131
|
-
*
|
|
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.
|
|
132
135
|
*/
|
|
133
136
|
inactiveduration?: number;
|
|
134
137
|
/**
|
|
135
|
-
* How long a visit must last before its session is recorded, in milliseconds. Default 5000,
|
|
136
|
-
*
|
|
137
|
-
*
|
|
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.
|
|
138
142
|
*/
|
|
139
143
|
min_session_duration?: number;
|
|
140
144
|
/**
|
|
@@ -144,8 +148,6 @@ export interface AppticsConfig {
|
|
|
144
148
|
track_heatmap?: boolean;
|
|
145
149
|
/** Most heatmap records one visit may produce. Default 500; capture pauses past it. */
|
|
146
150
|
heatmap_max_per_session?: number;
|
|
147
|
-
/** @deprecated the earlier name for `debug` (debug mode); `debug` wins when both are given */
|
|
148
|
-
debug_api?: boolean;
|
|
149
151
|
/**
|
|
150
152
|
* What to call this device in the debug stream, e.g. 'QA iPad 3'. Sent on engagement,
|
|
151
153
|
* exception and log, the three endpoints that declare it. Unset, nothing is sent unless
|
|
@@ -339,10 +341,11 @@ export interface AppticsSdk {
|
|
|
339
341
|
/**
|
|
340
342
|
* Turns debug mode on, before or after Apptics.init(). Engagement, exception and log then go to
|
|
341
343
|
* their `debug/` twins, whose answers carry a request id and a link into the server's own logs. It
|
|
342
|
-
* 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.
|
|
343
346
|
*/
|
|
344
347
|
enableDebug(): void;
|
|
345
|
-
/** 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. */
|
|
346
349
|
disableDebug(): void;
|
|
347
350
|
};
|
|
348
351
|
/** Android's AppticsEvents. */
|
|
@@ -424,7 +427,20 @@ export interface AppticsSdk {
|
|
|
424
427
|
AppticsSettings: {
|
|
425
428
|
/** The states setTrackingStatus takes. */
|
|
426
429
|
AP_TRACKING_STATUS: typeof AP_TRACKING_STATUS;
|
|
430
|
+
/** One of AP_TRACKING_STATUS, as AppticsSettings.AP_TRACKING_STATUS.ANONYMOUS. */
|
|
427
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'. */
|
|
428
435
|
getTrackingStatus(): TrackingStatus;
|
|
429
436
|
};
|
|
430
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,15 +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
|
-
//
|
|
106
|
-
|
|
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
|
|
107
119
|
addOrUpdateUser(user_info);
|
|
108
120
|
getUserInfo();
|
|
109
121
|
// the user and their customer group are known now: remote config conditions on them re-apply
|
|
110
122
|
hooks.remoteConfigUserChanged();
|
|
111
|
-
//
|
|
112
|
-
//
|
|
113
|
-
|
|
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
|
+
}
|
|
114
130
|
return data;
|
|
115
131
|
});
|
|
116
132
|
}
|
|
@@ -176,5 +192,6 @@ class UserBuilder {
|
|
|
176
192
|
return userValidateJSON(user);
|
|
177
193
|
}
|
|
178
194
|
}
|
|
195
|
+
hooks.activeUserGroupUntracked = activeUserGroupUntracked;
|
|
179
196
|
|
|
180
|
-
export { UserBuilder, addOrUpdateUser, getUser, getUserInfo, registerUserWithApptics, setUser };
|
|
197
|
+
export { UserBuilder, activeUserGroupUntracked, addOrUpdateUser, getUser, getUserInfo, registerUserWithApptics, setUser };
|