@zoho_apptics/apptics-js-sdk 2.0.0-beta.1 → 2.0.0-beta.2

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 (183) hide show
  1. package/CHANGELOG.md +80 -16
  2. package/README.md +187 -100
  3. package/dist/apptics.esm.min.js +2 -2
  4. package/dist/apptics.esm.min.js.map +1 -1
  5. package/dist/apptics.min.js +2 -2
  6. package/dist/apptics.min.js.map +1 -1
  7. package/dist/chunks/lifecycle-C6m1W7jo.min.js +3 -0
  8. package/dist/chunks/lifecycle-C6m1W7jo.min.js.map +1 -0
  9. package/dist/chunks/send-CgUO82ne.min.js +3 -0
  10. package/dist/chunks/send-CgUO82ne.min.js.map +1 -0
  11. package/dist/cjs/core/attempts.js +1 -1
  12. package/dist/cjs/core/batch.js +1 -2
  13. package/dist/cjs/core/consent.d.ts +13 -3
  14. package/dist/cjs/core/consent.js +24 -10
  15. package/dist/cjs/core/constants.d.ts +22 -17
  16. package/dist/cjs/core/constants.js +22 -19
  17. package/dist/cjs/core/db.js +1 -1
  18. package/dist/cjs/core/debug.js +1 -1
  19. package/dist/cjs/core/env.d.ts +0 -3
  20. package/dist/cjs/core/env.js +1 -9
  21. package/dist/cjs/core/framework-id.d.ts +1 -1
  22. package/dist/cjs/core/framework-id.js +3 -3
  23. package/dist/cjs/core/guard.js +1 -1
  24. package/dist/cjs/core/hooks.d.ts +5 -0
  25. package/dist/cjs/core/hooks.js +2 -1
  26. package/dist/cjs/core/locks.js +1 -1
  27. package/dist/cjs/core/logger.js +1 -1
  28. package/dist/cjs/core/state.d.ts +6 -4
  29. package/dist/cjs/core/state.js +2 -4
  30. package/dist/cjs/core/storage.js +1 -4
  31. package/dist/cjs/core/stylesheet.js +1 -1
  32. package/dist/cjs/core/transport.js +13 -16
  33. package/dist/cjs/core/utils.js +1 -1
  34. package/dist/cjs/core/validate.js +1 -1
  35. package/dist/cjs/device/appversion.d.ts +10 -1
  36. package/dist/cjs/device/appversion.js +26 -3
  37. package/dist/cjs/device/index.d.ts +17 -2
  38. package/dist/cjs/device/index.js +195 -27
  39. package/dist/cjs/engagement/api-rules.js +1 -1
  40. package/dist/cjs/engagement/auto-api.js +1 -1
  41. package/dist/cjs/engagement/auto-screen.js +1 -1
  42. package/dist/cjs/engagement/defined-events.js +1 -1
  43. package/dist/cjs/engagement/send.js +7 -3
  44. package/dist/cjs/engagement/session.d.ts +17 -0
  45. package/dist/cjs/engagement/session.js +95 -4
  46. package/dist/cjs/engagement/track.d.ts +4 -4
  47. package/dist/cjs/engagement/track.js +15 -12
  48. package/dist/cjs/errors/send.js +2 -2
  49. package/dist/cjs/errors/track.d.ts +2 -1
  50. package/dist/cjs/errors/track.js +6 -4
  51. package/dist/cjs/feedback/controls.d.ts +6 -0
  52. package/dist/cjs/feedback/controls.js +74 -25
  53. package/dist/cjs/feedback/index.js +1 -1
  54. package/dist/cjs/feedback/logs.d.ts +3 -6
  55. package/dist/cjs/feedback/logs.js +8 -18
  56. package/dist/cjs/feedback/quartz.js +1 -1
  57. package/dist/cjs/feedback/send.d.ts +2 -2
  58. package/dist/cjs/feedback/send.js +4 -27
  59. package/dist/cjs/feedback/styles.js +2 -2
  60. package/dist/cjs/feedback/template.d.ts +1 -1
  61. package/dist/cjs/feedback/template.js +9 -1
  62. package/dist/cjs/feedback/ui.d.ts +7 -0
  63. package/dist/cjs/feedback/ui.js +160 -25
  64. package/dist/cjs/heatmap/send.d.ts +2 -0
  65. package/dist/cjs/heatmap/send.js +3 -5
  66. package/dist/cjs/heatmap/track.js +1 -1
  67. package/dist/cjs/index.d.ts +1 -2
  68. package/dist/cjs/index.js +54 -17
  69. package/dist/cjs/lifecycle.d.ts +13 -2
  70. package/dist/cjs/lifecycle.js +122 -54
  71. package/dist/cjs/remoteconfig/country.js +1 -1
  72. package/dist/cjs/remoteconfig/custom.js +1 -1
  73. package/dist/cjs/remoteconfig/evaluate.js +1 -1
  74. package/dist/cjs/remoteconfig/fetch.d.ts +17 -10
  75. package/dist/cjs/remoteconfig/fetch.js +126 -31
  76. package/dist/cjs/remoteconfig/index.d.ts +13 -4
  77. package/dist/cjs/remoteconfig/index.js +36 -20
  78. package/dist/cjs/remoteconfig/store.d.ts +15 -7
  79. package/dist/cjs/remoteconfig/store.js +68 -35
  80. package/dist/cjs/remoteconfig/tz-countries.js +1 -1
  81. package/dist/cjs/{core → remotelog}/callsite.d.ts +5 -4
  82. package/dist/cjs/{core → remotelog}/callsite.js +6 -5
  83. package/dist/cjs/remotelog/gate.js +1 -1
  84. package/dist/cjs/remotelog/logger.js +2 -2
  85. package/dist/cjs/remotelog/send.js +2 -2
  86. package/dist/cjs/remotelogger/index.js +1 -1
  87. package/dist/cjs/scheduler.d.ts +3 -1
  88. package/dist/cjs/scheduler.js +24 -21
  89. package/dist/cjs/types.d.ts +61 -16
  90. package/dist/cjs/user/index.js +6 -2
  91. package/dist/esm/core/attempts.js +1 -1
  92. package/dist/esm/core/batch.js +1 -2
  93. package/dist/esm/core/consent.d.ts +13 -3
  94. package/dist/esm/core/consent.js +24 -11
  95. package/dist/esm/core/constants.d.ts +22 -17
  96. package/dist/esm/core/constants.js +22 -19
  97. package/dist/esm/core/db.js +1 -1
  98. package/dist/esm/core/debug.js +1 -1
  99. package/dist/esm/core/env.d.ts +0 -3
  100. package/dist/esm/core/env.js +2 -9
  101. package/dist/esm/core/framework-id.d.ts +1 -1
  102. package/dist/esm/core/framework-id.js +3 -3
  103. package/dist/esm/core/guard.js +1 -1
  104. package/dist/esm/core/hooks.d.ts +5 -0
  105. package/dist/esm/core/hooks.js +2 -1
  106. package/dist/esm/core/locks.js +1 -1
  107. package/dist/esm/core/logger.js +1 -1
  108. package/dist/esm/core/state.d.ts +6 -4
  109. package/dist/esm/core/state.js +2 -4
  110. package/dist/esm/core/storage.js +1 -4
  111. package/dist/esm/core/stylesheet.js +1 -1
  112. package/dist/esm/core/transport.js +13 -16
  113. package/dist/esm/core/utils.js +1 -1
  114. package/dist/esm/core/validate.js +1 -1
  115. package/dist/esm/device/appversion.d.ts +10 -1
  116. package/dist/esm/device/appversion.js +26 -4
  117. package/dist/esm/device/index.d.ts +17 -2
  118. package/dist/esm/device/index.js +195 -30
  119. package/dist/esm/engagement/api-rules.js +1 -1
  120. package/dist/esm/engagement/auto-api.js +1 -1
  121. package/dist/esm/engagement/auto-screen.js +1 -1
  122. package/dist/esm/engagement/defined-events.js +1 -1
  123. package/dist/esm/engagement/send.js +7 -3
  124. package/dist/esm/engagement/session.d.ts +17 -0
  125. package/dist/esm/engagement/session.js +93 -5
  126. package/dist/esm/engagement/track.d.ts +4 -4
  127. package/dist/esm/engagement/track.js +16 -13
  128. package/dist/esm/errors/send.js +2 -2
  129. package/dist/esm/errors/track.d.ts +2 -1
  130. package/dist/esm/errors/track.js +6 -4
  131. package/dist/esm/feedback/controls.d.ts +6 -0
  132. package/dist/esm/feedback/controls.js +74 -26
  133. package/dist/esm/feedback/index.js +1 -1
  134. package/dist/esm/feedback/logs.d.ts +3 -6
  135. package/dist/esm/feedback/logs.js +8 -18
  136. package/dist/esm/feedback/quartz.js +1 -1
  137. package/dist/esm/feedback/send.d.ts +2 -2
  138. package/dist/esm/feedback/send.js +6 -29
  139. package/dist/esm/feedback/styles.js +2 -2
  140. package/dist/esm/feedback/template.d.ts +1 -1
  141. package/dist/esm/feedback/template.js +9 -1
  142. package/dist/esm/feedback/ui.d.ts +7 -0
  143. package/dist/esm/feedback/ui.js +161 -26
  144. package/dist/esm/heatmap/send.d.ts +2 -0
  145. package/dist/esm/heatmap/send.js +3 -5
  146. package/dist/esm/heatmap/track.js +1 -1
  147. package/dist/esm/index.d.ts +1 -2
  148. package/dist/esm/index.js +57 -20
  149. package/dist/esm/lifecycle.d.ts +13 -2
  150. package/dist/esm/lifecycle.js +126 -60
  151. package/dist/esm/remoteconfig/country.js +1 -1
  152. package/dist/esm/remoteconfig/custom.js +1 -1
  153. package/dist/esm/remoteconfig/evaluate.js +1 -1
  154. package/dist/esm/remoteconfig/fetch.d.ts +17 -10
  155. package/dist/esm/remoteconfig/fetch.js +127 -32
  156. package/dist/esm/remoteconfig/index.d.ts +13 -4
  157. package/dist/esm/remoteconfig/index.js +36 -20
  158. package/dist/esm/remoteconfig/store.d.ts +15 -7
  159. package/dist/esm/remoteconfig/store.js +68 -36
  160. package/dist/esm/remoteconfig/tz-countries.js +1 -1
  161. package/dist/esm/{core → remotelog}/callsite.d.ts +5 -4
  162. package/dist/esm/{core → remotelog}/callsite.js +6 -5
  163. package/dist/esm/remotelog/gate.js +1 -1
  164. package/dist/esm/remotelog/logger.js +2 -2
  165. package/dist/esm/remotelog/send.js +2 -2
  166. package/dist/esm/remotelogger/index.js +1 -1
  167. package/dist/esm/scheduler.d.ts +3 -1
  168. package/dist/esm/scheduler.js +25 -23
  169. package/dist/esm/types.d.ts +61 -16
  170. package/dist/esm/user/index.js +7 -3
  171. package/dist/feedback.esm.min.js +2 -2
  172. package/dist/feedback.esm.min.js.map +1 -1
  173. package/dist/remoteconfig.esm.min.js +3 -0
  174. package/dist/remoteconfig.esm.min.js.map +1 -0
  175. package/dist/remotelogger.esm.min.js +3 -0
  176. package/dist/remotelogger.esm.min.js.map +1 -0
  177. package/package.json +3 -2
  178. package/dist/chunks/lifecycle-VYr43KcB.min.js +0 -3
  179. package/dist/chunks/lifecycle-VYr43KcB.min.js.map +0 -1
  180. package/dist/cjs/auto-init.d.ts +0 -8
  181. package/dist/cjs/auto-init.js +0 -32
  182. package/dist/esm/auto-init.d.ts +0 -8
  183. package/dist/esm/auto-init.js +0 -29
