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

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 (253) hide show
  1. package/CHANGELOG.md +127 -16
  2. package/README.md +357 -215
  3. package/dist/apptics-pn-sw.js +3 -0
  4. package/dist/apptics-pn-sw.js.map +1 -0
  5. package/dist/apptics.esm.min.js +2 -2
  6. package/dist/apptics.esm.min.js.map +1 -1
  7. package/dist/apptics.min.js +2 -2
  8. package/dist/apptics.min.js.map +1 -1
  9. package/dist/chunks/batch-Axq9sTzR.min.js +3 -0
  10. package/dist/chunks/batch-Axq9sTzR.min.js.map +1 -0
  11. package/dist/chunks/lifecycle-Cvg78jN_.min.js +3 -0
  12. package/dist/chunks/lifecycle-Cvg78jN_.min.js.map +1 -0
  13. package/dist/chunks/send-DBpesydB.min.js +3 -0
  14. package/dist/chunks/send-DBpesydB.min.js.map +1 -0
  15. package/dist/chunks/transport-B21X39p4.min.js +3 -0
  16. package/dist/chunks/transport-B21X39p4.min.js.map +1 -0
  17. package/dist/cjs/core/attempts.js +1 -1
  18. package/dist/cjs/core/batch.js +4 -4
  19. package/dist/cjs/core/consent.d.ts +17 -4
  20. package/dist/cjs/core/consent.js +81 -14
  21. package/dist/cjs/core/console-call.d.ts +23 -0
  22. package/dist/cjs/core/console-call.js +63 -0
  23. package/dist/cjs/core/constants.d.ts +66 -17
  24. package/dist/cjs/core/constants.js +76 -19
  25. package/dist/cjs/core/db.js +31 -7
  26. package/dist/cjs/core/debug.d.ts +6 -4
  27. package/dist/cjs/core/debug.js +36 -12
  28. package/dist/cjs/core/env.d.ts +0 -3
  29. package/dist/cjs/core/env.js +1 -9
  30. package/dist/cjs/core/framework-id.d.ts +1 -1
  31. package/dist/cjs/core/framework-id.js +3 -3
  32. package/dist/cjs/core/guard.js +19 -4
  33. package/dist/cjs/core/hooks.d.ts +29 -0
  34. package/dist/cjs/core/hooks.js +12 -1
  35. package/dist/cjs/core/locks.js +1 -1
  36. package/dist/cjs/core/logger.js +1 -1
  37. package/dist/cjs/core/shield.d.ts +31 -0
  38. package/dist/cjs/core/shield.js +129 -0
  39. package/dist/cjs/core/state.d.ts +11 -5
  40. package/dist/cjs/core/state.js +4 -4
  41. package/dist/cjs/core/storage.d.ts +7 -0
  42. package/dist/cjs/core/storage.js +28 -9
  43. package/dist/cjs/core/stylesheet.js +1 -1
  44. package/dist/cjs/core/transport.d.ts +15 -4
  45. package/dist/cjs/core/transport.js +72 -25
  46. package/dist/cjs/core/utils.js +1 -1
  47. package/dist/cjs/core/validate.js +6 -5
  48. package/dist/cjs/device/appversion.d.ts +10 -1
  49. package/dist/cjs/device/appversion.js +26 -3
  50. package/dist/cjs/device/index.d.ts +17 -2
  51. package/dist/cjs/device/index.js +251 -35
  52. package/dist/cjs/engagement/api-rules.js +1 -1
  53. package/dist/cjs/engagement/auto-api.js +4 -3
  54. package/dist/cjs/engagement/auto-screen.js +10 -6
  55. package/dist/cjs/engagement/defined-events.d.ts +2 -3
  56. package/dist/cjs/engagement/defined-events.js +10 -16
  57. package/dist/cjs/engagement/send.js +7 -3
  58. package/dist/cjs/engagement/session.d.ts +17 -0
  59. package/dist/cjs/engagement/session.js +154 -23
  60. package/dist/cjs/engagement/track.d.ts +4 -4
  61. package/dist/cjs/engagement/track.js +23 -17
  62. package/dist/cjs/errors/send.js +2 -2
  63. package/dist/cjs/errors/track.d.ts +2 -1
  64. package/dist/cjs/errors/track.js +8 -5
  65. package/dist/cjs/feedback/controls.d.ts +36 -4
  66. package/dist/cjs/feedback/controls.js +302 -67
  67. package/dist/cjs/feedback/i18n/index.d.ts +31 -0
  68. package/dist/cjs/feedback/i18n/index.js +187 -0
  69. package/dist/cjs/feedback/i18n/strings.d.ts +9 -0
  70. package/dist/cjs/feedback/i18n/strings.js +8 -0
  71. package/dist/cjs/feedback/index.js +1 -1
  72. package/dist/cjs/feedback/logs.d.ts +3 -6
  73. package/dist/cjs/feedback/logs.js +12 -21
  74. package/dist/cjs/feedback/quartz.js +5 -2
  75. package/dist/cjs/feedback/send.d.ts +6 -3
  76. package/dist/cjs/feedback/send.js +59 -41
  77. package/dist/cjs/feedback/styles.js +2 -2
  78. package/dist/cjs/feedback/template.d.ts +4 -2
  79. package/dist/cjs/feedback/template.js +73 -44
  80. package/dist/cjs/feedback/ui.d.ts +47 -4
  81. package/dist/cjs/feedback/ui.js +351 -97
  82. package/dist/cjs/heatmap/send.d.ts +2 -0
  83. package/dist/cjs/heatmap/send.js +3 -5
  84. package/dist/cjs/heatmap/track.js +13 -9
  85. package/dist/cjs/index.d.ts +1 -2
  86. package/dist/cjs/index.js +55 -18
  87. package/dist/cjs/lifecycle.d.ts +13 -2
  88. package/dist/cjs/lifecycle.js +233 -118
  89. package/dist/cjs/pushnotification/display.d.ts +65 -0
  90. package/dist/cjs/pushnotification/display.js +112 -0
  91. package/dist/cjs/pushnotification/index.d.ts +20 -0
  92. package/dist/cjs/pushnotification/index.js +96 -0
  93. package/dist/cjs/pushnotification/kept-opens.d.ts +23 -0
  94. package/dist/cjs/pushnotification/kept-opens.js +64 -0
  95. package/dist/cjs/pushnotification/notify.d.ts +45 -0
  96. package/dist/cjs/pushnotification/notify.js +476 -0
  97. package/dist/cjs/pushnotification/payload.d.ts +65 -0
  98. package/dist/cjs/pushnotification/payload.js +279 -0
  99. package/dist/cjs/pushnotification/session.d.ts +46 -0
  100. package/dist/cjs/pushnotification/session.js +413 -0
  101. package/dist/cjs/pushnotification/stats.d.ts +45 -0
  102. package/dist/cjs/pushnotification/stats.js +244 -0
  103. package/dist/cjs/pushnotification/wms.d.ts +30 -0
  104. package/dist/cjs/pushnotification/wms.js +374 -0
  105. package/dist/cjs/remoteconfig/country.js +1 -1
  106. package/dist/cjs/remoteconfig/custom.js +4 -3
  107. package/dist/cjs/remoteconfig/evaluate.js +1 -1
  108. package/dist/cjs/remoteconfig/fetch.d.ts +17 -10
  109. package/dist/cjs/remoteconfig/fetch.js +146 -32
  110. package/dist/cjs/remoteconfig/index.d.ts +9 -5
  111. package/dist/cjs/remoteconfig/index.js +24 -32
  112. package/dist/cjs/remoteconfig/store.d.ts +15 -7
  113. package/dist/cjs/remoteconfig/store.js +68 -35
  114. package/dist/cjs/remoteconfig/tz-countries.js +1 -1
  115. package/dist/cjs/{core → remotelog}/callsite.d.ts +5 -4
  116. package/dist/cjs/{core → remotelog}/callsite.js +6 -5
  117. package/dist/cjs/remotelog/gate.js +1 -1
  118. package/dist/cjs/remotelog/logger.js +2 -2
  119. package/dist/cjs/remotelog/send.js +6 -5
  120. package/dist/cjs/remotelogger/index.js +1 -1
  121. package/dist/cjs/scheduler.d.ts +3 -1
  122. package/dist/cjs/scheduler.js +34 -25
  123. package/dist/cjs/sw/apptics-pn-sw.d.ts +83 -0
  124. package/dist/cjs/sw/timers.d.ts +44 -0
  125. package/dist/cjs/types.d.ts +90 -29
  126. package/dist/cjs/user/index.d.ts +7 -0
  127. package/dist/cjs/user/index.js +25 -3
  128. package/dist/esm/core/attempts.js +1 -1
  129. package/dist/esm/core/batch.js +4 -4
  130. package/dist/esm/core/consent.d.ts +17 -4
  131. package/dist/esm/core/consent.js +84 -20
  132. package/dist/esm/core/console-call.d.ts +23 -0
  133. package/dist/esm/core/console-call.js +60 -0
  134. package/dist/esm/core/constants.d.ts +66 -17
  135. package/dist/esm/core/constants.js +73 -20
  136. package/dist/esm/core/db.js +31 -7
  137. package/dist/esm/core/debug.d.ts +6 -4
  138. package/dist/esm/core/debug.js +37 -13
  139. package/dist/esm/core/env.d.ts +0 -3
  140. package/dist/esm/core/env.js +2 -9
  141. package/dist/esm/core/framework-id.d.ts +1 -1
  142. package/dist/esm/core/framework-id.js +3 -3
  143. package/dist/esm/core/guard.js +19 -4
  144. package/dist/esm/core/hooks.d.ts +29 -0
  145. package/dist/esm/core/hooks.js +12 -1
  146. package/dist/esm/core/locks.js +1 -1
  147. package/dist/esm/core/logger.js +1 -1
  148. package/dist/esm/core/shield.d.ts +31 -0
  149. package/dist/esm/core/shield.js +119 -0
  150. package/dist/esm/core/state.d.ts +11 -5
  151. package/dist/esm/core/state.js +4 -4
  152. package/dist/esm/core/storage.d.ts +7 -0
  153. package/dist/esm/core/storage.js +28 -11
  154. package/dist/esm/core/stylesheet.js +1 -1
  155. package/dist/esm/core/transport.d.ts +15 -4
  156. package/dist/esm/core/transport.js +73 -28
  157. package/dist/esm/core/utils.js +1 -1
  158. package/dist/esm/core/validate.js +6 -5
  159. package/dist/esm/device/appversion.d.ts +10 -1
  160. package/dist/esm/device/appversion.js +26 -4
  161. package/dist/esm/device/index.d.ts +17 -2
  162. package/dist/esm/device/index.js +255 -42
  163. package/dist/esm/engagement/api-rules.js +1 -1
  164. package/dist/esm/engagement/auto-api.js +4 -3
  165. package/dist/esm/engagement/auto-screen.js +10 -6
  166. package/dist/esm/engagement/defined-events.d.ts +2 -3
  167. package/dist/esm/engagement/defined-events.js +10 -16
  168. package/dist/esm/engagement/send.js +7 -3
  169. package/dist/esm/engagement/session.d.ts +17 -0
  170. package/dist/esm/engagement/session.js +152 -24
  171. package/dist/esm/engagement/track.d.ts +4 -4
  172. package/dist/esm/engagement/track.js +24 -18
  173. package/dist/esm/errors/send.js +2 -2
  174. package/dist/esm/errors/track.d.ts +2 -1
  175. package/dist/esm/errors/track.js +8 -5
  176. package/dist/esm/feedback/controls.d.ts +36 -4
  177. package/dist/esm/feedback/controls.js +298 -68
  178. package/dist/esm/feedback/i18n/index.d.ts +31 -0
  179. package/dist/esm/feedback/i18n/index.js +178 -0
  180. package/dist/esm/feedback/i18n/strings.d.ts +9 -0
  181. package/dist/esm/feedback/i18n/strings.js +4 -0
  182. package/dist/esm/feedback/index.js +1 -1
  183. package/dist/esm/feedback/logs.d.ts +3 -6
  184. package/dist/esm/feedback/logs.js +12 -21
  185. package/dist/esm/feedback/quartz.js +5 -2
  186. package/dist/esm/feedback/send.d.ts +6 -3
  187. package/dist/esm/feedback/send.js +61 -44
  188. package/dist/esm/feedback/styles.js +2 -2
  189. package/dist/esm/feedback/template.d.ts +4 -2
  190. package/dist/esm/feedback/template.js +73 -44
  191. package/dist/esm/feedback/ui.d.ts +47 -4
  192. package/dist/esm/feedback/ui.js +353 -99
  193. package/dist/esm/heatmap/send.d.ts +2 -0
  194. package/dist/esm/heatmap/send.js +3 -5
  195. package/dist/esm/heatmap/track.js +13 -9
  196. package/dist/esm/index.d.ts +1 -2
  197. package/dist/esm/index.js +58 -21
  198. package/dist/esm/lifecycle.d.ts +13 -2
  199. package/dist/esm/lifecycle.js +238 -125
  200. package/dist/esm/pushnotification/display.d.ts +65 -0
  201. package/dist/esm/pushnotification/display.js +95 -0
  202. package/dist/esm/pushnotification/index.d.ts +20 -0
  203. package/dist/esm/pushnotification/index.js +91 -0
  204. package/dist/esm/pushnotification/kept-opens.d.ts +23 -0
  205. package/dist/esm/pushnotification/kept-opens.js +62 -0
  206. package/dist/esm/pushnotification/notify.d.ts +45 -0
  207. package/dist/esm/pushnotification/notify.js +469 -0
  208. package/dist/esm/pushnotification/payload.d.ts +65 -0
  209. package/dist/esm/pushnotification/payload.js +272 -0
  210. package/dist/esm/pushnotification/session.d.ts +46 -0
  211. package/dist/esm/pushnotification/session.js +402 -0
  212. package/dist/esm/pushnotification/stats.d.ts +45 -0
  213. package/dist/esm/pushnotification/stats.js +238 -0
  214. package/dist/esm/pushnotification/wms.d.ts +30 -0
  215. package/dist/esm/pushnotification/wms.js +368 -0
  216. package/dist/esm/remoteconfig/country.js +1 -1
  217. package/dist/esm/remoteconfig/custom.js +4 -3
  218. package/dist/esm/remoteconfig/evaluate.js +1 -1
  219. package/dist/esm/remoteconfig/fetch.d.ts +17 -10
  220. package/dist/esm/remoteconfig/fetch.js +147 -33
  221. package/dist/esm/remoteconfig/index.d.ts +9 -5
  222. package/dist/esm/remoteconfig/index.js +24 -32
  223. package/dist/esm/remoteconfig/store.d.ts +15 -7
  224. package/dist/esm/remoteconfig/store.js +68 -36
  225. package/dist/esm/remoteconfig/tz-countries.js +1 -1
  226. package/dist/esm/{core → remotelog}/callsite.d.ts +5 -4
  227. package/dist/esm/{core → remotelog}/callsite.js +6 -5
  228. package/dist/esm/remotelog/gate.js +1 -1
  229. package/dist/esm/remotelog/logger.js +2 -2
  230. package/dist/esm/remotelog/send.js +6 -5
  231. package/dist/esm/remotelogger/index.js +1 -1
  232. package/dist/esm/scheduler.d.ts +3 -1
  233. package/dist/esm/scheduler.js +35 -27
  234. package/dist/esm/sw/apptics-pn-sw.d.ts +83 -0
  235. package/dist/esm/sw/timers.d.ts +44 -0
  236. package/dist/esm/types.d.ts +90 -29
  237. package/dist/esm/user/index.d.ts +7 -0
  238. package/dist/esm/user/index.js +26 -5
  239. package/dist/feedback.esm.min.js +2 -2
  240. package/dist/feedback.esm.min.js.map +1 -1
  241. package/dist/pushnotification.esm.min.js +3 -0
  242. package/dist/pushnotification.esm.min.js.map +1 -0
  243. package/dist/remoteconfig.esm.min.js +3 -0
  244. package/dist/remoteconfig.esm.min.js.map +1 -0
  245. package/dist/remotelogger.esm.min.js +3 -0
  246. package/dist/remotelogger.esm.min.js.map +1 -0
  247. package/package.json +17 -3
  248. package/dist/chunks/lifecycle-VYr43KcB.min.js +0 -3
  249. package/dist/chunks/lifecycle-VYr43KcB.min.js.map +0 -1
  250. package/dist/cjs/auto-init.d.ts +0 -8
  251. package/dist/cjs/auto-init.js +0 -32
  252. package/dist/esm/auto-init.d.ts +0 -8
  253. package/dist/esm/auto-init.js +0 -29
