@zoho_apptics/apptics-js-sdk 1.0.2 → 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.
Files changed (226) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/LICENSE +13 -0
  3. package/README.md +747 -11
  4. package/dist/apptics.esm.min.js +3 -0
  5. package/dist/apptics.esm.min.js.map +1 -0
  6. package/dist/apptics.min.js +3 -0
  7. package/dist/apptics.min.js.map +1 -0
  8. package/dist/chunks/batch-BU_mTpm1.min.js +3 -0
  9. package/dist/chunks/batch-BU_mTpm1.min.js.map +1 -0
  10. package/dist/chunks/logs-Bea5zUW_.min.js +3 -0
  11. package/dist/chunks/logs-Bea5zUW_.min.js.map +1 -0
  12. package/dist/cjs/auto-init.d.ts +8 -0
  13. package/dist/cjs/auto-init.js +32 -0
  14. package/dist/cjs/core/attempts.d.ts +28 -0
  15. package/dist/cjs/core/attempts.js +113 -0
  16. package/dist/cjs/core/batch.d.ts +32 -0
  17. package/dist/cjs/core/batch.js +115 -0
  18. package/dist/cjs/core/callsite.d.ts +28 -0
  19. package/dist/cjs/core/callsite.js +93 -0
  20. package/dist/cjs/core/consent.d.ts +23 -0
  21. package/dist/cjs/core/consent.js +130 -0
  22. package/dist/cjs/core/constants.d.ts +212 -0
  23. package/dist/cjs/core/constants.js +299 -0
  24. package/dist/cjs/core/db.d.ts +40 -0
  25. package/dist/cjs/core/db.js +334 -0
  26. package/dist/cjs/core/debug.d.ts +22 -0
  27. package/dist/cjs/core/debug.js +88 -0
  28. package/dist/cjs/core/env.d.ts +28 -0
  29. package/dist/cjs/core/env.js +267 -0
  30. package/dist/cjs/core/framework-id.d.ts +1 -0
  31. package/dist/cjs/core/framework-id.js +9 -0
  32. package/dist/cjs/core/guard.d.ts +2 -0
  33. package/dist/cjs/core/guard.js +72 -0
  34. package/dist/cjs/core/hooks.d.ts +41 -0
  35. package/dist/cjs/core/hooks.js +23 -0
  36. package/dist/cjs/core/logger.d.ts +16 -0
  37. package/dist/cjs/core/logger.js +86 -0
  38. package/dist/cjs/core/state.d.ts +69 -0
  39. package/dist/cjs/core/state.js +78 -0
  40. package/dist/cjs/core/storage.d.ts +46 -0
  41. package/dist/cjs/core/storage.js +229 -0
  42. package/dist/cjs/core/transport.d.ts +83 -0
  43. package/dist/cjs/core/transport.js +441 -0
  44. package/dist/cjs/core/utils.d.ts +26 -0
  45. package/dist/cjs/core/utils.js +175 -0
  46. package/dist/cjs/core/validate.d.ts +18 -0
  47. package/dist/cjs/core/validate.js +233 -0
  48. package/dist/cjs/device/appversion.d.ts +20 -0
  49. package/dist/cjs/device/appversion.js +158 -0
  50. package/dist/cjs/device/index.d.ts +23 -0
  51. package/dist/cjs/device/index.js +372 -0
  52. package/dist/cjs/engagement/api-rules.d.ts +84 -0
  53. package/dist/cjs/engagement/api-rules.js +219 -0
  54. package/dist/cjs/engagement/auto-api.d.ts +7 -0
  55. package/dist/cjs/engagement/auto-api.js +200 -0
  56. package/dist/cjs/engagement/auto-screen.d.ts +16 -0
  57. package/dist/cjs/engagement/auto-screen.js +241 -0
  58. package/dist/cjs/engagement/defined-events.d.ts +23 -0
  59. package/dist/cjs/engagement/defined-events.js +58 -0
  60. package/dist/cjs/engagement/send.d.ts +6 -0
  61. package/dist/cjs/engagement/send.js +99 -0
  62. package/dist/cjs/engagement/session.d.ts +42 -0
  63. package/dist/cjs/engagement/session.js +327 -0
  64. package/dist/cjs/engagement/track.d.ts +56 -0
  65. package/dist/cjs/engagement/track.js +350 -0
  66. package/dist/cjs/errors/send.d.ts +6 -0
  67. package/dist/cjs/errors/send.js +73 -0
  68. package/dist/cjs/errors/track.d.ts +4 -0
  69. package/dist/cjs/errors/track.js +127 -0
  70. package/dist/cjs/feedback/controls.d.ts +31 -0
  71. package/dist/cjs/feedback/controls.js +286 -0
  72. package/dist/cjs/feedback/index.d.ts +8 -0
  73. package/dist/cjs/feedback/index.js +37 -0
  74. package/dist/cjs/feedback/logs.d.ts +40 -0
  75. package/dist/cjs/feedback/logs.js +202 -0
  76. package/dist/cjs/feedback/send.d.ts +25 -0
  77. package/dist/cjs/feedback/send.js +178 -0
  78. package/dist/cjs/feedback/template.d.ts +2 -0
  79. package/dist/cjs/feedback/template.js +162 -0
  80. package/dist/cjs/feedback/ui.d.ts +55 -0
  81. package/dist/cjs/feedback/ui.js +631 -0
  82. package/dist/cjs/heatmap/index.d.ts +16 -0
  83. package/dist/cjs/heatmap/index.js +22 -0
  84. package/dist/cjs/heatmap/send.d.ts +13 -0
  85. package/dist/cjs/heatmap/send.js +82 -0
  86. package/dist/cjs/heatmap/track.d.ts +4 -0
  87. package/dist/cjs/heatmap/track.js +377 -0
  88. package/dist/cjs/index.d.ts +68 -0
  89. package/dist/cjs/index.js +150 -0
  90. package/dist/cjs/lifecycle.d.ts +14 -0
  91. package/dist/cjs/lifecycle.js +538 -0
  92. package/dist/cjs/package.json +3 -0
  93. package/dist/cjs/remoteconfig/custom.d.ts +10 -0
  94. package/dist/cjs/remoteconfig/custom.js +78 -0
  95. package/dist/cjs/remoteconfig/evaluate.d.ts +24 -0
  96. package/dist/cjs/remoteconfig/evaluate.js +171 -0
  97. package/dist/cjs/remoteconfig/fetch.d.ts +24 -0
  98. package/dist/cjs/remoteconfig/fetch.js +214 -0
  99. package/dist/cjs/remoteconfig/index.d.ts +13 -0
  100. package/dist/cjs/remoteconfig/index.js +90 -0
  101. package/dist/cjs/remoteconfig/store.d.ts +18 -0
  102. package/dist/cjs/remoteconfig/store.js +98 -0
  103. package/dist/cjs/remotelog/gate.d.ts +11 -0
  104. package/dist/cjs/remotelog/gate.js +54 -0
  105. package/dist/cjs/remotelog/index.d.ts +25 -0
  106. package/dist/cjs/remotelog/index.js +55 -0
  107. package/dist/cjs/remotelog/logger.d.ts +28 -0
  108. package/dist/cjs/remotelog/logger.js +139 -0
  109. package/dist/cjs/remotelog/send.d.ts +13 -0
  110. package/dist/cjs/remotelog/send.js +153 -0
  111. package/dist/cjs/scheduler.d.ts +8 -0
  112. package/dist/cjs/scheduler.js +78 -0
  113. package/dist/cjs/types.d.ts +312 -0
  114. package/dist/cjs/user/index.d.ts +33 -0
  115. package/dist/cjs/user/index.js +178 -0
  116. package/dist/esm/auto-init.d.ts +8 -0
  117. package/dist/esm/auto-init.js +29 -0
  118. package/dist/esm/core/attempts.d.ts +28 -0
  119. package/dist/esm/core/attempts.js +106 -0
  120. package/dist/esm/core/batch.d.ts +32 -0
  121. package/dist/esm/core/batch.js +108 -0
  122. package/dist/esm/core/callsite.d.ts +28 -0
  123. package/dist/esm/core/callsite.js +89 -0
  124. package/dist/esm/core/consent.d.ts +23 -0
  125. package/dist/esm/core/consent.js +120 -0
  126. package/dist/esm/core/constants.d.ts +212 -0
  127. package/dist/esm/core/constants.js +277 -0
  128. package/dist/esm/core/db.d.ts +40 -0
  129. package/dist/esm/core/db.js +324 -0
  130. package/dist/esm/core/debug.d.ts +22 -0
  131. package/dist/esm/core/debug.js +81 -0
  132. package/dist/esm/core/env.d.ts +28 -0
  133. package/dist/esm/core/env.js +251 -0
  134. package/dist/esm/core/framework-id.d.ts +1 -0
  135. package/dist/esm/core/framework-id.js +7 -0
  136. package/dist/esm/core/guard.d.ts +2 -0
  137. package/dist/esm/core/guard.js +70 -0
  138. package/dist/esm/core/hooks.d.ts +41 -0
  139. package/dist/esm/core/hooks.js +21 -0
  140. package/dist/esm/core/logger.d.ts +16 -0
  141. package/dist/esm/core/logger.js +82 -0
  142. package/dist/esm/core/state.d.ts +69 -0
  143. package/dist/esm/core/state.js +73 -0
  144. package/dist/esm/core/storage.d.ts +46 -0
  145. package/dist/esm/core/storage.js +219 -0
  146. package/dist/esm/core/transport.d.ts +83 -0
  147. package/dist/esm/core/transport.js +425 -0
  148. package/dist/esm/core/utils.d.ts +26 -0
  149. package/dist/esm/core/utils.js +161 -0
  150. package/dist/esm/core/validate.d.ts +18 -0
  151. package/dist/esm/core/validate.js +226 -0
  152. package/dist/esm/device/appversion.d.ts +20 -0
  153. package/dist/esm/device/appversion.js +153 -0
  154. package/dist/esm/device/index.d.ts +23 -0
  155. package/dist/esm/device/index.js +362 -0
  156. package/dist/esm/engagement/api-rules.d.ts +84 -0
  157. package/dist/esm/engagement/api-rules.js +211 -0
  158. package/dist/esm/engagement/auto-api.d.ts +7 -0
  159. package/dist/esm/engagement/auto-api.js +198 -0
  160. package/dist/esm/engagement/auto-screen.d.ts +16 -0
  161. package/dist/esm/engagement/auto-screen.js +238 -0
  162. package/dist/esm/engagement/defined-events.d.ts +23 -0
  163. package/dist/esm/engagement/defined-events.js +55 -0
  164. package/dist/esm/engagement/send.d.ts +6 -0
  165. package/dist/esm/engagement/send.js +96 -0
  166. package/dist/esm/engagement/session.d.ts +42 -0
  167. package/dist/esm/engagement/session.js +315 -0
  168. package/dist/esm/engagement/track.d.ts +56 -0
  169. package/dist/esm/engagement/track.js +340 -0
  170. package/dist/esm/errors/send.d.ts +6 -0
  171. package/dist/esm/errors/send.js +70 -0
  172. package/dist/esm/errors/track.d.ts +4 -0
  173. package/dist/esm/errors/track.js +123 -0
  174. package/dist/esm/feedback/controls.d.ts +31 -0
  175. package/dist/esm/feedback/controls.js +280 -0
  176. package/dist/esm/feedback/index.d.ts +8 -0
  177. package/dist/esm/feedback/index.js +30 -0
  178. package/dist/esm/feedback/logs.d.ts +40 -0
  179. package/dist/esm/feedback/logs.js +188 -0
  180. package/dist/esm/feedback/send.d.ts +25 -0
  181. package/dist/esm/feedback/send.js +175 -0
  182. package/dist/esm/feedback/template.d.ts +2 -0
  183. package/dist/esm/feedback/template.js +159 -0
  184. package/dist/esm/feedback/ui.d.ts +55 -0
  185. package/dist/esm/feedback/ui.js +626 -0
  186. package/dist/esm/heatmap/index.d.ts +16 -0
  187. package/dist/esm/heatmap/index.js +17 -0
  188. package/dist/esm/heatmap/send.d.ts +13 -0
  189. package/dist/esm/heatmap/send.js +79 -0
  190. package/dist/esm/heatmap/track.d.ts +4 -0
  191. package/dist/esm/heatmap/track.js +374 -0
  192. package/dist/esm/index.d.ts +68 -0
  193. package/dist/esm/index.js +122 -0
  194. package/dist/esm/lifecycle.d.ts +14 -0
  195. package/dist/esm/lifecycle.js +534 -0
  196. package/dist/esm/package.json +3 -0
  197. package/dist/esm/remoteconfig/custom.d.ts +10 -0
  198. package/dist/esm/remoteconfig/custom.js +74 -0
  199. package/dist/esm/remoteconfig/evaluate.d.ts +24 -0
  200. package/dist/esm/remoteconfig/evaluate.js +166 -0
  201. package/dist/esm/remoteconfig/fetch.d.ts +24 -0
  202. package/dist/esm/remoteconfig/fetch.js +210 -0
  203. package/dist/esm/remoteconfig/index.d.ts +13 -0
  204. package/dist/esm/remoteconfig/index.js +85 -0
  205. package/dist/esm/remoteconfig/store.d.ts +18 -0
  206. package/dist/esm/remoteconfig/store.js +91 -0
  207. package/dist/esm/remotelog/gate.d.ts +11 -0
  208. package/dist/esm/remotelog/gate.js +48 -0
  209. package/dist/esm/remotelog/index.d.ts +25 -0
  210. package/dist/esm/remotelog/index.js +51 -0
  211. package/dist/esm/remotelog/logger.d.ts +28 -0
  212. package/dist/esm/remotelog/logger.js +136 -0
  213. package/dist/esm/remotelog/send.d.ts +13 -0
  214. package/dist/esm/remotelog/send.js +149 -0
  215. package/dist/esm/scheduler.d.ts +8 -0
  216. package/dist/esm/scheduler.js +74 -0
  217. package/dist/esm/types.d.ts +312 -0
  218. package/dist/esm/user/index.d.ts +33 -0
  219. package/dist/esm/user/index.js +170 -0
  220. package/dist/feedback.esm.min.js +3 -0
  221. package/dist/feedback.esm.min.js.map +1 -0
  222. package/dist/heatmap.esm.min.js +3 -0
  223. package/dist/heatmap.esm.min.js.map +1 -0
  224. package/dist/style.css +1 -0
  225. package/package.json +124 -7
  226. package/src/appticssdk.js +0 -1
