@zoho_apptics/apptics-js-sdk 1.0.1 → 2.0.0-beta
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 +87 -0
- package/LICENSE +13 -0
- package/README.md +747 -11
- package/dist/apptics.esm.min.js +3 -0
- package/dist/apptics.esm.min.js.map +1 -0
- package/dist/apptics.min.js +3 -0
- package/dist/apptics.min.js.map +1 -0
- package/dist/chunks/batch-BU_mTpm1.min.js +3 -0
- package/dist/chunks/batch-BU_mTpm1.min.js.map +1 -0
- package/dist/chunks/logs-Bea5zUW_.min.js +3 -0
- package/dist/chunks/logs-Bea5zUW_.min.js.map +1 -0
- package/dist/cjs/auto-init.d.ts +8 -0
- package/dist/cjs/auto-init.js +32 -0
- package/dist/cjs/core/attempts.d.ts +28 -0
- package/dist/cjs/core/attempts.js +113 -0
- package/dist/cjs/core/batch.d.ts +32 -0
- package/dist/cjs/core/batch.js +115 -0
- package/dist/cjs/core/callsite.d.ts +28 -0
- package/dist/cjs/core/callsite.js +93 -0
- package/dist/cjs/core/consent.d.ts +23 -0
- package/dist/cjs/core/consent.js +130 -0
- package/dist/cjs/core/constants.d.ts +212 -0
- package/dist/cjs/core/constants.js +299 -0
- package/dist/cjs/core/db.d.ts +40 -0
- package/dist/cjs/core/db.js +334 -0
- package/dist/cjs/core/debug.d.ts +22 -0
- package/dist/cjs/core/debug.js +88 -0
- package/dist/cjs/core/env.d.ts +28 -0
- package/dist/cjs/core/env.js +267 -0
- package/dist/cjs/core/framework-id.d.ts +1 -0
- package/dist/cjs/core/framework-id.js +9 -0
- package/dist/cjs/core/guard.d.ts +2 -0
- package/dist/cjs/core/guard.js +72 -0
- package/dist/cjs/core/hooks.d.ts +41 -0
- package/dist/cjs/core/hooks.js +23 -0
- package/dist/cjs/core/logger.d.ts +16 -0
- package/dist/cjs/core/logger.js +86 -0
- package/dist/cjs/core/state.d.ts +69 -0
- package/dist/cjs/core/state.js +78 -0
- package/dist/cjs/core/storage.d.ts +46 -0
- package/dist/cjs/core/storage.js +229 -0
- package/dist/cjs/core/transport.d.ts +83 -0
- package/dist/cjs/core/transport.js +441 -0
- package/dist/cjs/core/utils.d.ts +26 -0
- package/dist/cjs/core/utils.js +175 -0
- package/dist/cjs/core/validate.d.ts +18 -0
- package/dist/cjs/core/validate.js +233 -0
- package/dist/cjs/device/appversion.d.ts +20 -0
- package/dist/cjs/device/appversion.js +158 -0
- package/dist/cjs/device/index.d.ts +23 -0
- package/dist/cjs/device/index.js +372 -0
- package/dist/cjs/engagement/api-rules.d.ts +84 -0
- package/dist/cjs/engagement/api-rules.js +219 -0
- package/dist/cjs/engagement/auto-api.d.ts +7 -0
- package/dist/cjs/engagement/auto-api.js +200 -0
- package/dist/cjs/engagement/auto-screen.d.ts +16 -0
- package/dist/cjs/engagement/auto-screen.js +241 -0
- package/dist/cjs/engagement/defined-events.d.ts +23 -0
- package/dist/cjs/engagement/defined-events.js +58 -0
- package/dist/cjs/engagement/send.d.ts +6 -0
- package/dist/cjs/engagement/send.js +99 -0
- package/dist/cjs/engagement/session.d.ts +42 -0
- package/dist/cjs/engagement/session.js +327 -0
- package/dist/cjs/engagement/track.d.ts +56 -0
- package/dist/cjs/engagement/track.js +350 -0
- package/dist/cjs/errors/send.d.ts +6 -0
- package/dist/cjs/errors/send.js +73 -0
- package/dist/cjs/errors/track.d.ts +4 -0
- package/dist/cjs/errors/track.js +127 -0
- package/dist/cjs/feedback/controls.d.ts +31 -0
- package/dist/cjs/feedback/controls.js +286 -0
- package/dist/cjs/feedback/index.d.ts +8 -0
- package/dist/cjs/feedback/index.js +37 -0
- package/dist/cjs/feedback/logs.d.ts +40 -0
- package/dist/cjs/feedback/logs.js +202 -0
- package/dist/cjs/feedback/send.d.ts +25 -0
- package/dist/cjs/feedback/send.js +178 -0
- package/dist/cjs/feedback/template.d.ts +2 -0
- package/dist/cjs/feedback/template.js +162 -0
- package/dist/cjs/feedback/ui.d.ts +55 -0
- package/dist/cjs/feedback/ui.js +631 -0
- package/dist/cjs/heatmap/index.d.ts +16 -0
- package/dist/cjs/heatmap/index.js +22 -0
- package/dist/cjs/heatmap/send.d.ts +13 -0
- package/dist/cjs/heatmap/send.js +82 -0
- package/dist/cjs/heatmap/track.d.ts +4 -0
- package/dist/cjs/heatmap/track.js +377 -0
- package/dist/cjs/index.d.ts +68 -0
- package/dist/cjs/index.js +150 -0
- package/dist/cjs/lifecycle.d.ts +14 -0
- package/dist/cjs/lifecycle.js +538 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/remoteconfig/custom.d.ts +10 -0
- package/dist/cjs/remoteconfig/custom.js +78 -0
- package/dist/cjs/remoteconfig/evaluate.d.ts +24 -0
- package/dist/cjs/remoteconfig/evaluate.js +171 -0
- package/dist/cjs/remoteconfig/fetch.d.ts +24 -0
- package/dist/cjs/remoteconfig/fetch.js +214 -0
- package/dist/cjs/remoteconfig/index.d.ts +13 -0
- package/dist/cjs/remoteconfig/index.js +90 -0
- package/dist/cjs/remoteconfig/store.d.ts +18 -0
- package/dist/cjs/remoteconfig/store.js +98 -0
- package/dist/cjs/remotelog/gate.d.ts +11 -0
- package/dist/cjs/remotelog/gate.js +54 -0
- package/dist/cjs/remotelog/index.d.ts +25 -0
- package/dist/cjs/remotelog/index.js +55 -0
- package/dist/cjs/remotelog/logger.d.ts +28 -0
- package/dist/cjs/remotelog/logger.js +139 -0
- package/dist/cjs/remotelog/send.d.ts +13 -0
- package/dist/cjs/remotelog/send.js +153 -0
- package/dist/cjs/scheduler.d.ts +8 -0
- package/dist/cjs/scheduler.js +78 -0
- package/dist/cjs/types.d.ts +312 -0
- package/dist/cjs/user/index.d.ts +33 -0
- package/dist/cjs/user/index.js +178 -0
- package/dist/esm/auto-init.d.ts +8 -0
- package/dist/esm/auto-init.js +29 -0
- package/dist/esm/core/attempts.d.ts +28 -0
- package/dist/esm/core/attempts.js +106 -0
- package/dist/esm/core/batch.d.ts +32 -0
- package/dist/esm/core/batch.js +108 -0
- package/dist/esm/core/callsite.d.ts +28 -0
- package/dist/esm/core/callsite.js +89 -0
- package/dist/esm/core/consent.d.ts +23 -0
- package/dist/esm/core/consent.js +120 -0
- package/dist/esm/core/constants.d.ts +212 -0
- package/dist/esm/core/constants.js +277 -0
- package/dist/esm/core/db.d.ts +40 -0
- package/dist/esm/core/db.js +324 -0
- package/dist/esm/core/debug.d.ts +22 -0
- package/dist/esm/core/debug.js +81 -0
- package/dist/esm/core/env.d.ts +28 -0
- package/dist/esm/core/env.js +251 -0
- package/dist/esm/core/framework-id.d.ts +1 -0
- package/dist/esm/core/framework-id.js +7 -0
- package/dist/esm/core/guard.d.ts +2 -0
- package/dist/esm/core/guard.js +70 -0
- package/dist/esm/core/hooks.d.ts +41 -0
- package/dist/esm/core/hooks.js +21 -0
- package/dist/esm/core/logger.d.ts +16 -0
- package/dist/esm/core/logger.js +82 -0
- package/dist/esm/core/state.d.ts +69 -0
- package/dist/esm/core/state.js +73 -0
- package/dist/esm/core/storage.d.ts +46 -0
- package/dist/esm/core/storage.js +219 -0
- package/dist/esm/core/transport.d.ts +83 -0
- package/dist/esm/core/transport.js +425 -0
- package/dist/esm/core/utils.d.ts +26 -0
- package/dist/esm/core/utils.js +161 -0
- package/dist/esm/core/validate.d.ts +18 -0
- package/dist/esm/core/validate.js +226 -0
- package/dist/esm/device/appversion.d.ts +20 -0
- package/dist/esm/device/appversion.js +153 -0
- package/dist/esm/device/index.d.ts +23 -0
- package/dist/esm/device/index.js +362 -0
- package/dist/esm/engagement/api-rules.d.ts +84 -0
- package/dist/esm/engagement/api-rules.js +211 -0
- package/dist/esm/engagement/auto-api.d.ts +7 -0
- package/dist/esm/engagement/auto-api.js +198 -0
- package/dist/esm/engagement/auto-screen.d.ts +16 -0
- package/dist/esm/engagement/auto-screen.js +238 -0
- package/dist/esm/engagement/defined-events.d.ts +23 -0
- package/dist/esm/engagement/defined-events.js +55 -0
- package/dist/esm/engagement/send.d.ts +6 -0
- package/dist/esm/engagement/send.js +96 -0
- package/dist/esm/engagement/session.d.ts +42 -0
- package/dist/esm/engagement/session.js +315 -0
- package/dist/esm/engagement/track.d.ts +56 -0
- package/dist/esm/engagement/track.js +340 -0
- package/dist/esm/errors/send.d.ts +6 -0
- package/dist/esm/errors/send.js +70 -0
- package/dist/esm/errors/track.d.ts +4 -0
- package/dist/esm/errors/track.js +123 -0
- package/dist/esm/feedback/controls.d.ts +31 -0
- package/dist/esm/feedback/controls.js +280 -0
- package/dist/esm/feedback/index.d.ts +8 -0
- package/dist/esm/feedback/index.js +30 -0
- package/dist/esm/feedback/logs.d.ts +40 -0
- package/dist/esm/feedback/logs.js +188 -0
- package/dist/esm/feedback/send.d.ts +25 -0
- package/dist/esm/feedback/send.js +175 -0
- package/dist/esm/feedback/template.d.ts +2 -0
- package/dist/esm/feedback/template.js +159 -0
- package/dist/esm/feedback/ui.d.ts +55 -0
- package/dist/esm/feedback/ui.js +626 -0
- package/dist/esm/heatmap/index.d.ts +16 -0
- package/dist/esm/heatmap/index.js +17 -0
- package/dist/esm/heatmap/send.d.ts +13 -0
- package/dist/esm/heatmap/send.js +79 -0
- package/dist/esm/heatmap/track.d.ts +4 -0
- package/dist/esm/heatmap/track.js +374 -0
- package/dist/esm/index.d.ts +68 -0
- package/dist/esm/index.js +122 -0
- package/dist/esm/lifecycle.d.ts +14 -0
- package/dist/esm/lifecycle.js +534 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/remoteconfig/custom.d.ts +10 -0
- package/dist/esm/remoteconfig/custom.js +74 -0
- package/dist/esm/remoteconfig/evaluate.d.ts +24 -0
- package/dist/esm/remoteconfig/evaluate.js +166 -0
- package/dist/esm/remoteconfig/fetch.d.ts +24 -0
- package/dist/esm/remoteconfig/fetch.js +210 -0
- package/dist/esm/remoteconfig/index.d.ts +13 -0
- package/dist/esm/remoteconfig/index.js +85 -0
- package/dist/esm/remoteconfig/store.d.ts +18 -0
- package/dist/esm/remoteconfig/store.js +91 -0
- package/dist/esm/remotelog/gate.d.ts +11 -0
- package/dist/esm/remotelog/gate.js +48 -0
- package/dist/esm/remotelog/index.d.ts +25 -0
- package/dist/esm/remotelog/index.js +51 -0
- package/dist/esm/remotelog/logger.d.ts +28 -0
- package/dist/esm/remotelog/logger.js +136 -0
- package/dist/esm/remotelog/send.d.ts +13 -0
- package/dist/esm/remotelog/send.js +149 -0
- package/dist/esm/scheduler.d.ts +8 -0
- package/dist/esm/scheduler.js +74 -0
- package/dist/esm/types.d.ts +312 -0
- package/dist/esm/user/index.d.ts +33 -0
- package/dist/esm/user/index.js +170 -0
- package/dist/feedback.esm.min.js +3 -0
- package/dist/feedback.esm.min.js.map +1 -0
- package/dist/heatmap.esm.min.js +3 -0
- package/dist/heatmap.esm.min.js.map +1 -0
- package/dist/style.css +1 -0
- package/package.json +124 -7
- package/src/appticssdk.js +0 -3817
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Whether debug mode is on right now, idle hour included. */
|
|
2
|
+
export declare function debugEnabled(): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* Pushes the idle hour out. Called wherever something is actually tracked, which is the only
|
|
5
|
+
* evidence the SDK has that a person is still looking — there is no event for "watching".
|
|
6
|
+
*/
|
|
7
|
+
export declare function noteDebugActivity(): void;
|
|
8
|
+
/**
|
|
9
|
+
* Turns debug mode off if its hour has run out. Called from the flush timer, which ticks whether
|
|
10
|
+
* or not anything is happening — a check that only ran on the way into a request would never
|
|
11
|
+
* fire, because an idle SDK makes no requests.
|
|
12
|
+
*/
|
|
13
|
+
export declare function expireDebugIfIdle(): void;
|
|
14
|
+
/**
|
|
15
|
+
* Turns debug mode on, at any time: before init(), during start-up or while the SDK runs. The
|
|
16
|
+
* choice holds over `debug` in init() for the rest of the page's life.
|
|
17
|
+
*/
|
|
18
|
+
export declare function enableDebug(): void;
|
|
19
|
+
/** Turns debug mode off, at any time, with the same hold over `debug` as enableDebug(). */
|
|
20
|
+
export declare function disableDebug(): void;
|
|
21
|
+
/** What init() applies for `debug`: the config's value, unless the app has already chosen. */
|
|
22
|
+
export declare function applyDebugConfig(configured: boolean): void;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var constants = require('./constants.js');
|
|
5
|
+
var state = require('./state.js');
|
|
6
|
+
var logger = require('./logger.js');
|
|
7
|
+
var utils = require('./utils.js');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The switch for debug mode, and the hour that closes it.
|
|
11
|
+
*
|
|
12
|
+
* Debug mode is not free on either side: every engagement, exception and log call goes to its
|
|
13
|
+
* `debug/` twin instead of the ordinary endpoint, which makes the server keep a traceable
|
|
14
|
+
* record of the request. That is worth it while someone is watching, and pure
|
|
15
|
+
* cost once they have walked away — and walking away is the normal way a debugging session ends,
|
|
16
|
+
* not a deliberate switch-off. So the SDK closes it: an hour with nothing tracked turns debug
|
|
17
|
+
* back off by itself, and anything tracked pushes that hour out again.
|
|
18
|
+
*
|
|
19
|
+
* It lives in core because every send asks it: `debug: true` in init(), or enableDebug(), is
|
|
20
|
+
* enough to turn the twins on, and that alone must expire.
|
|
21
|
+
*/
|
|
22
|
+
/** Whether debug mode is on right now, idle hour included. */
|
|
23
|
+
function debugEnabled() {
|
|
24
|
+
return state._ZAP._config.debug_api === true && !debugIdle();
|
|
25
|
+
}
|
|
26
|
+
/** True once the idle hour has run out on a debug session nobody is watching. */
|
|
27
|
+
function debugIdle() {
|
|
28
|
+
return state._ZAP._debugUntil > 0 && utils.nowMs() > state._ZAP._debugUntil;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Pushes the idle hour out. Called wherever something is actually tracked, which is the only
|
|
32
|
+
* evidence the SDK has that a person is still looking — there is no event for "watching".
|
|
33
|
+
*/
|
|
34
|
+
function noteDebugActivity() {
|
|
35
|
+
if (state._ZAP._config.debug_api !== true) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
state._ZAP._debugUntil = utils.nowMs() + constants.DEBUG_IDLE_MS;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Turns debug mode off if its hour has run out. Called from the flush timer, which ticks whether
|
|
42
|
+
* or not anything is happening — a check that only ran on the way into a request would never
|
|
43
|
+
* fire, because an idle SDK makes no requests.
|
|
44
|
+
*/
|
|
45
|
+
function expireDebugIfIdle() {
|
|
46
|
+
if (!debugIdle()) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
logger.Console.log('apptics: debug mode has been idle for an hour, switching it off'); // no i18n
|
|
50
|
+
setDebug(false);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The app's own choice, from enableDebug() or disableDebug(). It wins over `debug` in init(),
|
|
54
|
+
* so debug mode can be switched on or off with one call, before init() runs or while the SDK is
|
|
55
|
+
* running, and an init() or reset() that comes after doesn't switch it back. null until the app
|
|
56
|
+
* has chosen.
|
|
57
|
+
*/
|
|
58
|
+
var chosen = null;
|
|
59
|
+
/** Turning it on starts the idle hour; turning it off clears it, so the next on gets a whole hour. */
|
|
60
|
+
function setDebug(on) {
|
|
61
|
+
state._ZAP._config.debug_api = on;
|
|
62
|
+
state._ZAP._debugUntil = on ? utils.nowMs() + constants.DEBUG_IDLE_MS : 0;
|
|
63
|
+
logger.Console.log('apptics: debug mode ' + (on ? 'on' : 'off')); // no i18n
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Turns debug mode on, at any time: before init(), during start-up or while the SDK runs. The
|
|
67
|
+
* choice holds over `debug` in init() for the rest of the page's life.
|
|
68
|
+
*/
|
|
69
|
+
function enableDebug() {
|
|
70
|
+
chosen = true;
|
|
71
|
+
setDebug(true);
|
|
72
|
+
}
|
|
73
|
+
/** Turns debug mode off, at any time, with the same hold over `debug` as enableDebug(). */
|
|
74
|
+
function disableDebug() {
|
|
75
|
+
chosen = false;
|
|
76
|
+
setDebug(false);
|
|
77
|
+
}
|
|
78
|
+
/** What init() applies for `debug`: the config's value, unless the app has already chosen. */
|
|
79
|
+
function applyDebugConfig(configured) {
|
|
80
|
+
setDebug(chosen !== null ? chosen : configured);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
exports.applyDebugConfig = applyDebugConfig;
|
|
84
|
+
exports.debugEnabled = debugEnabled;
|
|
85
|
+
exports.disableDebug = disableDebug;
|
|
86
|
+
exports.enableDebug = enableDebug;
|
|
87
|
+
exports.expireDebugIfIdle = expireDebugIfIdle;
|
|
88
|
+
exports.noteDebugActivity = noteDebugActivity;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { AppticsConfig } from '../types.js';
|
|
2
|
+
export declare function isBlockedWS(ua: string): boolean;
|
|
3
|
+
/** Device RAM as the API wants it ("4 GB"). Chromium only; empty elsewhere. */
|
|
4
|
+
export declare function getRam(): string;
|
|
5
|
+
export declare function getConnectionType(): string;
|
|
6
|
+
export declare function getNetworkStatus(): number;
|
|
7
|
+
/**
|
|
8
|
+
* The battery as a whole percentage, or null where the browser will not say.
|
|
9
|
+
*
|
|
10
|
+
* feedbackWebSDK types `battery` as an int and the console shows it next to a report, which is
|
|
11
|
+
* what makes "it died while I was filling this in" legible. The Battery Status API is behind a
|
|
12
|
+
* promise and is absent in Firefox and Safari entirely, so this answers null rather than 0 -
|
|
13
|
+
* a real 0% and "no answer" are different things, and only one of them belongs in a report.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getBatteryPercent(): Promise<number | null>;
|
|
16
|
+
export declare function getOrientation(): number;
|
|
17
|
+
export declare function getDevice(): string;
|
|
18
|
+
export declare function getOS(): string;
|
|
19
|
+
export declare function getBrowser(): string;
|
|
20
|
+
export declare function getBrowserVersion(): number | string;
|
|
21
|
+
export declare function getReferringURL(): string;
|
|
22
|
+
export declare function getTimeZone(): string;
|
|
23
|
+
/** True for crawlers and non-browser environments; the SDK does nothing for them. */
|
|
24
|
+
export declare function is_apptics_disabled(): boolean;
|
|
25
|
+
/** Pure DNT check (no side effects). consent.hasDoNotTrackEnabled() applies NO_TRACKING. */
|
|
26
|
+
export declare function isDntOn(): boolean;
|
|
27
|
+
/** The console snippet's config (window.appticssettings._defaultoptions), if the page defines one. */
|
|
28
|
+
export declare function getSnippetOptions(): AppticsConfig | undefined;
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var constants = require('./constants.js');
|
|
5
|
+
var utils = require('./utils.js');
|
|
6
|
+
|
|
7
|
+
function isBlockedWS(ua) {
|
|
8
|
+
var i;
|
|
9
|
+
ua = ua.toLowerCase();
|
|
10
|
+
for (i = 0; i < constants.BLOCKED_WS.length; i++) {
|
|
11
|
+
if (ua.indexOf(constants.BLOCKED_WS[i]) !== -1) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
/** Device RAM as the API wants it ("4 GB"). Chromium only; empty elsewhere. */
|
|
18
|
+
function getRam() {
|
|
19
|
+
var gb = navigator.deviceMemory;
|
|
20
|
+
return typeof gb === 'number' && gb > 0 ? gb + ' GB' : ''; // no i18n
|
|
21
|
+
}
|
|
22
|
+
function getConnectionType() {
|
|
23
|
+
var connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection || {};
|
|
24
|
+
return connection.effectiveType || connection.type || ''; // no i18n
|
|
25
|
+
}
|
|
26
|
+
function getNetworkStatus() {
|
|
27
|
+
return window.navigator.onLine ? 0 : -1;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The battery as a whole percentage, or null where the browser will not say.
|
|
31
|
+
*
|
|
32
|
+
* feedbackWebSDK types `battery` as an int and the console shows it next to a report, which is
|
|
33
|
+
* what makes "it died while I was filling this in" legible. The Battery Status API is behind a
|
|
34
|
+
* promise and is absent in Firefox and Safari entirely, so this answers null rather than 0 -
|
|
35
|
+
* a real 0% and "no answer" are different things, and only one of them belongs in a report.
|
|
36
|
+
*/
|
|
37
|
+
function getBatteryPercent() {
|
|
38
|
+
try {
|
|
39
|
+
var getBattery = navigator.getBattery;
|
|
40
|
+
if (typeof getBattery !== 'function') { // no i18n
|
|
41
|
+
return Promise.resolve(null);
|
|
42
|
+
}
|
|
43
|
+
return getBattery.call(navigator).then(function (battery) {
|
|
44
|
+
var level = battery && typeof battery.level === 'number' ? battery.level : -1; // no i18n
|
|
45
|
+
return level >= 0 && level <= 1 ? Math.round(level * 100) : null;
|
|
46
|
+
}, function () {
|
|
47
|
+
return null;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
return Promise.resolve(null);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function getOrientation() {
|
|
55
|
+
var orientation = (window.screen && window.screen.orientation && window.screen.orientation.type) || ''; // no i18n
|
|
56
|
+
if (utils.includes(orientation, 'portrait-primary')) { // no i18n
|
|
57
|
+
return 0;
|
|
58
|
+
}
|
|
59
|
+
if (utils.includes(orientation, 'landscape-primary')) { // no i18n
|
|
60
|
+
return 1;
|
|
61
|
+
}
|
|
62
|
+
if (utils.includes(orientation, 'landscape-secondary')) { // no i18n
|
|
63
|
+
return 2;
|
|
64
|
+
}
|
|
65
|
+
if (utils.includes(orientation, 'portrait-secondary')) { // no i18n
|
|
66
|
+
return 3;
|
|
67
|
+
}
|
|
68
|
+
return -1;
|
|
69
|
+
}
|
|
70
|
+
function getDevice() {
|
|
71
|
+
var ua = navigator.userAgent;
|
|
72
|
+
if (/Windows/i.test(ua)) {
|
|
73
|
+
return (/Phone/.test(ua) || /WPDesktop/.test(ua)) ? 'Windows Phone' : 'Windows'; // no i18n
|
|
74
|
+
}
|
|
75
|
+
if (/iPad/.test(ua)) {
|
|
76
|
+
return 'iPad'; // no i18n
|
|
77
|
+
}
|
|
78
|
+
if (/iPod/.test(ua)) {
|
|
79
|
+
return 'iPod Touch'; // no i18n
|
|
80
|
+
}
|
|
81
|
+
if (/iPhone/.test(ua)) {
|
|
82
|
+
return 'iPhone'; // no i18n
|
|
83
|
+
}
|
|
84
|
+
if (/(BlackBerry|PlayBook|BB10)/i.test(ua)) {
|
|
85
|
+
return 'BlackBerry'; // no i18n
|
|
86
|
+
}
|
|
87
|
+
if (/Android/.test(ua)) {
|
|
88
|
+
return 'Android'; // no i18n
|
|
89
|
+
}
|
|
90
|
+
if (/Mac/i.test(ua)) {
|
|
91
|
+
return 'Mac'; // no i18n
|
|
92
|
+
}
|
|
93
|
+
if (/Linux/.test(ua)) {
|
|
94
|
+
return 'Linux'; // no i18n
|
|
95
|
+
}
|
|
96
|
+
if (/CrOS/.test(ua)) {
|
|
97
|
+
return 'Chrome'; // no i18n
|
|
98
|
+
}
|
|
99
|
+
return ''; // no i18n
|
|
100
|
+
}
|
|
101
|
+
function getOS() {
|
|
102
|
+
var ua = navigator.userAgent;
|
|
103
|
+
if (/Windows/i.test(ua)) {
|
|
104
|
+
return (/Phone/.test(ua) || /WPDesktop/.test(ua)) ? 'Windows Phone' : 'Windows'; // no i18n
|
|
105
|
+
}
|
|
106
|
+
if (/(iPhone|iPad|iPod)/.test(ua)) {
|
|
107
|
+
return 'iOS'; // no i18n
|
|
108
|
+
}
|
|
109
|
+
if (/Android/.test(ua)) {
|
|
110
|
+
return 'Android'; // no i18n
|
|
111
|
+
}
|
|
112
|
+
if (/(BlackBerry|PlayBook|BB10)/i.test(ua)) {
|
|
113
|
+
return 'BlackBerry'; // no i18n
|
|
114
|
+
}
|
|
115
|
+
if (/Mac/i.test(ua)) {
|
|
116
|
+
return 'Mac OS X'; // no i18n
|
|
117
|
+
}
|
|
118
|
+
if (/Linux/.test(ua)) {
|
|
119
|
+
return 'Linux'; // no i18n
|
|
120
|
+
}
|
|
121
|
+
if (/CrOS/.test(ua)) {
|
|
122
|
+
return 'Chrome OS'; // no i18n
|
|
123
|
+
}
|
|
124
|
+
return ''; // no i18n
|
|
125
|
+
}
|
|
126
|
+
function getBrowser() {
|
|
127
|
+
var ua = navigator.userAgent;
|
|
128
|
+
var vendor = navigator.vendor || ''; // no i18n // vendor is undefined for at least IE9
|
|
129
|
+
var opera = window.opera;
|
|
130
|
+
if (opera || utils.includes(ua, ' OPR/')) { // no i18n
|
|
131
|
+
return (utils.includes(ua, 'Mini')) ? 'Opera Mini' : 'Opera'; // no i18n
|
|
132
|
+
}
|
|
133
|
+
if (/(BlackBerry|PlayBook|BB10)/i.test(ua)) {
|
|
134
|
+
return 'BlackBerry'; // no i18n
|
|
135
|
+
}
|
|
136
|
+
if (utils.includes(ua, 'IEMobile') || utils.includes(ua, 'WPDesktop')) { // no i18n
|
|
137
|
+
return 'Internet Explorer Mobile'; // no i18n
|
|
138
|
+
}
|
|
139
|
+
if (utils.includes(ua, 'SamsungBrowser/')) { // no i18n
|
|
140
|
+
return 'Samsung Internet'; // no i18n
|
|
141
|
+
}
|
|
142
|
+
if (utils.includes(ua, 'Edge') || utils.includes(ua, 'Edg/')) { // no i18n
|
|
143
|
+
return 'Microsoft Edge'; // no i18n
|
|
144
|
+
}
|
|
145
|
+
if (utils.includes(ua, 'FBIOS')) { // no i18n
|
|
146
|
+
return 'Facebook Mobile'; // no i18n
|
|
147
|
+
}
|
|
148
|
+
if (utils.includes(ua, 'Chrome')) { // no i18n
|
|
149
|
+
if (typeof ulaa == 'object') {
|
|
150
|
+
return 'Ulaa'; // no i18n
|
|
151
|
+
}
|
|
152
|
+
else if (window.navigator.brave != undefined && window.navigator.brave.isBrave.name == "isBrave") { // no i18n
|
|
153
|
+
return 'Brave'; // no i18n
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
return 'Chrome'; // no i18n
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (utils.includes(ua, 'CriOS')) { // no i18n
|
|
160
|
+
return 'Chrome iOS'; // no i18n
|
|
161
|
+
}
|
|
162
|
+
if (utils.includes(ua, 'UCWEB') || utils.includes(ua, 'UCBrowser')) { // no i18n
|
|
163
|
+
return 'UC Browser'; // no i18n
|
|
164
|
+
}
|
|
165
|
+
if (utils.includes(ua, 'FxiOS')) { // no i18n
|
|
166
|
+
return 'Firefox iOS'; // no i18n
|
|
167
|
+
}
|
|
168
|
+
if (utils.includes(vendor, 'Apple')) { // no i18n
|
|
169
|
+
return (utils.includes(ua, 'Mobile')) ? 'Mobile Safari' : 'Safari'; // no i18n
|
|
170
|
+
}
|
|
171
|
+
if (utils.includes(ua, 'Android')) { // no i18n
|
|
172
|
+
return 'Android Mobile'; // no i18n
|
|
173
|
+
}
|
|
174
|
+
if (utils.includes(ua, 'Konqueror')) { // no i18n
|
|
175
|
+
return 'Konqueror'; // no i18n
|
|
176
|
+
}
|
|
177
|
+
if (utils.includes(ua, 'Firefox')) { // no i18n
|
|
178
|
+
return 'Firefox'; // no i18n
|
|
179
|
+
}
|
|
180
|
+
if (utils.includes(ua, 'MSIE') || utils.includes(ua, 'Trident/')) { // no i18n
|
|
181
|
+
return 'Internet Explorer'; // no i18n
|
|
182
|
+
}
|
|
183
|
+
if (utils.includes(ua, 'Gecko')) { // no i18n
|
|
184
|
+
return 'Mozilla'; // no i18n
|
|
185
|
+
}
|
|
186
|
+
return ''; // no i18n
|
|
187
|
+
}
|
|
188
|
+
function getBrowserVersion() {
|
|
189
|
+
var browser = getBrowser();
|
|
190
|
+
var ua = navigator.userAgent;
|
|
191
|
+
var versionRegexs = {
|
|
192
|
+
'Internet Explorer Mobile': /rv:(\d+(\.\d+)?)/, // no i18n
|
|
193
|
+
'Microsoft Edge': /Edg\/(\d+(\.\d+)?)/, // no i18n
|
|
194
|
+
'Chrome': /Chrome\/(\d+(\.\d+)?)/, // no i18n
|
|
195
|
+
'Brave': /Chrome\/(\d+(\.\d+)?)/, // no i18n
|
|
196
|
+
'Chrome iOS': /CriOS\/(\d+(\.\d+)?)/, // no i18n
|
|
197
|
+
'UC Browser': /(UCBrowser|UCWEB)\/(\d+(\.\d+)?)/, // no i18n
|
|
198
|
+
'Safari': /Version\/(\d+(\.\d+)?)/, // no i18n
|
|
199
|
+
'Mobile Safari': /Version\/(\d+(\.\d+)?)/, // no i18n
|
|
200
|
+
'Opera': /(Opera|OPR)\/(\d+(\.\d+)?)/, // no i18n
|
|
201
|
+
'Firefox': /Firefox\/(\d+(\.\d+)?)/, // no i18n
|
|
202
|
+
'Firefox iOS': /FxiOS\/(\d+(\.\d+)?)/, // no i18n
|
|
203
|
+
'Konqueror': /Konqueror:(\d+(\.\d+)?)/, // no i18n
|
|
204
|
+
'BlackBerry': /BlackBerry (\d+(\.\d+)?)/, // no i18n
|
|
205
|
+
'Android Mobile': /android\s(\d+(\.\d+)?)/, // no i18n
|
|
206
|
+
'Internet Explorer': /(rv:|MSIE )(\d+(\.\d+)?)/, // no i18n
|
|
207
|
+
'Mozilla': /rv:(\d+(\.\d+)?)/ // no i18n
|
|
208
|
+
};
|
|
209
|
+
// Check for Ulaa browser version
|
|
210
|
+
if (browser === 'Ulaa' && typeof ulaa === 'object') { // no i18n
|
|
211
|
+
return ulaa.getVersion();
|
|
212
|
+
}
|
|
213
|
+
var regex = versionRegexs[browser];
|
|
214
|
+
if (regex === undefined) {
|
|
215
|
+
return ''; // no i18n
|
|
216
|
+
}
|
|
217
|
+
var matches = ua.match(regex);
|
|
218
|
+
if (!matches) {
|
|
219
|
+
return ''; // no i18n
|
|
220
|
+
}
|
|
221
|
+
return parseFloat(matches[matches.length - 2]);
|
|
222
|
+
}
|
|
223
|
+
function getReferringURL() {
|
|
224
|
+
var split = String(window.location.href || '').split(window.location.pathname); // no i18n
|
|
225
|
+
if (split.length >= 2) {
|
|
226
|
+
return split[1].length > 500 ? split[1].substring(0, 500) : split[1];
|
|
227
|
+
}
|
|
228
|
+
return ''; // no i18n
|
|
229
|
+
}
|
|
230
|
+
function getTimeZone() {
|
|
231
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
232
|
+
}
|
|
233
|
+
/** True for crawlers and non-browser environments; the SDK does nothing for them. */
|
|
234
|
+
function is_apptics_disabled() {
|
|
235
|
+
return typeof navigator === 'undefined' || isBlockedWS(navigator.userAgent || ''); // no i18n
|
|
236
|
+
}
|
|
237
|
+
/** Pure DNT check (no side effects). consent.hasDoNotTrackEnabled() applies NO_TRACKING. */
|
|
238
|
+
function isDntOn() {
|
|
239
|
+
var nav = window.navigator || {};
|
|
240
|
+
var dntValues = [true, 1, '1', 'yes']; // no i18n
|
|
241
|
+
return [nav.doNotTrack, nav.msDoNotTrack, window.doNotTrack].some(function (dntValue) {
|
|
242
|
+
return utils.includes(dntValues, dntValue);
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
/** The console snippet's config (window.appticssettings._defaultoptions), if the page defines one. */
|
|
246
|
+
function getSnippetOptions() {
|
|
247
|
+
if (typeof window === 'undefined' || !window.appticssettings) { // no i18n
|
|
248
|
+
return undefined;
|
|
249
|
+
}
|
|
250
|
+
return window.appticssettings._defaultoptions;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
exports.getBatteryPercent = getBatteryPercent;
|
|
254
|
+
exports.getBrowser = getBrowser;
|
|
255
|
+
exports.getBrowserVersion = getBrowserVersion;
|
|
256
|
+
exports.getConnectionType = getConnectionType;
|
|
257
|
+
exports.getDevice = getDevice;
|
|
258
|
+
exports.getNetworkStatus = getNetworkStatus;
|
|
259
|
+
exports.getOS = getOS;
|
|
260
|
+
exports.getOrientation = getOrientation;
|
|
261
|
+
exports.getRam = getRam;
|
|
262
|
+
exports.getReferringURL = getReferringURL;
|
|
263
|
+
exports.getSnippetOptions = getSnippetOptions;
|
|
264
|
+
exports.getTimeZone = getTimeZone;
|
|
265
|
+
exports.isBlockedWS = isBlockedWS;
|
|
266
|
+
exports.isDntOn = isDntOn;
|
|
267
|
+
exports.is_apptics_disabled = is_apptics_disabled;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const FRAMEWORK_ID = 5996;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
// Generated by scripts/register-version.mjs — do not edit by hand.
|
|
5
|
+
// The framework id Apptics issued for this SDK, from POST /sdk/web/v1/framework/addversion
|
|
6
|
+
// (version 2.0.0-beta, platform Browser). Regenerated on every npm pack.
|
|
7
|
+
const FRAMEWORK_ID = 5996;
|
|
8
|
+
|
|
9
|
+
exports.FRAMEWORK_ID = FRAMEWORK_ID;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var state = require('./state.js');
|
|
5
|
+
var logger = require('./logger.js');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Calls that run immediately while storage is loading. Everything else is buffered and replayed in order.
|
|
9
|
+
* getUser / getTrackingStatus answer from defaults until then; sendFeedback waits for ready() itself.
|
|
10
|
+
* The two log collectors run now so an entry keeps the time it actually happened.
|
|
11
|
+
*/
|
|
12
|
+
const RUN_BEFORE_READY = {
|
|
13
|
+
'Apptics.init': true, ready: true, reset: true, getUser: true, getTrackingStatus: true, sendFeedback: true,
|
|
14
|
+
addFeedbackLog: true, addDiagnosticsInfo: true,
|
|
15
|
+
// a switch, so it takes effect in order with the lines logged after it
|
|
16
|
+
'AppticsLogger.enable': true, 'AppticsLogger.disable': true, 'AppticsLogger.isEnabled': true,
|
|
17
|
+
// a switch, and a call that hands back the id endTrackApi needs: neither can wait in a queue
|
|
18
|
+
'AppticsApiTracker.configure': true, 'AppticsApiTracker.startTrackApi': true,
|
|
19
|
+
// these wait for ready() themselves, and a queued call would hand back undefined, not a Promise
|
|
20
|
+
'AppticsRemoteConfig.fetchValue': true, 'AppticsRemoteConfig.fetchValues': true,
|
|
21
|
+
'AppticsRemoteConfig.setFallbackWithOfflineValue': true, 'AppticsRemoteConfig.setCustomConditionValue': true,
|
|
22
|
+
enableDebug: true, disableDebug: true,
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Calls that record or send something, and so are lost when the SDK hasn't started. Calls that only
|
|
26
|
+
* set a switch or read a value (enableDebug, AppticsLogger.enable, addFeedbackLog, getUser, …)
|
|
27
|
+
* work without Apptics.init() and are not listed.
|
|
28
|
+
*/
|
|
29
|
+
const NEEDS_INIT = {
|
|
30
|
+
'AppticsEvents.addEvent': true, 'AppticsScreenTracker.inScreen': true, 'AppticsScreenTracker.outScreen': true,
|
|
31
|
+
'AppticsApiTracker.endTrackApi': true, AppticsTrackError: true, AppticsSetUser: true, flush: true,
|
|
32
|
+
AppticsLogger: true, sendFeedback: true, 'AppticsRemoteConfig.fetchValue': true,
|
|
33
|
+
'AppticsRemoteConfig.fetchValues': true,
|
|
34
|
+
};
|
|
35
|
+
/** How a call is named in a message: `AppticsEvents.addEvent` as it is, `flush` as `apptics.flush`. */
|
|
36
|
+
function publicName(name) {
|
|
37
|
+
return name.indexOf('Apptics') === 0 ? name : 'apptics.' + name; // no i18n
|
|
38
|
+
}
|
|
39
|
+
/** Warned once per page: one line is a clue, a line per call would bury the console. */
|
|
40
|
+
var warnedNotStarted = false;
|
|
41
|
+
/** Public calls never throw into the host app, and are buffered until start-up finishes. */
|
|
42
|
+
function guard(name, fn) {
|
|
43
|
+
const guarded = function (...args) {
|
|
44
|
+
// not started: init() wasn't called, or it refused the config. Say so whether or not
|
|
45
|
+
// console_log is on, since console_log itself is only switched on by init()
|
|
46
|
+
if (!state._ZAP._initialised && NEEDS_INIT[name] && !warnedNotStarted) {
|
|
47
|
+
warnedNotStarted = true;
|
|
48
|
+
logger.warnAlways(publicName(name) + ': the SDK has not started, so this call is ignored. Call Apptics.init() first, and check its warnings if you did.'); // no i18n
|
|
49
|
+
}
|
|
50
|
+
if (state._ZAP._initialised && !state._ZAP._ready && !RUN_BEFORE_READY[name]) {
|
|
51
|
+
state._ZAP._pending.push(function () {
|
|
52
|
+
guarded(...args);
|
|
53
|
+
});
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
return fn(...args);
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
// a public call swallowing its own exception into a debug-gated console line is how
|
|
61
|
+
// "the modal does not open" looks from the outside: nothing happens, nothing is said.
|
|
62
|
+
// The app is still shielded - the call returns undefined rather than throwing - but
|
|
63
|
+
// the failure is now visible without debug, and reaches the remote logger
|
|
64
|
+
logger.warnAlways(publicName(name) + ' failed:', err); // no i18n
|
|
65
|
+
logger.logFailure(name, err);
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
return guarded;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
exports.guard = guard;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { CallSite } from './callsite.js';
|
|
2
|
+
import type { DeviceInfo, ServerResult } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Late-bound calls from lower modules up to the modules above them (see spec §5). device.ts and
|
|
5
|
+
* remotelog/index.ts assign these when they are evaluated; the defaults only run if that module
|
|
6
|
+
* was never imported.
|
|
7
|
+
*/
|
|
8
|
+
export declare const hooks: {
|
|
9
|
+
updateDevice: (deviceInfo: DeviceInfo) => Promise<ServerResult>;
|
|
10
|
+
refreshDeviceInfo: () => void;
|
|
11
|
+
/** Set by remotelog/index.ts. Here, not imported, so the logger doesn't depend on the sender. */
|
|
12
|
+
remoteLog: (module: string, message: unknown, site?: CallSite) => void;
|
|
13
|
+
/**
|
|
14
|
+
* Set by feedback/controls.ts: the user picked in the feedback form, or null for anonymous.
|
|
15
|
+
* Here so transport can read the choice without importing the modal.
|
|
16
|
+
*/
|
|
17
|
+
feedbackUser: () => {
|
|
18
|
+
userid: string;
|
|
19
|
+
groupid: string;
|
|
20
|
+
} | null;
|
|
21
|
+
/**
|
|
22
|
+
* Set by heatmap/send.ts. Here so the scheduler can flush heatmap records without importing
|
|
23
|
+
* the module — an app that never imports the heatmap entry keeps the default no-op.
|
|
24
|
+
*/
|
|
25
|
+
sendHeatmaps: (forget?: boolean) => Promise<void>;
|
|
26
|
+
/** Set by heatmap/track.ts, so init() and reset() can switch capture without importing it. */
|
|
27
|
+
enableHeatmap: (status?: boolean) => void;
|
|
28
|
+
/** Set by heatmap/track.ts: clears what this visit recorded, so the cap starts again. */
|
|
29
|
+
resetHeatmap: () => void;
|
|
30
|
+
/** Set by remoteconfig/fetch.ts, so reset() can forget the rule set without importing it. */
|
|
31
|
+
resetRemoteConfig: () => void;
|
|
32
|
+
/**
|
|
33
|
+
* Set by engagement/auto-screen.ts: the app called inScreen() itself. Here because
|
|
34
|
+
* auto-screen records through track.ts, so track.ts cannot import it back.
|
|
35
|
+
*/
|
|
36
|
+
screenTrackedByApp: () => void;
|
|
37
|
+
/** Set by remoteconfig/fetch.ts: start-up has finished, so remote config fetches its values. */
|
|
38
|
+
remoteConfigStarted: () => void;
|
|
39
|
+
/** Set by remoteconfig/fetch.ts: AppticsSetUser changed who this is, so conditions on the user re-apply. */
|
|
40
|
+
remoteConfigUserChanged: () => void;
|
|
41
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Late-bound calls from lower modules up to the modules above them (see spec §5). device.ts and
|
|
6
|
+
* remotelog/index.ts assign these when they are evaluated; the defaults only run if that module
|
|
7
|
+
* was never imported.
|
|
8
|
+
*/
|
|
9
|
+
const hooks = {
|
|
10
|
+
updateDevice: () => Promise.reject('apptics: device module not loaded'), // no i18n
|
|
11
|
+
refreshDeviceInfo: () => { },
|
|
12
|
+
remoteLog: () => { },
|
|
13
|
+
feedbackUser: () => null,
|
|
14
|
+
sendHeatmaps: () => Promise.resolve(),
|
|
15
|
+
enableHeatmap: () => { },
|
|
16
|
+
resetHeatmap: () => { },
|
|
17
|
+
resetRemoteConfig: () => { },
|
|
18
|
+
screenTrackedByApp: () => { },
|
|
19
|
+
remoteConfigStarted: () => { },
|
|
20
|
+
remoteConfigUserChanged: () => { },
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
exports.hooks = hooks;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const Console: {
|
|
2
|
+
log: (...args: unknown[]) => void;
|
|
3
|
+
warn: (...args: unknown[]) => void;
|
|
4
|
+
error: (...args: unknown[]) => void;
|
|
5
|
+
info: (...args: unknown[]) => void;
|
|
6
|
+
dir(arg: unknown): void;
|
|
7
|
+
};
|
|
8
|
+
/** Warnings the integrator must see even with debug off (e.g. missing required config). */
|
|
9
|
+
export declare function warnAlways(...args: unknown[]): void;
|
|
10
|
+
/**
|
|
11
|
+
* A failure inside one of the SDK's own modules: logged to the console as usual, and sent to
|
|
12
|
+
* console/addlog so it can be read back from the Apptics console when the SDK misbehaves in the
|
|
13
|
+
* wild. `module` is one of AP_LOG_MODULE's values. The remote half does nothing until
|
|
14
|
+
* the remotelog module has been loaded and its own switch allows it.
|
|
15
|
+
*/
|
|
16
|
+
export declare function logFailure(module: string, ...args: unknown[]): void;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var state = require('./state.js');
|
|
5
|
+
var hooks = require('./hooks.js');
|
|
6
|
+
var utils = require('./utils.js');
|
|
7
|
+
var callsite = require('./callsite.js');
|
|
8
|
+
|
|
9
|
+
const APConsole = typeof console !== 'undefined' ? console : null;
|
|
10
|
+
function gated(method) {
|
|
11
|
+
return function (...args) {
|
|
12
|
+
if (state._ZAP._config.debug && APConsole) {
|
|
13
|
+
try {
|
|
14
|
+
APConsole[method].apply(APConsole, args);
|
|
15
|
+
}
|
|
16
|
+
catch (err) {
|
|
17
|
+
utils.each(args, function (arg) {
|
|
18
|
+
APConsole[method](arg);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
// Console override
|
|
25
|
+
const Console = {
|
|
26
|
+
log: gated('log'),
|
|
27
|
+
warn: gated('warn'),
|
|
28
|
+
error: gated('error'),
|
|
29
|
+
info: gated('info'),
|
|
30
|
+
dir(arg) {
|
|
31
|
+
if (state._ZAP._config.debug && APConsole) {
|
|
32
|
+
APConsole.dir(arg);
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
/** Warnings the integrator must see even with debug off (e.g. missing required config). */
|
|
37
|
+
function warnAlways(...args) {
|
|
38
|
+
if (APConsole)
|
|
39
|
+
APConsole.warn(...args);
|
|
40
|
+
}
|
|
41
|
+
function safeJson(value) {
|
|
42
|
+
try {
|
|
43
|
+
return JSON.stringify(value) || String(value);
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
return String(value);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* A failure inside one of the SDK's own modules: logged to the console as usual, and sent to
|
|
51
|
+
* console/addlog so it can be read back from the Apptics console when the SDK misbehaves in the
|
|
52
|
+
* wild. `module` is one of AP_LOG_MODULE's values. The remote half does nothing until
|
|
53
|
+
* the remotelog module has been loaded and its own switch allows it.
|
|
54
|
+
*/
|
|
55
|
+
function logFailure(module, ...args) {
|
|
56
|
+
Console.error.apply(null, args);
|
|
57
|
+
hooks.hooks.remoteLog(module, args.map(function (arg) {
|
|
58
|
+
if (arg instanceof Error) {
|
|
59
|
+
return arg.stack || (arg.name + ': ' + arg.message); // no i18n
|
|
60
|
+
}
|
|
61
|
+
return typeof arg === 'string' ? arg : safeJson(arg); // no i18n
|
|
62
|
+
}).join(' '), siteOf(args)); // no i18n
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Where to say the failure happened. An Error knows where it was thrown, which is the place
|
|
66
|
+
* worth reporting; the alternative is where it was caught, which is usually a catch block three
|
|
67
|
+
* modules away. Only a frame we could actually read counts, so an Error with no usable stack
|
|
68
|
+
* falls through to logFailure's own caller.
|
|
69
|
+
*/
|
|
70
|
+
function siteOf(args) {
|
|
71
|
+
for (var i = 0; i < args.length; i++) {
|
|
72
|
+
var arg = args[i];
|
|
73
|
+
if (arg instanceof Error) {
|
|
74
|
+
var thrownAt = callsite.callSiteFromStack(arg.stack, 0);
|
|
75
|
+
if (thrownAt.linenumber > 0) {
|
|
76
|
+
return thrownAt;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
// past siteOf and logFailure, to whoever reported the failure
|
|
81
|
+
return callsite.callSite(2);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
exports.Console = Console;
|
|
85
|
+
exports.logFailure = logFailure;
|
|
86
|
+
exports.warnAlways = warnAlways;
|