@zoho_apptics/apptics-js-sdk 1.0.1 → 2.0.0-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +87 -0
- package/LICENSE +13 -0
- package/README.md +747 -11
- package/dist/apptics.esm.min.js +3 -0
- package/dist/apptics.esm.min.js.map +1 -0
- package/dist/apptics.min.js +3 -0
- package/dist/apptics.min.js.map +1 -0
- package/dist/chunks/batch-BU_mTpm1.min.js +3 -0
- package/dist/chunks/batch-BU_mTpm1.min.js.map +1 -0
- package/dist/chunks/logs-Bea5zUW_.min.js +3 -0
- package/dist/chunks/logs-Bea5zUW_.min.js.map +1 -0
- package/dist/cjs/auto-init.d.ts +8 -0
- package/dist/cjs/auto-init.js +32 -0
- package/dist/cjs/core/attempts.d.ts +28 -0
- package/dist/cjs/core/attempts.js +113 -0
- package/dist/cjs/core/batch.d.ts +32 -0
- package/dist/cjs/core/batch.js +115 -0
- package/dist/cjs/core/callsite.d.ts +28 -0
- package/dist/cjs/core/callsite.js +93 -0
- package/dist/cjs/core/consent.d.ts +23 -0
- package/dist/cjs/core/consent.js +130 -0
- package/dist/cjs/core/constants.d.ts +212 -0
- package/dist/cjs/core/constants.js +299 -0
- package/dist/cjs/core/db.d.ts +40 -0
- package/dist/cjs/core/db.js +334 -0
- package/dist/cjs/core/debug.d.ts +22 -0
- package/dist/cjs/core/debug.js +88 -0
- package/dist/cjs/core/env.d.ts +28 -0
- package/dist/cjs/core/env.js +267 -0
- package/dist/cjs/core/framework-id.d.ts +1 -0
- package/dist/cjs/core/framework-id.js +9 -0
- package/dist/cjs/core/guard.d.ts +2 -0
- package/dist/cjs/core/guard.js +72 -0
- package/dist/cjs/core/hooks.d.ts +41 -0
- package/dist/cjs/core/hooks.js +23 -0
- package/dist/cjs/core/logger.d.ts +16 -0
- package/dist/cjs/core/logger.js +86 -0
- package/dist/cjs/core/state.d.ts +69 -0
- package/dist/cjs/core/state.js +78 -0
- package/dist/cjs/core/storage.d.ts +46 -0
- package/dist/cjs/core/storage.js +229 -0
- package/dist/cjs/core/transport.d.ts +83 -0
- package/dist/cjs/core/transport.js +441 -0
- package/dist/cjs/core/utils.d.ts +26 -0
- package/dist/cjs/core/utils.js +175 -0
- package/dist/cjs/core/validate.d.ts +18 -0
- package/dist/cjs/core/validate.js +233 -0
- package/dist/cjs/device/appversion.d.ts +20 -0
- package/dist/cjs/device/appversion.js +158 -0
- package/dist/cjs/device/index.d.ts +23 -0
- package/dist/cjs/device/index.js +372 -0
- package/dist/cjs/engagement/api-rules.d.ts +84 -0
- package/dist/cjs/engagement/api-rules.js +219 -0
- package/dist/cjs/engagement/auto-api.d.ts +7 -0
- package/dist/cjs/engagement/auto-api.js +200 -0
- package/dist/cjs/engagement/auto-screen.d.ts +16 -0
- package/dist/cjs/engagement/auto-screen.js +241 -0
- package/dist/cjs/engagement/defined-events.d.ts +23 -0
- package/dist/cjs/engagement/defined-events.js +58 -0
- package/dist/cjs/engagement/send.d.ts +6 -0
- package/dist/cjs/engagement/send.js +99 -0
- package/dist/cjs/engagement/session.d.ts +42 -0
- package/dist/cjs/engagement/session.js +327 -0
- package/dist/cjs/engagement/track.d.ts +56 -0
- package/dist/cjs/engagement/track.js +350 -0
- package/dist/cjs/errors/send.d.ts +6 -0
- package/dist/cjs/errors/send.js +73 -0
- package/dist/cjs/errors/track.d.ts +4 -0
- package/dist/cjs/errors/track.js +127 -0
- package/dist/cjs/feedback/controls.d.ts +31 -0
- package/dist/cjs/feedback/controls.js +286 -0
- package/dist/cjs/feedback/index.d.ts +8 -0
- package/dist/cjs/feedback/index.js +37 -0
- package/dist/cjs/feedback/logs.d.ts +40 -0
- package/dist/cjs/feedback/logs.js +202 -0
- package/dist/cjs/feedback/send.d.ts +25 -0
- package/dist/cjs/feedback/send.js +178 -0
- package/dist/cjs/feedback/template.d.ts +2 -0
- package/dist/cjs/feedback/template.js +162 -0
- package/dist/cjs/feedback/ui.d.ts +55 -0
- package/dist/cjs/feedback/ui.js +631 -0
- package/dist/cjs/heatmap/index.d.ts +16 -0
- package/dist/cjs/heatmap/index.js +22 -0
- package/dist/cjs/heatmap/send.d.ts +13 -0
- package/dist/cjs/heatmap/send.js +82 -0
- package/dist/cjs/heatmap/track.d.ts +4 -0
- package/dist/cjs/heatmap/track.js +377 -0
- package/dist/cjs/index.d.ts +68 -0
- package/dist/cjs/index.js +150 -0
- package/dist/cjs/lifecycle.d.ts +14 -0
- package/dist/cjs/lifecycle.js +538 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/remoteconfig/custom.d.ts +10 -0
- package/dist/cjs/remoteconfig/custom.js +78 -0
- package/dist/cjs/remoteconfig/evaluate.d.ts +24 -0
- package/dist/cjs/remoteconfig/evaluate.js +171 -0
- package/dist/cjs/remoteconfig/fetch.d.ts +24 -0
- package/dist/cjs/remoteconfig/fetch.js +214 -0
- package/dist/cjs/remoteconfig/index.d.ts +13 -0
- package/dist/cjs/remoteconfig/index.js +90 -0
- package/dist/cjs/remoteconfig/store.d.ts +18 -0
- package/dist/cjs/remoteconfig/store.js +98 -0
- package/dist/cjs/remotelog/gate.d.ts +11 -0
- package/dist/cjs/remotelog/gate.js +54 -0
- package/dist/cjs/remotelog/index.d.ts +25 -0
- package/dist/cjs/remotelog/index.js +55 -0
- package/dist/cjs/remotelog/logger.d.ts +28 -0
- package/dist/cjs/remotelog/logger.js +139 -0
- package/dist/cjs/remotelog/send.d.ts +13 -0
- package/dist/cjs/remotelog/send.js +153 -0
- package/dist/cjs/scheduler.d.ts +8 -0
- package/dist/cjs/scheduler.js +78 -0
- package/dist/cjs/types.d.ts +312 -0
- package/dist/cjs/user/index.d.ts +33 -0
- package/dist/cjs/user/index.js +178 -0
- package/dist/esm/auto-init.d.ts +8 -0
- package/dist/esm/auto-init.js +29 -0
- package/dist/esm/core/attempts.d.ts +28 -0
- package/dist/esm/core/attempts.js +106 -0
- package/dist/esm/core/batch.d.ts +32 -0
- package/dist/esm/core/batch.js +108 -0
- package/dist/esm/core/callsite.d.ts +28 -0
- package/dist/esm/core/callsite.js +89 -0
- package/dist/esm/core/consent.d.ts +23 -0
- package/dist/esm/core/consent.js +120 -0
- package/dist/esm/core/constants.d.ts +212 -0
- package/dist/esm/core/constants.js +277 -0
- package/dist/esm/core/db.d.ts +40 -0
- package/dist/esm/core/db.js +324 -0
- package/dist/esm/core/debug.d.ts +22 -0
- package/dist/esm/core/debug.js +81 -0
- package/dist/esm/core/env.d.ts +28 -0
- package/dist/esm/core/env.js +251 -0
- package/dist/esm/core/framework-id.d.ts +1 -0
- package/dist/esm/core/framework-id.js +7 -0
- package/dist/esm/core/guard.d.ts +2 -0
- package/dist/esm/core/guard.js +70 -0
- package/dist/esm/core/hooks.d.ts +41 -0
- package/dist/esm/core/hooks.js +21 -0
- package/dist/esm/core/logger.d.ts +16 -0
- package/dist/esm/core/logger.js +82 -0
- package/dist/esm/core/state.d.ts +69 -0
- package/dist/esm/core/state.js +73 -0
- package/dist/esm/core/storage.d.ts +46 -0
- package/dist/esm/core/storage.js +219 -0
- package/dist/esm/core/transport.d.ts +83 -0
- package/dist/esm/core/transport.js +425 -0
- package/dist/esm/core/utils.d.ts +26 -0
- package/dist/esm/core/utils.js +161 -0
- package/dist/esm/core/validate.d.ts +18 -0
- package/dist/esm/core/validate.js +226 -0
- package/dist/esm/device/appversion.d.ts +20 -0
- package/dist/esm/device/appversion.js +153 -0
- package/dist/esm/device/index.d.ts +23 -0
- package/dist/esm/device/index.js +362 -0
- package/dist/esm/engagement/api-rules.d.ts +84 -0
- package/dist/esm/engagement/api-rules.js +211 -0
- package/dist/esm/engagement/auto-api.d.ts +7 -0
- package/dist/esm/engagement/auto-api.js +198 -0
- package/dist/esm/engagement/auto-screen.d.ts +16 -0
- package/dist/esm/engagement/auto-screen.js +238 -0
- package/dist/esm/engagement/defined-events.d.ts +23 -0
- package/dist/esm/engagement/defined-events.js +55 -0
- package/dist/esm/engagement/send.d.ts +6 -0
- package/dist/esm/engagement/send.js +96 -0
- package/dist/esm/engagement/session.d.ts +42 -0
- package/dist/esm/engagement/session.js +315 -0
- package/dist/esm/engagement/track.d.ts +56 -0
- package/dist/esm/engagement/track.js +340 -0
- package/dist/esm/errors/send.d.ts +6 -0
- package/dist/esm/errors/send.js +70 -0
- package/dist/esm/errors/track.d.ts +4 -0
- package/dist/esm/errors/track.js +123 -0
- package/dist/esm/feedback/controls.d.ts +31 -0
- package/dist/esm/feedback/controls.js +280 -0
- package/dist/esm/feedback/index.d.ts +8 -0
- package/dist/esm/feedback/index.js +30 -0
- package/dist/esm/feedback/logs.d.ts +40 -0
- package/dist/esm/feedback/logs.js +188 -0
- package/dist/esm/feedback/send.d.ts +25 -0
- package/dist/esm/feedback/send.js +175 -0
- package/dist/esm/feedback/template.d.ts +2 -0
- package/dist/esm/feedback/template.js +159 -0
- package/dist/esm/feedback/ui.d.ts +55 -0
- package/dist/esm/feedback/ui.js +626 -0
- package/dist/esm/heatmap/index.d.ts +16 -0
- package/dist/esm/heatmap/index.js +17 -0
- package/dist/esm/heatmap/send.d.ts +13 -0
- package/dist/esm/heatmap/send.js +79 -0
- package/dist/esm/heatmap/track.d.ts +4 -0
- package/dist/esm/heatmap/track.js +374 -0
- package/dist/esm/index.d.ts +68 -0
- package/dist/esm/index.js +122 -0
- package/dist/esm/lifecycle.d.ts +14 -0
- package/dist/esm/lifecycle.js +534 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/remoteconfig/custom.d.ts +10 -0
- package/dist/esm/remoteconfig/custom.js +74 -0
- package/dist/esm/remoteconfig/evaluate.d.ts +24 -0
- package/dist/esm/remoteconfig/evaluate.js +166 -0
- package/dist/esm/remoteconfig/fetch.d.ts +24 -0
- package/dist/esm/remoteconfig/fetch.js +210 -0
- package/dist/esm/remoteconfig/index.d.ts +13 -0
- package/dist/esm/remoteconfig/index.js +85 -0
- package/dist/esm/remoteconfig/store.d.ts +18 -0
- package/dist/esm/remoteconfig/store.js +91 -0
- package/dist/esm/remotelog/gate.d.ts +11 -0
- package/dist/esm/remotelog/gate.js +48 -0
- package/dist/esm/remotelog/index.d.ts +25 -0
- package/dist/esm/remotelog/index.js +51 -0
- package/dist/esm/remotelog/logger.d.ts +28 -0
- package/dist/esm/remotelog/logger.js +136 -0
- package/dist/esm/remotelog/send.d.ts +13 -0
- package/dist/esm/remotelog/send.js +149 -0
- package/dist/esm/scheduler.d.ts +8 -0
- package/dist/esm/scheduler.js +74 -0
- package/dist/esm/types.d.ts +312 -0
- package/dist/esm/user/index.d.ts +33 -0
- package/dist/esm/user/index.js +170 -0
- package/dist/feedback.esm.min.js +3 -0
- package/dist/feedback.esm.min.js.map +1 -0
- package/dist/heatmap.esm.min.js +3 -0
- package/dist/heatmap.esm.min.js.map +1 -0
- package/dist/style.css +1 -0
- package/package.json +124 -7
- package/src/appticssdk.js +0 -3817
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import type { AP_FEEDBACK_TYPE, AP_TRACKING_STATUS } from './core/constants.js';
|
|
2
|
+
import type { UserBuilder } from './user/index.js';
|
|
3
|
+
import type { ApiTrackingBuilder, ApiTrackingConfig } from './engagement/api-rules.js';
|
|
4
|
+
import type { DefinedEvent } from './engagement/defined-events.js';
|
|
5
|
+
import type { AppticsLogger } from './remotelog/logger.js';
|
|
6
|
+
/** Loose record for legacy payloads and server JSON that are built and sent as-is. */
|
|
7
|
+
export type Dict = Record<string, any>;
|
|
8
|
+
/** An item in the engagement or error queue. */
|
|
9
|
+
export interface QueueItem {
|
|
10
|
+
id?: string;
|
|
11
|
+
type?: string;
|
|
12
|
+
starttime?: number;
|
|
13
|
+
endtime?: number;
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
}
|
|
16
|
+
/** Device properties sent to and returned by `device/add`. */
|
|
17
|
+
export type DeviceInfo = Dict;
|
|
18
|
+
export interface UserInfo {
|
|
19
|
+
userid?: string;
|
|
20
|
+
groupid?: string;
|
|
21
|
+
status?: number;
|
|
22
|
+
[key: string]: any;
|
|
23
|
+
}
|
|
24
|
+
export interface ServerResult<T = Dict> {
|
|
25
|
+
result: string;
|
|
26
|
+
data?: T;
|
|
27
|
+
error_code?: unknown;
|
|
28
|
+
[key: string]: any;
|
|
29
|
+
}
|
|
30
|
+
export type TrackingStatus = (typeof AP_TRACKING_STATUS)[keyof typeof AP_TRACKING_STATUS];
|
|
31
|
+
export type FeedbackType = (typeof AP_FEEDBACK_TYPE)[keyof typeof AP_FEEDBACK_TYPE];
|
|
32
|
+
export type Properties = Record<string, unknown>;
|
|
33
|
+
/** The config init() requires. The console snippet provides the same shape as window.appticssettings._defaultoptions. */
|
|
34
|
+
export interface AppticsConfig {
|
|
35
|
+
/** Apptics host every request goes to, e.g. https://apptics.localzoho.com (a trailing slash is ignored). */
|
|
36
|
+
serviceUrl: string;
|
|
37
|
+
/** The app's token, sent as the `zak` header on app/addversion and device registration. */
|
|
38
|
+
zak: string;
|
|
39
|
+
/** App identifier, e.g. com.zoho.web.zylker. */
|
|
40
|
+
identifier: string;
|
|
41
|
+
/**
|
|
42
|
+
* Your app's version or build number, e.g. '2.4.0' or 512. Required: everything the SDK reports
|
|
43
|
+
* is only meaningful against the build it came from, so there is no default. Changing it
|
|
44
|
+
* registers the new version. Sent as text: a string is trimmed, and a number keeps only the
|
|
45
|
+
* digits JavaScript gives it (1.10 is '1.1'), so pass a dotted version as a string. A blank
|
|
46
|
+
* value, or a snippet placeholder such as 'YOUR_APP_VERSION', is refused.
|
|
47
|
+
*/
|
|
48
|
+
appversion: string | number;
|
|
49
|
+
/** @deprecated ignored: app/addversion answers with the aaid */
|
|
50
|
+
aaid?: string;
|
|
51
|
+
/** @deprecated ignored: app/addversion answers with the aaid */
|
|
52
|
+
aaID?: string;
|
|
53
|
+
/** @deprecated ignored: app/addversion answers with the portal id */
|
|
54
|
+
zsoid?: string;
|
|
55
|
+
/** @deprecated ignored: app/addversion answers with the project id */
|
|
56
|
+
projectID?: string;
|
|
57
|
+
/** @deprecated console-snippet name for serviceUrl */
|
|
58
|
+
base_domain?: string;
|
|
59
|
+
/** @deprecated console-snippet name for zak */
|
|
60
|
+
token?: string;
|
|
61
|
+
/** Data centre key for Quartz screen recording: US, EU, IN, AU, CN, CA, JP, SA, AE, Local, or '-' to disable. */
|
|
62
|
+
DC?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Debug mode: send engagement, exception and log payloads to their `debug/` twins, which answer
|
|
65
|
+
* with a request id and a link to the server's own logs, for following in the Apptics web
|
|
66
|
+
* console. Off by default; it does not change what is sent. Same as calling enableDebug().
|
|
67
|
+
*/
|
|
68
|
+
debug?: boolean;
|
|
69
|
+
/** Log the SDK's own activity to the browser console. Off by default. */
|
|
70
|
+
console_log?: boolean;
|
|
71
|
+
ignore_do_not_track?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Send the SDK's own failures to console/addlog, so they can be read from the Apptics console.
|
|
74
|
+
* This carries no app data: one line per failure, tagged with the SDK module it happened in.
|
|
75
|
+
*/
|
|
76
|
+
remote_log?: boolean;
|
|
77
|
+
quartz_workspace_key?: string;
|
|
78
|
+
quartz_department_key?: string;
|
|
79
|
+
/**
|
|
80
|
+
* Record the app's API calls automatically, by wrapping XHR and fetch. Off by default. The SDK's
|
|
81
|
+
* own requests are never recorded. Which hosts and endpoints are recorded, and under what path,
|
|
82
|
+
* is set with configureApiTracking(new ApiTrackingBuilder()...build()).
|
|
83
|
+
*/
|
|
84
|
+
track_api?: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Record screen views automatically: the page the SDK starts on, then every navigation —
|
|
87
|
+
* history.pushState / replaceState, back and forward, and `#/` hash routes. The screen is named
|
|
88
|
+
* by its path, without the query string. On by default. A inScreen() call within 300 ms of a
|
|
89
|
+
* navigation replaces its automatic view; set this false to track only the app's own calls.
|
|
90
|
+
*/
|
|
91
|
+
track_screen?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Print each `logger` line to the browser console too, at its level, as Android's showLogs
|
|
94
|
+
* prints to Logcat. Off by default. `console_log` is the SDK's own activity; this is the app's lines.
|
|
95
|
+
*/
|
|
96
|
+
show_logs?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Record sessions automatically. On by default; `false` records no sessions, while events,
|
|
99
|
+
* screens and the rest still are — Android's `automaticSessionsTrackingStatus = false`.
|
|
100
|
+
*/
|
|
101
|
+
track_session?: boolean;
|
|
102
|
+
/** How often queued data is sent, in milliseconds. Default 30000, at least 1000. */
|
|
103
|
+
batch_flush_interval?: number;
|
|
104
|
+
/** How often the server's tracking flags are fetched, in milliseconds. Default 120000, at least 10000. */
|
|
105
|
+
getupdates_interval?: number;
|
|
106
|
+
/** Most items in one batch. Default 50, between 1 and 500. */
|
|
107
|
+
batch_size?: number;
|
|
108
|
+
/** Days an unsent item is kept before it is dropped. Default 7, between 1 and 30. */
|
|
109
|
+
batch_request_timeout?: number;
|
|
110
|
+
/** Idle minutes that end a session. Default 30, between 1 and 1440. */
|
|
111
|
+
inactiveduration?: number;
|
|
112
|
+
/**
|
|
113
|
+
* How long a visit must last before its session is recorded, in milliseconds. Default 5000, at
|
|
114
|
+
* most 60000. A shorter visit with nothing tracked in it is not reported at all; anything tracked
|
|
115
|
+
* inside the window records the session at once, with its real start time. 0 turns the wait off.
|
|
116
|
+
*/
|
|
117
|
+
min_session_duration?: number;
|
|
118
|
+
/**
|
|
119
|
+
* Record where people click and how far they scroll. Off by default, and it does nothing unless
|
|
120
|
+
* the app also imports '@zoho_apptics/apptics-js-sdk/heatmap'.
|
|
121
|
+
*/
|
|
122
|
+
track_heatmap?: boolean;
|
|
123
|
+
/** Most heatmap records one visit may produce. Default 500; capture pauses past it. */
|
|
124
|
+
heatmap_max_per_session?: number;
|
|
125
|
+
/** @deprecated the earlier name for `debug` (debug mode); `debug` wins when both are given */
|
|
126
|
+
debug_api?: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* What to call this device in the debug stream, e.g. 'QA iPad 3'. Sent on engagement,
|
|
129
|
+
* exception and log, the three endpoints that declare it. Unset, nothing is sent unless
|
|
130
|
+
* debug mode is on, where a label is derived from the browser and OS instead.
|
|
131
|
+
*/
|
|
132
|
+
device_name?: string;
|
|
133
|
+
[key: string]: unknown;
|
|
134
|
+
}
|
|
135
|
+
export interface UserValidationResult {
|
|
136
|
+
data: Record<string, string | number | boolean>;
|
|
137
|
+
datatype: Record<string, 'String' | 'Number' | 'Boolean'>;
|
|
138
|
+
message: Array<{
|
|
139
|
+
code: 101 | 102 | 103 | 104;
|
|
140
|
+
keys: string[];
|
|
141
|
+
}>;
|
|
142
|
+
}
|
|
143
|
+
export interface QuartzApi {
|
|
144
|
+
startRecording(details: {
|
|
145
|
+
workspaceLinkName: string;
|
|
146
|
+
departmentLinkName: string;
|
|
147
|
+
recordingDomain: string;
|
|
148
|
+
}): void;
|
|
149
|
+
previewVideo(): void;
|
|
150
|
+
editVideo(options: {
|
|
151
|
+
quartzBranding: boolean;
|
|
152
|
+
}): void;
|
|
153
|
+
clearFeedback(): void;
|
|
154
|
+
endRecording(): void;
|
|
155
|
+
setVideoContent(element: Element | null): void;
|
|
156
|
+
submitRecording(details: {
|
|
157
|
+
email: string;
|
|
158
|
+
subject: string;
|
|
159
|
+
}): Promise<{
|
|
160
|
+
feedbackLink?: string;
|
|
161
|
+
} | undefined>;
|
|
162
|
+
}
|
|
163
|
+
export interface QuartzConstantsApi {
|
|
164
|
+
ErrorType: Record<string, string>;
|
|
165
|
+
FeedbackState: Record<string, string>;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* One heatmap record: a click or a finished scroll gesture, as `heatmap/add` takes it.
|
|
169
|
+
*
|
|
170
|
+
* Web-shaped. The endpoint's mobile fields have no meaning in a browser and are not sent:
|
|
171
|
+
* `battery_in`/`battery_out` (the Battery Status API is gone from Firefox and never existed in
|
|
172
|
+
* Safari), `pressure` and `finger_count` (0 and 1 for any mouse), `service_provider` (a carrier
|
|
173
|
+
* name, which the web has no access to). Sending constants for them would put dead columns in
|
|
174
|
+
* every record.
|
|
175
|
+
*/
|
|
176
|
+
export interface HeatmapRecord {
|
|
177
|
+
/** Queue key; removed before the record is sent. */
|
|
178
|
+
id?: string;
|
|
179
|
+
session_start_time: number;
|
|
180
|
+
/** When this record happened. The only thing that orders records inside a session. */
|
|
181
|
+
triggered_time: number;
|
|
182
|
+
screen: string;
|
|
183
|
+
url_path: string;
|
|
184
|
+
/**
|
|
185
|
+
* 'buttonclick' for a click on something clickable, 'default' otherwise. The server accepts
|
|
186
|
+
* only `event|default|buttonclick`; the kind of movement goes in `gesture_type`.
|
|
187
|
+
*/
|
|
188
|
+
triggered_type: 'event' | 'default' | 'buttonclick';
|
|
189
|
+
/** 'click', or 'up-scroll' / 'down-scroll' / 'left-scroll' / 'right-scroll'. */
|
|
190
|
+
gesture_type: string;
|
|
191
|
+
/** Milliseconds the gesture took. 0 for a click. */
|
|
192
|
+
gesture_duration: number;
|
|
193
|
+
/** 'mouse', 'touch' or 'pen' from the pointer event. Absent for a scroll, which has none. */
|
|
194
|
+
input_type?: string;
|
|
195
|
+
/** A name for the element: an author's attribute where there is one, its text only with PII consent. */
|
|
196
|
+
element_label: string;
|
|
197
|
+
/** A stable number for the element's position in the tree, so clicks on one control group together. */
|
|
198
|
+
triggered_id: number;
|
|
199
|
+
coordinate_x: number;
|
|
200
|
+
coordinate_y: number;
|
|
201
|
+
/** 0-1 across the viewport width. */
|
|
202
|
+
normalized_x: number;
|
|
203
|
+
/** 0-1 down the full page height, which is what a scroll-depth map reads. */
|
|
204
|
+
normalized_y: number;
|
|
205
|
+
scroll_offset_x: number;
|
|
206
|
+
scroll_offset_y: number;
|
|
207
|
+
screen_width: number;
|
|
208
|
+
screen_height: number;
|
|
209
|
+
content_height: number;
|
|
210
|
+
orientation: number;
|
|
211
|
+
network_status: number;
|
|
212
|
+
edge_type: string;
|
|
213
|
+
/** Pixels per second, x1000. 0 for a click. */
|
|
214
|
+
velocity: number;
|
|
215
|
+
is_clickable: 0 | 1;
|
|
216
|
+
is_rage_click: 0 | 1;
|
|
217
|
+
is_dead_click: 0 | 1;
|
|
218
|
+
}
|
|
219
|
+
/** What `AppticsTrackError` accepts: a window `error` / `unhandledrejection` event or the same shape. */
|
|
220
|
+
export type ErrorLike = Event | {
|
|
221
|
+
type?: string;
|
|
222
|
+
error?: unknown;
|
|
223
|
+
reason?: unknown;
|
|
224
|
+
};
|
|
225
|
+
/** The optional feedback modal, from '@zoho_apptics/apptics-js-sdk/feedback'. */
|
|
226
|
+
export interface AppticsFeedbackApi {
|
|
227
|
+
/**
|
|
228
|
+
* Sends feedback without the form. Resolves once it is sent; rejects when it wasn't: the SDK
|
|
229
|
+
* has not started (no init()), the browser is offline, or the server refused it.
|
|
230
|
+
*/
|
|
231
|
+
sendFeedback(type?: FeedbackType, message?: string, attachments?: FileList | File[] | null, logFiles?: FileList | File[] | null,
|
|
232
|
+
/** dyninfo.txt (diagnostics entries + device info): unset sends it when diagnostics are waiting. */
|
|
233
|
+
includeDyninfo?: boolean,
|
|
234
|
+
/** Stored addFeedbackLog() lines: unset sends them when there are any, false never does. */
|
|
235
|
+
includeLog?: boolean): Promise<void>;
|
|
236
|
+
/**
|
|
237
|
+
* Opens the form. Every argument is optional: `type` and `message` pre-fill it, the include
|
|
238
|
+
* flags start the log and diagnostics toggles on, and `isAnonymous` starts the user picker on
|
|
239
|
+
* Anonymous even when a user is registered.
|
|
240
|
+
*/
|
|
241
|
+
feedbackOpen(type?: FeedbackType, message?: string, includeLog?: boolean, includeDyninfo?: boolean, attachments?: FileList | File[] | null, logFiles?: FileList | File[] | null, isAnonymous?: boolean): void;
|
|
242
|
+
feedbackClose(): void;
|
|
243
|
+
}
|
|
244
|
+
export interface AppticsApi {
|
|
245
|
+
/** Android's Apptics. */
|
|
246
|
+
Apptics: {
|
|
247
|
+
/** Starts the SDK. The config object is required; the console snippet supplies it via auto-init. */
|
|
248
|
+
init(config: AppticsConfig): boolean;
|
|
249
|
+
};
|
|
250
|
+
/** Android's AppticsEvents. */
|
|
251
|
+
AppticsEvents: {
|
|
252
|
+
/** An event. An invalid name or group is not logged; a group left out is `default`. */
|
|
253
|
+
addEvent(eventName: string, groupName?: string, properties?: Properties): void;
|
|
254
|
+
/** A defined event (DefinedEvents.AP_USER_LOGIN, …), which brings its own group. */
|
|
255
|
+
addEvent(definedEvent: DefinedEvent, properties?: Properties): void;
|
|
256
|
+
};
|
|
257
|
+
/** Apptics' defined events, as Android's DefinedEvents. */
|
|
258
|
+
DefinedEvents: Readonly<Record<string, DefinedEvent>>;
|
|
259
|
+
/** Android's AppticsScreenTracker. */
|
|
260
|
+
AppticsScreenTracker: {
|
|
261
|
+
/** Records a screen view and returns its id, for outScreen; '' for an invalid name. */
|
|
262
|
+
inScreen(screenName: string, properties?: Properties): string;
|
|
263
|
+
/** Ends the screen view inScreen began, before the next screen would. */
|
|
264
|
+
outScreen(id: string): void;
|
|
265
|
+
};
|
|
266
|
+
/** Android's AppticsApiTracker. */
|
|
267
|
+
AppticsApiTracker: {
|
|
268
|
+
/** Begins timing one call; returns the id endTrackApi takes. */
|
|
269
|
+
startTrackApi(url: string, method?: string): string;
|
|
270
|
+
/** Finishes the call startTrackApi began, and records it. */
|
|
271
|
+
endTrackApi(id: string, responseCode: number, responseMessage?: string): void;
|
|
272
|
+
/** The rules API tracking records by, from ApiTrackingBuilder. Works before Apptics.init(). */
|
|
273
|
+
configure(config: ApiTrackingConfig | ApiTrackingBuilder): void;
|
|
274
|
+
};
|
|
275
|
+
ApiTrackingBuilder: typeof ApiTrackingBuilder;
|
|
276
|
+
/** Android's AppticsLogger: off until enable(), then v / d / i / w / e(tag, message). */
|
|
277
|
+
AppticsLogger: AppticsLogger;
|
|
278
|
+
/** Resolves true once start-up (storage load, device, session) has finished; false if it can't start. */
|
|
279
|
+
ready(): Promise<boolean>;
|
|
280
|
+
/**
|
|
281
|
+
* Turns debug mode on, before or after Apptics.init(). Engagement, exception and log then go to
|
|
282
|
+
* their `debug/` twins, whose answers carry a request id and a link into the server's own logs. It
|
|
283
|
+
* switches itself off after an hour with nothing tracked.
|
|
284
|
+
*/
|
|
285
|
+
enableDebug(): void;
|
|
286
|
+
/** Turns debug mode off, before or after Apptics.init(); wins over `debug` in init(). */
|
|
287
|
+
disableDebug(): void;
|
|
288
|
+
/**
|
|
289
|
+
* Turns automatic API tracking on or off after Apptics.init(). Equivalent to the `track_api`
|
|
290
|
+
* config flag, which is the usual way to set it.
|
|
291
|
+
*/
|
|
292
|
+
enableApiTracking(enabled?: boolean): void;
|
|
293
|
+
/** Reports an error the app caught, or an `error` / `unhandledrejection` event. */
|
|
294
|
+
AppticsTrackError(error: ErrorLike, properties?: Properties): void;
|
|
295
|
+
enableGlobalErrorHandler(enabled?: boolean): void;
|
|
296
|
+
/** Properties may be a plain object, or the result of UserBuilder.build(). */
|
|
297
|
+
AppticsSetUser(userid: string, groupid?: string, properties?: Properties | UserValidationResult): void;
|
|
298
|
+
getUser(): UserInfo;
|
|
299
|
+
users: {
|
|
300
|
+
UserBuilder: typeof UserBuilder;
|
|
301
|
+
};
|
|
302
|
+
setTrackingStatus(status: TrackingStatus): void;
|
|
303
|
+
getTrackingStatus(): TrackingStatus;
|
|
304
|
+
flush(): void;
|
|
305
|
+
/** Records a timestamped line, sent as feedbacklog.txt with the next feedback submission. */
|
|
306
|
+
addFeedbackLog(message: string): void;
|
|
307
|
+
/** Records a diagnostics key/value under `heading`, sent inside dyninfo.txt with the next feedback. */
|
|
308
|
+
addDiagnosticsInfo(heading: string, key: string, value?: unknown): void;
|
|
309
|
+
reset(): void;
|
|
310
|
+
AP_TRACKING_STATUS: typeof AP_TRACKING_STATUS;
|
|
311
|
+
AP_FEEDBACK_TYPE: typeof AP_FEEDBACK_TYPE;
|
|
312
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Dict, Properties, UserInfo, UserValidationResult } from '../types.js';
|
|
2
|
+
export declare function getUser(): UserInfo;
|
|
3
|
+
export declare function setUser(userid?: string, groupid?: string, jsonObj?: Properties | UserValidationResult): void;
|
|
4
|
+
export declare function addOrUpdateUser(user_info: Dict): void;
|
|
5
|
+
export declare function getUserInfo(): void;
|
|
6
|
+
export declare function registerUserWithApptics(user_info: Dict): Promise<Dict>;
|
|
7
|
+
/** Builds validated user properties for setUser. */
|
|
8
|
+
export declare class UserBuilder {
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
setFirstName(first_name: string): this;
|
|
11
|
+
setLastName(last_name: string): this;
|
|
12
|
+
setCompanyName(company_name: string): this;
|
|
13
|
+
setEmailAddress(email_address: string): this;
|
|
14
|
+
setContactNumber(contact_number: string): this;
|
|
15
|
+
setCountry(country: string): this;
|
|
16
|
+
setRegion(region: string): this;
|
|
17
|
+
setCity(city: string): this;
|
|
18
|
+
setGeoLocation(geo_location: string): this;
|
|
19
|
+
setGender(gender: string): this;
|
|
20
|
+
setPlanType(plan_type: string): this;
|
|
21
|
+
setTimezone(timezone: string): this;
|
|
22
|
+
setLanguage(language: string): this;
|
|
23
|
+
setEngagementScore(engagement_score: number): this;
|
|
24
|
+
setDateOfBirth(date_of_birth: number): this;
|
|
25
|
+
addStringProperty(key: string, value: string): this;
|
|
26
|
+
addBooleanProperty(key: string, value: boolean): this;
|
|
27
|
+
addNumberProperty(key: string, value: number): this;
|
|
28
|
+
setCustomProperties(obj: Record<string, unknown>): this;
|
|
29
|
+
build(): UserValidationResult;
|
|
30
|
+
}
|
|
31
|
+
export declare const users: {
|
|
32
|
+
UserBuilder: typeof UserBuilder;
|
|
33
|
+
};
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var constants = require('../core/constants.js');
|
|
5
|
+
var state = require('../core/state.js');
|
|
6
|
+
var logger = require('../core/logger.js');
|
|
7
|
+
var utils = require('../core/utils.js');
|
|
8
|
+
var storage = require('../core/storage.js');
|
|
9
|
+
var consent = require('../core/consent.js');
|
|
10
|
+
var transport = require('../core/transport.js');
|
|
11
|
+
var validate = require('../core/validate.js');
|
|
12
|
+
var hooks = require('../core/hooks.js');
|
|
13
|
+
|
|
14
|
+
function getUser() {
|
|
15
|
+
return state._ZAP._user_info || {}; // no i18n
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* user/register wants properties as the validated triple — the values, their types, and what
|
|
19
|
+
* was rejected — which is what UserBuilder.build() returns. A plain object passed to setUser
|
|
20
|
+
* is validated here, so both forms go up in the same shape.
|
|
21
|
+
*/
|
|
22
|
+
function asUserProperties(jsonObj) {
|
|
23
|
+
var maybeBuilt = jsonObj;
|
|
24
|
+
var built = maybeBuilt && typeof maybeBuilt === 'object' && maybeBuilt.data && maybeBuilt.datatype // no i18n
|
|
25
|
+
? maybeBuilt
|
|
26
|
+
: validate.userValidateJSON(jsonObj);
|
|
27
|
+
built.message.forEach(function (problem) {
|
|
28
|
+
logger.logFailure(constants.AP_LOG_MODULE.PROPERTIES, 'AppticsSetUser: dropped ' + problem.keys.join(', ') + ' (error ' + problem.code + ')'); // no i18n
|
|
29
|
+
});
|
|
30
|
+
return built;
|
|
31
|
+
}
|
|
32
|
+
function setUser(userid, groupid, jsonObj) {
|
|
33
|
+
let _jsonObj = jsonObj || {};
|
|
34
|
+
userid = userid || ''; // no i18n
|
|
35
|
+
groupid = groupid || ''; // no i18n
|
|
36
|
+
if (!consent.canTrack('setUser')) { // no i18n
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (utils.isEmpty(userid)) {
|
|
40
|
+
logger.logFailure(constants.AP_LOG_MODULE.PROPERTIES, 'AppticsSetUser: Invalid userid'); // no i18n
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
var user_info = {
|
|
44
|
+
mam: userid,
|
|
45
|
+
customergroupid: groupid,
|
|
46
|
+
appversionid: state._ZAP._device_info.appversionid || '', // no i18n
|
|
47
|
+
status: 1,
|
|
48
|
+
happendat: utils.nowMs()
|
|
49
|
+
};
|
|
50
|
+
if (!utils.isEmptyObj(_jsonObj)) { // no i18n
|
|
51
|
+
user_info.userproperties = asUserProperties(_jsonObj);
|
|
52
|
+
}
|
|
53
|
+
registerUserWithApptics(user_info).then(function (user_info) {
|
|
54
|
+
logger.Console.log('setUser: ' + JSON.stringify(user_info)); // no i18n
|
|
55
|
+
}).catch(function (err) {
|
|
56
|
+
logger.Console.log(err);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function addOrUpdateUser(user_info) {
|
|
60
|
+
user_info.status = 1;
|
|
61
|
+
var users = storage.user_defaults.item('users') || []; // no i18n
|
|
62
|
+
users = users.map((item) => ({ ...item, status: 0 }));
|
|
63
|
+
var index = users.findIndex((userobj) => userobj.userid === user_info.userid);
|
|
64
|
+
if (index !== -1) {
|
|
65
|
+
users[index] = { ...users[index], ...user_info };
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
users.push(user_info);
|
|
69
|
+
}
|
|
70
|
+
storage.user_defaults.add('users', users); // no i18n
|
|
71
|
+
}
|
|
72
|
+
function getUserInfo() {
|
|
73
|
+
var users = storage.user_defaults.item('users') || []; // no i18n
|
|
74
|
+
var activeuser = {};
|
|
75
|
+
if (users.length > 0) {
|
|
76
|
+
activeuser = users.filter((item) => item.status === 1)[0] || {};
|
|
77
|
+
}
|
|
78
|
+
state._ZAP._user_info = activeuser;
|
|
79
|
+
}
|
|
80
|
+
// Function to register the user
|
|
81
|
+
function registerUserWithApptics(user_info) {
|
|
82
|
+
var label = 'registerUserWithApptics'; // no i18n
|
|
83
|
+
var blocked = transport.rejectIfDisabled(label) || transport.rejectIfOffline(label);
|
|
84
|
+
if (blocked) {
|
|
85
|
+
return blocked;
|
|
86
|
+
}
|
|
87
|
+
if (utils.isEmptyObj(user_info)) {
|
|
88
|
+
return Promise.reject(label + ': nothing to register'); // no i18n
|
|
89
|
+
}
|
|
90
|
+
var missing = transport.rejectIfNoDeviceIds(label);
|
|
91
|
+
if (missing) {
|
|
92
|
+
return missing;
|
|
93
|
+
}
|
|
94
|
+
var payload = JSON.stringify(utils.cloneMapExcludingKeys(user_info, ['userid', 'groupid', 'happendat'])); // no i18n
|
|
95
|
+
return transport.postToApptics('reguser', payload, transport.apiHeaders(), label).then(function (result) {
|
|
96
|
+
var data = result.data || {};
|
|
97
|
+
user_info.userid = data.userid;
|
|
98
|
+
user_info.groupid = data.customergroupid;
|
|
99
|
+
consent.setTrackingStatus(constants.AP_TRACKING_STATUS.USAGE_TRACKING_WITH_PII);
|
|
100
|
+
addOrUpdateUser(user_info);
|
|
101
|
+
getUserInfo();
|
|
102
|
+
// the user and their customer group are known now: remote config conditions on them re-apply
|
|
103
|
+
hooks.hooks.remoteConfigUserChanged();
|
|
104
|
+
return data;
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/** Builds validated user properties for setUser. */
|
|
108
|
+
class UserBuilder {
|
|
109
|
+
setFirstName(first_name) { this.first_name = first_name; return this; }
|
|
110
|
+
setLastName(last_name) { this.last_name = last_name; return this; }
|
|
111
|
+
setCompanyName(company_name) { this.company_name = company_name; return this; }
|
|
112
|
+
setEmailAddress(email_address) { this.email_address = email_address; return this; }
|
|
113
|
+
setContactNumber(contact_number) { this.contact_number = contact_number; return this; }
|
|
114
|
+
setCountry(country) { this.country = country; return this; }
|
|
115
|
+
setRegion(region) { this.region = region; return this; }
|
|
116
|
+
setCity(city) { this.city = city; return this; }
|
|
117
|
+
setGeoLocation(geo_location) { this.geo_location = geo_location; return this; }
|
|
118
|
+
setGender(gender) { this.gender = gender; return this; }
|
|
119
|
+
setPlanType(plan_type) { this.plan_type = plan_type; return this; }
|
|
120
|
+
setTimezone(timezone) { this.timezone = timezone; return this; }
|
|
121
|
+
setLanguage(language) { this.language = language; return this; }
|
|
122
|
+
setEngagementScore(engagement_score) { this.engagement_score = engagement_score; return this; }
|
|
123
|
+
setDateOfBirth(date_of_birth) { this.date_of_birth = date_of_birth; return this; }
|
|
124
|
+
addStringProperty(key, value) {
|
|
125
|
+
if (typeof value === 'string') { // no i18n
|
|
126
|
+
this[key] = value;
|
|
127
|
+
}
|
|
128
|
+
return this;
|
|
129
|
+
}
|
|
130
|
+
addBooleanProperty(key, value) {
|
|
131
|
+
if (typeof value === 'boolean') { // no i18n
|
|
132
|
+
this[key] = value;
|
|
133
|
+
}
|
|
134
|
+
return this;
|
|
135
|
+
}
|
|
136
|
+
addNumberProperty(key, value) {
|
|
137
|
+
if (typeof value === 'number' && Number.isFinite(value)) { // no i18n
|
|
138
|
+
this[key] = value;
|
|
139
|
+
}
|
|
140
|
+
return this;
|
|
141
|
+
}
|
|
142
|
+
setCustomProperties(obj) {
|
|
143
|
+
if (typeof obj === 'object' && obj !== null) { // no i18n
|
|
144
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
145
|
+
this[key] = value;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return this;
|
|
149
|
+
}
|
|
150
|
+
build() {
|
|
151
|
+
const user = {};
|
|
152
|
+
const knownFields = [
|
|
153
|
+
'first_name', 'last_name', 'company_name', 'email_address', 'contact_number',
|
|
154
|
+
'country', 'region', 'city', 'geo_location', 'gender', 'plan_type', 'timezone',
|
|
155
|
+
'language', 'engagement_score', 'date_of_birth'
|
|
156
|
+
]; // no i18n
|
|
157
|
+
knownFields.forEach((field) => {
|
|
158
|
+
if (this[field] !== undefined)
|
|
159
|
+
user[field] = this[field];
|
|
160
|
+
});
|
|
161
|
+
Object.entries(this).forEach(([key, value]) => {
|
|
162
|
+
if (knownFields.indexOf(key) === -1 && typeof value !== 'function') { // no i18n
|
|
163
|
+
user[key] = value;
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
return validate.userValidateJSON(user);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
// Users module for user management
|
|
170
|
+
const users = { UserBuilder: UserBuilder };
|
|
171
|
+
|
|
172
|
+
exports.UserBuilder = UserBuilder;
|
|
173
|
+
exports.addOrUpdateUser = addOrUpdateUser;
|
|
174
|
+
exports.getUser = getUser;
|
|
175
|
+
exports.getUserInfo = getUserInfo;
|
|
176
|
+
exports.registerUserWithApptics = registerUserWithApptics;
|
|
177
|
+
exports.setUser = setUser;
|
|
178
|
+
exports.users = users;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AppticsApi } from './types.js';
|
|
2
|
+
/** Calls Apptics.init() when the page has the console snippet (window.appticssettings) and it hasn't run. */
|
|
3
|
+
export declare function autoInit(api: AppticsApi['Apptics']): boolean;
|
|
4
|
+
/**
|
|
5
|
+
* Queues autoInit so an app that sets window.appticssettings and calls init() in its
|
|
6
|
+
* top-level code runs first (autoInit then sees init() already ran).
|
|
7
|
+
*/
|
|
8
|
+
export declare function scheduleAutoInit(api: AppticsApi['Apptics']): void;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0-beta | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
|
+
import { _ZAP } from './core/state.js';
|
|
3
|
+
import { getSnippetOptions } from './core/env.js';
|
|
4
|
+
|
|
5
|
+
/** Calls Apptics.init() when the page has the console snippet (window.appticssettings) and it hasn't run. */
|
|
6
|
+
function autoInit(api) {
|
|
7
|
+
if (_ZAP._initialised) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
var opts = getSnippetOptions();
|
|
11
|
+
if (!opts || typeof opts !== 'object') { // no i18n
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
return api.init(opts);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Queues autoInit so an app that sets window.appticssettings and calls init() in its
|
|
18
|
+
* top-level code runs first (autoInit then sees init() already ran).
|
|
19
|
+
*/
|
|
20
|
+
function scheduleAutoInit(api) {
|
|
21
|
+
if (typeof window === 'undefined') { // no i18n
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
queueMicrotask(function () {
|
|
25
|
+
autoInit(api);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { autoInit, scheduleAutoInit };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Dict } from '../types.js';
|
|
2
|
+
/** The largest value `attempt` may carry, from its own regex. */
|
|
3
|
+
export declare const MAX_ATTEMPTS = 5;
|
|
4
|
+
/**
|
|
5
|
+
* Whether this path has already used its five attempts, so the batch should be dropped rather
|
|
6
|
+
* than sent a sixth time with a param the proxy will refuse.
|
|
7
|
+
*/
|
|
8
|
+
export declare function attemptsExhausted(path: string): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Records that a send is going out, and returns the params to put on it.
|
|
11
|
+
*
|
|
12
|
+
* Call it once per request, immediately before sending: it is what moves the attempt counter on,
|
|
13
|
+
* so calling it twice for one request would skip a number and reach five early.
|
|
14
|
+
*/
|
|
15
|
+
export declare function beginAttempt(path: string): Dict;
|
|
16
|
+
/**
|
|
17
|
+
* Records that a send was accepted: the counter goes back to 1 and `lst` moves to now.
|
|
18
|
+
*
|
|
19
|
+
* For a page-close send the confirmation arrives after the caller has moved on, which is fine —
|
|
20
|
+
* nothing waits for this, it only decides what the *next* send says about itself.
|
|
21
|
+
*/
|
|
22
|
+
export declare function attemptSucceeded(path: string): void;
|
|
23
|
+
/** Gives up on the current run of attempts, so the next send starts again at 1. */
|
|
24
|
+
export declare function resetAttempts(path: string): void;
|
|
25
|
+
/** When this path last had a send accepted, or 0. */
|
|
26
|
+
export declare function lastSendTime(path: string): number;
|
|
27
|
+
/** Forgets every path's bookkeeping. reset() calls it. */
|
|
28
|
+
export declare function clearAttempts(): void;
|