@zoho_apptics/apptics-js-sdk 2.0.0-beta → 2.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +111 -5
- package/README.md +399 -300
- package/dist/apptics.esm.min.js +2 -2
- package/dist/apptics.esm.min.js.map +1 -1
- package/dist/apptics.min.js +2 -2
- package/dist/apptics.min.js.map +1 -1
- package/dist/chunks/lifecycle-VYr43KcB.min.js +3 -0
- package/dist/chunks/lifecycle-VYr43KcB.min.js.map +1 -0
- package/dist/cjs/auto-init.d.ts +3 -3
- package/dist/cjs/auto-init.js +1 -1
- package/dist/cjs/core/attempts.js +1 -1
- package/dist/cjs/core/batch.js +2 -1
- package/dist/cjs/core/callsite.d.ts +6 -0
- package/dist/cjs/core/callsite.js +25 -3
- package/dist/cjs/core/consent.d.ts +5 -1
- package/dist/cjs/core/consent.js +8 -6
- package/dist/cjs/core/constants.d.ts +35 -10
- package/dist/cjs/core/constants.js +31 -15
- package/dist/cjs/core/db.d.ts +12 -4
- package/dist/cjs/core/db.js +167 -34
- package/dist/cjs/core/debug.js +1 -1
- package/dist/cjs/core/env.js +1 -1
- package/dist/cjs/core/framework-id.d.ts +1 -1
- package/dist/cjs/core/framework-id.js +3 -3
- package/dist/cjs/core/guard.d.ts +9 -0
- package/dist/cjs/core/guard.js +27 -13
- package/dist/cjs/core/hooks.d.ts +2 -4
- package/dist/cjs/core/hooks.js +2 -3
- package/dist/cjs/core/locks.d.ts +9 -0
- package/dist/cjs/core/locks.js +22 -0
- package/dist/cjs/core/logger.d.ts +3 -4
- package/dist/cjs/core/logger.js +4 -40
- package/dist/cjs/core/state.d.ts +3 -2
- package/dist/cjs/core/state.js +2 -2
- package/dist/cjs/core/storage.d.ts +20 -5
- package/dist/cjs/core/storage.js +115 -17
- package/dist/cjs/core/stylesheet.d.ts +8 -0
- package/dist/cjs/core/stylesheet.js +29 -0
- package/dist/cjs/core/transport.d.ts +2 -0
- package/dist/cjs/core/transport.js +19 -4
- package/dist/cjs/core/utils.js +1 -1
- package/dist/cjs/core/validate.js +2 -2
- package/dist/cjs/device/appversion.d.ts +1 -6
- package/dist/cjs/device/appversion.js +13 -1
- package/dist/cjs/device/index.d.ts +11 -0
- package/dist/cjs/device/index.js +120 -20
- package/dist/cjs/engagement/api-rules.d.ts +32 -67
- package/dist/cjs/engagement/api-rules.js +144 -157
- package/dist/cjs/engagement/auto-api.js +2 -2
- package/dist/cjs/engagement/auto-screen.d.ts +2 -0
- package/dist/cjs/engagement/auto-screen.js +67 -3
- package/dist/cjs/engagement/defined-events.js +1 -1
- package/dist/cjs/engagement/send.js +6 -1
- package/dist/cjs/engagement/session.d.ts +12 -3
- package/dist/cjs/engagement/session.js +161 -25
- package/dist/cjs/engagement/track.js +45 -20
- package/dist/cjs/errors/send.js +1 -1
- package/dist/cjs/errors/track.d.ts +1 -1
- package/dist/cjs/errors/track.js +46 -6
- package/dist/cjs/feedback/controls.d.ts +6 -0
- package/dist/cjs/feedback/controls.js +31 -1
- package/dist/cjs/feedback/index.d.ts +8 -7
- package/dist/cjs/feedback/index.js +32 -13
- package/dist/cjs/feedback/logs.d.ts +10 -5
- package/dist/cjs/feedback/logs.js +52 -13
- package/dist/cjs/feedback/quartz.d.ts +18 -0
- package/dist/cjs/feedback/quartz.js +105 -0
- package/dist/cjs/feedback/send.d.ts +3 -0
- package/dist/cjs/feedback/send.js +28 -3
- package/dist/cjs/feedback/styles.d.ts +10 -0
- package/dist/cjs/feedback/styles.js +8 -0
- package/dist/cjs/feedback/template.d.ts +1 -1
- package/dist/cjs/feedback/template.js +12 -12
- package/dist/cjs/feedback/ui.d.ts +14 -6
- package/dist/cjs/feedback/ui.js +126 -48
- package/dist/cjs/heatmap/send.js +1 -1
- package/dist/cjs/heatmap/track.d.ts +1 -1
- package/dist/cjs/heatmap/track.js +87 -16
- package/dist/cjs/index.d.ts +17 -63
- package/dist/cjs/index.js +104 -92
- package/dist/cjs/lifecycle.d.ts +8 -1
- package/dist/cjs/lifecycle.js +258 -62
- package/dist/cjs/remoteconfig/country.d.ts +4 -0
- package/dist/cjs/remoteconfig/country.js +73 -0
- package/dist/cjs/remoteconfig/custom.d.ts +7 -7
- package/dist/cjs/remoteconfig/custom.js +31 -51
- package/dist/cjs/remoteconfig/evaluate.d.ts +3 -3
- package/dist/cjs/remoteconfig/evaluate.js +56 -43
- package/dist/cjs/remoteconfig/fetch.d.ts +3 -3
- package/dist/cjs/remoteconfig/fetch.js +9 -23
- package/dist/cjs/remoteconfig/index.d.ts +10 -8
- package/dist/cjs/remoteconfig/index.js +65 -39
- package/dist/cjs/remoteconfig/store.js +1 -1
- package/dist/cjs/remoteconfig/tz-countries.d.ts +8 -0
- package/dist/cjs/remoteconfig/tz-countries.js +13 -0
- package/dist/cjs/remotelog/gate.d.ts +2 -11
- package/dist/cjs/remotelog/gate.js +9 -35
- package/dist/cjs/remotelog/index.d.ts +4 -21
- package/dist/cjs/remotelog/logger.d.ts +11 -17
- package/dist/cjs/remotelog/logger.js +30 -58
- package/dist/cjs/remotelog/send.js +10 -10
- package/dist/cjs/remotelogger/index.d.ts +12 -0
- package/dist/cjs/remotelogger/index.js +18 -0
- package/dist/cjs/scheduler.js +2 -2
- package/dist/cjs/types.d.ts +155 -82
- package/dist/cjs/user/index.js +11 -6
- package/dist/esm/auto-init.d.ts +3 -3
- package/dist/esm/auto-init.js +1 -1
- package/dist/esm/core/attempts.js +1 -1
- package/dist/esm/core/batch.js +2 -1
- package/dist/esm/core/callsite.d.ts +6 -0
- package/dist/esm/core/callsite.js +25 -4
- package/dist/esm/core/consent.d.ts +5 -1
- package/dist/esm/core/consent.js +9 -7
- package/dist/esm/core/constants.d.ts +35 -10
- package/dist/esm/core/constants.js +30 -15
- package/dist/esm/core/db.d.ts +12 -4
- package/dist/esm/core/db.js +164 -35
- package/dist/esm/core/debug.js +1 -1
- package/dist/esm/core/env.js +1 -1
- package/dist/esm/core/framework-id.d.ts +1 -1
- package/dist/esm/core/framework-id.js +3 -3
- package/dist/esm/core/guard.d.ts +9 -0
- package/dist/esm/core/guard.js +27 -14
- package/dist/esm/core/hooks.d.ts +2 -4
- package/dist/esm/core/hooks.js +2 -3
- package/dist/esm/core/locks.d.ts +9 -0
- package/dist/esm/core/locks.js +20 -0
- package/dist/esm/core/logger.d.ts +3 -4
- package/dist/esm/core/logger.js +4 -40
- package/dist/esm/core/state.d.ts +3 -2
- package/dist/esm/core/state.js +2 -2
- package/dist/esm/core/storage.d.ts +20 -5
- package/dist/esm/core/storage.js +113 -18
- package/dist/esm/core/stylesheet.d.ts +8 -0
- package/dist/esm/core/stylesheet.js +27 -0
- package/dist/esm/core/transport.d.ts +2 -0
- package/dist/esm/core/transport.js +19 -5
- package/dist/esm/core/utils.js +1 -1
- package/dist/esm/core/validate.js +2 -2
- package/dist/esm/device/appversion.d.ts +1 -6
- package/dist/esm/device/appversion.js +13 -2
- package/dist/esm/device/index.d.ts +11 -0
- package/dist/esm/device/index.js +123 -24
- package/dist/esm/engagement/api-rules.d.ts +32 -67
- package/dist/esm/engagement/api-rules.js +143 -155
- package/dist/esm/engagement/auto-api.js +3 -3
- package/dist/esm/engagement/auto-screen.d.ts +2 -0
- package/dist/esm/engagement/auto-screen.js +67 -4
- package/dist/esm/engagement/defined-events.js +1 -1
- package/dist/esm/engagement/send.js +6 -1
- package/dist/esm/engagement/session.d.ts +12 -3
- package/dist/esm/engagement/session.js +162 -29
- package/dist/esm/engagement/track.js +52 -27
- package/dist/esm/errors/send.js +1 -1
- package/dist/esm/errors/track.d.ts +1 -1
- package/dist/esm/errors/track.js +46 -6
- package/dist/esm/feedback/controls.d.ts +6 -0
- package/dist/esm/feedback/controls.js +31 -2
- package/dist/esm/feedback/index.d.ts +8 -7
- package/dist/esm/feedback/index.js +34 -13
- package/dist/esm/feedback/logs.d.ts +10 -5
- package/dist/esm/feedback/logs.js +54 -15
- package/dist/esm/feedback/quartz.d.ts +18 -0
- package/dist/esm/feedback/quartz.js +99 -0
- package/dist/esm/feedback/send.d.ts +3 -0
- package/dist/esm/feedback/send.js +28 -5
- package/dist/esm/feedback/styles.d.ts +10 -0
- package/dist/esm/feedback/styles.js +4 -0
- package/dist/esm/feedback/template.d.ts +1 -1
- package/dist/esm/feedback/template.js +12 -12
- package/dist/esm/feedback/ui.d.ts +14 -6
- package/dist/esm/feedback/ui.js +126 -49
- package/dist/esm/heatmap/send.js +1 -1
- package/dist/esm/heatmap/track.d.ts +1 -1
- package/dist/esm/heatmap/track.js +87 -16
- package/dist/esm/index.d.ts +17 -63
- package/dist/esm/index.js +108 -80
- package/dist/esm/lifecycle.d.ts +8 -1
- package/dist/esm/lifecycle.js +266 -71
- package/dist/esm/remoteconfig/country.d.ts +4 -0
- package/dist/esm/remoteconfig/country.js +70 -0
- package/dist/esm/remoteconfig/custom.d.ts +7 -7
- package/dist/esm/remoteconfig/custom.js +32 -52
- package/dist/esm/remoteconfig/evaluate.d.ts +3 -3
- package/dist/esm/remoteconfig/evaluate.js +57 -44
- package/dist/esm/remoteconfig/fetch.d.ts +3 -3
- package/dist/esm/remoteconfig/fetch.js +9 -23
- package/dist/esm/remoteconfig/index.d.ts +10 -8
- package/dist/esm/remoteconfig/index.js +66 -40
- package/dist/esm/remoteconfig/store.js +1 -1
- package/dist/esm/remoteconfig/tz-countries.d.ts +8 -0
- package/dist/esm/remoteconfig/tz-countries.js +11 -0
- package/dist/esm/remotelog/gate.d.ts +2 -11
- package/dist/esm/remotelog/gate.js +10 -32
- package/dist/esm/remotelog/index.d.ts +4 -21
- package/dist/esm/remotelog/logger.d.ts +11 -17
- package/dist/esm/remotelog/logger.js +32 -60
- package/dist/esm/remotelog/send.js +12 -12
- package/dist/esm/remotelogger/index.d.ts +12 -0
- package/dist/esm/remotelogger/index.js +13 -0
- package/dist/esm/scheduler.js +2 -2
- package/dist/esm/types.d.ts +155 -82
- package/dist/esm/user/index.js +12 -6
- package/dist/feedback.esm.min.js +2 -2
- package/dist/feedback.esm.min.js.map +1 -1
- package/package.json +14 -16
- package/dist/chunks/batch-BU_mTpm1.min.js +0 -3
- package/dist/chunks/batch-BU_mTpm1.min.js.map +0 -1
- package/dist/chunks/logs-Bea5zUW_.min.js +0 -3
- package/dist/chunks/logs-Bea5zUW_.min.js.map +0 -1
- package/dist/cjs/heatmap/index.d.ts +0 -16
- package/dist/cjs/heatmap/index.js +0 -22
- package/dist/cjs/remotelog/index.js +0 -55
- package/dist/esm/heatmap/index.d.ts +0 -16
- package/dist/esm/heatmap/index.js +0 -17
- package/dist/esm/remotelog/index.js +0 -51
- package/dist/heatmap.esm.min.js +0 -3
- package/dist/heatmap.esm.min.js.map +0 -1
- package/dist/style.css +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
// Generated by scripts/register-version.mjs — do not edit by hand.
|
|
5
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 =
|
|
6
|
+
// (version 2.0.0-beta.1, platform Browser). Regenerated on every npm pack.
|
|
7
|
+
const FRAMEWORK_ID = 6002;
|
|
8
8
|
|
|
9
9
|
exports.FRAMEWORK_ID = FRAMEWORK_ID;
|
package/dist/cjs/core/guard.d.ts
CHANGED
|
@@ -1,2 +1,11 @@
|
|
|
1
1
|
/** Public calls never throw into the host app, and are buffered until start-up finishes. */
|
|
2
2
|
export declare function guard<F extends (...args: any[]) => any>(name: string, fn: F): F;
|
|
3
|
+
/**
|
|
4
|
+
* Hands a public call's own `arguments` to its guarded function, exactly as they were given.
|
|
5
|
+
*
|
|
6
|
+
* guard() returns a wrapper that takes `...args`, so a browser console shows every public call as
|
|
7
|
+
* `(...args)`. Each public call is therefore its own function with named parameters, which is what
|
|
8
|
+
* the console shows, and forwards through this: `arguments` rather than the named parameters, so
|
|
9
|
+
* a call keeps its argument count (addEvent tells its two forms apart by it).
|
|
10
|
+
*/
|
|
11
|
+
export declare function forward<F extends (...args: any[]) => any>(guarded: F, args: IArguments): ReturnType<F>;
|
package/dist/cjs/core/guard.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var state = require('./state.js');
|
|
@@ -10,29 +10,31 @@ var logger = require('./logger.js');
|
|
|
10
10
|
* The two log collectors run now so an entry keeps the time it actually happened.
|
|
11
11
|
*/
|
|
12
12
|
const RUN_BEFORE_READY = {
|
|
13
|
-
'Apptics.init': true, ready: true, reset: true, getUser: true,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
'Apptics.init': true, 'Apptics.ready': true, 'Apptics.reset': true, 'AppticsUser.getUser': true,
|
|
14
|
+
'AppticsSettings.getTrackingStatus': true, 'AppticsFeedback.sendFeedback': true,
|
|
15
|
+
'AppticsFeedback.addFeedbackLog': true, 'AppticsFeedback.addDiagnosticsInfo': true,
|
|
16
|
+
// a switch, which init() must not undo: it keeps what was set when its config has no theme
|
|
17
|
+
'AppticsFeedback.setFeedbackTheme': true,
|
|
17
18
|
// a switch, and a call that hands back the id endTrackApi needs: neither can wait in a queue
|
|
18
|
-
'
|
|
19
|
+
'AppticsApi.configure': true, 'AppticsApi.startTrackApi': true,
|
|
19
20
|
// these wait for ready() themselves, and a queued call would hand back undefined, not a Promise
|
|
20
21
|
'AppticsRemoteConfig.fetchValue': true, 'AppticsRemoteConfig.fetchValues': true,
|
|
21
|
-
'AppticsRemoteConfig.
|
|
22
|
-
enableDebug: true, disableDebug: true,
|
|
22
|
+
'AppticsRemoteConfig.setCustomConditionValue': true,
|
|
23
|
+
'Apptics.enableDebug': true, 'Apptics.disableDebug': true,
|
|
23
24
|
};
|
|
24
25
|
/**
|
|
25
26
|
* 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,
|
|
27
|
+
* set a switch or read a value (Apptics.enableDebug, AppticsLogger.enable, AppticsFeedback.addFeedbackLog,
|
|
28
|
+
* AppticsUser.getUser, …)
|
|
27
29
|
* work without Apptics.init() and are not listed.
|
|
28
30
|
*/
|
|
29
31
|
const NEEDS_INIT = {
|
|
30
|
-
'
|
|
31
|
-
'
|
|
32
|
-
AppticsLogger: true, sendFeedback: true, 'AppticsRemoteConfig.fetchValue': true,
|
|
32
|
+
'AppticsEvent.addEvent': true, 'AppticsScreen.inScreen': true, 'AppticsScreen.outScreen': true,
|
|
33
|
+
'AppticsApi.endTrackApi': true, 'AppticsError.trackError': true, 'AppticsUser.setUser': true,
|
|
34
|
+
'Apptics.flush': true, AppticsLogger: true, 'AppticsFeedback.sendFeedback': true, 'AppticsRemoteConfig.fetchValue': true,
|
|
33
35
|
'AppticsRemoteConfig.fetchValues': true,
|
|
34
36
|
};
|
|
35
|
-
/** How a call is named in a message:
|
|
37
|
+
/** How a call is named in a message: every public call is named after its object, as `AppticsEvent.addEvent`. */
|
|
36
38
|
function publicName(name) {
|
|
37
39
|
return name.indexOf('Apptics') === 0 ? name : 'apptics.' + name; // no i18n
|
|
38
40
|
}
|
|
@@ -68,5 +70,17 @@ function guard(name, fn) {
|
|
|
68
70
|
};
|
|
69
71
|
return guarded;
|
|
70
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Hands a public call's own `arguments` to its guarded function, exactly as they were given.
|
|
75
|
+
*
|
|
76
|
+
* guard() returns a wrapper that takes `...args`, so a browser console shows every public call as
|
|
77
|
+
* `(...args)`. Each public call is therefore its own function with named parameters, which is what
|
|
78
|
+
* the console shows, and forwards through this: `arguments` rather than the named parameters, so
|
|
79
|
+
* a call keeps its argument count (addEvent tells its two forms apart by it).
|
|
80
|
+
*/
|
|
81
|
+
function forward(guarded, args) {
|
|
82
|
+
return guarded.apply(null, Array.prototype.slice.call(args));
|
|
83
|
+
}
|
|
71
84
|
|
|
85
|
+
exports.forward = forward;
|
|
72
86
|
exports.guard = guard;
|
package/dist/cjs/core/hooks.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { CallSite } from './callsite.js';
|
|
2
1
|
import type { DeviceInfo, ServerResult } from '../types.js';
|
|
3
2
|
/**
|
|
4
3
|
* Late-bound calls from lower modules up to the modules above them (see spec §5). device.ts and
|
|
@@ -9,7 +8,6 @@ export declare const hooks: {
|
|
|
9
8
|
updateDevice: (deviceInfo: DeviceInfo) => Promise<ServerResult>;
|
|
10
9
|
refreshDeviceInfo: () => void;
|
|
11
10
|
/** 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
11
|
/**
|
|
14
12
|
* Set by feedback/controls.ts: the user picked in the feedback form, or null for anonymous.
|
|
15
13
|
* Here so transport can read the choice without importing the modal.
|
|
@@ -24,7 +22,7 @@ export declare const hooks: {
|
|
|
24
22
|
*/
|
|
25
23
|
sendHeatmaps: (forget?: boolean) => Promise<void>;
|
|
26
24
|
/** Set by heatmap/track.ts, so init() and reset() can switch capture without importing it. */
|
|
27
|
-
|
|
25
|
+
trackHeatmap: (status?: boolean) => void;
|
|
28
26
|
/** Set by heatmap/track.ts: clears what this visit recorded, so the cap starts again. */
|
|
29
27
|
resetHeatmap: () => void;
|
|
30
28
|
/** Set by remoteconfig/fetch.ts, so reset() can forget the rule set without importing it. */
|
|
@@ -36,6 +34,6 @@ export declare const hooks: {
|
|
|
36
34
|
screenTrackedByApp: () => void;
|
|
37
35
|
/** Set by remoteconfig/fetch.ts: start-up has finished, so remote config fetches its values. */
|
|
38
36
|
remoteConfigStarted: () => void;
|
|
39
|
-
/** Set by remoteconfig/fetch.ts:
|
|
37
|
+
/** Set by remoteconfig/fetch.ts: AppticsUser.setUser changed who this is, so conditions on the user re-apply. */
|
|
40
38
|
remoteConfigUserChanged: () => void;
|
|
41
39
|
};
|
package/dist/cjs/core/hooks.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -9,10 +9,9 @@
|
|
|
9
9
|
const hooks = {
|
|
10
10
|
updateDevice: () => Promise.reject('apptics: device module not loaded'), // no i18n
|
|
11
11
|
refreshDeviceInfo: () => { },
|
|
12
|
-
remoteLog: () => { },
|
|
13
12
|
feedbackUser: () => null,
|
|
14
13
|
sendHeatmaps: () => Promise.resolve(),
|
|
15
|
-
|
|
14
|
+
trackHeatmap: () => { },
|
|
16
15
|
resetHeatmap: () => { },
|
|
17
16
|
resetRemoteConfig: () => { },
|
|
18
17
|
screenTrackedByApp: () => { },
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs `run` while holding the Web Lock `name`, waiting for it if another tab of this site holds
|
|
3
|
+
* it. Locks are shared by every tab of an origin, which is what keeps two tabs from registering
|
|
4
|
+
* the same browser twice or overwriting each other's session.
|
|
5
|
+
*
|
|
6
|
+
* Without the Web Locks API (older browsers), `run` simply runs, as it did before locks were used.
|
|
7
|
+
* Not reentrant: `run` must not ask for the same lock again, or it waits for itself.
|
|
8
|
+
*/
|
|
9
|
+
export declare function withLock<T>(name: string, run: () => Promise<T>): Promise<T>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Runs `run` while holding the Web Lock `name`, waiting for it if another tab of this site holds
|
|
6
|
+
* it. Locks are shared by every tab of an origin, which is what keeps two tabs from registering
|
|
7
|
+
* the same browser twice or overwriting each other's session.
|
|
8
|
+
*
|
|
9
|
+
* Without the Web Locks API (older browsers), `run` simply runs, as it did before locks were used.
|
|
10
|
+
* Not reentrant: `run` must not ask for the same lock again, or it waits for itself.
|
|
11
|
+
*/
|
|
12
|
+
function withLock(name, run) {
|
|
13
|
+
var locks = typeof navigator !== 'undefined' ? navigator.locks : undefined; // no i18n
|
|
14
|
+
if (!locks || typeof locks.request !== 'function') { // no i18n
|
|
15
|
+
return run();
|
|
16
|
+
}
|
|
17
|
+
return locks.request('apptics-' + name, function () {
|
|
18
|
+
return run();
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
exports.withLock = withLock;
|
|
@@ -8,9 +8,8 @@ export declare const Console: {
|
|
|
8
8
|
/** Warnings the integrator must see even with debug off (e.g. missing required config). */
|
|
9
9
|
export declare function warnAlways(...args: unknown[]): void;
|
|
10
10
|
/**
|
|
11
|
-
* A failure inside one of the SDK's own modules
|
|
12
|
-
* console
|
|
13
|
-
*
|
|
14
|
-
* the remotelog module has been loaded and its own switch allows it.
|
|
11
|
+
* A failure inside one of the SDK's own modules, `module` one of AP_LOG_MODULE's values: said in
|
|
12
|
+
* the browser console in debug mode. Nothing is sent: the Remote Logger page carries only the
|
|
13
|
+
* lines an app logs with AppticsLogger.
|
|
15
14
|
*/
|
|
16
15
|
export declare function logFailure(module: string, ...args: unknown[]): void;
|
package/dist/cjs/core/logger.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var state = require('./state.js');
|
|
5
|
-
var hooks = require('./hooks.js');
|
|
6
5
|
var utils = require('./utils.js');
|
|
7
|
-
var callsite = require('./callsite.js');
|
|
8
6
|
|
|
9
7
|
const APConsole = typeof console !== 'undefined' ? console : null;
|
|
10
8
|
function gated(method) {
|
|
@@ -38,47 +36,13 @@ function warnAlways(...args) {
|
|
|
38
36
|
if (APConsole)
|
|
39
37
|
APConsole.warn(...args);
|
|
40
38
|
}
|
|
41
|
-
function safeJson(value) {
|
|
42
|
-
try {
|
|
43
|
-
return JSON.stringify(value) || String(value);
|
|
44
|
-
}
|
|
45
|
-
catch (err) {
|
|
46
|
-
return String(value);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
39
|
/**
|
|
50
|
-
* A failure inside one of the SDK's own modules
|
|
51
|
-
* console
|
|
52
|
-
*
|
|
53
|
-
* the remotelog module has been loaded and its own switch allows it.
|
|
40
|
+
* A failure inside one of the SDK's own modules, `module` one of AP_LOG_MODULE's values: said in
|
|
41
|
+
* the browser console in debug mode. Nothing is sent: the Remote Logger page carries only the
|
|
42
|
+
* lines an app logs with AppticsLogger.
|
|
54
43
|
*/
|
|
55
44
|
function logFailure(module, ...args) {
|
|
56
45
|
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
46
|
}
|
|
83
47
|
|
|
84
48
|
exports.Console = Console;
|
package/dist/cjs/core/state.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ApConfig } from './constants.js';
|
|
2
|
-
import type { DeviceInfo, Dict, TrackingStatus, UserInfo } from '../types.js';
|
|
2
|
+
import type { DeviceInfo, Dict, QuartzSettings, TrackingStatus, UserInfo } from '../types.js';
|
|
3
3
|
/** Runtime state shared by every module (the former `_ZAP` object). */
|
|
4
4
|
export interface State {
|
|
5
5
|
_initialised: boolean;
|
|
@@ -44,7 +44,8 @@ export interface State {
|
|
|
44
44
|
_remoteConfigReported: boolean;
|
|
45
45
|
/** getsdkconfig module 12. */
|
|
46
46
|
_feedbackEnabled: boolean;
|
|
47
|
-
|
|
47
|
+
/** getsdkconfig's `quartz` block: screen recording in the feedback form. Off until it says otherwise. */
|
|
48
|
+
_quartz: QuartzSettings;
|
|
48
49
|
/** Epoch ms getsdkconfig asked us to wait until before asking again. 0 means no answer yet. */
|
|
49
50
|
_nextConfigCheck: number;
|
|
50
51
|
/**
|
package/dist/cjs/core/state.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var constants = require('./constants.js');
|
|
@@ -45,7 +45,7 @@ function initialState() {
|
|
|
45
45
|
_nextConfigCheck: 0,
|
|
46
46
|
_debugUntil: 0,
|
|
47
47
|
_errorTracking: true,
|
|
48
|
-
|
|
48
|
+
_quartz: { enabled: false, workspace: '', department: '', domain: '', cdnUrl: '' }, // no i18n
|
|
49
49
|
_trackinfo: {},
|
|
50
50
|
};
|
|
51
51
|
}
|
|
@@ -20,23 +20,38 @@ export declare const error_transactions: Queue;
|
|
|
20
20
|
* These are not sent on their own: feedback/logs.ts renders them into the files that
|
|
21
21
|
* feedback/add carries, and removes the ones a submission took with it.
|
|
22
22
|
*/
|
|
23
|
-
export declare const
|
|
23
|
+
export declare const feedbacklog_transactions: Queue;
|
|
24
24
|
/** Clicks and scrolls waiting for heatmap/add. */
|
|
25
25
|
export declare const heatmap_transactions: Queue;
|
|
26
26
|
/**
|
|
27
|
-
* Remote log lines waiting for
|
|
27
|
+
* Remote log lines waiting for log/add. Stored rather than sent straight out because the
|
|
28
28
|
* endpoint takes one line per call and counts retries (`attempt`), so a line has to outlive a
|
|
29
29
|
* failed send — and a reload.
|
|
30
30
|
*/
|
|
31
|
-
export declare const
|
|
32
|
-
/**
|
|
31
|
+
export declare const remotelog_transactions: Queue;
|
|
32
|
+
/**
|
|
33
|
+
* Sets one key of the stored device_info, and of this tab's copy: the uuid the device is
|
|
34
|
+
* registered under, whether it has had a session. Its other keys stay as they are.
|
|
35
|
+
*/
|
|
36
|
+
export declare function setDeviceInfoKey(key: string, value: unknown): void;
|
|
37
|
+
/** device_info (uuid included), app_version_info, trackinfo (tracking_status included), users, user_info, and the rest. */
|
|
33
38
|
export declare const user_defaults: {
|
|
34
39
|
all(): Dict;
|
|
35
40
|
item(key: string): any;
|
|
36
41
|
add(key: string, value: unknown): void;
|
|
42
|
+
/** As add(), and resolves once the value is in storage, where other tabs can read it. */
|
|
43
|
+
save(key: string, value: unknown): Promise<void>;
|
|
37
44
|
clear(): void;
|
|
38
45
|
};
|
|
39
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* Re-reads `keys` from storage. Settings are loaded into memory once, when a tab starts, so a value
|
|
48
|
+
* another tab of this site wrote since then — the device ids it registered — is only in storage.
|
|
49
|
+
* A key storage doesn't hold keeps this tab's value.
|
|
50
|
+
*/
|
|
51
|
+
export declare function reloadSettings(keys: string[]): Promise<void>;
|
|
52
|
+
/** The visitor's tracking status, stored in trackinfo as tracking_status. */
|
|
53
|
+
export declare function storedTrackingStatus(): TrackingStatus | undefined;
|
|
54
|
+
/** Opt-in status, stored in the trackinfo setting as tracking_status. */
|
|
40
55
|
export declare const tracking_preference: {
|
|
41
56
|
_tracking_status: string;
|
|
42
57
|
all(): Dict;
|
package/dist/cjs/core/storage.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var constants = require('./constants.js');
|
|
@@ -30,8 +30,6 @@ function migrateLegacy(b) {
|
|
|
30
30
|
errors: localStorage.getItem(db.LEGACY_KEYS.errors),
|
|
31
31
|
logs: localStorage.getItem(db.LEGACY_KEYS.logs),
|
|
32
32
|
consolelogs: localStorage.getItem(db.LEGACY_KEYS.consolelogs),
|
|
33
|
-
// read for completeness of the shape only: 1.x never wrote this key
|
|
34
|
-
heatmaps: null,
|
|
35
33
|
};
|
|
36
34
|
}
|
|
37
35
|
catch (err) {
|
|
@@ -49,15 +47,17 @@ function migrateLegacy(b) {
|
|
|
49
47
|
return null;
|
|
50
48
|
}
|
|
51
49
|
};
|
|
50
|
+
// 1.x's keys are logs and consolelogs; they are feedbacklogs and remotelogs now, and a
|
|
51
|
+
// feedback entry's type is feedbacklog or feedbackdiagnostics instead of log or diagnostics
|
|
52
52
|
var queues = {
|
|
53
53
|
engagements: db.asList(parse(raw.engagements)),
|
|
54
54
|
errors: db.asList(parse(raw.errors)),
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
feedbacklogs: db.asList(parse(raw.logs)).map(db.renameFeedbackType),
|
|
56
|
+
remotelogs: db.asList(parse(raw.consolelogs)),
|
|
57
57
|
// nothing to migrate: 1.x had no heatmaps
|
|
58
58
|
heatmaps: [],
|
|
59
59
|
};
|
|
60
|
-
queues.engagements.concat(queues.errors, queues.
|
|
60
|
+
queues.engagements.concat(queues.errors, queues.feedbacklogs, queues.remotelogs).forEach(function (item) {
|
|
61
61
|
if (!item.id)
|
|
62
62
|
item.id = utils.getNewUUID();
|
|
63
63
|
});
|
|
@@ -91,6 +91,7 @@ function storageReady() {
|
|
|
91
91
|
}).then(function (loaded) {
|
|
92
92
|
// writes made before loading finished win over stored values
|
|
93
93
|
settings = Object.assign({}, loaded, settings);
|
|
94
|
+
moveRetiredSettings();
|
|
94
95
|
return b;
|
|
95
96
|
});
|
|
96
97
|
}).catch(function (err) {
|
|
@@ -161,21 +162,75 @@ const error_transactions = createQueue('errors'); // no i18n
|
|
|
161
162
|
* These are not sent on their own: feedback/logs.ts renders them into the files that
|
|
162
163
|
* feedback/add carries, and removes the ones a submission took with it.
|
|
163
164
|
*/
|
|
164
|
-
const
|
|
165
|
+
const feedbacklog_transactions = createQueue('feedbacklogs'); // no i18n
|
|
165
166
|
/** Clicks and scrolls waiting for heatmap/add. */
|
|
166
167
|
const heatmap_transactions = createQueue('heatmaps'); // no i18n
|
|
167
168
|
/**
|
|
168
|
-
* Remote log lines waiting for
|
|
169
|
+
* Remote log lines waiting for log/add. Stored rather than sent straight out because the
|
|
169
170
|
* endpoint takes one line per call and counts retries (`attempt`), so a line has to outlive a
|
|
170
171
|
* failed send — and a reload.
|
|
171
172
|
*/
|
|
172
|
-
const
|
|
173
|
+
const remotelog_transactions = createQueue('remotelogs'); // no i18n
|
|
173
174
|
/* ---------------- settings (sync reads, background writes) ---------------- */
|
|
175
|
+
/** Writes `key`, or removes it from storage altogether when `value` is undefined. */
|
|
176
|
+
function writeSetting(b, key) {
|
|
177
|
+
return settings[key] === undefined ? b.deleteSetting(key) : b.putSetting(key, settings[key]);
|
|
178
|
+
}
|
|
174
179
|
function setSetting(key, value) {
|
|
175
|
-
|
|
176
|
-
|
|
180
|
+
if (value === undefined) {
|
|
181
|
+
delete settings[key];
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
settings[key] = utils.cloneObject(value);
|
|
185
|
+
}
|
|
186
|
+
withBackend('save ' + key, undefined, function (b) { return writeSetting(b, key); }); // no i18n
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Settings 2.0.0-beta kept as keys of their own, now kept inside device_info and trackinfo.
|
|
190
|
+
* Moved once, on the first load after an upgrade, before anything reads them: the uuid is the one
|
|
191
|
+
* the device is registered under, and the tracking status is the visitor's own choice, so losing
|
|
192
|
+
* either would register a new device or forget a consent. token was never read, and goes.
|
|
193
|
+
* appkey and appversion are read and removed by init(), which compares them with this visit's app.
|
|
194
|
+
*/
|
|
195
|
+
function moveRetiredSettings() {
|
|
196
|
+
var device = settings.device_info && typeof settings.device_info === 'object' ? settings.device_info : null; // no i18n
|
|
197
|
+
if (settings.uuid !== undefined || settings.hadsession !== undefined) {
|
|
198
|
+
device = Object.assign({}, device || {});
|
|
199
|
+
if (utils.isEmpty(device.uuid) && !utils.isEmpty(settings.uuid)) {
|
|
200
|
+
device.uuid = settings.uuid;
|
|
201
|
+
}
|
|
202
|
+
if (settings.hadsession === true) {
|
|
203
|
+
device.hadsession = true;
|
|
204
|
+
}
|
|
205
|
+
setSetting('device_info', device); // no i18n
|
|
206
|
+
setSetting('uuid', undefined); // no i18n
|
|
207
|
+
setSetting('hadsession', undefined); // no i18n
|
|
208
|
+
}
|
|
209
|
+
if (settings.tracking_status !== undefined) {
|
|
210
|
+
var track = Object.assign({}, settings.trackinfo && typeof settings.trackinfo === 'object' ? settings.trackinfo : {}); // no i18n
|
|
211
|
+
if (track.tracking_status === undefined) {
|
|
212
|
+
track.tracking_status = settings.tracking_status;
|
|
213
|
+
}
|
|
214
|
+
setSetting('trackinfo', track); // no i18n
|
|
215
|
+
setSetting('tracking_status', undefined); // no i18n
|
|
216
|
+
}
|
|
217
|
+
if (settings.token !== undefined) {
|
|
218
|
+
setSetting('token', undefined); // no i18n
|
|
219
|
+
}
|
|
177
220
|
}
|
|
178
|
-
/**
|
|
221
|
+
/**
|
|
222
|
+
* Sets one key of the stored device_info, and of this tab's copy: the uuid the device is
|
|
223
|
+
* registered under, whether it has had a session. Its other keys stay as they are.
|
|
224
|
+
*/
|
|
225
|
+
function setDeviceInfoKey(key, value) {
|
|
226
|
+
var device = Object.assign({}, settings.device_info && typeof settings.device_info === 'object' ? settings.device_info : {}); // no i18n
|
|
227
|
+
device[key] = value;
|
|
228
|
+
if (state._ZAP._device_info && typeof state._ZAP._device_info === 'object') { // no i18n
|
|
229
|
+
state._ZAP._device_info[key] = value;
|
|
230
|
+
}
|
|
231
|
+
setSetting('device_info', device); // no i18n
|
|
232
|
+
}
|
|
233
|
+
/** device_info (uuid included), app_version_info, trackinfo (tracking_status included), users, user_info, and the rest. */
|
|
179
234
|
const user_defaults = {
|
|
180
235
|
all() {
|
|
181
236
|
return utils.cloneObject(settings);
|
|
@@ -187,26 +242,66 @@ const user_defaults = {
|
|
|
187
242
|
add(key, value) {
|
|
188
243
|
setSetting(key, value);
|
|
189
244
|
},
|
|
245
|
+
/** As add(), and resolves once the value is in storage, where other tabs can read it. */
|
|
246
|
+
save(key, value) {
|
|
247
|
+
if (value === undefined) {
|
|
248
|
+
delete settings[key];
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
settings[key] = utils.cloneObject(value);
|
|
252
|
+
}
|
|
253
|
+
return withBackend('save ' + key, undefined, function (b) { return writeSetting(b, key); }); // no i18n
|
|
254
|
+
},
|
|
190
255
|
clear() {
|
|
191
256
|
settings = {};
|
|
192
257
|
withBackend('clear settings', undefined, function (b) { return b.clearSettings(); }); // no i18n
|
|
193
258
|
},
|
|
194
259
|
};
|
|
195
|
-
/**
|
|
260
|
+
/**
|
|
261
|
+
* Re-reads `keys` from storage. Settings are loaded into memory once, when a tab starts, so a value
|
|
262
|
+
* another tab of this site wrote since then — the device ids it registered — is only in storage.
|
|
263
|
+
* A key storage doesn't hold keeps this tab's value.
|
|
264
|
+
*/
|
|
265
|
+
function reloadSettings(keys) {
|
|
266
|
+
return withBackend('reload settings', undefined, function (b) {
|
|
267
|
+
return b.loadSettings().then(function (loaded) {
|
|
268
|
+
keys.forEach(function (key) {
|
|
269
|
+
if (loaded[key] !== undefined) {
|
|
270
|
+
settings[key] = loaded[key];
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
/** The visitor's tracking status, stored in trackinfo as tracking_status. */
|
|
277
|
+
function storedTrackingStatus() {
|
|
278
|
+
var track = settings.trackinfo;
|
|
279
|
+
var status = track && typeof track === 'object' ? track.tracking_status : undefined; // no i18n
|
|
280
|
+
// a status only: getsdkconfig's own answer uses the same key for its per-module flags, and
|
|
281
|
+
// one stored by mistake must not read as a consent and stop all tracking
|
|
282
|
+
return status === constants.AP_TRACKING_STATUS.USAGE_TRACKING_WITH_PII || status === constants.AP_TRACKING_STATUS.USAGE_TRACKING_WITHOUT_PII
|
|
283
|
+
|| status === constants.AP_TRACKING_STATUS.NO_TRACKING ? status : undefined;
|
|
284
|
+
}
|
|
285
|
+
/** Opt-in status, stored in the trackinfo setting as tracking_status. */
|
|
196
286
|
const tracking_preference = {
|
|
197
287
|
_tracking_status: 'tracking_status', // no i18n
|
|
198
288
|
all() {
|
|
199
289
|
return user_defaults.all();
|
|
200
290
|
},
|
|
201
291
|
opt_in_status() {
|
|
202
|
-
return (
|
|
292
|
+
return (storedTrackingStatus() || constants.AP_TRACKING_STATUS.USAGE_TRACKING_WITHOUT_PII);
|
|
203
293
|
},
|
|
204
294
|
update_status(tracking_status) {
|
|
205
295
|
state._ZAP._devicestatus = tracking_status;
|
|
206
296
|
// Legacy order kept: this reads the status *before* the write below (setTrackingStatus recomputes it after).
|
|
207
297
|
state._ZAP._isanonrequired =
|
|
208
298
|
tracking_preference.opt_in_status() == constants.AP_TRACKING_STATUS.USAGE_TRACKING_WITH_PII ? false : state._ZAP._isanonrequired;
|
|
209
|
-
|
|
299
|
+
var track = Object.assign({}, settings.trackinfo && typeof settings.trackinfo === 'object' ? settings.trackinfo : {}); // no i18n
|
|
300
|
+
track.tracking_status = tracking_status;
|
|
301
|
+
if (state._ZAP._trackinfo && typeof state._ZAP._trackinfo === 'object') { // no i18n
|
|
302
|
+
state._ZAP._trackinfo.tracking_status = tracking_status;
|
|
303
|
+
}
|
|
304
|
+
setSetting('trackinfo', track); // no i18n
|
|
210
305
|
},
|
|
211
306
|
};
|
|
212
307
|
function getKeyFromDeviceInfo(key) {
|
|
@@ -218,12 +313,15 @@ function getKeyFromDeviceInfo(key) {
|
|
|
218
313
|
return null;
|
|
219
314
|
}
|
|
220
315
|
|
|
221
|
-
exports.consolelog_transactions = consolelog_transactions;
|
|
222
316
|
exports.engagement_transactions = engagement_transactions;
|
|
223
317
|
exports.error_transactions = error_transactions;
|
|
318
|
+
exports.feedbacklog_transactions = feedbacklog_transactions;
|
|
224
319
|
exports.getKeyFromDeviceInfo = getKeyFromDeviceInfo;
|
|
225
320
|
exports.heatmap_transactions = heatmap_transactions;
|
|
226
|
-
exports.
|
|
321
|
+
exports.reloadSettings = reloadSettings;
|
|
322
|
+
exports.remotelog_transactions = remotelog_transactions;
|
|
323
|
+
exports.setDeviceInfoKey = setDeviceInfoKey;
|
|
227
324
|
exports.storageReady = storageReady;
|
|
325
|
+
exports.storedTrackingStatus = storedTrackingStatus;
|
|
228
326
|
exports.tracking_preference = tracking_preference;
|
|
229
327
|
exports.user_defaults = user_defaults;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adds the feedback form's styles to the page, once, as a <style> element, so no app imports or
|
|
3
|
+
* links a stylesheet: the css is carried in the JavaScript, for npm and the CDN builds alike.
|
|
4
|
+
*
|
|
5
|
+
* Nothing happens when `css` is empty (running from source, as the tests do) or when the page
|
|
6
|
+
* already has the styles (the element is marked data-apptics="style"). Never throws.
|
|
7
|
+
*/
|
|
8
|
+
export declare function injectStylesheet(css: string): void;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Adds the feedback form's styles to the page, once, as a <style> element, so no app imports or
|
|
6
|
+
* links a stylesheet: the css is carried in the JavaScript, for npm and the CDN builds alike.
|
|
7
|
+
*
|
|
8
|
+
* Nothing happens when `css` is empty (running from source, as the tests do) or when the page
|
|
9
|
+
* already has the styles (the element is marked data-apptics="style"). Never throws.
|
|
10
|
+
*/
|
|
11
|
+
function injectStylesheet(css) {
|
|
12
|
+
try {
|
|
13
|
+
if (!css || typeof document === 'undefined') { // no i18n
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (document.querySelector('[data-apptics="style"]')) { // no i18n
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
var style = document.createElement('style'); // no i18n
|
|
20
|
+
style.setAttribute('data-apptics', 'style'); // no i18n
|
|
21
|
+
style.textContent = css;
|
|
22
|
+
(document.head || document.documentElement).appendChild(style);
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
// the form still works unstyled; the app must not break over a stylesheet
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
exports.injectStylesheet = injectStylesheet;
|
|
@@ -81,3 +81,5 @@ export declare function getMetaObj(): Dict;
|
|
|
81
81
|
* and feedback (P11).
|
|
82
82
|
*/
|
|
83
83
|
export declare function rejectIfNoDeviceIds(label: string): Promise<never> | null;
|
|
84
|
+
/** Whether device/add has given this browser its deviceid. */
|
|
85
|
+
export declare function hasDeviceId(): boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var constants = require('./constants.js');
|
|
@@ -174,8 +174,11 @@ function getParameters(path) {
|
|
|
174
174
|
}
|
|
175
175
|
return returnVal + mandatoryParams(returnVal);
|
|
176
176
|
}
|
|
177
|
-
// add userid and groupid if opt_in_status is USAGE_TRACKING_WITH_PII
|
|
178
|
-
|
|
177
|
+
// add userid and groupid if opt_in_status is USAGE_TRACKING_WITH_PII. getupdates doesn't declare
|
|
178
|
+
// them, and refuses userid as EXTRA_PARAM_FOUND; it has no use for them either, since remote
|
|
179
|
+
// config conditions on the user are evaluated here, against the rule set it answers with
|
|
180
|
+
var carriesUser = path != 'reguser' && path != 'getupdates'; // no i18n
|
|
181
|
+
if (carriesUser && identifiesDevice) {
|
|
179
182
|
if (consent.opt_in_status() == constants.AP_TRACKING_STATUS.USAGE_TRACKING_WITH_PII) {
|
|
180
183
|
if (state._ZAP._user_info.hasOwnProperty('userid') && !utils.isEmpty(state._ZAP._user_info.userid)) { // no i18n
|
|
181
184
|
returnVal += '&userid=' + encodeURIComponent(String(state._ZAP._user_info.userid)); // no i18n
|
|
@@ -419,10 +422,21 @@ function getMetaObj() {
|
|
|
419
422
|
function rejectIfNoDeviceIds(label) {
|
|
420
423
|
if (utils.isEmpty(getHeaderParams('apid')) && utils.isEmpty(getHeaderParams('mapid'))) { // no i18n
|
|
421
424
|
hooks.hooks.refreshDeviceInfo();
|
|
422
|
-
return Promise.reject(label + ': You must call
|
|
425
|
+
return Promise.reject(label + ': You must call Apptics.init() first'); // no i18n
|
|
426
|
+
}
|
|
427
|
+
// app/addversion has answered, device/add not yet (offline, or it failed): what is stored waits
|
|
428
|
+
// for the device it belongs to rather than going out without a deviceid. The refresh registers
|
|
429
|
+
// the device, joining a registration already in flight
|
|
430
|
+
if (!hasDeviceId()) {
|
|
431
|
+
hooks.hooks.refreshDeviceInfo();
|
|
432
|
+
return Promise.reject(label + ': the device is not registered yet, kept for the next send'); // no i18n
|
|
423
433
|
}
|
|
424
434
|
return null;
|
|
425
435
|
}
|
|
436
|
+
/** Whether device/add has given this browser its deviceid. */
|
|
437
|
+
function hasDeviceId() {
|
|
438
|
+
return !utils.isEmpty(state._ZAP._device_info && state._ZAP._device_info.deviceid) || !utils.isEmpty(storage.getKeyFromDeviceInfo('deviceid')); // no i18n
|
|
439
|
+
}
|
|
426
440
|
|
|
427
441
|
exports.KEEPALIVE_BUDGET = KEEPALIVE_BUDGET;
|
|
428
442
|
exports.REQUEST_TIMEOUT_MS = REQUEST_TIMEOUT_MS;
|
|
@@ -431,6 +445,7 @@ exports.getHeaderParams = getHeaderParams;
|
|
|
431
445
|
exports.getMetaObj = getMetaObj;
|
|
432
446
|
exports.getParameters = getParameters;
|
|
433
447
|
exports.getUrlWithParams = getUrlWithParams;
|
|
448
|
+
exports.hasDeviceId = hasDeviceId;
|
|
434
449
|
exports.isPermanentRefusal = isPermanentRefusal;
|
|
435
450
|
exports.makeRequest = makeRequest;
|
|
436
451
|
exports.postKeepalive = postKeepalive;
|