@@ -1,4 +1,4 @@
1
- /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
2
2
  'use strict';
3
3
 
4
4
  var constants = require('../core/constants.js');
@@ -42,7 +42,7 @@ function entryFor(item) {
42
42
  var entry = {
43
43
  sessionstarttime: state._ZAP._current_session.starttime || item.happenedat || utils.nowMs(),
44
44
  logtime: item.happenedat || utils.nowMs(),
45
- // an app's line carries the level it was logged at; the SDK's own failures carry none
45
+ // an app's line carries the level it was logged at; only a line an older SDK stored has none
46
46
  level: Number(item.level) || constants.REMOTE_LOG_LEVEL,
47
47
  logmessage: String(item.exceptionlog).slice(0, constants.CONSOLE_LOG_MAX_BODY),
48
48
  function: String(item.module || 'SDK').slice(0, constants.LOG_FUNCTION_MAX), // no i18n
@@ -1,4 +1,4 @@
1
- /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
2
2
  'use strict';
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
@@ -3,6 +3,8 @@
3
3
  * response (page hide), so they survive the page going away.
4
4
  */
5
5
  export declare function flush(forget?: boolean): Promise<void>;
6
- /** Starts the flush and getupdates intervals once; later calls do nothing until stopTimers(). */
6
+ /** Apptics.flush(): flush(), at most once every CALLED_FLUSH_GAP_MS. A call sooner sends nothing. */
7
+ export declare function calledFlush(): Promise<void>;
8
+ /** Starts the flush interval once; later calls do nothing until stopTimers(). */
7
9
  export declare function startTimers(): void;
8
10
  export declare function stopTimers(): void;
@@ -1,9 +1,9 @@
1
- /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
2
2
  'use strict';
3
3
 
4
4
  var state = require('./core/state.js');
5
- var utils = require('./core/utils.js');
6
5
  var logger = require('./core/logger.js');
6
+ var utils = require('./core/utils.js');
7
7
  var consent = require('./core/consent.js');
8
8
  var batch = require('./core/batch.js');
9
9
  var send = require('./engagement/send.js');
@@ -29,9 +29,26 @@ function flush(forget) {
29
29
  return hooks.hooks.sendHeatmaps(forget);
30
30
  });
31
31
  }