@@ -8,6 +8,8 @@ import type { Dict, ServerResult } from '../types.js';
8
8
  *
9
9
  * Gated on the server's own heatmap flag (getsdkconfig module 18), not on engagement: an app may
10
10
  * want events while declining to have every click's coordinates recorded.
11
+ *
12
+ * The scheduler reaches it through hooks.sendHeatmaps, which src/index.ts sets.
11
13
  */
12
14
  export declare function sendHeatmapData(forget?: boolean): Promise<void>;
13
15
  export declare function requestToSendHeatmaps(_payload: Dict, forget?: boolean): Promise<ServerResult>;
@@ -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 | (c) Zoho Corporation Private Limited | see LICENSE */
2
2
  import { _ZAP } from '../core/state.js';
3
3
  import { Console, warnAlways } from '../core/logger.js';
4
4
  import { cloneObject } from '../core/utils.js';
@@ -7,7 +7,6 @@ import { is_apptics_disabled } from '../core/env.js';
7
7
  import { shouldTrackOrSendData } from '../core/consent.js';
8
8
  import { defer, clearDefer, withSendLock, freshItems, awaitUnlessClosing, sendBatch } from '../core/batch.js';
9
9
  import { isPermanentRefusal } from '../core/transport.js';
10
- import { hooks } from '../core/hooks.js';
11
10
 
