@zoho_apptics/apptics-js-sdk 1.0.2 → 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 +193 -0
- package/LICENSE +13 -0
- package/README.md +846 -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/lifecycle-VYr43KcB.min.js +3 -0
- package/dist/chunks/lifecycle-VYr43KcB.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 +116 -0
- package/dist/cjs/core/callsite.d.ts +34 -0
- package/dist/cjs/core/callsite.js +115 -0
- package/dist/cjs/core/consent.d.ts +27 -0
- package/dist/cjs/core/consent.js +132 -0
- package/dist/cjs/core/constants.d.ts +237 -0
- package/dist/cjs/core/constants.js +315 -0
- package/dist/cjs/core/db.d.ts +48 -0
- package/dist/cjs/core/db.js +467 -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 +11 -0
- package/dist/cjs/core/guard.js +86 -0
- package/dist/cjs/core/hooks.d.ts +39 -0
- package/dist/cjs/core/hooks.js +22 -0
- package/dist/cjs/core/locks.d.ts +9 -0
- package/dist/cjs/core/locks.js +22 -0
- package/dist/cjs/core/logger.d.ts +15 -0
- package/dist/cjs/core/logger.js +50 -0
- package/dist/cjs/core/state.d.ts +70 -0
- package/dist/cjs/core/state.js +78 -0
- package/dist/cjs/core/storage.d.ts +61 -0
- package/dist/cjs/core/storage.js +327 -0
- package/dist/cjs/core/stylesheet.d.ts +8 -0
- package/dist/cjs/core/stylesheet.js +29 -0
- package/dist/cjs/core/transport.d.ts +85 -0
- package/dist/cjs/core/transport.js +456 -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 +15 -0
- package/dist/cjs/device/appversion.js +170 -0
- package/dist/cjs/device/index.d.ts +34 -0
- package/dist/cjs/device/index.js +472 -0
- package/dist/cjs/engagement/api-rules.d.ts +49 -0
- package/dist/cjs/engagement/api-rules.js +206 -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 +18 -0
- package/dist/cjs/engagement/auto-screen.js +305 -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 +104 -0
- package/dist/cjs/engagement/session.d.ts +51 -0
- package/dist/cjs/engagement/session.js +463 -0
- package/dist/cjs/engagement/track.d.ts +56 -0
- package/dist/cjs/engagement/track.js +375 -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 +167 -0
- package/dist/cjs/feedback/controls.d.ts +37 -0
- package/dist/cjs/feedback/controls.js +316 -0
- package/dist/cjs/feedback/index.d.ts +9 -0
- package/dist/cjs/feedback/index.js +56 -0
- package/dist/cjs/feedback/logs.d.ts +45 -0
- package/dist/cjs/feedback/logs.js +241 -0
- package/dist/cjs/feedback/quartz.d.ts +18 -0
- package/dist/cjs/feedback/quartz.js +105 -0
- package/dist/cjs/feedback/send.d.ts +28 -0
- package/dist/cjs/feedback/send.js +203 -0
- package/dist/cjs/feedback/styles.d.ts +10 -0
- package/dist/cjs/feedback/styles.js +8 -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 +63 -0
- package/dist/cjs/feedback/ui.js +709 -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 +448 -0
- package/dist/cjs/index.d.ts +22 -0
- package/dist/cjs/index.js +162 -0
- package/dist/cjs/lifecycle.d.ts +21 -0
- package/dist/cjs/lifecycle.js +734 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/remoteconfig/country.d.ts +4 -0
- package/dist/cjs/remoteconfig/country.js +73 -0
- package/dist/cjs/remoteconfig/custom.d.ts +10 -0
- package/dist/cjs/remoteconfig/custom.js +58 -0
- package/dist/cjs/remoteconfig/evaluate.d.ts +24 -0
- package/dist/cjs/remoteconfig/evaluate.js +184 -0
- package/dist/cjs/remoteconfig/fetch.d.ts +24 -0
- package/dist/cjs/remoteconfig/fetch.js +200 -0
- package/dist/cjs/remoteconfig/index.d.ts +15 -0
- package/dist/cjs/remoteconfig/index.js +116 -0
- package/dist/cjs/remoteconfig/store.d.ts +18 -0
- package/dist/cjs/remoteconfig/store.js +98 -0
- 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 -0
- package/dist/cjs/remotelog/gate.js +28 -0
- package/dist/cjs/remotelog/index.d.ts +8 -0
- package/dist/cjs/remotelog/logger.d.ts +22 -0
- package/dist/cjs/remotelog/logger.js +111 -0
- package/dist/cjs/remotelog/send.d.ts +13 -0
- package/dist/cjs/remotelog/send.js +153 -0
- package/dist/cjs/remotelogger/index.d.ts +12 -0
- package/dist/cjs/remotelogger/index.js +18 -0
- package/dist/cjs/scheduler.d.ts +8 -0
- package/dist/cjs/scheduler.js +78 -0
- package/dist/cjs/types.d.ts +385 -0
- package/dist/cjs/user/index.d.ts +33 -0
- package/dist/cjs/user/index.js +183 -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 +109 -0
- package/dist/esm/core/callsite.d.ts +34 -0
- package/dist/esm/core/callsite.js +110 -0
- package/dist/esm/core/consent.d.ts +27 -0
- package/dist/esm/core/consent.js +122 -0
- package/dist/esm/core/constants.d.ts +237 -0
- package/dist/esm/core/constants.js +292 -0
- package/dist/esm/core/db.d.ts +48 -0
- package/dist/esm/core/db.js +453 -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 +11 -0
- package/dist/esm/core/guard.js +83 -0
- package/dist/esm/core/hooks.d.ts +39 -0
- package/dist/esm/core/hooks.js +20 -0
- package/dist/esm/core/locks.d.ts +9 -0
- package/dist/esm/core/locks.js +20 -0
- package/dist/esm/core/logger.d.ts +15 -0
- package/dist/esm/core/logger.js +46 -0
- package/dist/esm/core/state.d.ts +70 -0
- package/dist/esm/core/state.js +73 -0
- package/dist/esm/core/storage.d.ts +61 -0
- package/dist/esm/core/storage.js +314 -0
- package/dist/esm/core/stylesheet.d.ts +8 -0
- package/dist/esm/core/stylesheet.js +27 -0
- package/dist/esm/core/transport.d.ts +85 -0
- package/dist/esm/core/transport.js +439 -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 +15 -0
- package/dist/esm/device/appversion.js +164 -0
- package/dist/esm/device/index.d.ts +34 -0
- package/dist/esm/device/index.js +461 -0
- package/dist/esm/engagement/api-rules.d.ts +49 -0
- package/dist/esm/engagement/api-rules.js +199 -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 +18 -0
- package/dist/esm/engagement/auto-screen.js +301 -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 +101 -0
- package/dist/esm/engagement/session.d.ts +51 -0
- package/dist/esm/engagement/session.js +448 -0
- package/dist/esm/engagement/track.d.ts +56 -0
- package/dist/esm/engagement/track.js +365 -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 +163 -0
- package/dist/esm/feedback/controls.d.ts +37 -0
- package/dist/esm/feedback/controls.js +309 -0
- package/dist/esm/feedback/index.d.ts +9 -0
- package/dist/esm/feedback/index.js +51 -0
- package/dist/esm/feedback/logs.d.ts +45 -0
- package/dist/esm/feedback/logs.js +227 -0
- package/dist/esm/feedback/quartz.d.ts +18 -0
- package/dist/esm/feedback/quartz.js +99 -0
- package/dist/esm/feedback/send.d.ts +28 -0
- package/dist/esm/feedback/send.js +198 -0
- package/dist/esm/feedback/styles.d.ts +10 -0
- package/dist/esm/feedback/styles.js +4 -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 +63 -0
- package/dist/esm/feedback/ui.js +703 -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 +445 -0
- package/dist/esm/index.d.ts +22 -0
- package/dist/esm/index.js +150 -0
- package/dist/esm/lifecycle.d.ts +21 -0
- package/dist/esm/lifecycle.js +729 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/remoteconfig/country.d.ts +4 -0
- package/dist/esm/remoteconfig/country.js +70 -0
- package/dist/esm/remoteconfig/custom.d.ts +10 -0
- package/dist/esm/remoteconfig/custom.js +54 -0
- package/dist/esm/remoteconfig/evaluate.d.ts +24 -0
- package/dist/esm/remoteconfig/evaluate.js +179 -0
- package/dist/esm/remoteconfig/fetch.d.ts +24 -0
- package/dist/esm/remoteconfig/fetch.js +196 -0
- package/dist/esm/remoteconfig/index.d.ts +15 -0
- package/dist/esm/remoteconfig/index.js +111 -0
- package/dist/esm/remoteconfig/store.d.ts +18 -0
- package/dist/esm/remoteconfig/store.js +91 -0
- 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 -0
- package/dist/esm/remotelog/gate.js +26 -0
- package/dist/esm/remotelog/index.d.ts +8 -0
- package/dist/esm/remotelog/logger.d.ts +22 -0
- package/dist/esm/remotelog/logger.js +108 -0
- package/dist/esm/remotelog/send.d.ts +13 -0
- package/dist/esm/remotelog/send.js +149 -0
- package/dist/esm/remotelogger/index.d.ts +12 -0
- package/dist/esm/remotelogger/index.js +13 -0
- package/dist/esm/scheduler.d.ts +8 -0
- package/dist/esm/scheduler.js +74 -0
- package/dist/esm/types.d.ts +385 -0
- package/dist/esm/user/index.d.ts +33 -0
- package/dist/esm/user/index.js +176 -0
- package/dist/feedback.esm.min.js +3 -0
- package/dist/feedback.esm.min.js.map +1 -0
- package/package.json +122 -7
- package/src/appticssdk.js +0 -1
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
|
+
import { forward, guard } from '../core/guard.js';
|
|
3
|
+
import { Console } from '../core/logger.js';
|
|
4
|
+
import { obtain } from './fetch.js';
|
|
5
|
+
import { setCustomConditionValue } from './custom.js';
|
|
6
|
+
import { all } from './store.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Remote config, shipped as its own entry point:
|
|
10
|
+
* import { AppticsRemoteConfig } from '@zoho_apptics/apptics-js-sdk/remote-config';
|
|
11
|
+
*
|
|
12
|
+
* fetchValue(name) reads one parameter, fetchValues(['a', 'b']) several, and fetchValues() every
|
|
13
|
+
* parameter the console has. Each parameter's value is the console's: the value of the first
|
|
14
|
+
* condition, in the console's order, that this device matches, else the parameter's default value.
|
|
15
|
+
* setCustomConditionValue(conditionname, 'a,b') answers the custom conditions.
|
|
16
|
+
* The rule set is stored and resolved on the device, so a fetch within five minutes answers without
|
|
17
|
+
* waiting on the network, and a failed one answers with the values fetched before. The SDK fetches
|
|
18
|
+
* on start-up, and re-applies the rules on its own when AppticsUser.setUser changes the user.
|
|
19
|
+
*
|
|
20
|
+
* A name the console does not have is null, never undefined: a config system whose failure mode
|
|
21
|
+
* is `undefined` moves the problem into the app's rendering code.
|
|
22
|
+
*/
|
|
23
|
+
function raw(name) {
|
|
24
|
+
var values = all();
|
|
25
|
+
return Object.prototype.hasOwnProperty.call(values, name) ? values[name] : undefined;
|
|
26
|
+
}
|
|
27
|
+
/** Hands a result to the app's callback, which must not be able to break the Promise. */
|
|
28
|
+
function answer(value, callback) {
|
|
29
|
+
if (typeof callback === 'function') { // no i18n
|
|
30
|
+
try {
|
|
31
|
+
callback(value);
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
Console.warn('AppticsRemoteConfig: the callback threw', err); // no i18n
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* One parameter, fetched for this page, as Android's fetchValue: resolves with its value, or null
|
|
41
|
+
* when the console has no such parameter. A failed fetch answers with the value fetched before.
|
|
42
|
+
*/
|
|
43
|
+
function fetchValue(name, callback) {
|
|
44
|
+
return obtain().then(function () {
|
|
45
|
+
var value = raw(name);
|
|
46
|
+
return answer(value === undefined ? null : value, callback);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Several parameters at once: `names` lists the ones wanted, and the result has exactly those
|
|
51
|
+
* names, null for one the console does not have. With no names (or an empty list), every
|
|
52
|
+
* parameter the console has. A callback may come first when there are no names.
|
|
53
|
+
*/
|
|
54
|
+
function fetchValues(names, callback) {
|
|
55
|
+
if (typeof names === 'function') { // no i18n
|
|
56
|
+
// fetchValues(callback)
|
|
57
|
+
callback = names;
|
|
58
|
+
names = undefined;
|
|
59
|
+
}
|
|
60
|
+
var wanted = wantedNames(names);
|
|
61
|
+
var done = typeof callback === 'function' ? callback : undefined; // no i18n
|
|
62
|
+
return obtain().then(function () {
|
|
63
|
+
var values = all();
|
|
64
|
+
var out = {};
|
|
65
|
+
(wanted === null ? Object.keys(values) : wanted).forEach(function (name) {
|
|
66
|
+
var value = raw(name);
|
|
67
|
+
out[name] = value === undefined ? null : value;
|
|
68
|
+
});
|
|
69
|
+
return answer(out, done);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/** The names asked for, or null for every parameter. Anything but a list of names counts as none. */
|
|
73
|
+
function wantedNames(names) {
|
|
74
|
+
if (names === undefined || names === null) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
if (!Array.isArray(names)) {
|
|
78
|
+
Console.warn('AppticsRemoteConfig.fetchValues: takes a list of parameter names, as fetchValues([\'a\', \'b\']); answering with every parameter'); // no i18n
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
var out = [];
|
|
82
|
+
names.forEach(function (name) {
|
|
83
|
+
var one = typeof name === 'string' ? name.trim() : ''; // no i18n
|
|
84
|
+
if (one !== '' && out.indexOf(one) === -1) { // no i18n
|
|
85
|
+
out.push(one);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
return out.length === 0 ? null : out;
|
|
89
|
+
}
|
|
90
|
+
const fetchValueGuarded = guard('AppticsRemoteConfig.fetchValue', fetchValue); // no i18n
|
|
91
|
+
const fetchValuesGuarded = guard('AppticsRemoteConfig.fetchValues', fetchValues); // no i18n
|
|
92
|
+
const setCustomConditionValueGuarded = guard('AppticsRemoteConfig.setCustomConditionValue', setCustomConditionValue); // no i18n
|
|
93
|
+
/** AppticsRemoteConfig: fetchValue, fetchValues and setCustomConditionValue, each with the parameter names the console shows. */
|
|
94
|
+
const AppticsRemoteConfig = {
|
|
95
|
+
fetchValue: function fetchValue(name, callback) {
|
|
96
|
+
return forward(fetchValueGuarded, arguments);
|
|
97
|
+
},
|
|
98
|
+
/** The parameters named, or every parameter when none are: name -> value, null when there is none. */
|
|
99
|
+
fetchValues: function fetchValues(names, callback) {
|
|
100
|
+
return forward(fetchValuesGuarded, arguments);
|
|
101
|
+
}, // no i18n
|
|
102
|
+
/**
|
|
103
|
+
* What this device is for a custom condition, by the condition's name, as comma separated
|
|
104
|
+
* values: it matches when one of them is listed. An empty value removes it.
|
|
105
|
+
*/
|
|
106
|
+
setCustomConditionValue: function setCustomConditionValue(conditionname, value) {
|
|
107
|
+
forward(setCustomConditionValueGuarded, arguments);
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export { AppticsRemoteConfig, AppticsRemoteConfig as default };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Dict } from '../types.js';
|
|
2
|
+
/** The flagtime to send: 0 until we hold a rule set, which asks the server for everything. */
|
|
3
|
+
export declare function flagtime(): number;
|
|
4
|
+
/** Re-resolves the stored rules against this device, without fetching. */
|
|
5
|
+
export declare function reresolve(): void;
|
|
6
|
+
/** Stores a rule set the server just sent, and resolves it. */
|
|
7
|
+
export declare function store(rules: Dict, at: number): void;
|
|
8
|
+
/**
|
|
9
|
+
* Records a fetch that brought no rule set.
|
|
10
|
+
*
|
|
11
|
+
* That is the normal answer when nothing has changed, and it is not a failure: what is stored
|
|
12
|
+
* stays, and only the fetch time moves.
|
|
13
|
+
*/
|
|
14
|
+
export declare function storeUnchanged(at: number): void;
|
|
15
|
+
/** Forgets the rule set and its values, so the next fetch asks with flagtime 0. */
|
|
16
|
+
export declare function clearRemoteConfig(): void;
|
|
17
|
+
/** Every parameter resolved for this device. Loads from storage on the first read. */
|
|
18
|
+
export declare function all(): Record<string, string>;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
|
+
import { Console } from '../core/logger.js';
|
|
3
|
+
import { user_defaults } from '../core/storage.js';
|
|
4
|
+
import { resolveAll, resetEvaluationWarnings } from './evaluate.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* What remote config keeps between visits.
|
|
8
|
+
*
|
|
9
|
+
* The rule set is stored, not just the resolved values, for two reasons. The server only resends
|
|
10
|
+
* it when something changed — a fetch with a non-zero `flagtime` and no changes answers with no
|
|
11
|
+
* `remoteconfig` block at all — so throwing it away would mean asking for it again with
|
|
12
|
+
* flagtime 0 on every visit. And the resolved values depend on the device: an app version or a
|
|
13
|
+
* customer group that changed since the last visit has to re-resolve against the same rules.
|
|
14
|
+
*
|
|
15
|
+
* `flagtime` is the whole protocol here: it is the moment this SDK last had a rule set, and
|
|
16
|
+
* sending it back is how the server decides whether anything needs saying.
|
|
17
|
+
*/
|
|
18
|
+
const STORE_KEY = 'remoteconfig'; // no i18n
|
|
19
|
+
var values = {};
|
|
20
|
+
var loaded = false;
|
|
21
|
+
function read() {
|
|
22
|
+
var saved = user_defaults.item(STORE_KEY);
|
|
23
|
+
return saved && typeof saved === 'object' ? saved : null;
|
|
24
|
+
}
|
|
25
|
+
/** The flagtime to send: 0 until we hold a rule set, which asks the server for everything. */
|
|
26
|
+
function flagtime() {
|
|
27
|
+
var saved = read();
|
|
28
|
+
return saved && typeof saved.flagtime === 'number' ? saved.flagtime : 0;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The newest `version[].date` in a rule set, which is what the next fetch sends as flagtime.
|
|
32
|
+
*
|
|
33
|
+
* The array is a publication history and is not promised to be in order, so it is the highest
|
|
34
|
+
* date that matters rather than the first or last entry.
|
|
35
|
+
*/
|
|
36
|
+
function publishedAt(rules) {
|
|
37
|
+
var versions = Array.isArray(rules.version) ? rules.version : [];
|
|
38
|
+
var newest = 0;
|
|
39
|
+
versions.forEach(function (one) {
|
|
40
|
+
var at = Number(one.date);
|
|
41
|
+
if (isFinite(at) && at > newest) {
|
|
42
|
+
newest = at;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
return newest;
|
|
46
|
+
}
|
|
47
|
+
/** Re-resolves the stored rules against this device, without fetching. */
|
|
48
|
+
function reresolve() {
|
|
49
|
+
var saved = read();
|
|
50
|
+
values = saved && saved.rules ? resolveAll(saved.rules) : {};
|
|
51
|
+
loaded = true;
|
|
52
|
+
}
|
|
53
|
+
/** Stores a rule set the server just sent, and resolves it. */
|
|
54
|
+
function store(rules, at) {
|
|
55
|
+
resetEvaluationWarnings();
|
|
56
|
+
var record = { flagtime: publishedAt(rules) || at, rules: rules, fetchedat: at };
|
|
57
|
+
user_defaults.add(STORE_KEY, record);
|
|
58
|
+
values = resolveAll(rules);
|
|
59
|
+
loaded = true;
|
|
60
|
+
Console.log('AppticsRemoteConfig: ' + Object.keys(values).length + ' parameters, published ' + record.flagtime); // no i18n
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Records a fetch that brought no rule set.
|
|
64
|
+
*
|
|
65
|
+
* That is the normal answer when nothing has changed, and it is not a failure: what is stored
|
|
66
|
+
* stays, and only the fetch time moves.
|
|
67
|
+
*/
|
|
68
|
+
function storeUnchanged(at) {
|
|
69
|
+
var saved = read();
|
|
70
|
+
if (saved === null) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
saved.fetchedat = at;
|
|
74
|
+
user_defaults.add(STORE_KEY, saved);
|
|
75
|
+
}
|
|
76
|
+
/** Forgets the rule set and its values, so the next fetch asks with flagtime 0. */
|
|
77
|
+
function clearRemoteConfig() {
|
|
78
|
+
user_defaults.add(STORE_KEY, undefined);
|
|
79
|
+
values = {};
|
|
80
|
+
loaded = false;
|
|
81
|
+
resetEvaluationWarnings();
|
|
82
|
+
}
|
|
83
|
+
/** Every parameter resolved for this device. Loads from storage on the first read. */
|
|
84
|
+
function all() {
|
|
85
|
+
if (!loaded) {
|
|
86
|
+
reresolve();
|
|
87
|
+
}
|
|
88
|
+
return values;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export { all, clearRemoteConfig, flagtime, reresolve, store, storeUnchanged };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The country of every IANA time zone, by its ISO 3166 code: generated by
|
|
3
|
+
* scripts/tz-countries.mjs from tzdata 2026d-rearguard (zone.tab, and the old names its links keep).
|
|
4
|
+
* Do not edit by hand.
|
|
5
|
+
*
|
|
6
|
+
* Packed as "CC:Area/City,City|Area/City;CC:...": a country, then its zones grouped by area.
|
|
7
|
+
*/
|
|
8
|
+
export declare const TZ_COUNTRIES = "AD:Europe/Andorra;AE:Asia/Dubai;AF:Asia/Kabul;AG:America/Antigua;AI:America/Anguilla;AL:Europe/Tirane;AM:Asia/Yerevan;AO:Africa/Luanda;AQ:Antarctica/Casey,Davis,DumontDUrville,Mawson,McMurdo,Palmer,Rothera,Syowa,Troll,Vostok;AR:America/Argentina/Buenos_Aires,Argentina/Catamarca,Argentina/ComodRivadavia,Argentina/Cordoba,Argentina/Jujuy,Argentina/La_Rioja,Argentina/Mendoza,Argentina/Rio_Gallegos,Argentina/Salta,Argentina/San_Juan,Argentina/San_Luis,Argentina/Tucuman,Argentina/Ushuaia,Buenos_Aires,Catamarca,Cordoba,Jujuy,Mendoza,Rosario;AS:Pacific/Pago_Pago,Samoa|US/Samoa;AT:Europe/Vienna;AU:Antarctica/Macquarie|Australia/ACT,Adelaide,Brisbane,Broken_Hill,Canberra,Currie,Darwin,Eucla,Hobart,LHI,Lindeman,Lord_Howe,Melbourne,NSW,North,Perth,Queensland,South,Sydney,Tasmania,Victoria,West,Yancowinna;AW:America/Aruba;AX:Europe/Mariehamn;AZ:Asia/Baku;BA:Europe/Sarajevo;BB:America/Barbados;BD:Asia/Dacca,Dhaka;BE:CET,MET|Europe/Brussels;BF:Africa/Ouagadougou;BG:Europe/Sofia;BH:Asia/Bahrain;BI:Africa/Bujumbura;BJ:Africa/Porto-Novo;BL:America/St_Barthelemy;BM:Atlantic/Bermuda;BN:Asia/Brunei;BO:America/La_Paz;BQ:America/Kralendijk;BR:America/Araguaina,Bahia,Belem,Boa_Vista,Campo_Grande,Cuiaba,Eirunepe,Fortaleza,Maceio,Manaus,Noronha,Porto_Acre,Porto_Velho,Recife,Rio_Branco,Santarem,Sao_Paulo|Brazil/Acre,DeNoronha,East,West;BS:America/Nassau;BT:Asia/Thimbu,Thimphu;BW:Africa/Gaborone;BY:Europe/Minsk;BZ:America/Belize;CA:America/Atikokan,Blanc-Sablon,Cambridge_Bay,Creston,Dawson,Dawson_Creek,Edmonton,Fort_Nelson,Glace_Bay,Goose_Bay,Halifax,Inuvik,Iqaluit,Moncton,Montreal,Nipigon,Pangnirtung,Rainy_River,Rankin_Inlet,Regina,Resolute,St_Johns,Swift_Current,Thunder_Bay,Toronto,Vancouver,Whitehorse,Winnipeg,Yellowknife|Canada/Atlantic,Central,Eastern,Mountain,Newfoundland,Pacific,Saskatchewan,Yukon;CC:Indian/Cocos;CD:Africa/Kinshasa,Lubumbashi;CF:Africa/Bangui;CG:Africa/Brazzaville;CH:Europe/Zurich;CI:Africa/Abidjan,Timbuktu|Iceland;CK:Pacific/Rarotonga;CL:America/Coyhaique,Punta_Arenas,Santiago|Chile/Continental,EasterIsland|Pacific/Easter;CM:Africa/Douala;CN:Asia/Chongqing,Chungking,Harbin,Kashgar,Shanghai,Urumqi|PRC;CO:America/Bogota;CR:America/Costa_Rica;CU:America/Havana|Cuba;CV:Atlantic/Cape_Verde;CW:America/Curacao;CX:Indian/Christmas;CY:Asia/Famagusta,Nicosia|Europe/Nicosia;CZ:Europe/Prague;DE:Atlantic/Jan_Mayen|Europe/Berlin,Busingen;DJ:Africa/Djibouti;DK:Europe/Copenhagen;DM:America/Dominica;DO:America/Santo_Domingo;DZ:Africa/Algiers;EC:America/Guayaquil|Pacific/Galapagos;EE:Europe/Tallinn;EG:Africa/Cairo|Egypt;EH:Africa/El_Aaiun;ER:Africa/Asmara;ES:Africa/Ceuta|Atlantic/Canary|Europe/Madrid;ET:Africa/Addis_Ababa;FI:Europe/Helsinki;FJ:Pacific/Fiji;FK:Atlantic/Stanley;FM:Pacific/Chuuk,Kosrae,Pohnpei;FO:Atlantic/Faeroe,Faroe;FR:Europe/Paris;GA:Africa/Libreville;GB:Europe/Belfast,London|GB,GB-Eire;GD:America/Grenada;GE:Asia/Tbilisi;GF:America/Cayenne;GG:Europe/Guernsey;GH:Africa/Accra;GI:Europe/Gibraltar;GL:America/Danmarkshavn,Godthab,Nuuk,Scoresbysund,Thule;GM:Africa/Banjul;GN:Africa/Conakry;GP:America/Guadeloupe;GQ:Africa/Malabo;GR:EET|Europe/Athens;GS:Atlantic/South_Georgia;GT:America/Guatemala;GU:Pacific/Guam;GW:Africa/Bissau;GY:America/Guyana;HK:Asia/Hong_Kong|Hongkong;HN:America/Tegucigalpa;HR:Europe/Zagreb;HT:America/Port-au-Prince;HU:Europe/Budapest;ID:Asia/Jakarta,Jayapura,Makassar,Pontianak,Ujung_Pandang;IE:Eire|Europe/Dublin;IL:Asia/Jerusalem,Tel_Aviv|Israel;IM:Europe/Isle_of_Man;IN:Asia/Calcutta,Kolkata;IO:Indian/Chagos;IQ:Asia/Baghdad;IR:Asia/Tehran|Iran;IS:Atlantic/Reykjavik;IT:Europe/Rome;JE:Europe/Jersey;JM:America/Jamaica|Jamaica;JO:Asia/Amman;JP:Asia/Tokyo|Japan;KE:Africa/Asmera,Nairobi;KG:Asia/Bishkek;KH:Asia/Phnom_Penh;KI:Pacific/Enderbury,Kanton,Kiritimati,Tarawa;KM:Indian/Comoro;KN:America/St_Kitts;KP:Asia/Pyongyang;KR:Asia/Seoul|ROK;KW:Asia/Kuwait;KY:America/Cayman;KZ:Asia/Almaty,Aqtau,Aqtobe,Atyrau,Oral,Qostanay,Qyzylorda;LA:Asia/Vientiane;LB:Asia/Beirut;LC:America/St_Lucia;LI:Europe/Vaduz;LK:Asia/Colombo;LR:Africa/Monrovia;LS:Africa/Maseru;LT:Europe/Vilnius;LU:Europe/Luxembourg;LV:Europe/Riga;LY:Africa/Tripoli|Libya;MA:Africa/Casablanca;MC:Europe/Monaco;MD:Europe/Chisinau,Tiraspol;ME:Europe/Podgorica;MF:America/Marigot;MG:Indian/Antananarivo;MH:Kwajalein|Pacific/Kwajalein,Majuro;MK:Europe/Skopje;ML:Africa/Bamako;MM:Asia/Rangoon,Yangon;MN:Asia/Choibalsan,Hovd,Ulaanbaatar,Ulan_Bator;MO:Asia/Macao,Macau;MP:Pacific/Saipan;MQ:America/Martinique;MR:Africa/Nouakchott;MS:America/Montserrat;MT:Europe/Malta;MU:Indian/Mauritius;MV:Indian/Maldives;MW:Africa/Blantyre;MX:America/Bahia_Banderas,Cancun,Chihuahua,Ciudad_Juarez,Ensenada,Hermosillo,Matamoros,Mazatlan,Merida,Mexico_City,Monterrey,Ojinaga,Santa_Isabel,Tijuana|Mexico/BajaNorte,BajaSur,General;MY:Asia/Kuala_Lumpur,Kuching;MZ:Africa/Maputo;NA:Africa/Windhoek;NC:Pacific/Noumea;NE:Africa/Niamey;NF:Pacific/Norfolk;NG:Africa/Lagos;NI:America/Managua;NL:Europe/Amsterdam;NO:Europe/Oslo;NP:Asia/Kathmandu,Katmandu;NR:Pacific/Nauru;NU:Pacific/Niue;NZ:Antarctica/South_Pole|NZ,NZ-CHAT|Pacific/Auckland,Chatham;OM:Asia/Muscat;PA:America/Coral_Harbour,Panama|EST;PE:America/Lima;PF:Pacific/Gambier,Marquesas,Tahiti;PG:Pacific/Bougainville,Port_Moresby,Truk,Yap;PH:Asia/Manila;PK:Asia/Karachi;PL:Europe/Warsaw|Poland;PM:America/Miquelon;PN:Pacific/Pitcairn;PR:America/Puerto_Rico,Virgin;PS:Asia/Gaza,Hebron;PT:Atlantic/Azores,Madeira|Europe/Lisbon|Portugal,WET;PW:Pacific/Palau;PY:America/Asuncion;QA:Asia/Qatar;RE:Indian/Reunion;RO:Europe/Bucharest;RS:Europe/Belgrade;RU:Asia/Anadyr,Barnaul,Chita,Irkutsk,Kamchatka,Khandyga,Krasnoyarsk,Magadan,Novokuznetsk,Novosibirsk,Omsk,Sakhalin,Srednekolymsk,Tomsk,Ust-Nera,Vladivostok,Yakutsk,Yekaterinburg|Europe/Astrakhan,Kaliningrad,Kirov,Moscow,Samara,Saratov,Ulyanovsk,Volgograd|W-SU;RW:Africa/Kigali;SA:Asia/Riyadh;SB:Pacific/Guadalcanal,Ponape;SC:Indian/Mahe;SD:Africa/Khartoum;SE:Europe/Stockholm;SG:Asia/Singapore|Singapore;SH:Atlantic/St_Helena;SI:Europe/Ljubljana;SJ:Arctic/Longyearbyen;SK:Europe/Bratislava;SL:Africa/Freetown;SM:Europe/San_Marino;SN:Africa/Dakar;SO:Africa/Mogadishu;SR:America/Paramaribo;SS:Africa/Juba;ST:Africa/Sao_Tome;SV:America/El_Salvador;SX:America/Lower_Princes;SY:Asia/Damascus;SZ:Africa/Mbabane;TC:America/Grand_Turk;TD:Africa/Ndjamena;TF:Indian/Kerguelen;TG:Africa/Lome;TH:Asia/Bangkok;TJ:Asia/Dushanbe;TK:Pacific/Fakaofo;TL:Asia/Dili;TM:Asia/Ashgabat,Ashkhabad;TN:Africa/Tunis;TO:Pacific/Tongatapu;TR:Asia/Istanbul|Europe/Istanbul|Turkey;TT:America/Port_of_Spain;TV:Pacific/Funafuti;TW:Asia/Taipei|ROC;TZ:Africa/Dar_es_Salaam;UA:Europe/Kiev,Kyiv,Simferopol,Uzhgorod,Zaporozhye;UG:Africa/Kampala;UM:Pacific/Midway,Wake;US:America/Adak,Anchorage,Atka,Boise,Chicago,Denver,Detroit,Fort_Wayne,Indiana/Indianapolis,Indiana/Knox,Indiana/Marengo,Indiana/Petersburg,Indiana/Tell_City,Indiana/Vevay,Indiana/Vincennes,Indiana/Winamac,Indianapolis,Juneau,Kentucky/Louisville,Kentucky/Monticello,Knox_IN,Los_Angeles,Louisville,Menominee,Metlakatla,New_York,Nome,North_Dakota/Beulah,North_Dakota/Center,North_Dakota/New_Salem,Phoenix,Shiprock,Sitka,Yakutat|HST,MST,Navajo|Pacific/Honolulu,Johnston|US/Alaska,Aleutian,Arizona,Central,East-Indiana,Eastern,Hawaii,Indiana-Starke,Michigan,Mountain,Pacific;UY:America/Montevideo;UZ:Asia/Samarkand,Tashkent;VA:Europe/Vatican;VC:America/St_Vincent;VE:America/Caracas;VG:America/Tortola;VI:America/St_Thomas;VN:Asia/Ho_Chi_Minh,Saigon;VU:Pacific/Efate;WF:Pacific/Wallis;WS:Pacific/Apia;YE:Asia/Aden;YT:Indian/Mayotte;ZA:Africa/Johannesburg;ZM:Africa/Lusaka;ZW:Africa/Harare";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
|
+
/**
|
|
3
|
+
* The country of every IANA time zone, by its ISO 3166 code: generated by
|
|
4
|
+
* scripts/tz-countries.mjs from tzdata 2026d-rearguard (zone.tab, and the old names its links keep).
|
|
5
|
+
* Do not edit by hand.
|
|
6
|
+
*
|
|
7
|
+
* Packed as "CC:Area/City,City|Area/City;CC:...": a country, then its zones grouped by area.
|
|
8
|
+
*/
|
|
9
|
+
const TZ_COUNTRIES = 'AD:Europe/Andorra;AE:Asia/Dubai;AF:Asia/Kabul;AG:America/Antigua;AI:America/Anguilla;AL:Europe/Tirane;AM:Asia/Yerevan;AO:Africa/Luanda;AQ:Antarctica/Casey,Davis,DumontDUrville,Mawson,McMurdo,Palmer,Rothera,Syowa,Troll,Vostok;AR:America/Argentina/Buenos_Aires,Argentina/Catamarca,Argentina/ComodRivadavia,Argentina/Cordoba,Argentina/Jujuy,Argentina/La_Rioja,Argentina/Mendoza,Argentina/Rio_Gallegos,Argentina/Salta,Argentina/San_Juan,Argentina/San_Luis,Argentina/Tucuman,Argentina/Ushuaia,Buenos_Aires,Catamarca,Cordoba,Jujuy,Mendoza,Rosario;AS:Pacific/Pago_Pago,Samoa|US/Samoa;AT:Europe/Vienna;AU:Antarctica/Macquarie|Australia/ACT,Adelaide,Brisbane,Broken_Hill,Canberra,Currie,Darwin,Eucla,Hobart,LHI,Lindeman,Lord_Howe,Melbourne,NSW,North,Perth,Queensland,South,Sydney,Tasmania,Victoria,West,Yancowinna;AW:America/Aruba;AX:Europe/Mariehamn;AZ:Asia/Baku;BA:Europe/Sarajevo;BB:America/Barbados;BD:Asia/Dacca,Dhaka;BE:CET,MET|Europe/Brussels;BF:Africa/Ouagadougou;BG:Europe/Sofia;BH:Asia/Bahrain;BI:Africa/Bujumbura;BJ:Africa/Porto-Novo;BL:America/St_Barthelemy;BM:Atlantic/Bermuda;BN:Asia/Brunei;BO:America/La_Paz;BQ:America/Kralendijk;BR:America/Araguaina,Bahia,Belem,Boa_Vista,Campo_Grande,Cuiaba,Eirunepe,Fortaleza,Maceio,Manaus,Noronha,Porto_Acre,Porto_Velho,Recife,Rio_Branco,Santarem,Sao_Paulo|Brazil/Acre,DeNoronha,East,West;BS:America/Nassau;BT:Asia/Thimbu,Thimphu;BW:Africa/Gaborone;BY:Europe/Minsk;BZ:America/Belize;CA:America/Atikokan,Blanc-Sablon,Cambridge_Bay,Creston,Dawson,Dawson_Creek,Edmonton,Fort_Nelson,Glace_Bay,Goose_Bay,Halifax,Inuvik,Iqaluit,Moncton,Montreal,Nipigon,Pangnirtung,Rainy_River,Rankin_Inlet,Regina,Resolute,St_Johns,Swift_Current,Thunder_Bay,Toronto,Vancouver,Whitehorse,Winnipeg,Yellowknife|Canada/Atlantic,Central,Eastern,Mountain,Newfoundland,Pacific,Saskatchewan,Yukon;CC:Indian/Cocos;CD:Africa/Kinshasa,Lubumbashi;CF:Africa/Bangui;CG:Africa/Brazzaville;CH:Europe/Zurich;CI:Africa/Abidjan,Timbuktu|Iceland;CK:Pacific/Rarotonga;CL:America/Coyhaique,Punta_Arenas,Santiago|Chile/Continental,EasterIsland|Pacific/Easter;CM:Africa/Douala;CN:Asia/Chongqing,Chungking,Harbin,Kashgar,Shanghai,Urumqi|PRC;CO:America/Bogota;CR:America/Costa_Rica;CU:America/Havana|Cuba;CV:Atlantic/Cape_Verde;CW:America/Curacao;CX:Indian/Christmas;CY:Asia/Famagusta,Nicosia|Europe/Nicosia;CZ:Europe/Prague;DE:Atlantic/Jan_Mayen|Europe/Berlin,Busingen;DJ:Africa/Djibouti;DK:Europe/Copenhagen;DM:America/Dominica;DO:America/Santo_Domingo;DZ:Africa/Algiers;EC:America/Guayaquil|Pacific/Galapagos;EE:Europe/Tallinn;EG:Africa/Cairo|Egypt;EH:Africa/El_Aaiun;ER:Africa/Asmara;ES:Africa/Ceuta|Atlantic/Canary|Europe/Madrid;ET:Africa/Addis_Ababa;FI:Europe/Helsinki;FJ:Pacific/Fiji;FK:Atlantic/Stanley;FM:Pacific/Chuuk,Kosrae,Pohnpei;FO:Atlantic/Faeroe,Faroe;FR:Europe/Paris;GA:Africa/Libreville;GB:Europe/Belfast,London|GB,GB-Eire;GD:America/Grenada;GE:Asia/Tbilisi;GF:America/Cayenne;GG:Europe/Guernsey;GH:Africa/Accra;GI:Europe/Gibraltar;GL:America/Danmarkshavn,Godthab,Nuuk,Scoresbysund,Thule;GM:Africa/Banjul;GN:Africa/Conakry;GP:America/Guadeloupe;GQ:Africa/Malabo;GR:EET|Europe/Athens;GS:Atlantic/South_Georgia;GT:America/Guatemala;GU:Pacific/Guam;GW:Africa/Bissau;GY:America/Guyana;HK:Asia/Hong_Kong|Hongkong;HN:America/Tegucigalpa;HR:Europe/Zagreb;HT:America/Port-au-Prince;HU:Europe/Budapest;ID:Asia/Jakarta,Jayapura,Makassar,Pontianak,Ujung_Pandang;IE:Eire|Europe/Dublin;IL:Asia/Jerusalem,Tel_Aviv|Israel;IM:Europe/Isle_of_Man;IN:Asia/Calcutta,Kolkata;IO:Indian/Chagos;IQ:Asia/Baghdad;IR:Asia/Tehran|Iran;IS:Atlantic/Reykjavik;IT:Europe/Rome;JE:Europe/Jersey;JM:America/Jamaica|Jamaica;JO:Asia/Amman;JP:Asia/Tokyo|Japan;KE:Africa/Asmera,Nairobi;KG:Asia/Bishkek;KH:Asia/Phnom_Penh;KI:Pacific/Enderbury,Kanton,Kiritimati,Tarawa;KM:Indian/Comoro;KN:America/St_Kitts;KP:Asia/Pyongyang;KR:Asia/Seoul|ROK;KW:Asia/Kuwait;KY:America/Cayman;KZ:Asia/Almaty,Aqtau,Aqtobe,Atyrau,Oral,Qostanay,Qyzylorda;LA:Asia/Vientiane;LB:Asia/Beirut;LC:America/St_Lucia;LI:Europe/Vaduz;LK:Asia/Colombo;LR:Africa/Monrovia;LS:Africa/Maseru;LT:Europe/Vilnius;LU:Europe/Luxembourg;LV:Europe/Riga;LY:Africa/Tripoli|Libya;MA:Africa/Casablanca;MC:Europe/Monaco;MD:Europe/Chisinau,Tiraspol;ME:Europe/Podgorica;MF:America/Marigot;MG:Indian/Antananarivo;MH:Kwajalein|Pacific/Kwajalein,Majuro;MK:Europe/Skopje;ML:Africa/Bamako;MM:Asia/Rangoon,Yangon;MN:Asia/Choibalsan,Hovd,Ulaanbaatar,Ulan_Bator;MO:Asia/Macao,Macau;MP:Pacific/Saipan;MQ:America/Martinique;MR:Africa/Nouakchott;MS:America/Montserrat;MT:Europe/Malta;MU:Indian/Mauritius;MV:Indian/Maldives;MW:Africa/Blantyre;MX:America/Bahia_Banderas,Cancun,Chihuahua,Ciudad_Juarez,Ensenada,Hermosillo,Matamoros,Mazatlan,Merida,Mexico_City,Monterrey,Ojinaga,Santa_Isabel,Tijuana|Mexico/BajaNorte,BajaSur,General;MY:Asia/Kuala_Lumpur,Kuching;MZ:Africa/Maputo;NA:Africa/Windhoek;NC:Pacific/Noumea;NE:Africa/Niamey;NF:Pacific/Norfolk;NG:Africa/Lagos;NI:America/Managua;NL:Europe/Amsterdam;NO:Europe/Oslo;NP:Asia/Kathmandu,Katmandu;NR:Pacific/Nauru;NU:Pacific/Niue;NZ:Antarctica/South_Pole|NZ,NZ-CHAT|Pacific/Auckland,Chatham;OM:Asia/Muscat;PA:America/Coral_Harbour,Panama|EST;PE:America/Lima;PF:Pacific/Gambier,Marquesas,Tahiti;PG:Pacific/Bougainville,Port_Moresby,Truk,Yap;PH:Asia/Manila;PK:Asia/Karachi;PL:Europe/Warsaw|Poland;PM:America/Miquelon;PN:Pacific/Pitcairn;PR:America/Puerto_Rico,Virgin;PS:Asia/Gaza,Hebron;PT:Atlantic/Azores,Madeira|Europe/Lisbon|Portugal,WET;PW:Pacific/Palau;PY:America/Asuncion;QA:Asia/Qatar;RE:Indian/Reunion;RO:Europe/Bucharest;RS:Europe/Belgrade;RU:Asia/Anadyr,Barnaul,Chita,Irkutsk,Kamchatka,Khandyga,Krasnoyarsk,Magadan,Novokuznetsk,Novosibirsk,Omsk,Sakhalin,Srednekolymsk,Tomsk,Ust-Nera,Vladivostok,Yakutsk,Yekaterinburg|Europe/Astrakhan,Kaliningrad,Kirov,Moscow,Samara,Saratov,Ulyanovsk,Volgograd|W-SU;RW:Africa/Kigali;SA:Asia/Riyadh;SB:Pacific/Guadalcanal,Ponape;SC:Indian/Mahe;SD:Africa/Khartoum;SE:Europe/Stockholm;SG:Asia/Singapore|Singapore;SH:Atlantic/St_Helena;SI:Europe/Ljubljana;SJ:Arctic/Longyearbyen;SK:Europe/Bratislava;SL:Africa/Freetown;SM:Europe/San_Marino;SN:Africa/Dakar;SO:Africa/Mogadishu;SR:America/Paramaribo;SS:Africa/Juba;ST:Africa/Sao_Tome;SV:America/El_Salvador;SX:America/Lower_Princes;SY:Asia/Damascus;SZ:Africa/Mbabane;TC:America/Grand_Turk;TD:Africa/Ndjamena;TF:Indian/Kerguelen;TG:Africa/Lome;TH:Asia/Bangkok;TJ:Asia/Dushanbe;TK:Pacific/Fakaofo;TL:Asia/Dili;TM:Asia/Ashgabat,Ashkhabad;TN:Africa/Tunis;TO:Pacific/Tongatapu;TR:Asia/Istanbul|Europe/Istanbul|Turkey;TT:America/Port_of_Spain;TV:Pacific/Funafuti;TW:Asia/Taipei|ROC;TZ:Africa/Dar_es_Salaam;UA:Europe/Kiev,Kyiv,Simferopol,Uzhgorod,Zaporozhye;UG:Africa/Kampala;UM:Pacific/Midway,Wake;US:America/Adak,Anchorage,Atka,Boise,Chicago,Denver,Detroit,Fort_Wayne,Indiana/Indianapolis,Indiana/Knox,Indiana/Marengo,Indiana/Petersburg,Indiana/Tell_City,Indiana/Vevay,Indiana/Vincennes,Indiana/Winamac,Indianapolis,Juneau,Kentucky/Louisville,Kentucky/Monticello,Knox_IN,Los_Angeles,Louisville,Menominee,Metlakatla,New_York,Nome,North_Dakota/Beulah,North_Dakota/Center,North_Dakota/New_Salem,Phoenix,Shiprock,Sitka,Yakutat|HST,MST,Navajo|Pacific/Honolulu,Johnston|US/Alaska,Aleutian,Arizona,Central,East-Indiana,Eastern,Hawaii,Indiana-Starke,Michigan,Mountain,Pacific;UY:America/Montevideo;UZ:Asia/Samarkand,Tashkent;VA:Europe/Vatican;VC:America/St_Vincent;VE:America/Caracas;VG:America/Tortola;VI:America/St_Thomas;VN:Asia/Ho_Chi_Minh,Saigon;VU:Pacific/Efate;WF:Pacific/Wallis;WS:Pacific/Apia;YE:Asia/Aden;YT:Indian/Mayotte;ZA:Africa/Johannesburg;ZM:Africa/Lusaka;ZW:Africa/Harare'; // no i18n
|
|
10
|
+
|
|
11
|
+
export { TZ_COUNTRIES };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
|
+
import { _ZAP } from '../core/state.js';
|
|
3
|
+
import { is_apptics_disabled } from '../core/env.js';
|
|
4
|
+
import { shouldTrackOrSendData } from '../core/consent.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The one switch both halves of the remote logger ask: may this line be recorded, and may what is
|
|
8
|
+
* stored be sent? It lives on its own so recording and sending don't import each other.
|
|
9
|
+
*
|
|
10
|
+
* There is no switch of the app's own: a line the app writes with AppticsLogger is recorded,
|
|
11
|
+
* whenever the SDK is running, the server has the remote logger on for the app, and the visitor
|
|
12
|
+
* allows tracking.
|
|
13
|
+
*/
|
|
14
|
+
/** Whether a remote log line may be recorded and sent now. */
|
|
15
|
+
function remoteLoggerReachable() {
|
|
16
|
+
if (!_ZAP._token || is_apptics_disabled()) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
// getsdkconfig module 17: the server can switch the remote logger off on its own
|
|
20
|
+
if (!_ZAP._remoteLoggerEnabled) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
return shouldTrackOrSendData();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { remoteLoggerReachable };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remote logger delivery: the AppticsLogger lines (logger.ts) are stored in the remotelogs queue
|
|
3
|
+
* and sent from it to log/add by send.ts. gate.ts holds the switch both ask.
|
|
4
|
+
*
|
|
5
|
+
* The SDK writes nothing of its own here: its failures go to the browser console (core/logger.ts,
|
|
6
|
+
* in debug mode), and only the lines an app logs reach the Remote Logger page.
|
|
7
|
+
*/
|
|
8
|
+
export { forgetStoredLogs, sendStoredLogs } from './send.js';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** The level numbers log/add takes and the Remote Logger page names, in the native SDKs' order. */
|
|
2
|
+
export declare const LOG_LEVEL: Readonly<{
|
|
3
|
+
VERBOSE: 1;
|
|
4
|
+
DEBUG: 2;
|
|
5
|
+
INFO: 3;
|
|
6
|
+
WARN: 4;
|
|
7
|
+
ERROR: 5;
|
|
8
|
+
}>;
|
|
9
|
+
export interface AppticsLogger {
|
|
10
|
+
/** Verbose, level 1 (Android's v). `properties` (an object, as JSON; an Error, as its stack) is appended to the message. */
|
|
11
|
+
verbose(message: unknown, properties?: unknown): void;
|
|
12
|
+
/** Debug, level 2 (Android's d). */
|
|
13
|
+
debug(message: unknown, properties?: unknown): void;
|
|
14
|
+
/** Info, level 3 (Android's i). */
|
|
15
|
+
info(message: unknown, properties?: unknown): void;
|
|
16
|
+
/** Warning, level 4 (Android's w). */
|
|
17
|
+
warn(message: unknown, properties?: unknown): void;
|
|
18
|
+
/** Error, level 5 (Android's e). */
|
|
19
|
+
error(message: unknown, properties?: unknown): void;
|
|
20
|
+
}
|
|
21
|
+
/** AppticsLogger: verbose / debug / info / warn / error(message, properties?). */
|
|
22
|
+
export declare const AppticsLogger: AppticsLogger;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
|
+
import { LOG_FUNCTION_MAX } from '../core/constants.js';
|
|
3
|
+
import { callSite } from '../core/callsite.js';
|
|
4
|
+
import { remotelog_transactions } from '../core/storage.js';
|
|
5
|
+
import { guard } from '../core/guard.js';
|
|
6
|
+
import { nowMs } from '../core/utils.js';
|
|
7
|
+
import { remoteLoggerReachable } from './gate.js';
|
|
8
|
+
import { scheduleSend } from './send.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* AppticsLogger: lines the app writes, shown on the console's Remote Logger page.
|
|
12
|
+
*
|
|
13
|
+
* AppticsLogger.info('Payment started');
|
|
14
|
+
* AppticsLogger.error('Payment failed', err);
|
|
15
|
+
*
|
|
16
|
+
* Nothing is logged on its own: only the lines the app writes, at five levels in the native SDKs'
|
|
17
|
+
* order (verbose, debug, info, warn, error, sent as 1 to 5, the scale the Remote Logger page reads
|
|
18
|
+
* back). A line is recorded as it is written, with no switch to turn on first, whenever the server
|
|
19
|
+
* has the remote logger on for the app and the visitor allows tracking.
|
|
20
|
+
*
|
|
21
|
+
* Lines are stored before they are sent (send.ts), so they survive a failed send and a reload.
|
|
22
|
+
*/
|
|
23
|
+
/** The level numbers log/add takes and the Remote Logger page names, in the native SDKs' order. */
|
|
24
|
+
const LOG_LEVEL = Object.freeze({ VERBOSE: 1, DEBUG: 2, INFO: 3, WARN: 4, ERROR: 5 });
|
|
25
|
+
/** What a line's `function` says when the caller had no name to give (an anonymous callback). */
|
|
26
|
+
const ANONYMOUS_CALLER = 'App'; // no i18n
|
|
27
|
+
/**
|
|
28
|
+
* The caller's name as logSDK's `function` accepts it: safe_string refuses angle brackets and an
|
|
29
|
+
* empty value, and the field stops at 100 characters.
|
|
30
|
+
*/
|
|
31
|
+
function functionName(site) {
|
|
32
|
+
var name = String(site.fn || '').replace(/<anonymous>/g, '').replace(/[<>]/g, '').trim(); // no i18n
|
|
33
|
+
if (name === '' || /^(Object|Module|eval)\.?$/.test(name)) {
|
|
34
|
+
return ANONYMOUS_CALLER;
|
|
35
|
+
}
|
|
36
|
+
return name.slice(0, LOG_FUNCTION_MAX);
|
|
37
|
+
}
|
|
38
|
+
/** One detail as text: an Error as its stack (which leads with name and message), JSON otherwise. */
|
|
39
|
+
function describe(value) {
|
|
40
|
+
if (value instanceof Error) {
|
|
41
|
+
var head = value.name + ': ' + value.message; // no i18n
|
|
42
|
+
return value.stack && value.stack.indexOf(value.message) !== -1 ? value.stack : head;
|
|
43
|
+
}
|
|
44
|
+
if (typeof value === 'string') { // no i18n
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
var json = JSON.stringify(value);
|
|
49
|
+
return json === undefined ? String(value) : json;
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
return String(value);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Stores one line. Reached through guard(), so a line logged before start-up finishes waits for
|
|
57
|
+
* it — which is why the time and call site are taken by the caller, not here.
|
|
58
|
+
*/
|
|
59
|
+
function record(level, message, details, at, site) {
|
|
60
|
+
if (!remoteLoggerReachable()) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
var text = [message].concat(details).map(describe).join(' '); // no i18n
|
|
64
|
+
remotelog_transactions.add({
|
|
65
|
+
type: 'remotelog', // no i18n
|
|
66
|
+
module: functionName(site),
|
|
67
|
+
level: level,
|
|
68
|
+
happenedat: at,
|
|
69
|
+
exceptionlog: text,
|
|
70
|
+
attempt: 1,
|
|
71
|
+
filename: site.filename,
|
|
72
|
+
linenumber: site.linenumber,
|
|
73
|
+
});
|
|
74
|
+
scheduleSend();
|
|
75
|
+
}
|
|
76
|
+
const recordLine = guard('AppticsLogger', record); // no i18n
|
|
77
|
+
/**
|
|
78
|
+
* A level's method, `verbose/debug/info/warn/error(message, properties?)` (Android's v/d/i/w/e,
|
|
79
|
+
* without the tag, which the Remote Logger page does not use). The function, file and line are
|
|
80
|
+
* the caller's.
|
|
81
|
+
*/
|
|
82
|
+
function atLevel(level) {
|
|
83
|
+
return function log(message, properties) {
|
|
84
|
+
try {
|
|
85
|
+
void properties;
|
|
86
|
+
// everything after the message is appended to it: properties, and anything else a caller
|
|
87
|
+
// passed (an Error as well, say), as before
|
|
88
|
+
var details = Array.prototype.slice.call(arguments, 1);
|
|
89
|
+
// skip 1: this function's own frame, so the site is the app's line that logged
|
|
90
|
+
recordLine(level, message, details, nowMs(), callSite(1));
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
// logging must never be the thing that breaks the app
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/** AppticsLogger: verbose / debug / info / warn / error(message, properties?). */
|
|
98
|
+
const AppticsLogger = {
|
|
99
|
+
// not wrapped in a guard of their own: the call site is read a fixed number of frames up, and
|
|
100
|
+
// a frame more would report the SDK's own line instead of the app's
|
|
101
|
+
verbose: atLevel(LOG_LEVEL.VERBOSE),
|
|
102
|
+
debug: atLevel(LOG_LEVEL.DEBUG),
|
|
103
|
+
info: atLevel(LOG_LEVEL.INFO),
|
|
104
|
+
warn: atLevel(LOG_LEVEL.WARN),
|
|
105
|
+
error: atLevel(LOG_LEVEL.ERROR),
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export { AppticsLogger, LOG_LEVEL };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Queues a pass over the stored lines, coalescing a burst into one. */
|
|
2
|
+
export declare function scheduleSend(): void;
|
|
3
|
+
/**
|
|
4
|
+
* Sends the stored lines as one batch. A batch the server refuses for its shape is dropped —
|
|
5
|
+
* retrying it could only fail the same way and would hold every later line behind it.
|
|
6
|
+
*/
|
|
7
|
+
export declare function sendStoredLogs(): Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* Sends what is stored as the page goes away, where a normal request would be cancelled.
|
|
10
|
+
* One keepalive request for the whole batch, which is what the endpoint now accepts. The lines
|
|
11
|
+
* stay stored until the server has confirmed them.
|
|
12
|
+
*/
|
|
13
|
+
export declare function forgetStoredLogs(): Promise<void>;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
|
+
import { LOG_FUNCTION_MAX, CONSOLE_LOG_MAX_BODY, REMOTE_LOG_LEVEL, LOG_FILENAME_MAX } from '../core/constants.js';
|
|
3
|
+
import { _ZAP } from '../core/state.js';
|
|
4
|
+
import { warnAlways, Console } from '../core/logger.js';
|
|
5
|
+
import { nowMs, isEmpty } from '../core/utils.js';
|
|
6
|
+
import { remotelog_transactions } from '../core/storage.js';
|
|
7
|
+
import { postToApptics, apiHeaders, isPermanentRefusal, getMetaObj, postKeepalive } from '../core/transport.js';
|
|
8
|
+
import { remoteLoggerReachable } from './gate.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Delivery for the remote logger.
|
|
12
|
+
*
|
|
13
|
+
* v2 replaced console/addlog, which took one line per call and counted retries in an `attempt`
|
|
14
|
+
* param, with log/add, which takes a batch: `{ logs: [...], meta }`. A pass over the queue is now
|
|
15
|
+
* one request however many lines are waiting, so a burst of failures costs one call instead of
|
|
16
|
+
* twenty, and a line no longer has to carry its own retry bookkeeping — the batch either lands or
|
|
17
|
+
* stays for the next pass.
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* What the stored lines may take up, as on Android (1 MB): past it the oldest are dropped, so a
|
|
21
|
+
* failing SDK or a chatty app can't fill storage. Measured in size rather than in lines, since one
|
|
22
|
+
* line can be a 10,000-character stack and another a word.
|
|
23
|
+
*/
|
|
24
|
+
const MAX_STORED_BYTES = 1024 * 1024;
|
|
25
|
+
/** Sends are grouped, so one broken flow that logs twice makes one pass over the queue. */
|
|
26
|
+
const SEND_DELAY_MS = 1000;
|
|
27
|
+
/** The endpoint takes a 10 MB body; a batch is capped well inside that. */
|
|
28
|
+
const MAX_PER_BATCH = 50;
|
|
29
|
+
const LABEL = 'remoteLog'; // no i18n
|
|
30
|
+
let sendScheduled = false;
|
|
31
|
+
let sending = false;
|
|
32
|
+
/**
|
|
33
|
+
* One stored line as logSDK wants it.
|
|
34
|
+
*
|
|
35
|
+
* `function` is where the module name goes — it is the only field describing *where* a line came
|
|
36
|
+
* from, and the template caps it at 100. `logmessage` is capped at 10000, so a long stack is
|
|
37
|
+
* trimmed rather than having the whole batch refused for one oversized line.
|
|
38
|
+
*/
|
|
39
|
+
function entryFor(item) {
|
|
40
|
+
var entry = {
|
|
41
|
+
sessionstarttime: _ZAP._current_session.starttime || item.happenedat || nowMs(),
|
|
42
|
+
logtime: item.happenedat || nowMs(),
|
|
43
|
+
// an app's line carries the level it was logged at; the SDK's own failures carry none
|
|
44
|
+
level: Number(item.level) || REMOTE_LOG_LEVEL,
|
|
45
|
+
logmessage: String(item.exceptionlog).slice(0, CONSOLE_LOG_MAX_BODY),
|
|
46
|
+
function: String(item.module || 'SDK').slice(0, LOG_FUNCTION_MAX), // no i18n
|
|
47
|
+
// the endpoint reads linenumber with getInt(), which throws on a missing key rather than
|
|
48
|
+
// defaulting, so it goes out on every line - 0 where the stack gave us no frame
|
|
49
|
+
linenumber: Number(item.linenumber) || 0,
|
|
50
|
+
};
|
|
51
|
+
// filename is read with optString and validated against file_name, whose pattern needs at
|
|
52
|
+
// least one character: sending '' would have the whole batch refused, so it is left out
|
|
53
|
+
if (!isEmpty(item.filename)) {
|
|
54
|
+
entry.filename = String(item.filename).slice(0, LOG_FILENAME_MAX);
|
|
55
|
+
}
|
|
56
|
+
return entry;
|
|
57
|
+
}
|
|
58
|
+
/** The batch body: `{ logs, meta }`, where meta is metaWebSDKV2 like every other v2 payload. */
|
|
59
|
+
function bodyFor(items) {
|
|
60
|
+
return JSON.stringify({ logs: items.map(entryFor), meta: getMetaObj() }); // no i18n
|
|
61
|
+
}
|
|
62
|
+
/** Queues a pass over the stored lines, coalescing a burst into one. */
|
|
63
|
+
function scheduleSend() {
|
|
64
|
+
if (sendScheduled) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
sendScheduled = true;
|
|
68
|
+
setTimeout(function () {
|
|
69
|
+
sendScheduled = false;
|
|
70
|
+
sendStoredLogs();
|
|
71
|
+
}, SEND_DELAY_MS);
|
|
72
|
+
}
|
|
73
|
+
/** Drops the oldest lines once the queue is over MAX_STORED_BYTES, keeping the newest that fit. */
|
|
74
|
+
function trim(items) {
|
|
75
|
+
var total = 0;
|
|
76
|
+
var keepFrom = items.length;
|
|
77
|
+
// newest first: they are the ones worth keeping
|
|
78
|
+
for (var i = items.length - 1; i >= 0; i--) {
|
|
79
|
+
total += JSON.stringify(items[i]).length;
|
|
80
|
+
if (total > MAX_STORED_BYTES) {
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
keepFrom = i;
|
|
84
|
+
}
|
|
85
|
+
if (keepFrom === 0) {
|
|
86
|
+
return items;
|
|
87
|
+
}
|
|
88
|
+
remotelog_transactions.remove(items.slice(0, keepFrom));
|
|
89
|
+
return items.slice(keepFrom);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Sends the stored lines as one batch. A batch the server refuses for its shape is dropped —
|
|
93
|
+
* retrying it could only fail the same way and would hold every later line behind it.
|
|
94
|
+
*/
|
|
95
|
+
function sendStoredLogs() {
|
|
96
|
+
if (sending || !remoteLoggerReachable() || navigator.onLine === false) {
|
|
97
|
+
return Promise.resolve();
|
|
98
|
+
}
|
|
99
|
+
sending = true;
|
|
100
|
+
return remotelog_transactions.all().then(function (stored) {
|
|
101
|
+
var batch = trim(stored).slice(0, MAX_PER_BATCH);
|
|
102
|
+
if (batch.length === 0) {
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
return postToApptics('consolelog', bodyFor(batch), apiHeaders(), LABEL).then(function () {
|
|
106
|
+
return remotelog_transactions.remove(batch);
|
|
107
|
+
}, function (err) {
|
|
108
|
+
if (isPermanentRefusal(err)) {
|
|
109
|
+
warnAlways('apptics: the server refused these log lines, so they were dropped: ' + String(err && err.message)); // no i18n
|
|
110
|
+
return remotelog_transactions.remove(batch);
|
|
111
|
+
}
|
|
112
|
+
Console.log(LABEL + ': ' + String(err)); // no i18n
|
|
113
|
+
return undefined;
|
|
114
|
+
});
|
|
115
|
+
}).then(function () {
|
|
116
|
+
sending = false;
|
|
117
|
+
}).catch(function () {
|
|
118
|
+
sending = false;
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Sends what is stored as the page goes away, where a normal request would be cancelled.
|
|
123
|
+
* One keepalive request for the whole batch, which is what the endpoint now accepts. The lines
|
|
124
|
+
* stay stored until the server has confirmed them.
|
|
125
|
+
*/
|
|
126
|
+
function forgetStoredLogs() {
|
|
127
|
+
if (!remoteLoggerReachable()) {
|
|
128
|
+
return Promise.resolve();
|
|
129
|
+
}
|
|
130
|
+
return remotelog_transactions.all().then(function (stored) {
|
|
131
|
+
if (stored.length === 0) {
|
|
132
|
+
return undefined;
|
|
133
|
+
}
|
|
134
|
+
var batch = stored.slice(0, MAX_PER_BATCH);
|
|
135
|
+
// removed once the server has them; lines whose answer never comes go on the next visit
|
|
136
|
+
postKeepalive('consolelog', bodyFor(batch), apiHeaders(), LABEL).then(function () {
|
|
137
|
+
return remotelog_transactions.remove(batch);
|
|
138
|
+
}, function (err) {
|
|
139
|
+
if (isPermanentRefusal(err)) {
|
|
140
|
+
return remotelog_transactions.remove(batch);
|
|
141
|
+
}
|
|
142
|
+
Console.log(LABEL + ': ' + String(err)); // no i18n
|
|
143
|
+
return undefined;
|
|
144
|
+
});
|
|
145
|
+
return undefined;
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export { forgetStoredLogs, scheduleSend, sendStoredLogs };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The app logger, shipped as its own entry point:
|
|
3
|
+
* import { AppticsLogger } from '@zoho_apptics/apptics-js-sdk/remote-logger';
|
|
4
|
+
*
|
|
5
|
+
* AppticsLogger: verbose / debug / info / warn / error(message, props?), shown on the
|
|
6
|
+
* console's Remote Logger page. A line is recorded as it is written, with no switch to turn on.
|
|
7
|
+
* Apps that don't import it don't ship it.
|
|
8
|
+
*/
|
|
9
|
+
import { AppticsLogger } from '../remotelog/logger.js';
|
|
10
|
+
export { AppticsLogger };
|
|
11
|
+
export type { AppticsLogger as AppticsLoggerApi } from '../remotelog/logger.js';
|
|
12
|
+
export default AppticsLogger;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
|
+
import { AppticsLogger } from '../remotelog/logger.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The app logger, shipped as its own entry point:
|
|
6
|
+
* import { AppticsLogger } from '@zoho_apptics/apptics-js-sdk/remote-logger';
|
|
7
|
+
*
|
|
8
|
+
* AppticsLogger: verbose / debug / info / warn / error(message, props?), shown on the
|
|
9
|
+
* console's Remote Logger page. A line is recorded as it is written, with no switch to turn on.
|
|
10
|
+
* Apps that don't import it don't ship it.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export { AppticsLogger, AppticsLogger as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sends everything queued now. With `forget`, the requests are sent without waiting for a
|
|
3
|
+
* response (page hide), so they survive the page going away.
|
|
4
|
+
*/
|
|
5
|
+
export declare function flush(forget?: boolean): Promise<void>;
|
|
6
|
+
/** Starts the flush and getupdates intervals once; later calls do nothing until stopTimers(). */
|
|
7
|
+
export declare function startTimers(): void;
|
|
8
|
+
export declare function stopTimers(): void;
|