32
+ /**
33
+ * How often Apptics.flush() sends when it is called by hand, from the console or the app's own
34
+ * code: once every 15 seconds, however often it is called. The SDK's own sends (the flush
35
+ * interval, page hide and close, back online) call flush() directly and are not held to it.
36
+ */
37
+ const CALLED_FLUSH_GAP_MS = 15 * 1000;
38
+ /** When Apptics.flush() last sent; 0 until it has. */
39
+ var calledFlushAt = 0;
40
+ /** Apptics.flush(): flush(), at most once every CALLED_FLUSH_GAP_MS. A call sooner sends nothing. */
41
+ function calledFlush() {
42
+ var now = utils.nowMs();
43
+ if (calledFlushAt > 0 && now - calledFlushAt < CALLED_FLUSH_GAP_MS) {
44
+ logger.Console.log('Apptics.flush: sent ' + (now - calledFlushAt) + ' ms ago; it sends at most once every ' + CALLED_FLUSH_GAP_MS + ' ms, and the timer sends the rest'); // no i18n
45
+ return Promise.resolve();
46
+ }
47
+ calledFlushAt = now;
48
+ return flush();
49
+ }
32
50
  var sendingInterval = null;
33
- var getUpdatesInterval = null;
34
- /** Starts the flush and getupdates intervals once; later calls do nothing until stopTimers(). */
51
+ /** Starts the flush interval once; later calls do nothing until stopTimers(). */
35
52
  function startTimers() {
36
53
  if (sendingInterval === null) {
37
54
  sendingInterval = setInterval(function () {
@@ -48,31 +65,17 @@ function startTimers() {
48
65
  });
49
66
  }, state.getConfig('batch_flush_interval')); // no i18n
50
67
  }
51
- if (getUpdatesInterval === null) {
52
- // the interval is the floor, not the schedule: getsdkconfig answers with next_check_after,
53
- // and asking again before then is a call the server has already told us it will not answer
54
- // differently. The timer still ticks so a server that sends no hint behaves as before.
55
- getUpdatesInterval = setInterval(function () {
56
- if (state._ZAP._nextConfigCheck > 0 && utils.nowMs() < state._ZAP._nextConfigCheck) {
57
- return;
58
- }
59
- logger.Console.log('scheduleToGetUpdatesFromServer: asking the server for its config'); // no i18n
60
- index.getUpdatesFromServer().catch(function (err) {
61
- logger.Console.log(err);
62
- });
63
- }, state.getConfig('getupdates_interval')); // no i18n
64
- }
65
68
  }
66
69
  function stopTimers() {
67
70
  if (sendingInterval !== null)
68
71
  clearInterval(sendingInterval);
69
- if (getUpdatesInterval !== null)
70
- clearInterval(getUpdatesInterval);
71
72
  sendingInterval = null;
72
- getUpdatesInterval = null;
73
73
  batch.clearDefer();
74
+ index.stopServerSettingChecks();
75
+ calledFlushAt = 0;
74
76
  }
75
77
 
78
+ exports.calledFlush = calledFlush;
76
79
  exports.flush = flush;
77
80
  exports.startTimers = startTimers;
78
81
  exports.stopTimers = stopTimers;