12
11
  /**
13
12
  * Sends queued heatmap records to heatmap/add.
@@ -18,6 +17,8 @@ import { hooks } from '../core/hooks.js';
18
17
  *
19
18
  * Gated on the server's own heatmap flag (getsdkconfig module 18), not on engagement: an app may
20
19
  * want events while declining to have every click's coordinates recorded.
20
+ *
21
+ * The scheduler reaches it through hooks.sendHeatmaps, which src/index.ts sets.
21
22
  */
22
23
  function sendHeatmapData(forget) {
23
24
  if (is_apptics_disabled() || !shouldTrackOrSendData() || !_ZAP._heatmapTracking) {
@@ -72,8 +73,5 @@ function requestToSendHeatmaps(_payload, forget) {
72
73
  var label = 'requestToSendHeatmaps'; // no i18n
73
74
  return sendBatch('heatmap', label, _payload, forget); // no i18n
74
75
  }
75
- // the scheduler flushes through this, so importing the heatmap entry is what puts heatmap
76
- // records on the flush timer at all
77
- hooks.sendHeatmaps = sendHeatmapData;
78
76
 
79
77
  export { requestToSendHeatmaps, sendHeatmapData };
@@ -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 | (c) Zoho Corporation Private Limited | see LICENSE */
2
2
  import { AP_LOG_MODULE, AP_CONFIG, AP_TRACKING_STATUS } from '../core/constants.js';
3
3
  import { getConfig, _ZAP } from '../core/state.js';
4
4
  import { Console, logFailure } from '../core/logger.js';
@@ -10,6 +10,7 @@ import { canTrackHeatmap, getTrackingStatus } from '../core/consent.js';
10
10
  import { screenForRecord } from '../engagement/track.js';
11
11
  import { hooks } from '../core/hooks.js';
12
12
  import { noteDebugActivity } from '../core/debug.js';
13
+ import { shield, quietly } from '../core/shield.js';
13
14
 
14
15
  /**
15
16
  * Where people click and how far they scroll.
@@ -219,7 +220,7 @@ function store(record) {
219
220
  recorded++;
220
221
  noteDebugActivity();
221
222
  // a heatmap record is worth a session in the same way an event is
222
- commitPendingSession();
223
+ quietly('session', commitPendingSession()); // no i18n
223
224
  heatmap_transactions.add(record);
224
225
  Console.dir(record);
225
226
  }
@@ -280,13 +281,13 @@ function watchForDeadClick(record, target) {
280
281
  catch (err) {
281
282
  return;
282
283
  }
283
- setTimeout(function () {
284
+ setTimeout(shield('heatmap dead click', function () {
284
285
  observer.disconnect();
285
286
  if (!changed && window.location.href === url) {
286
287
  record.is_dead_click = 1;
287
288
  heatmap_transactions.update(record);
288
289
  }
289
- }, DEAD_CLICK_MS);
290
+ }), DEAD_CLICK_MS);
290
291
  }
291
292
  /**
292
293
  * What a scroll event moved, as a gesture counts it: null for the window (the event's target is
@@ -343,7 +344,7 @@ function onScroll(event) {
343
344
  else {
344
345
  clearTimeout(scrollTimer);
345
346
  }
346
- scrollTimer = setTimeout(endScrollGesture, SCROLL_IDLE_MS);
347
+ scrollTimer = setTimeout(shield('heatmap scroll', endScrollGesture), SCROLL_IDLE_MS); // no i18n
347
348
  }
348
349
  /** One record for the whole burst, once the page has been still for SCROLL_IDLE_MS. */
349
350
  function endScrollGesture() {
@@ -402,6 +403,9 @@ function endScrollGesture() {
402
403
  logFailure(AP_LOG_MODULE.HEATMAP, 'apptics.heatmap: scroll capture failed: ' + String(err)); // no i18n
403
404
  }
404
405
  }
406
+ // the listeners as added, so the same functions come off again
407
+ const pointerListener = shield('heatmap click', onPointerDown); // no i18n
408
+ const scrollListener = shield('heatmap scroll', onScroll); // no i18n
405
409
  /** Turns capture on or off. Listeners are passive, so they never delay a click or a scroll. */
406
410
  function trackHeatmap(status) {
407
411
  var wanted = typeof status === 'boolean' ? status : true; // no i18n
@@ -412,14 +416,14 @@ function trackHeatmap(status) {
412
416
  // where the page already is, so the first gesture is measured from here and not from 0
413
417
  lastX = Math.round(window.scrollX || 0);
414
418
  lastY = Math.round(window.scrollY || 0);
415
- window.addEventListener('pointerdown', onPointerDown, { capture: true, passive: true }); // no i18n
416
- window.addEventListener('scroll', onScroll, { capture: true, passive: true }); // no i18n
419
+ window.addEventListener('pointerdown', pointerListener, { capture: true, passive: true }); // no i18n
420
+ window.addEventListener('scroll', scrollListener, { capture: true, passive: true }); // no i18n
417
421
  installed = true;
418
422
  Console.log('apptics.heatmap: capturing clicks and scrolls'); // no i18n
419
423
  return;
420
424
  }
421
- window.removeEventListener('pointerdown', onPointerDown, true); // no i18n
422
- window.removeEventListener('scroll', onScroll, true); // no i18n
425
+ window.removeEventListener('pointerdown', pointerListener, true); // no i18n
426
+ window.removeEventListener('scroll', scrollListener, true); // no i18n
423
427
  // a gesture still settling when capture stops (a single-page app leaving a heatmap page) is
424
428
  // recorded as it stands, not dropped: it was the visitor's last scroll on that page
425
429
  if (scrollTimer !== null) {
@@ -1,4 +1,3 @@
1
- import './heatmap/send.js';
2
1
  import type { AppticsSdk } from './types.js';
3
2
  export type { AppticsSdk, AppticsConfig, ErrorLike, FeedbackType, Properties, TrackingStatus, UserInfo, UserValidationResult, } from './types.js';
4
3
  /** Android's Apptics: starting the SDK, and what applies to all of it. */
@@ -14,7 +13,7 @@ export type { ApiTrackingConfig } from './engagement/api-rules.js';
14
13
  export declare const AppticsError: AppticsSdk['AppticsError'];
15
14
  /** Android's AppticsUser: the signed-in user, and the builder for their properties. */
16
15
  export declare const AppticsUser: AppticsSdk['AppticsUser'];
17
- /** Heatmap capture: AppticsHeatmap.trackHeatmap() starts or stops recording clicks and scrolls. */
16
+ /** Heatmap capture: AppticsHeatmap.setHeatmapTracking() starts or stops recording clicks and scrolls. */
18
17
  export declare const AppticsHeatmap: AppticsSdk['AppticsHeatmap'];
19
18
  /** Android's AppticsSettings: what the SDK may track for this visitor. */
20
19
  export declare const AppticsSettings: AppticsSdk['AppticsSettings'];
package/dist/esm/index.js CHANGED
@@ -1,29 +1,35 @@
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 | (c) Zoho Corporation Private Limited | see LICENSE */
2
2
  import { AP_TRACKING_STATUS } from './core/constants.js';
3
3
  import { forward, guard } from './core/guard.js';
4
- import { reset, ready, init } from './lifecycle.js';
4
+ import { warnAlways } from './core/logger.js';
5
+ import { reset, ready, init, setClickTracking, setScreenTracking } from './lifecycle.js';
5
6
  import { enableApiTracking } from './engagement/auto-api.js';
6
7
  import { endTrackApiAt, outScreenAt, inScreenAt, startTrackApi, trackEvent } from './engagement/track.js';
7
8
  import { DefinedEvents } from './engagement/defined-events.js';
8
9
  import { nowMs, getNewUUID } from './core/utils.js';
9
10
  import { validateScreenName } from './core/validate.js';
10
11
  import { ApiTrackingBuilder, configureApiTracking } from './engagement/api-rules.js';
11
- import { trackGlobalErrorHandler, trackError } from './errors/track.js';
12
+ import { setErrorTracking, trackError } from './errors/track.js';
12
13
  import { UserBuilder, getUser, setUser } from './user/index.js';
13
14
  import { getTrackingStatus, setTrackingStatus } from './core/consent.js';
14
- import { flush } from './scheduler.js';
15
+ import { calledFlush } from './scheduler.js';
15
16
  import { trackHeatmap } from './heatmap/track.js';
16
- import './heatmap/send.js';
17
- import { scheduleAutoInit } from './auto-init.js';
17
+ import { sendHeatmapData } from './heatmap/send.js';
18
+ import { hooks } from './core/hooks.js';
18
19
  import { disableDebug, enableDebug } from './core/debug.js';
19
20
 
21
+ // flush() and the flush timer send heatmap records through this hook. Set here, from a named
22
+ // import, rather than by heatmap/send.ts on being imported: the package's sideEffects list names
23
+ // only the CDN bundle, so a bundler drops a bare `import './heatmap/send.js'`, and with it every
24
+ // heatmap send, while capture carries on filling the queue
25
+ hooks.sendHeatmaps = sendHeatmapData;
20
26
  /*
21
27
  * Every public call below is a function of its own, with the parameter names the console shows
22
28
  * on hover, forwarding to its guard()ed implementation (see forward).
23
29
  */
24
30
  const initGuarded = guard('Apptics.init', init); // no i18n
25
31
  const readyGuarded = guard('Apptics.ready', ready); // no i18n
26
- const flushGuarded = guard('Apptics.flush', flush); // no i18n
32
+ const flushGuarded = guard('Apptics.flush', calledFlush); // no i18n
27
33
  const resetGuarded = guard('Apptics.reset', reset); // no i18n
28
34
  /**
29
35
  * Debug mode, on or off; works before init(), and wins over `debug` in init(). On, engagement,
@@ -33,13 +39,23 @@ const resetGuarded = guard('Apptics.reset', reset); // no i18n
33
39
  */
34
40
  const enableDebugGuarded = guard('Apptics.enableDebug', enableDebug); // no i18n
35
41
  const disableDebugGuarded = guard('Apptics.disableDebug', disableDebug); // no i18n
42
+ /** The renamed calls already warned about: once per page each, not once per call. */
43
+ var warnedRenamed = {};
44
+ /** An earlier name of a call still works, with a console warning naming the call to use. */
45
+ function renamed(old, current) {
46
+ if (warnedRenamed[old]) {
47
+ return;
48
+ }
49
+ warnedRenamed[old] = true;
50
+ warnAlways(old + ' is now ' + current + '; rename it in your code'); // no i18n
51
+ }
36
52
  /** Android's Apptics: starting the SDK, and what applies to all of it. */
37
53
  const Apptics = {
38
- /** Starts the SDK. The config object is required; the console snippet supplies it via auto-init. */
54
+ /** Starts the SDK with the app's config object, which is required. */
39
55
  init: function init(config) { return forward(initGuarded, arguments); },
40
56
  /** Resolves true once the SDK is running, false if it can't start. */
41
57
  ready: function ready() { return forward(readyGuarded, arguments); },
42
- /** Sends stored engagements, errors and heatmap records now. */
58
+ /** Sends stored engagements, errors and heatmap records now; at most once every 15 seconds. */
43
59
  flush: function flush() { return forward(flushGuarded, arguments); },
44
60
  /** Clears stored identity, queued data and remote config values, then starts again. */
45
61
  reset: function reset() { return forward(resetGuarded, arguments); },
@@ -47,19 +63,23 @@ const Apptics = {
47
63
  disableDebug: function disableDebug() { return forward(disableDebugGuarded, arguments); },
48
64
  };
49
65
  /**
50
- * Android's AppticsEvents: `addEvent(name, group?, properties?)`, or
66
+ * Android's AppticsEvents: `addEvent(name, group, properties?)`, or
51
67
  * `addEvent(AppticsEvent.DefinedEvents.X, properties?)`.
52
68
  */
53
69
  const addEventGuarded = guard('AppticsEvent.addEvent', trackEvent); // no i18n
70
+ const setClickTrackingGuarded = guard('AppticsEvent.setClickTracking', setClickTracking); // no i18n
54
71
  const AppticsEvent = {
55
72
  /** Apptics' defined events, as Android's DefinedEvents, to log with addEvent. */
56
73
  DefinedEvents: DefinedEvents,
57
74
  addEvent: function addEvent(eventName, groupName, properties) {
58
75
  return forward(addEventGuarded, arguments);
59
76
  },
77
+ /** Turns click tracking from markup (apeventaction) on or off; the `track_click` config flag sets it at start-up. */
78
+ setClickTracking: function setClickTracking(enabled) { return forward(setClickTrackingGuarded, arguments); },
60
79
  };
61
80
  const inScreenGuarded = guard('AppticsScreen.inScreen', inScreenAt); // no i18n
62
81
  const outScreenGuarded = guard('AppticsScreen.outScreen', outScreenAt); // no i18n
82
+ const setScreenTrackingGuarded = guard('AppticsScreen.setScreenTracking', setScreenTracking); // no i18n
63
83
  /** Android's AppticsScreenTracker: inScreen(name) returns the view's id, outScreen(id) ends it. */
64
84
  const AppticsScreen = {
65
85
  /**
@@ -81,11 +101,13 @@ const AppticsScreen = {
81
101
  outScreen: function outScreen(id) {
82
102
  outScreenGuarded(id, nowMs());
83
103
  },
104
+ /** Turns automatic screen tracking on or off; the `track_screen` config flag sets it at start-up. */
105
+ setScreenTracking: function setScreenTracking(enabled) { return forward(setScreenTrackingGuarded, arguments); },
84
106
  };
85
107
  const endTrackApiGuarded = guard('AppticsApi.endTrackApi', endTrackApiAt); // no i18n
86
108
  const startTrackApiGuarded = guard('AppticsApi.startTrackApi', startTrackApi); // no i18n
87
109
  const configureGuarded = guard('AppticsApi.configure', configureApiTracking); // no i18n
88
- const enableApiTrackingGuarded = guard('AppticsApi.enableApiTracking', enableApiTracking); // no i18n
110
+ const setApiTrackingGuarded = guard('AppticsApi.setApiTracking', enableApiTracking); // no i18n
89
111
  /** Android's AppticsApiTracker: startTrackApi / endTrackApi, and configure for the rules. */
90
112
  const AppticsApi = {
91
113
  /** Begins timing one call: returns the id endTrackApi takes. */
@@ -99,17 +121,27 @@ const AppticsApi = {
99
121
  ApiTrackingBuilder: ApiTrackingBuilder,
100
122
  /** The rules API tracking records by, from ApiTrackingBuilder. Works before Apptics.init(). */
101
123
  configure: function configure(config) { return forward(configureGuarded, arguments); },
102
- /** Turns automatic API tracking on or off; the `track_api` config flag is the usual way to set it. */
103
- enableApiTracking: function enableApiTracking(enabled) { return forward(enableApiTrackingGuarded, arguments); },
124
+ /** Turns automatic API tracking on or off; the `track_api` config flag sets it at start-up. */
125
+ setApiTracking: function setApiTracking(enabled) { return forward(setApiTrackingGuarded, arguments); },
126
+ /** @deprecated the earlier name of setApiTracking, which it calls, with a warning */
127
+ enableApiTracking: function enableApiTracking(enabled) {
128
+ renamed('AppticsApi.enableApiTracking', 'AppticsApi.setApiTracking'); // no i18n
129
+ return forward(setApiTrackingGuarded, arguments);
130
+ },
104
131
  };
105
132
  const trackErrorGuarded = guard('AppticsError.trackError', trackError); // no i18n
106
- const trackGlobalErrorHandlerGuarded = guard('AppticsError.trackGlobalErrorHandler', trackGlobalErrorHandler); // no i18n
133
+ const setErrorTrackingGuarded = guard('AppticsError.setErrorTracking', setErrorTracking); // no i18n
107
134
  /** Errors: the ones the app caught, and the switch for the uncaught ones tracked on their own. */
108
135
  const AppticsError = {
109
136
  /** Reports an error the app caught, or an `error` / `unhandledrejection` event. */
110
137
  trackError: function trackError(error, properties) { return forward(trackErrorGuarded, arguments); },
111
- /** Turns the automatic tracking of uncaught errors and unhandled rejections on or off. */
112
- trackGlobalErrorHandler: function trackGlobalErrorHandler(enabled) { return forward(trackGlobalErrorHandlerGuarded, arguments); },
138
+ /** Turns the automatic tracking of uncaught errors and unhandled rejections on or off; the `track_error` config flag sets it at start-up. */
139
+ setErrorTracking: function setErrorTracking(enabled) { return forward(setErrorTrackingGuarded, arguments); },
140
+ /** @deprecated the earlier name of setErrorTracking, which it calls, with a warning */
141
+ trackGlobalErrorHandler: function trackGlobalErrorHandler(enabled) {
142
+ renamed('AppticsError.trackGlobalErrorHandler', 'AppticsError.setErrorTracking'); // no i18n
143
+ return forward(setErrorTrackingGuarded, arguments);
144
+ },
113
145
  };
114
146
  const setUserGuarded = guard('AppticsUser.setUser', setUser); // no i18n
115
147
  const getUserGuarded = guard('AppticsUser.getUser', getUser); // no i18n
@@ -121,16 +153,22 @@ const AppticsUser = {
121
153
  getUser: function getUser() { return forward(getUserGuarded, arguments); },
122
154
  UserBuilder: UserBuilder,
123
155
  };
124
- const trackHeatmapGuarded = guard('AppticsHeatmap.trackHeatmap', trackHeatmap); // no i18n
125
- /** Heatmap capture: AppticsHeatmap.trackHeatmap() starts or stops recording clicks and scrolls. */
156
+ const setHeatmapTrackingGuarded = guard('AppticsHeatmap.setHeatmapTracking', trackHeatmap); // no i18n
157
+ /** Heatmap capture: AppticsHeatmap.setHeatmapTracking() starts or stops recording clicks and scrolls. */
126
158
  const AppticsHeatmap = {
127
- trackHeatmap: function trackHeatmap(on) { return forward(trackHeatmapGuarded, arguments); },
159
+ /** Starts or stops recording clicks and scrolls; the `track_heatmap` config flag sets it at start-up. */
160
+ setHeatmapTracking: function setHeatmapTracking(enabled) { return forward(setHeatmapTrackingGuarded, arguments); },
161
+ /** @deprecated the earlier name of setHeatmapTracking, which it calls, with a warning */
162
+ trackHeatmap: function trackHeatmap(on) {
163
+ renamed('AppticsHeatmap.trackHeatmap', 'AppticsHeatmap.setHeatmapTracking'); // no i18n
164
+ return forward(setHeatmapTrackingGuarded, arguments);
165
+ },
128
166
  };
129
167
  const setTrackingStatusGuarded = guard('AppticsSettings.setTrackingStatus', setTrackingStatus); // no i18n
130
168
  const getTrackingStatusGuarded = guard('AppticsSettings.getTrackingStatus', getTrackingStatus); // no i18n
131
169
  /** Android's AppticsSettings: what the SDK may track for this visitor. */
132
170
  const AppticsSettings = {
133
- /** The states setTrackingStatus takes: USAGE_TRACKING_WITH_PII, USAGE_TRACKING_WITHOUT_PII, NO_TRACKING. */
171
+ /** The states setTrackingStatus takes: USAGE_TRACKING_WITH_PII, USAGE_TRACKING_WITHOUT_PII, ANONYMOUS, NO_TRACKING. */
134
172
  AP_TRACKING_STATUS: AP_TRACKING_STATUS,
135
173
  setTrackingStatus: function setTrackingStatus(status) { return forward(setTrackingStatusGuarded, arguments); },
136
174
  getTrackingStatus: function getTrackingStatus() { return forward(getTrackingStatusGuarded, arguments); },
@@ -145,6 +183,5 @@ const apptics = {
145
183
  AppticsSettings,
146
184
  AppticsHeatmap,
147
185
  };
148
- scheduleAutoInit(Apptics);
149
186
 
150
187
  export { Apptics, AppticsApi, AppticsError, AppticsEvent, AppticsHeatmap, AppticsScreen, AppticsSettings, AppticsUser, apptics as default };
@@ -1,8 +1,7 @@
1
1
  import { type ScreenRouteRule } from './core/constants.js';
2
2
  import type { AppticsConfig } from './types.js';
3
3
  /**
4
- * Starts the SDK. The config object is required: pass it directly, or let the console snippet
5
- * supply it (auto-init reads window.appticssettings._defaultoptions and calls init with it).
4
+ * Starts the SDK. The config object is required: the SDK starts only when the app calls this.
6
5
  * Returns true when the config has base_url, auth_key, app_domain and appversion and start-up has
7
6
  * begun (see ready()), false when it was already running, the config is missing or incomplete, or
8
7
  * there is no browser. Start-up calls app/addversion with those four, which answers with aaid, the
@@ -19,3 +18,15 @@ export declare function screenRouteRules(routes: unknown): ScreenRouteRule[];
19
18
  export declare function ready(): Promise<boolean>;
20
19
  /** Clears stored identity and queues, then starts again from the snippet. */
21
20
  export declare function reset(): void;
21
+ /**
22
+ * AppticsEvent.setClickTracking: click tracking from markup on or off, as the `track_click`
23
+ * config sets it. The listener stays; it checks the switch on every click.
24
+ */
25
+ export declare function setClickTracking(enabled?: boolean): void;
26
+ /**
27
+ * AppticsScreen.setScreenTracking: automatic screen tracking on or off, as the `track_screen`
28
+ * config sets it. Applied now once the SDK is running; before that it is only noted, and start()
29
+ * switches tracking to it. Like the other switches, the next init() (a reset() too) goes back to
30
+ * what its config says.
31
+ */
32
+ export declare function setScreenTracking(enabled?: boolean): void;