@@ -0,0 +1,212 @@
1
+ export declare const AP_TRACKING_STATUS: Readonly<{
2
+ readonly USAGE_TRACKING_WITH_PII: 1;
3
+ readonly USAGE_TRACKING_WITHOUT_PII: 4;
4
+ readonly NO_TRACKING: -1;
5
+ }>;
6
+ export declare const AP_FEEDBACK_TYPE: Readonly<{
7
+ readonly BUG: 0;
8
+ readonly FEEDBACK: 1;
9
+ readonly HELP: 2;
10
+ readonly REPORT: 3;
11
+ }>;
12
+ export declare const AP_CONSTANTS: Readonly<{
13
+ readonly SCREEN: "screen";
14
+ readonly SESSION: "session";
15
+ readonly EVENT: "event";
16
+ readonly API: "api";
17
+ readonly ERROR: "error";
18
+ readonly SUCCESS: "success";
19
+ readonly BROWSER: "Browser";
20
+ }>;
21
+ export declare const DEFAULT_API_PATHS: Readonly<{
22
+ readonly addversion: "app/addversion";
23
+ readonly regdevice: "device/add";
24
+ readonly reguser: "user/register";
25
+ readonly engagement: "engagement/add";
26
+ readonly error: "exception/error";
27
+ readonly feedback: "feedback/add";
28
+ readonly sdkconfig: "getsdkconfig";
29
+ readonly getupdates: "getupdates";
30
+ readonly consolelog: "log/add";
31
+ readonly heatmap: "heatmap/add";
32
+ }>;
33
+ /**
34
+ * Which API version each path lives under.
35
+ *
36
+ * Every path the SDK calls is defined under v2 in the proxy's security-sdk.xml, and four of them —
37
+ * app/addversion, getsdkconfig, heatmap/add and log/add — are defined there *only* under v2: there
38
+ * is no v1 url for them to fall back to, so sending v1 reaches nothing. It stays a per-path map
39
+ * rather than one shared prefix because v1 urls do still exist for the other five, so a path can
40
+ * be moved back on its own if one of them turns out not to be ready.
41
+ */
42
+ export declare const API_VERSIONS: Readonly<Record<keyof typeof DEFAULT_API_PATHS, string>>;
43
+ /**
44
+ * The SDK subsystem a remote log line is about, as console/addlog's `module` param.
45
+ * These are the server's own names, so they are sent exactly as written here.
46
+ */
47
+ export declare const AP_LOG_MODULE: Readonly<{
48
+ readonly SESSION: "Session";
49
+ readonly SCREEN: "Screen";
50
+ readonly EVENT: "Event";
51
+ readonly API: "API";
52
+ readonly HEATMAP: "Heatmap";
53
+ readonly PROPERTIES: "Properties";
54
+ }>;
55
+ /**
56
+ * The modules getsdkconfig reports on, by the ids it keys them with. The SDK acts on the ones it
57
+ * has something to switch off; anything else the server sends is stored but unused.
58
+ */
59
+ export declare const SDK_MODULE: Readonly<{
60
+ /**
61
+ * Remote config. It is the one module both answers report on: getupdates names it in
62
+ * `moduleids` and reports its flag back, and getsdkconfig reports the same flag as the
63
+ * authority. Where they disagree, getsdkconfig wins.
64
+ */
65
+ readonly REMOTE_CONFIG: "2";
66
+ readonly SESSION: "11";
67
+ readonly FEEDBACK: "12";
68
+ readonly CRASH: "13";
69
+ readonly REMOTE_LOGGER: "17";
70
+ readonly HEATMAP: "18";
71
+ }>;
72
+ /** logSDK declares max-len="10000" on logmessage, so a line is trimmed to fit that. */
73
+ export declare const CONSOLE_LOG_MAX_BODY = 10000;
74
+ /** logSDK caps `function` at 100 characters. */
75
+ export declare const LOG_FUNCTION_MAX = 100;
76
+ /** logSDK caps `filename` at 100 too, which is why a call site carries a basename, not a url. */
77
+ export declare const LOG_FILENAME_MAX = 100;
78
+ /**
79
+ * How much of `devicename` is sent. The url declares no max-len, only safe_string, but this is a
80
+ * label a person reads in a list: anything longer is a paragraph, not a name.
81
+ */
82
+ export declare const DEVICE_NAME_MAX = 100;
83
+ /**
84
+ * The `level` every line goes out with. Everything the remote logger carries is a failure inside
85
+ * the SDK — logFailure is its only caller — so the level never varies. 3 is what the v2 reference
86
+ * shows in its only example; the scale itself is not documented anywhere we can see.
87
+ */
88
+ export declare const REMOTE_LOG_LEVEL = 3;
89
+ /**
90
+ * How long debug mode survives with nothing tracked, before switching itself off.
91
+ *
92
+ * An hour is long enough to cover reading a payload, changing the app and reloading, and short
93
+ * enough that a tab left open overnight is not still sending every call to its debug twin.
94
+ */
95
+ export declare const DEBUG_IDLE_MS: number;
96
+ /** Idle minutes that end a session. Lives on state, not in _config, but defaults here. */
97
+ export declare const DEFAULT_INACTIVE_MINUTES = 30;
98
+ /** Global defaults. `state._config` holds a mutable copy per init. */
99
+ export declare const AP_CONFIG: Readonly<{
100
+ endpoint: "/sdk/web/";
101
+ method: "POST";
102
+ transport: "XHR";
103
+ track_link_timeout: 300;
104
+ cookie_expiration_days: 365;
105
+ storage_type: "localStorage";
106
+ enable_batch_requests: true;
107
+ batch_size: 50;
108
+ batch_flush_interval: 30000;
109
+ getupdates_interval: 120000;
110
+ batch_request_timeout: 7;
111
+ auto_starts_batch: true;
112
+ mode: 1;
113
+ default_group_name: "default";
114
+ default_optin_status: number;
115
+ enable_pageview_tracking: false;
116
+ save_referrer: true;
117
+ debug: boolean;
118
+ track_by_default: true;
119
+ ignore_do_not_track: boolean;
120
+ remote_log: boolean;
121
+ /**
122
+ * Wrap XHR and fetch to record the app's API calls without it calling startTrackApi(). Off by
123
+ * default: the hostnames and paths of every request an app makes is a wider grant than events
124
+ * and screens, so the app opts in.
125
+ */
126
+ track_api: boolean;
127
+ /**
128
+ * Record a screen view for the first page and every navigation after it, from the url. On by
129
+ * default; the app's own inScreen() during a navigation replaces that navigation's view.
130
+ */
131
+ track_screen: boolean;
132
+ /**
133
+ * Print each app logger line to the browser console as well, as Android's showLogs prints to
134
+ * Logcat. Off by default; console_log is the SDK's own activity, this is the app's lines.
135
+ */
136
+ show_logs: boolean;
137
+ /**
138
+ * Record sessions automatically. On by default; false is Android's
139
+ * automaticSessionsTrackingStatus = false: no sessions, while events and screens still are.
140
+ */
141
+ track_session: boolean;
142
+ /**
143
+ * How long a visit must last before its session is stored, in milliseconds. A shorter visit with
144
+ * nothing tracked in it is dropped: a bounce or a crawler is not a session. Anything tracked
145
+ * inside the window writes the session immediately, keeping its original start time. 0 disables
146
+ * the wait and stores every session as it starts.
147
+ */
148
+ min_session_duration: number;
149
+ /**
150
+ * Record where people click and how far they scroll, for the console's heatmaps. Off by default:
151
+ * coordinates and element labels are a wider grant than events and screens, so the app opts in.
152
+ */
153
+ track_heatmap: boolean;
154
+ /**
155
+ * Send engagement, exception and log payloads to their `debug/` twins, which answer with a
156
+ * request id and a link to the server's own logs for that request. For tracing a payload that
157
+ * is not showing up in the console; off in normal use, and it does not change what is sent.
158
+ */
159
+ debug_api: boolean;
160
+ /**
161
+ * What to call this device in the debug stream. Engagement, exception and log are the three
162
+ * urls that declare `devicename`, and it is what tells one tester's browser from another's
163
+ * when several are tracing the same build. Empty by default: it rides on every one of those
164
+ * calls, so an app that is not tracing should not pay for it. With `debug_api` on and nothing
165
+ * set here, a label is derived from the browser and OS instead, since an unnamed row in the
166
+ * debug stream is no use to whoever is reading it.
167
+ */
168
+ device_name: string;
169
+ /**
170
+ * Most heatmap records one visit may produce. Clicks are cheap, but a page that scrolls a lot
171
+ * can produce them faster than they are sent, and an unbounded queue is a memory leak on a tab
172
+ * left open for a day. Reached, capture stops for the rest of the session.
173
+ */
174
+ heatmap_max_per_session: number;
175
+ }>;
176
+ export type ApConfig = {
177
+ -readonly [K in keyof typeof AP_CONFIG]: (typeof AP_CONFIG)[K];
178
+ };
179
+ /**
180
+ * Config keys `init()` refuses to start without (after the snippet aliases are resolved).
181
+ *
182
+ * `appversion` is here rather than defaulted on purpose. Every error, every device registration
183
+ * and every uploaded source map is only meaningful against the build it came from, and a default
184
+ * would answer that question wrongly and silently for every app that forgot to set it.
185
+ */
186
+ /**
187
+ * What init() must be given. Everything else the SDK needs — aaid, the portal and project ids that
188
+ * go in every url — comes back from app/addversion, which these four are enough to call.
189
+ */
190
+ export declare const REQUIRED_CONFIG: readonly ["serviceUrl", "zak", "identifier", "appversion"];
191
+ /**
192
+ * Paths with a `debug/` twin. The debug endpoints take the same body and answer with a request id
193
+ * and a link to the server-side logs for that request, which is how a payload is traced end to
194
+ * end when the console does not show what was expected.
195
+ */
196
+ export declare const DEBUG_CAPABLE_PATHS: Readonly<Record<string, boolean>>;
197
+ /**
198
+ * Paths that declare `attempt`, `firstattempttime` and `lst`.
199
+ *
200
+ * Every url that carries data declares all three. app/addversion and getsdkconfig declare none:
201
+ * they are start-up calls whose answers the SDK needs, not payloads it is pushing, and sending
202
+ * an undeclared param is refused outright as EXTRA_PARAM_FOUND.
203
+ */
204
+ export declare const RETRY_CAPABLE_PATHS: Readonly<Record<string, boolean>>;
205
+ /**
206
+ * Paths that live directly under the version, with no org and project segments. app/addversion is
207
+ * called before those ids are known, so it cannot carry them.
208
+ */
209
+ export declare const PATHS_WITHOUT_ORG: Readonly<Record<string, boolean>>;
210
+ /** Console-snippet names accepted for the canonical keys above. */
211
+ export declare const CONFIG_ALIASES: Readonly<Record<string, string>>;
212
+ export declare const BLOCKED_WS: readonly string[];
@@ -0,0 +1,277 @@
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta | (c) Zoho Corporation Private Limited | see LICENSE */
2
+ const AP_TRACKING_STATUS = Object.freeze({
3
+ USAGE_TRACKING_WITH_PII: 1,
4
+ USAGE_TRACKING_WITHOUT_PII: 4,
5
+ NO_TRACKING: -1,
6
+ });
7
+ const AP_FEEDBACK_TYPE = Object.freeze({
8
+ BUG: 0,
9
+ FEEDBACK: 1,
10
+ HELP: 2,
11
+ REPORT: 3,
12
+ });
13
+ const AP_CONSTANTS = Object.freeze({
14
+ SCREEN: 'screen', // no i18n
15
+ SESSION: 'session', // no i18n
16
+ EVENT: 'event', // no i18n
17
+ API: 'api', // no i18n
18
+ ERROR: 'error', // no i18n
19
+ SUCCESS: 'success', // no i18n
20
+ BROWSER: 'Browser', // no i18n
21
+ });
22
+ const DEFAULT_API_PATHS = Object.freeze({
23
+ // the first call: registers the build and answers with the ids every later call needs
24
+ addversion: 'app/addversion', // no i18n
25
+ regdevice: 'device/add', // no i18n
26
+ reguser: 'user/register', // no i18n
27
+ engagement: 'engagement/add', // no i18n
28
+ // the exception group is part of the path, and the proxy matches it with [a-z]+ — no
29
+ // underscore, so js_error cannot route. 'error' is in the accepted set and is what we send
30
+ error: 'exception/error', // no i18n
31
+ feedback: 'feedback/add', // no i18n
32
+ // the source of truth for which modules are on. v2 replaced the old getupdates answer: it is
33
+ // per-module flags keyed by id now, not loose booleans
34
+ sdkconfig: 'getsdkconfig', // no i18n
35
+ // still its own endpoint, and not a synonym for the one above: it takes a body naming the
36
+ // modules being asked about, and answers with their payloads - remote config among them
37
+ getupdates: 'getupdates', // no i18n
38
+ // v2 replaced console/addlog: one call now carries a batch of lines, not one line
39
+ consolelog: 'log/add', // no i18n
40
+ heatmap: 'heatmap/add', // no i18n
41
+ });
42
+ /**
43
+ * Which API version each path lives under.
44
+ *
45
+ * Every path the SDK calls is defined under v2 in the proxy's security-sdk.xml, and four of them —
46
+ * app/addversion, getsdkconfig, heatmap/add and log/add — are defined there *only* under v2: there
47
+ * is no v1 url for them to fall back to, so sending v1 reaches nothing. It stays a per-path map
48
+ * rather than one shared prefix because v1 urls do still exist for the other five, so a path can
49
+ * be moved back on its own if one of them turns out not to be ready.
50
+ */
51
+ const API_VERSIONS = Object.freeze({
52
+ addversion: 'v2', // no i18n
53
+ regdevice: 'v2', // no i18n
54
+ engagement: 'v2', // no i18n
55
+ error: 'v2', // no i18n
56
+ reguser: 'v2', // no i18n
57
+ feedback: 'v2', // no i18n
58
+ sdkconfig: 'v2', // no i18n
59
+ getupdates: 'v2', // no i18n
60
+ consolelog: 'v2', // no i18n
61
+ heatmap: 'v2', // no i18n
62
+ });
63
+ /**
64
+ * The SDK subsystem a remote log line is about, as console/addlog's `module` param.
65
+ * These are the server's own names, so they are sent exactly as written here.
66
+ */
67
+ const AP_LOG_MODULE = Object.freeze({
68
+ SESSION: 'Session', // no i18n
69
+ SCREEN: 'Screen', // no i18n
70
+ EVENT: 'Event', // no i18n
71
+ API: 'API', // no i18n
72
+ HEATMAP: 'Heatmap', // no i18n
73
+ PROPERTIES: 'Properties', // no i18n
74
+ });
75
+ /**
76
+ * The modules getsdkconfig reports on, by the ids it keys them with. The SDK acts on the ones it
77
+ * has something to switch off; anything else the server sends is stored but unused.
78
+ */
79
+ const SDK_MODULE = Object.freeze({
80
+ /**
81
+ * Remote config. It is the one module both answers report on: getupdates names it in
82
+ * `moduleids` and reports its flag back, and getsdkconfig reports the same flag as the
83
+ * authority. Where they disagree, getsdkconfig wins.
84
+ */
85
+ REMOTE_CONFIG: '2', // no i18n
86
+ SESSION: '11', // no i18n
87
+ FEEDBACK: '12', // no i18n
88
+ CRASH: '13', // no i18n
89
+ REMOTE_LOGGER: '17', // no i18n
90
+ HEATMAP: '18', // no i18n
91
+ });
92
+ /** logSDK declares max-len="10000" on logmessage, so a line is trimmed to fit that. */
93
+ const CONSOLE_LOG_MAX_BODY = 10000;
94
+ /** logSDK caps `function` at 100 characters. */
95
+ const LOG_FUNCTION_MAX = 100;
96
+ /** logSDK caps `filename` at 100 too, which is why a call site carries a basename, not a url. */
97
+ const LOG_FILENAME_MAX = 100;
98
+ /**
99
+ * How much of `devicename` is sent. The url declares no max-len, only safe_string, but this is a
100
+ * label a person reads in a list: anything longer is a paragraph, not a name.
101
+ */
102
+ const DEVICE_NAME_MAX = 100;
103
+ /**
104
+ * The `level` every line goes out with. Everything the remote logger carries is a failure inside
105
+ * the SDK — logFailure is its only caller — so the level never varies. 3 is what the v2 reference
106
+ * shows in its only example; the scale itself is not documented anywhere we can see.
107
+ */
108
+ const REMOTE_LOG_LEVEL = 3;
109
+ /**
110
+ * How long debug mode survives with nothing tracked, before switching itself off.
111
+ *
112
+ * An hour is long enough to cover reading a payload, changing the app and reloading, and short
113
+ * enough that a tab left open overnight is not still sending every call to its debug twin.
114
+ */
115
+ const DEBUG_IDLE_MS = 60 * 60 * 1000;
116
+ /** Idle minutes that end a session. Lives on state, not in _config, but defaults here. */
117
+ const DEFAULT_INACTIVE_MINUTES = 30;
118
+ /** Global defaults. `state._config` holds a mutable copy per init. */
119
+ const AP_CONFIG = Object.freeze({
120
+ // the version is per path (API_VERSIONS); this is only the part before it
121
+ endpoint: '/sdk/web/', // no i18n
122
+ method: 'POST', // no i18n
123
+ transport: 'XHR', // no i18n
124
+ track_link_timeout: 300,
125
+ cookie_expiration_days: 365,
126
+ storage_type: 'localStorage', // no i18n
127
+ enable_batch_requests: true,
128
+ batch_size: 50,
129
+ batch_flush_interval: 30000,
130
+ getupdates_interval: 120000, // 2 minutes in milliseconds
131
+ batch_request_timeout: 7,
132
+ auto_starts_batch: true,
133
+ mode: 1,
134
+ default_group_name: 'default', // no i18n
135
+ default_optin_status: AP_TRACKING_STATUS.USAGE_TRACKING_WITHOUT_PII,
136
+ enable_pageview_tracking: false,
137
+ save_referrer: true,
138
+ debug: false,
139
+ track_by_default: true,
140
+ ignore_do_not_track: false,
141
+ // the SDK's own failure reports to the Remote Logger page: off unless the app passes remote_log: true
142
+ remote_log: false,
143
+ /**
144
+ * Wrap XHR and fetch to record the app's API calls without it calling startTrackApi(). Off by
145
+ * default: the hostnames and paths of every request an app makes is a wider grant than events
146
+ * and screens, so the app opts in.
147
+ */
148
+ track_api: false,
149
+ /**
150
+ * Record a screen view for the first page and every navigation after it, from the url. On by
151
+ * default; the app's own inScreen() during a navigation replaces that navigation's view.
152
+ */
153
+ track_screen: true,
154
+ /**
155
+ * Print each app logger line to the browser console as well, as Android's showLogs prints to
156
+ * Logcat. Off by default; console_log is the SDK's own activity, this is the app's lines.
157
+ */
158
+ show_logs: false,
159
+ /**
160
+ * Record sessions automatically. On by default; false is Android's
161
+ * automaticSessionsTrackingStatus = false: no sessions, while events and screens still are.
162
+ */
163
+ track_session: true,
164
+ /**
165
+ * How long a visit must last before its session is stored, in milliseconds. A shorter visit with
166
+ * nothing tracked in it is dropped: a bounce or a crawler is not a session. Anything tracked
167
+ * inside the window writes the session immediately, keeping its original start time. 0 disables
168
+ * the wait and stores every session as it starts.
169
+ */
170
+ min_session_duration: 5000,
171
+ /**
172
+ * Record where people click and how far they scroll, for the console's heatmaps. Off by default:
173
+ * coordinates and element labels are a wider grant than events and screens, so the app opts in.
174
+ */
175
+ track_heatmap: false,
176
+ /**
177
+ * Send engagement, exception and log payloads to their `debug/` twins, which answer with a
178
+ * request id and a link to the server's own logs for that request. For tracing a payload that
179
+ * is not showing up in the console; off in normal use, and it does not change what is sent.
180
+ */
181
+ debug_api: false,
182
+ /**
183
+ * What to call this device in the debug stream. Engagement, exception and log are the three
184
+ * urls that declare `devicename`, and it is what tells one tester's browser from another's
185
+ * when several are tracing the same build. Empty by default: it rides on every one of those
186
+ * calls, so an app that is not tracing should not pay for it. With `debug_api` on and nothing
187
+ * set here, a label is derived from the browser and OS instead, since an unnamed row in the
188
+ * debug stream is no use to whoever is reading it.
189
+ */
190
+ device_name: '',
191
+ /**
192
+ * Most heatmap records one visit may produce. Clicks are cheap, but a page that scrolls a lot
193
+ * can produce them faster than they are sent, and an unbounded queue is a memory leak on a tab
194
+ * left open for a day. Reached, capture stops for the rest of the session.
195
+ */
196
+ heatmap_max_per_session: 500,
197
+ });
198
+ /**
199
+ * Config keys `init()` refuses to start without (after the snippet aliases are resolved).
200
+ *
201
+ * `appversion` is here rather than defaulted on purpose. Every error, every device registration
202
+ * and every uploaded source map is only meaningful against the build it came from, and a default
203
+ * would answer that question wrongly and silently for every app that forgot to set it.
204
+ */
205
+ /**
206
+ * What init() must be given. Everything else the SDK needs — aaid, the portal and project ids that
207
+ * go in every url — comes back from app/addversion, which these four are enough to call.
208
+ */
209
+ const REQUIRED_CONFIG = Object.freeze(['serviceUrl', 'zak', 'identifier', 'appversion']); // no i18n
210
+ /**
211
+ * Paths with a `debug/` twin. The debug endpoints take the same body and answer with a request id
212
+ * and a link to the server-side logs for that request, which is how a payload is traced end to
213
+ * end when the console does not show what was expected.
214
+ */
215
+ const DEBUG_CAPABLE_PATHS = Object.freeze({
216
+ engagement: true, // no i18n
217
+ error: true, // no i18n
218
+ consolelog: true, // no i18n
219
+ });
220
+ /**
221
+ * Paths that declare `attempt`, `firstattempttime` and `lst`.
222
+ *
223
+ * Every url that carries data declares all three. app/addversion and getsdkconfig declare none:
224
+ * they are start-up calls whose answers the SDK needs, not payloads it is pushing, and sending
225
+ * an undeclared param is refused outright as EXTRA_PARAM_FOUND.
226
+ */
227
+ const RETRY_CAPABLE_PATHS = Object.freeze({
228
+ regdevice: true, // no i18n
229
+ reguser: true, // no i18n
230
+ engagement: true, // no i18n
231
+ error: true, // no i18n
232
+ heatmap: true, // no i18n
233
+ consolelog: true, // no i18n
234
+ feedback: true, // no i18n
235
+ getupdates: true, // no i18n
236
+ });
237
+ /**
238
+ * Paths that live directly under the version, with no org and project segments. app/addversion is
239
+ * called before those ids are known, so it cannot carry them.
240
+ */
241
+ const PATHS_WITHOUT_ORG = Object.freeze({
242
+ addversion: true, // no i18n
243
+ });
244
+ /** Console-snippet names accepted for the canonical keys above. */
245
+ const CONFIG_ALIASES = Object.freeze({
246
+ serviceUrl: 'base_domain', // no i18n
247
+ zak: 'token', // no i18n
248
+ });
249
+ // crawlers reference
250
+ // https://developers.google.com/search/docs/advanced/crawling/overview-google-crawlers
251
+ const BLOCKED_WS = Object.freeze([
252
+ 'ahrefsbot', // no i18n
253
+ 'ahrefssiteaudit', // no i18n
254
+ 'baiduspider', // no i18n
255
+ 'bingbot', // no i18n
256
+ 'bingpreview', // no i18n
257
+ 'chrome-lighthouse', // no i18n
258
+ 'facebookexternal', // no i18n
259
+ 'petalbot', // no i18n
260
+ 'pinterest', // no i18n
261
+ 'screaming frog', // no i18n
262
+ 'yahoo! slurp', // no i18n
263
+ 'yandexbot', // no i18n
264
+ 'adsbot-google', // no i18n
265
+ 'apis-google', // no i18n
266
+ 'duplexweb-google', // no i18n
267
+ 'feedfetcher-google', // no i18n
268
+ 'google favicon', // no i18n
269
+ 'google web preview', // no i18n
270
+ 'google-read-aloud', // no i18n
271
+ 'googlebot', // no i18n
272
+ 'googleweblight', // no i18n
273
+ 'mediapartners-google', // no i18n
274
+ 'storebot-google', // no i18n
275
+ ]);
276
+
277
+ export { API_VERSIONS, AP_CONFIG, AP_CONSTANTS, AP_FEEDBACK_TYPE, AP_LOG_MODULE, AP_TRACKING_STATUS, BLOCKED_WS, CONFIG_ALIASES, CONSOLE_LOG_MAX_BODY, DEBUG_CAPABLE_PATHS, DEBUG_IDLE_MS, DEFAULT_API_PATHS, DEFAULT_INACTIVE_MINUTES, DEVICE_NAME_MAX, LOG_FILENAME_MAX, LOG_FUNCTION_MAX, PATHS_WITHOUT_ORG, REMOTE_LOG_LEVEL, REQUIRED_CONFIG, RETRY_CAPABLE_PATHS, SDK_MODULE };
@@ -0,0 +1,40 @@
1
+ import type { Dict, QueueItem } from '../types.js';
2
+ export type QueueName = 'engagements' | 'errors' | 'logs' | 'consolelogs' | 'heatmaps';
3
+ /** One storage implementation. storage.ts talks only to this interface. */
4
+ export interface Backend {
5
+ readonly kind: 'indexeddb' | 'localstorage';
6
+ loadSettings(): Promise<Dict>;
7
+ putSetting(key: string, value: unknown): Promise<void>;
8
+ clearSettings(): Promise<void>;
9
+ /** Items in insertion order. */
10
+ queueAll(store: QueueName): Promise<QueueItem[]>;
11
+ /** Adds items, or replaces the item with the same id (keeping its position). */
12
+ queuePut(store: QueueName, items: QueueItem[]): Promise<void>;
13
+ queueDelete(store: QueueName, ids: string[]): Promise<void>;
14
+ queueClear(store: QueueName): Promise<void>;
15
+ /** One-transaction import of 1.x data; existing settings and items win. IndexedDB only. */
16
+ importAll?(settings: Dict, queues: Record<QueueName, QueueItem[]>): Promise<void>;
17
+ }
18
+ export declare const DB_NAME = "apptics";
19
+ export declare const DB_VERSION = 3;
20
+ /** 1.x localStorage keys; also the layout of the localStorage backend. */
21
+ export declare const LEGACY_KEYS: Readonly<{
22
+ readonly settings: "apptics-device-info";
23
+ readonly engagements: "apptics-engagements-transactions";
24
+ readonly errors: "apptics-errors-transactions";
25
+ readonly logs: "apptics-log-transactions";
26
+ readonly consolelogs: "apptics-consolelog-transactions";
27
+ readonly heatmaps: "apptics-heatmap-transactions";
28
+ }>;
29
+ /** Shape guards shared by both backends and the 1.x migration. */
30
+ export declare function asList(value: unknown): QueueItem[];
31
+ export declare function asDict(value: unknown): Dict;
32
+ export declare function createLocalStorageBackend(): Backend;
33
+ /**
34
+ * Opens the database, and repairs it once if something else created an "apptics" database
35
+ * without our stores (then onupgradeneeded never fires and every read would fail).
36
+ */
37
+ export declare function openIndexedDB(factory?: IDBFactory, timeoutMs?: number): Promise<IDBDatabase>;
38
+ export declare function createIndexedDBBackend(db: IDBDatabase): Backend;
39
+ /** IndexedDB when it opens, otherwise localStorage, otherwise null. Never rejects. */
40
+ export declare function openBackend(): Promise<Backend | null>;