@@ -37,7 +37,7 @@ export interface ServerResult<T = Dict> {
37
37
  export type TrackingStatus = (typeof AP_TRACKING_STATUS)[keyof typeof AP_TRACKING_STATUS];
38
38
  export type FeedbackType = (typeof AP_FEEDBACK_TYPE)[keyof typeof AP_FEEDBACK_TYPE];
39
39
  export type Properties = Record<string, unknown>;
40
- /** The config init() requires. The console snippet provides the same shape as window.appticssettings._defaultoptions. */
40
+ /** The config init() requires. */
41
41
  export interface AppticsConfig {
42
42
  /** Apptics host every request goes to, e.g. https://apptics.zoho.com (a trailing slash is ignored). Was `serviceUrl`. */
43
43
  base_url: string;
@@ -87,6 +87,18 @@ export interface AppticsConfig {
87
87
  * navigation replaces its automatic view; set this false to track only the app's own calls.
88
88
  */
89
89
  track_screen?: boolean;
90
+ /**
91
+ * Record uncaught errors and unhandled promise rejections automatically. On by default; set this
92
+ * false to record only the errors the app hands to AppticsError.trackError(). Switched later with
93
+ * AppticsError.setErrorTracking().
94
+ */
95
+ track_error?: boolean;
96
+ /**
97
+ * Record clicks on elements tagged `apeventaction` (or `data-apeventaction`) as events, in the
98
+ * group of the nearest `apgroupaction` around them. On by default; switched later with
99
+ * AppticsEvent.setClickTracking().
100
+ */
101
+ track_click?: boolean;
90
102
  /**
91
103
  * How automatic screen tracking names a path, tried in order; the first that matches wins, and a
92
104
  * path none matches keeps its own name. Each entry is one of:
@@ -105,13 +117,19 @@ export interface AppticsConfig {
105
117
  feedback_theme?: 'light' | 'dark' | 'auto';
106
118
  /** How often queued data is sent, in milliseconds. Default 30000, at least 1000. */
107
119
  batch_flush_interval?: number;
108
- /** How often the server's tracking flags are fetched, in milliseconds. Default 120000, at least 10000. */
120
+ /**
121
+ * How long to wait before reading the server's tracking settings again, in milliseconds, when its
122
+ * answer gives no time for the next check (next_check_after). Default 120000, at least 10000.
123
+ */
109
124
  getupdates_interval?: number;
110
125
  /** Most items in one batch. Default 50, between 1 and 500. */
111
126
  batch_size?: number;
112
127
  /** Days an unsent item is kept before it is dropped. Default 7, between 1 and 30. */
113
128
  batch_request_timeout?: number;
114
- /** Idle minutes that end a session. Default 30, between 1 and 1440. */
129
+ /**
130
+ * Minutes a tab can be inactive (hidden, minimised, in the background) before its session ends,
131
+ * at the moment the user left. Default 30, between 1 and 1440.
132
+ */
115
133
  inactiveduration?: number;
116
134
  /**
117
135
  * How long a visit must last before its session is recorded, in milliseconds. Default 5000, at
@@ -120,8 +138,8 @@ export interface AppticsConfig {
120
138
  */
121
139
  min_session_duration?: number;
122
140
  /**
123
- * Record where people click and how far they scroll. Off by default; AppticsHeatmap.trackHeatmap()
124
- * switches it later.
141
+ * Record where people click and how far they scroll. Off by default;
142
+ * AppticsHeatmap.setHeatmapTracking() switches it later.
125
143
  */
126
144
  track_heatmap?: boolean;
127
145
  /** Most heatmap records one visit may produce. Default 500; capture pauses past it. */
@@ -175,8 +193,9 @@ export interface QuartzApi {
175
193
  quartzBranding: boolean;
176
194
  }): void;
177
195
  clearFeedback(): void;
178
- endRecording(): void;
179
- setVideoContent(element: Element | null): void;
196
+ /** Resolves once the recording has ended and is stored; Quartz's own build returns a Promise. */
197
+ endRecording(): Promise<unknown> | void;
198
+ setVideoContent(element: Element | null): Promise<unknown> | void;
180
199
  submitRecording(details: {
181
200
  email: string;
182
201
  subject: string;
@@ -256,7 +275,7 @@ export interface SendFeedbackOptions {
256
275
  attachments?: FileList | File[] | null;
257
276
  /** Log files of the app's own to send along. */
258
277
  logFiles?: FileList | File[] | null;
259
- /** The addDiagnosticsInfo() entries and the device's details: unset sends them when there are entries waiting. */
278
+ /** The addDiagnosticsInfo() entries: unset sends them when there are any, false never does. */
260
279
  includeDiagnostics?: boolean;
261
280
  /** The addFeedbackLog() lines: unset sends them when there are any, false never does. */
262
281
  includeLog?: boolean;
@@ -305,11 +324,15 @@ export interface AppticsFeedbackApi {
305
324
  export interface AppticsSdk {
306
325
  /** Android's Apptics: starting the SDK, and what applies to all of it. */
307
326
  Apptics: {
308
- /** Starts the SDK. The config object is required; the console snippet supplies it via auto-init. */
327
+ /** Starts the SDK with the app's config object, which is required. */
309
328
  init(config: AppticsConfig): boolean;
310
329
  /** Resolves true once start-up (storage load, device, session) has finished; false if it can't start. */
311
330
  ready(): Promise<boolean>;
312
- /** Sends stored engagements, errors and heatmap records now; resolves once they have gone out. */
331
+ /**
332
+ * Sends stored engagements, errors and heatmap records now; resolves once they have gone out.
333
+ * At most once every 15 seconds: a call sooner than that sends nothing and resolves at once,
334
+ * and what is queued goes with the next timed send.
335
+ */
313
336
  flush(): Promise<void>;
314
337
  /** Clears stored identity, queued data and remote config values, then starts again. */
315
338
  reset(): void;
@@ -326,10 +349,15 @@ export interface AppticsSdk {
326
349
  AppticsEvent: {
327
350
  /** Apptics' defined events, as Android's DefinedEvents, to log with addEvent. */
328
351
  DefinedEvents: typeof DefinedEvents;
329
- /** An event. An invalid name or group is not logged; a group left out is `default`. */
330
- addEvent(eventName: string, groupName?: string, properties?: Properties): void;
352
+ /** An event. The group is required: an event without one, or with an invalid name or group, is not logged, and the console says why. */
353
+ addEvent(eventName: string, groupName: string, properties?: Properties): void;
331
354
  /** A defined event (AppticsEvent.DefinedEvents.AP_USER_LOGIN, …), which brings its own group. */
332
355
  addEvent(definedEvent: DefinedEvent, properties?: Properties): void;
356
+ /**
357
+ * Turns click tracking from markup (`apeventaction`) on or off after Apptics.init(); `enabled`
358
+ * defaults to true. The `track_click` config flag sets it at start-up.
359
+ */
360
+ setClickTracking(enabled?: boolean): void;
333
361
  };
334
362
  /** Android's AppticsScreenTracker. */
335
363
  AppticsScreen: {
@@ -337,6 +365,11 @@ export interface AppticsSdk {
337
365
  inScreen(screenName: string, properties?: Properties): string;
338
366
  /** Ends the screen view inScreen began, before the next screen would. */
339
367
  outScreen(id: string): void;
368
+ /**
369
+ * Turns automatic screen tracking on or off after Apptics.init(); `enabled` defaults to true.
370
+ * The `track_screen` config flag sets it at start-up. inScreen() records either way.
371
+ */
372
+ setScreenTracking(enabled?: boolean): void;
340
373
  };
341
374
  /** Android's AppticsApiTracker. */
342
375
  AppticsApi: {
@@ -349,16 +382,23 @@ export interface AppticsSdk {
349
382
  /** The rules API tracking records by, from ApiTrackingBuilder. Works before Apptics.init(). */
350
383
  configure(config: ApiTrackingConfig | ApiTrackingBuilder): void;
351
384
  /**
352
- * Turns automatic API tracking on or off after Apptics.init(). Equivalent to the `track_api`
353
- * config flag, which is the usual way to set it.
385
+ * Turns automatic API tracking on or off after Apptics.init(); `enabled` defaults to true.
386
+ * The `track_api` config flag sets it at start-up.
354
387
  */
388
+ setApiTracking(enabled?: boolean): void;
389
+ /** @deprecated renamed setApiTracking; this name still works, with a console warning */
355
390
  enableApiTracking(enabled?: boolean): void;
356
391
  };
357
392
  /** Errors the app caught, and the switch for tracking uncaught ones. */
358
393
  AppticsError: {
359
394
  /** Reports an error the app caught, or an `error` / `unhandledrejection` event. */
360
395
  trackError(error: ErrorLike, properties?: Properties): void;
361
- /** Turns the automatic tracking of uncaught errors and unhandled rejections on or off. */
396
+ /**
397
+ * Turns the automatic tracking of uncaught errors and unhandled rejections on or off after
398
+ * Apptics.init(); `enabled` defaults to true. The `track_error` config flag sets it at start-up.
399
+ */
400
+ setErrorTracking(enabled?: boolean): void;
401
+ /** @deprecated renamed setErrorTracking; this name still works, with a console warning */
362
402
  trackGlobalErrorHandler(enabled?: boolean): void;
363
403
  };
364
404
  /** Android's AppticsUser. */
@@ -372,7 +412,12 @@ export interface AppticsSdk {
372
412
  };
373
413
  /** Click and scroll capture for the console's heatmaps. */
374
414
  AppticsHeatmap: {
375
- /** Starts or stops recording clicks and scrolls; `on` defaults to true. */
415
+ /**
416
+ * Starts or stops recording clicks and scrolls; `enabled` defaults to true. The
417
+ * `track_heatmap` config flag sets it at start-up.
418
+ */
419
+ setHeatmapTracking(enabled?: boolean): void;
420
+ /** @deprecated renamed setHeatmapTracking; this name still works, with a console warning */
376
421
  trackHeatmap(on?: boolean): void;
377
422
  };
378
423
  /** Android's AppticsSettings: what the SDK may track for this visitor. */
@@ -1,4 +1,4 @@
1
- /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
2
2
  'use strict';
3
3
 
4
4
  var constants = require('../core/constants.js');
@@ -104,11 +104,15 @@ function registerUserWithApptics(user_info) {
104
104
  var data = result.data || {};
105
105
  user_info.userid = data.userid;
106
106
  user_info.groupid = data.customergroupid;
107
- consent.setTrackingStatus(constants.AP_TRACKING_STATUS.USAGE_TRACKING_WITH_PII);
107
+ // stored only: user/register has told the server, and the device is registered already
108
+ consent.recordTrackingStatus(constants.AP_TRACKING_STATUS.USAGE_TRACKING_WITH_PII);
108
109
  addOrUpdateUser(user_info);
109
110
  getUserInfo();
110
111
  // the user and their customer group are known now: remote config conditions on them re-apply
111
112
  hooks.hooks.remoteConfigUserChanged();
113
+ // getsdkconfig answers for the user (with every module off for one whose customer group
114
+ // is not tracked, customergrouptracking: false), so it is asked again for them now
115
+ hooks.hooks.askServerSettings();
112
116
  return data;
113
117
  });
114
118
  }
@@ -1,4 +1,4 @@
1
- /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
2
2
  import { RETRY_CAPABLE_PATHS } from './constants.js';
3
3
  import { user_defaults } from './storage.js';
4
4
  import { nowMs } from './utils.js';
@@ -1,8 +1,7 @@
1
- /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
2
2
  import { _ZAP, isExpired } from './state.js';
3
3
  import { Console, warnAlways } from './logger.js';
4
4
  import { isEmptyObj, sizeof } from './utils.js';
5
- import './constants.js';
6
5
  import './db.js';
7
6
  import { shouldTrackOrSendData } from './consent.js';
8
7
  import { attemptsExhausted, MAX_ATTEMPTS, resetAttempts } from './attempts.js';
@@ -1,3 +1,4 @@
1
+ import { type EngagementType } from './constants.js';
1
2
  import type { TrackingStatus } from '../types.js';
2
3
  /**
3
4
  * DNT counts only when not ignored; while it counts, tracking is NO_TRACKING (opt_in_status).
@@ -12,8 +13,11 @@ export declare function shouldTrackOrSendData(): boolean;
12
13
  * and consent / server flags allow tracking.
13
14
  */
14
15
  export declare function canTrack(caller: string): boolean;
15
- /** canTrack plus the server's `engagementtracking` flag from getupdates (events, screens, sessions, api calls). */
16
- export declare function canTrackEngagement(caller: string): boolean;
16
+ /**
17
+ * canTrack plus the server's flag for this kind of item: getsdkconfig's event (5), api (6),
18
+ * screen (10) and session (11) modules, each switched on its own.
19
+ */
20
+ export declare function canTrackEngagement(caller: string, type: EngagementType): boolean;
17
21
  /**
18
22
  * canTrack plus the server's heatmap flag (getsdkconfig module 18).
19
23
  *
@@ -21,7 +25,13 @@ export declare function canTrackEngagement(caller: string): boolean;
21
25
  * well want events while declining to have every click's coordinates recorded.
22
26
  */
23
27
  export declare function canTrackHeatmap(caller: string): boolean;
24
- /** canTrack plus the server's `errortracking` flag from getupdates. */
28
+ /** canTrack plus the server's js_error module (15) from getsdkconfig. */
25
29
  export declare function canTrackErrors(caller: string): boolean;
30
+ /**
31
+ * Stores the visitor's tracking status without telling the server. True when it changed.
32
+ * user/register uses this alone: the server learns of the user from that call, so a device/add
33
+ * after it would only repeat a registration the device already has.
34
+ */
35
+ export declare function recordTrackingStatus(trackingState: TrackingStatus): boolean;
26
36
  export declare function setTrackingStatus(trackingState: TrackingStatus): void;
27
37
  export declare function getTrackingStatus(): TrackingStatus;
@@ -1,4 +1,4 @@
1
- /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
2
2
  import { AP_TRACKING_STATUS } from './constants.js';
3
3
  import { _ZAP } from './state.js';
4
4
  import { Console } from './logger.js';
@@ -51,13 +51,16 @@ function canTrack(caller) {
51
51
  }
52
52
  return shouldTrackOrSendData();
53
53
  }
54
- /** canTrack plus the server's `engagementtracking` flag from getupdates (events, screens, sessions, api calls). */
55
- function canTrackEngagement(caller) {
54
+ /**
55
+ * canTrack plus the server's flag for this kind of item: getsdkconfig's event (5), api (6),
56
+ * screen (10) and session (11) modules, each switched on its own.
57
+ */
58
+ function canTrackEngagement(caller, type) {
56
59
  if (!canTrack(caller)) {
57
60
  return false;
58
61
  }
59
- if (!_ZAP._engagementTracking) {
60
- Console.log('apptics.' + caller + ': engagement tracking is turned off by the server'); // no i18n
62
+ if (!_ZAP._engagementTracking[type]) {
63
+ Console.log('apptics.' + caller + ': ' + type + ' tracking is turned off by the server'); // no i18n
61
64
  return false;
62
65
  }
63
66
  return true;
@@ -78,7 +81,7 @@ function canTrackHeatmap(caller) {
78
81
  }
79
82
  return true;
80
83
  }
81
- /** canTrack plus the server's `errortracking` flag from getupdates. */
84
+ /** canTrack plus the server's js_error module (15) from getsdkconfig. */
82
85
  function canTrackErrors(caller) {
83
86
  if (!canTrack(caller)) {
84
87
  return false;
@@ -89,17 +92,27 @@ function canTrackErrors(caller) {
89
92
  }
90
93
  return true;
91
94
  }
95
+ /**
96
+ * Stores the visitor's tracking status without telling the server. True when it changed.
97
+ * user/register uses this alone: the server learns of the user from that call, so a device/add
98
+ * after it would only repeat a registration the device already has.
99
+ */
100
+ function recordTrackingStatus(trackingState) {
101
+ if (tracking_preference.opt_in_status() == trackingState) {
102
+ return false;
103
+ }
104
+ tracking_preference.update_status(trackingState);
105
+ _ZAP._devicestatus = tracking_preference.opt_in_status();
106
+ return true;
107
+ }
92
108
  function setTrackingStatus(trackingState) {
93
109
  if (isEmpty(trackingState)) {
94
110
  Console.warn('setTrackingStatus: trackingStatus is Empty'); // no i18n
95
111
  return;
96
112
  }
97
- if (tracking_preference.opt_in_status() == trackingState) {
113
+ if (!recordTrackingStatus(trackingState)) {
98
114
  return;
99
115
  }
100
- tracking_preference.update_status(trackingState);
101
- _ZAP._devicestatus = tracking_preference.opt_in_status();
102
- _ZAP._isanonrequired = tracking_preference.opt_in_status() == AP_TRACKING_STATUS.USAGE_TRACKING_WITH_PII ? false : _ZAP._isanonrequired;
103
116
  if (tracking_preference.opt_in_status() != AP_TRACKING_STATUS.NO_TRACKING) {
104
117
  Console.log('setTrackingStatus: Updating device info with new tracking status'); // no i18n
105
118
  hooks.updateDevice(_ZAP._device_info).then(function (result) {
@@ -119,4 +132,4 @@ function getTrackingStatus() {
119
132
  return opt_in_status();
120
133
  }
121
134
 
122
- export { canTrack, canTrackEngagement, canTrackErrors, canTrackHeatmap, getTrackingStatus, hasDoNotTrackEnabled, opt_in_status, setTrackingStatus, shouldTrackOrSendData };
135
+ export { canTrack, canTrackEngagement, canTrackErrors, canTrackHeatmap, getTrackingStatus, hasDoNotTrackEnabled, opt_in_status, recordTrackingStatus, setTrackingStatus, shouldTrackOrSendData };
@@ -34,6 +34,8 @@ export declare const AP_CONSTANTS: Readonly<{
34
34
  readonly SUCCESS: "success";
35
35
  readonly BROWSER: "Browser";
36
36
  }>;
37
+ /** The kinds of engagement item, each with its own getsdkconfig module: AP_CONSTANTS' type values. */
38
+ export type EngagementType = 'event' | 'screen' | 'session' | 'api';
37
39
  export declare const DEFAULT_API_PATHS: Readonly<{
38
40
  readonly addversion: "app/addversion";
39
41
  readonly regdevice: "device/add";
@@ -79,9 +81,13 @@ export declare const SDK_MODULE: Readonly<{
79
81
  * authority. Where they disagree, getsdkconfig wins.
80
82
  */
81
83
  readonly REMOTE_CONFIG: "2";
84
+ readonly EVENT: "5";
85
+ readonly API: "6";
86
+ readonly SCREEN: "10";
82
87
  readonly SESSION: "11";
83
88
  readonly FEEDBACK: "12";
84
- readonly CRASH: "13";
89
+ /** Uncaught and reported JavaScript errors: js_error. 13 (crash) and 14 (nonfatal) are the native SDKs'. */
90
+ readonly JS_ERROR: "15";
85
91
  readonly REMOTE_LOGGER: "17";
86
92
  readonly HEATMAP: "18";
87
93
  }>;
@@ -97,9 +103,10 @@ export declare const LOG_FILENAME_MAX = 100;
97
103
  */
98
104
  export declare const DEVICE_NAME_MAX = 100;
99
105
  /**
100
- * The `level` every line goes out with. Everything the remote logger carries is a failure inside
101
- * the SDK — logFailure is its only caller — so the level never varies. 3 is what the v2 reference
102
- * shows in its only example; the scale itself is not documented anywhere we can see.
106
+ * The `level` a remote log line goes out with when it has none of its own: 3, Info. Every line an
107
+ * app writes with AppticsLogger carries its level (1 verbose to 5 error, see LOG_LEVEL in
108
+ * remotelog/logger.ts). Only a line an older SDK stored, when the SDK logged its own failures
109
+ * there, has none; it is sent as Info rather than having the batch refused for a missing level.
103
110
  */
104
111
  export declare const REMOTE_LOG_LEVEL = 3;
105
112
  /**
@@ -109,29 +116,17 @@ export declare const REMOTE_LOG_LEVEL = 3;
109
116
  * enough that a tab left open overnight is not still sending every call to its debug twin.
110
117
  */
111
118
  export declare const DEBUG_IDLE_MS: number;
112
- /** Idle minutes that end a session. Lives on state, not in _config, but defaults here. */
119
+ /** Minutes a tab can be inactive before its session ends. Lives on state, not in _config, but defaults here. */
113
120
  export declare const DEFAULT_INACTIVE_MINUTES = 30;
114
121
  /** Global defaults. `state._config` holds a mutable copy per init. */
115
122
  export declare const AP_CONFIG: Readonly<{
116
123
  endpoint: "/sdk/web/";
117
124
  method: "POST";
118
- transport: "XHR";
119
- track_link_timeout: 300;
120
- cookie_expiration_days: 365;
121
- storage_type: "localStorage";
122
- enable_batch_requests: true;
123
125
  batch_size: 50;
124
126
  batch_flush_interval: 30000;
125
127
  getupdates_interval: 120000;
126
128
  batch_request_timeout: 7;
127
- auto_starts_batch: true;
128
- mode: 1;
129
- default_group_name: "default";
130
- default_optin_status: number;
131
- enable_pageview_tracking: false;
132
- save_referrer: true;
133
129
  debug: boolean;
134
- track_by_default: true;
135
130
  ignore_do_not_track: boolean;
136
131
  /**
137
132
  * Wrap XHR and fetch to record the app's API calls without it calling startTrackApi(). Off by
@@ -144,6 +139,16 @@ export declare const AP_CONFIG: Readonly<{
144
139
  * default; the app's own inScreen() during a navigation replaces that navigation's view.
145
140
  */
146
141
  track_screen: boolean;
142
+ /**
143
+ * Record uncaught errors and unhandled promise rejections, from the window's `error` and
144
+ * `unhandledrejection` events. On by default; AppticsError.setErrorTracking() switches it later.
145
+ */
146
+ track_error: boolean;
147
+ /**
148
+ * Record clicks on elements tagged `apeventaction` (or `data-apeventaction`) as events. On by
149
+ * default; AppticsEvent.setClickTracking() switches it later.
150
+ */
151
+ track_click: boolean;
147
152
  /**
148
153
  * How automatic screen tracking names a path, as init() keeps the config's screen_routes: route
149
154
  * patterns (`/users/{id}/orders`, each id recorded as a star), exact paths and regular
@@ -1,4 +1,4 @@
1
- /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
2
2
  const AP_TRACKING_STATUS = Object.freeze({
3
3
  USAGE_TRACKING_WITH_PII: 1,
4
4
  USAGE_TRACKING_WITHOUT_PII: 4,
@@ -83,9 +83,13 @@ const SDK_MODULE = Object.freeze({
83
83
  * authority. Where they disagree, getsdkconfig wins.
84
84
  */
85
85
  REMOTE_CONFIG: '2', // no i18n
86
+ EVENT: '5', // no i18n
87
+ API: '6', // no i18n
88
+ SCREEN: '10', // no i18n
86
89
  SESSION: '11', // no i18n
87
90
  FEEDBACK: '12', // no i18n
88
- CRASH: '13', // no i18n
91
+ /** Uncaught and reported JavaScript errors: js_error. 13 (crash) and 14 (nonfatal) are the native SDKs'. */
92
+ JS_ERROR: '15', // no i18n
89
93
  REMOTE_LOGGER: '17', // no i18n
90
94
  HEATMAP: '18', // no i18n
91
95
  });
@@ -101,9 +105,10 @@ const LOG_FILENAME_MAX = 100;
101
105
  */
102
106
  const DEVICE_NAME_MAX = 100;
103
107
  /**
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.
108
+ * The `level` a remote log line goes out with when it has none of its own: 3, Info. Every line an
109
+ * app writes with AppticsLogger carries its level (1 verbose to 5 error, see LOG_LEVEL in
110
+ * remotelog/logger.ts). Only a line an older SDK stored, when the SDK logged its own failures
111
+ * there, has none; it is sent as Info rather than having the batch refused for a missing level.
107
112
  */
108
113
  const REMOTE_LOG_LEVEL = 3;
109
114
  /**
@@ -113,30 +118,18 @@ const REMOTE_LOG_LEVEL = 3;
113
118
  * enough that a tab left open overnight is not still sending every call to its debug twin.
114
119
  */
115
120
  const DEBUG_IDLE_MS = 60 * 60 * 1000;
116
- /** Idle minutes that end a session. Lives on state, not in _config, but defaults here. */
121
+ /** Minutes a tab can be inactive before its session ends. Lives on state, not in _config, but defaults here. */
117
122
  const DEFAULT_INACTIVE_MINUTES = 30;
118
123
  /** Global defaults. `state._config` holds a mutable copy per init. */
119
124
  const AP_CONFIG = Object.freeze({
120
125
  // the version is per path (API_VERSIONS); this is only the part before it
121
126
  endpoint: '/sdk/web/', // no i18n
122
127
  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
128
  batch_size: 50,
129
129
  batch_flush_interval: 30000,
130
- getupdates_interval: 120000, // 2 minutes in milliseconds
130
+ getupdates_interval: 120000, // 2 minutes in milliseconds, when getsdkconfig gives no next_check_after
131
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
132
  debug: false,
139
- track_by_default: true,
140
133
  ignore_do_not_track: false,
141
134
  /**
142
135
  * Wrap XHR and fetch to record the app's API calls without it calling startTrackApi(). Off by
@@ -149,6 +142,16 @@ const AP_CONFIG = Object.freeze({
149
142
  * default; the app's own inScreen() during a navigation replaces that navigation's view.
150
143
  */
151
144
  track_screen: true,
145
+ /**
146
+ * Record uncaught errors and unhandled promise rejections, from the window's `error` and
147
+ * `unhandledrejection` events. On by default; AppticsError.setErrorTracking() switches it later.
148
+ */
149
+ track_error: true,
150
+ /**
151
+ * Record clicks on elements tagged `apeventaction` (or `data-apeventaction`) as events. On by
152
+ * default; AppticsEvent.setClickTracking() switches it later.
153
+ */
154
+ track_click: true,
152
155
  /**
153
156
  * How automatic screen tracking names a path, as init() keeps the config's screen_routes: route
154
157
  * patterns (`/users/{id}/orders`, each id recorded as a star), exact paths and regular
@@ -1,4 +1,4 @@
1
- /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
2
2
  import { Console } from './logger.js';
3
3
  import { nowMs } from './utils.js';
4
4
 
@@ -1,4 +1,4 @@
1
- /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
2
2
  import { DEBUG_IDLE_MS } from './constants.js';
3
3
  import { _ZAP } from './state.js';
4
4
  import { Console } from './logger.js';
@@ -1,4 +1,3 @@
1
- import type { AppticsConfig } from '../types.js';
2
1
  export declare function isBlockedWS(ua: string): boolean;
3
2
  /** Device RAM as the API wants it ("4 GB"). Chromium only; empty elsewhere. */
4
3
  export declare function getRam(): string;
@@ -24,5 +23,3 @@ export declare function getTimeZone(): string;
24
23
  export declare function is_apptics_disabled(): boolean;
25
24
  /** Pure DNT check (no side effects). consent.hasDoNotTrackEnabled() applies NO_TRACKING. */
26
25
  export declare function isDntOn(): boolean;
27
- /** The console snippet's config (window.appticssettings._defaultoptions), if the page defines one. */
28
- export declare function getSnippetOptions(): AppticsConfig | undefined;
@@ -1,4 +1,4 @@
1
- /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
2
2
  import { BLOCKED_WS } from './constants.js';
3
3
  import { includes } from './utils.js';
4
4
 
@@ -240,12 +240,5 @@ function isDntOn() {
240
240
  return includes(dntValues, dntValue);
241
241
  });
242
242
  }
243
- /** The console snippet's config (window.appticssettings._defaultoptions), if the page defines one. */
244
- function getSnippetOptions() {
245
- if (typeof window === 'undefined' || !window.appticssettings) { // no i18n
246
- return undefined;
247
- }
248
- return window.appticssettings._defaultoptions;
249
- }
250
243
 
251
- export { getBatteryPercent, getBrowser, getBrowserVersion, getConnectionType, getDevice, getNetworkStatus, getOS, getOrientation, getRam, getReferringURL, getSnippetOptions, getTimeZone, isBlockedWS, isDntOn, is_apptics_disabled };
244
+ export { getBatteryPercent, getBrowser, getBrowserVersion, getConnectionType, getDevice, getNetworkStatus, getOS, getOrientation, getRam, getReferringURL, getTimeZone, isBlockedWS, isDntOn, is_apptics_disabled };