@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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,116 @@
1
1
  # Change Log
2
2
 
3
+ # Apptics JS SDK 2.0.0
4
+ The first stable 2.0 release, published under the `latest` npm tag, with everything from the 2.0.0 betas. **New: web push notifications**, `AppticsPushNotification`. **New: anonymous tracking.** **New: the feedback form's new look, in 21 languages.** **Breaking: the tracking status is a name, not a number. Breaking: `AppticsUser.setUser` no longer changes the tracking status. Breaking: `AppticsRemoteConfig.fetchValue` is removed. Breaking: the defined events are browser events. Breaking: debug mode is switched from the browser console only.**
5
+
6
+ ## Web push notifications
7
+ - When push is on for the app in the Apptics console, the SDK registers the browser and receives messages while a tab of the site is open. On a site outside Zoho's domains no routing or proxy is needed; a strict Content-Security-Policy must allow the Apptics host of your data centre in `frame-src`.
8
+ - `AppticsPushNotification.setEnabled(true)` and `setEnabled(false)` switch it on demand; `setEnabled(false)` holds across visits. `isEnabled()` tells the state. With `NO_TRACKING`, nothing is registered.
9
+ - `AppticsPushNotification.requestPermission()` asks for notification permission; the SDK never asks on its own. With permission, each message shows as a browser notification: title, text, icon, image, auto-dismiss, stay-on-screen and silent. A click opens the message's click action URL.
10
+ - A page that already uses Zoho WMS keeps its own handlers.
11
+ - Add `/apptics-pn-sw.js` to the site, holding `importScripts('https://static.zohocdn.com/apptics-js-sdk/2.0.0/apptics-pn-sw.js')`, for action buttons, the image carousel, the countdown and clicks after the tab has closed. Without it, notifications are plain. A site whose own service worker already controls its root keeps it.
12
+ - Received, opened and conversion stats are sent once per message per browser.
13
+
14
+ ## Anonymous tracking
15
+ - New status `AppticsSettings.AP_TRACKING_STATUS.ANONYMOUS`, set with `AppticsSettings.setTrackingStatus(AppticsSettings.AP_TRACKING_STATUS.ANONYMOUS)`. Data is then tracked by an anonymous id, with no user on it. It is kept across visits, like the other statuses.
16
+
17
+ ## The tracking status is a name
18
+ - Breaking: each `AP_TRACKING_STATUS` value is its own name (`AP_TRACKING_STATUS.ANONYMOUS === 'ANONYMOUS'`), and `AppticsSettings.getTrackingStatus()` returns one: `'USAGE_TRACKING_WITH_PII'`, `'USAGE_TRACKING_WITHOUT_PII'`, `'ANONYMOUS'` or `'NO_TRACKING'`. Code that compared it with a number compares with `AP_TRACKING_STATUS.<name>` now.
19
+ - A value that is no status is ignored, with a console warning. A status chosen under an earlier version is kept.
20
+
21
+ ## setUser leaves the tracking status alone
22
+ - Breaking: a successful `AppticsUser.setUser` used to switch the status to `USAGE_TRACKING_WITH_PII`. It now registers the user and changes nothing else; only `setTrackingStatus` changes the status. To attribute data to the user, call `AppticsSettings.setTrackingStatus(AppticsSettings.AP_TRACKING_STATUS.USAGE_TRACKING_WITH_PII)`.
23
+ - A visitor on `NO_TRACKING` is still not registered by `setUser`.
24
+
25
+ ## Remote config: fetchValues only
26
+ - Breaking: `AppticsRemoteConfig.fetchValue(name)` is removed. Read one parameter with `fetchValues([name])`: `const { bannerText } = await AppticsRemoteConfig.fetchValues(['bannerText'])`. The callback and `coldFetch` work as before.
27
+
28
+ ## Defined events for the browser
29
+ - Breaking: `AppticsEvent.DefinedEvents` lists browser events now: page life cycle (`AP_PAGE_LOAD`, `AP_PAGE_VISIBLE`, `AP_PAGE_HIDDEN`, `AP_PAGE_UNLOAD`, `AP_PAGE_PRINT`), installed web app, sharing, downloads, notification permission, online and offline, language and full screen, and `AP_BROWSER`. The mobile-only events (app install and foreground, deep links, battery, orientation, OS) are removed. `AP_USER_SIGNUP`, `AP_USER_LOGIN`, `AP_USER_LOGOUT`, `AP_SEARCH`, the notification and theme events keep their names. They are still logged only when you call `addEvent`.
30
+
31
+ ## The feedback form's new look, in 21 languages
32
+ - The form follows the Apptics web console's design, in light and dark. The `--zasdk-*` CSS variables still apply and element ids stay, apart from `#zasdkattachinfo`.
33
+ - Breaking for pages that style the form's insides: the markup is new, and `#zasdkattachinfo` and the `.zaleftcharcnt` and `.zasdk-btncnt` classes are gone.
34
+ - English, Čeština, Dansk, Deutsch, Español (España, México), Français (Canada, France), Bahasa Indonesia, Italiano, 日本語, 한국어, Nederlands, Polski, Português (Brasil, Portugal), Русский, Svenska, Türkçe, 中文简体 and 中文繁體. The form opens in the browser's language, else English, and a dropdown in the form switches it; the choice is remembered in that browser.
35
+
36
+ ## Debug mode from the browser console only
37
+ - Breaking: `Apptics.enableDebug()` and `Apptics.disableDebug()` work only when typed in the browser's developer console; a call from the page's code is ignored, with a console warning.
38
+ - Breaking: `debug` (and `debug_api`) are no longer init options, and are ignored with a console warning.
39
+
40
+ ## Fixes
41
+ - The SDK's own failures, and errors from its own script, feedback form and screen recorder, are no longer recorded as the app's JS errors.
42
+ - Opening the feedback form no longer records a JS error.
43
+ - A session now ends when the user leaves, even after a tab of the site was reloaded or closed.
44
+ - Event, screen and error properties: `true` and `false` arrive as Boolean; they arrived as the numbers `1` and `0`.
45
+ - The feedback form's file picker offers `.png`, `.jpg`, `.jpeg`, `.gif` and `.svg`; it offered `.txt`, which failed the feedback.
46
+ - After a new `appversion`, calls carry the new version correctly.
47
+ - While remote config can't be fetched, `fetchValues` no longer sends a request on every call.
48
+ - A push message whose text or URLs contain `-` is shown; it was dropped.
49
+
50
+ # Apptics JS SDK 2.0.0-beta.2
51
+ Published under the `beta` npm tag; `latest` stays on 1.0.2. **Fixes heatmaps for npm apps**: with 2.0.0-beta.1 from npm, heatmap records were captured but never sent. **Breaking: an event's group is required.** **New: every automatic tracker switched the same way: a config key and a `set…Tracking()` call, and each kind of engagement follows its own switch in the Apptics console.**
52
+
53
+ ## Switching automatic tracking: a config key and a set…Tracking() call each
54
+ - New config keys: `track_error` (uncaught errors and unhandled rejections, on by default) and `track_click` (clicks on elements tagged `apeventaction`, on by default), beside `track_screen`, `track_api` and `track_heatmap`.
55
+ - New calls: `AppticsEvent.setClickTracking(enabled?)` and `AppticsScreen.setScreenTracking(enabled?)`.
56
+ - Renamed, so all five read the same: `AppticsApi.enableApiTracking` is `AppticsApi.setApiTracking`, `AppticsError.trackGlobalErrorHandler` is `AppticsError.setErrorTracking`, and `AppticsHeatmap.trackHeatmap` is `AppticsHeatmap.setHeatmapTracking`. The earlier names still work, with a console warning naming the call to use, once per page.
57
+ - Each call takes `true` or `false`, `true` when left out. The config key decides at start-up: a call made before `Apptics.init()` is replaced by it, and `Apptics.reset()` goes back to it. Before, `trackGlobalErrorHandler(false)` called before `Apptics.init()` stayed in force; now `track_error: false` is the way to start with it off.
58
+ - The calls the app makes itself (`addEvent`, `inScreen`, `trackError`, `startTrackApi`) record whichever way a switch is set.
59
+
60
+ ## Each kind of engagement follows its own module in getsdkconfig
61
+ - Events (module 5), API calls (6), screens (10) and sessions (11) are each switched by their own module. 2.0.0-beta.1 read only sessions (11) and switched all four with it, so turning off one kind in the Apptics console stopped them all, and turning off events alone did nothing.
62
+ - A kind that is off is not recorded, and the console says so in debug mode. Items of that kind already queued stay until it is on again, or until they expire (`batch_request_timeout`, 7 days).
63
+ - With sessions off and events or screens on, events and screens are still recorded, each with its session's start time; only the session itself is not sent.
64
+ - Errors follow `js_error` (module 15), the web SDK's own. 2.0.0-beta.1 read `crash` (13), which belongs to the native SDKs.
65
+ - A module the server does not mention is on, as before. Settings stored by an earlier build, with one `engagementtracking` flag, still switch all four.
66
+
67
+ ## An event's group is required
68
+ - Breaking: `AppticsEvent.addEvent(eventName, groupName, properties?)` needs a group. An event without one (left out, `''` or `null`) is not logged, and the console says so, debug or not: `AppticsEvent.addEvent: groupName is required for "<event>": addEvent(eventName, groupName, properties?)`, once per event name. 2.0.0-beta.1 filed it under `default`, a group the app never named.
69
+ - `addEvent(eventName, properties)`, with the properties in the group's place, is refused the same way.
70
+ - Click tracking: an element with `apeventaction` and no `apgroupaction` around it is not tracked, and the console says the group is missing. 2.0.0-beta.1 filed it under `default`.
71
+ - Defined events (`AppticsEvent.DefinedEvents.X`) bring their own group, as before. An invalid group is still refused, as before.
72
+ - TypeScript: `groupName` is required in `addEvent`'s types, so a call without it is a compile error.
73
+
74
+ ## Heatmaps are sent from npm builds
75
+ - Fix: with the npm package, heatmap records were captured and stored but never sent, by the flush timer or by `Apptics.flush()`. The sender was wired up by a module imported only for its side effect, and since the package's `sideEffects` names only the CDN bundle, app bundlers (Vite, webpack, Rollup) left it out. The CDN `<script>` build was not affected. A test now bundles the main entry the way an app does and checks that the sender is kept.
76
+
77
+ ## Sessions end when the user left
78
+ - When a tab goes inactive (hidden, minimised, or its window loses focus to another one), that moment is the session's `lastactivetime`. Focus moving into an iframe on the page does not count.
79
+ - Back within `inactiveduration` (30 minutes by default), the same session goes on.
80
+ - Not back by then, the session ends at `lastactivetime` and is sent straight away, rather than staying open until the user returns or the tab closes. Coming back later starts a new session.
81
+ - A tab closed while inactive ends its session at `lastactivetime`, not when it closed: the time it sat hidden is no longer session time. A tab closed while in use ends it then, as before.
82
+ - While another tab of the site is on the same session, a tab that goes inactive or closes only leaves it; the last one ends it.
83
+
84
+ ## The server's settings (getsdkconfig) are read on the server's schedule
85
+ - Once per page load: after `device/add` on a first visit, after `app/addversion` on a returning one (2.0.0-beta.1 made a returning visit wait for the first timer tick).
86
+ - Then at the time the answer's `next_check_after` gives, instead of every `getupdates_interval`. `getupdates_interval` is the wait only when an answer gives no time.
87
+ - Coming back to the tab asks again only once that time has passed; switching tabs used to ask every time.
88
+ - A device registered again during a page load (new device details, or a new SDK build) no longer asks a second time.
89
+
90
+ ## Remote config stays up to date by itself
91
+ - The first fetch of each page load sends `flagtime` 0 and gets the whole rule set, which replaces what was stored.
92
+ - After that the SDK asks every 3 minutes, and when the tab comes back after 15 seconds or more away, with `flagtime` set to the time of its last answered fetch. The server answers with only what changed, which is merged into the stored set by `paramid` and `conditionid`; parameters and conditions it does not resend are kept.
93
+ - The five-minute cache is removed: `fetchValue` and `fetchValues` answer from the values the polling keeps up to date, without a request of their own.
94
+ - **`coldFetch` is back**, as the last argument of `fetchValue(name, callback?, coldFetch?)` and `fetchValues(names?, callback?, coldFetch?)`, `false` by default; it may take the callback's place (`fetchValue(name, true)`, `fetchValues(true)`). `true` asks the server for the whole rule set now (`flagtime` 0), replaces the stored set with it and answers from it. At most three a minute; one past that answers from the values the page already has.
95
+
96
+ ## Apptics.flush() sends at most once every 15 seconds
97
+ - `Apptics.flush()` called by an app, or from the browser console, sends at most once every 15 seconds. A call sooner than that sends nothing and resolves at once; what is stored goes with the next send. The SDK's own sends (the flush timer, page hide and close, back online) are not held to it.
98
+
99
+ ## Stored data follows the app it belongs to
100
+ - A page that starts with a different `base_url`, `app_domain` or `auth_key` from the stored data's clears everything the SDK stored (settings and all five queues, unsent data included) before start-up, which then runs as on a first visit: `app/addversion`, `device/add` and the rest. 2.0.0-beta.1 compared only `base_url` and `app_domain`, and kept the heatmap, remote logger and feedback log queues.
101
+ - `app_version_info` keeps an 8-character fingerprint of `auth_key` (`zakhash`), not the key itself. Data stored by 2.0.0-beta.1, which has none, registers the app version again once and is not cleared.
102
+ - `Apptics.reset()` empties the heatmap, remote logger and feedback log queues too.
103
+
104
+ ## The CDN build is served from static.zohocdn.com
105
+ - `https://static.zohocdn.com/apptics-js-sdk/{version}/apptics.min.js`, with `apptics.esm.min.js`, `feedback.esm.min.js`, `chunks/` and the source maps in the same folder. Each release has a folder of its own.
106
+ - Remote config and the remote logger have module files of their own, as on npm: `remoteconfig.esm.min.js` (`AppticsRemoteConfig`) and `remotelogger.esm.min.js` (`AppticsLogger`), beside `apptics.esm.min.js` and `feedback.esm.min.js`. A page imports only the ones it uses, and they share one copy of the SDK.
107
+ - `npm run build` also writes that layout to `cdn/{version}/`, and the build server (`npm run build:cdn`, which registers the version first) zips it as `{version}/…` with `dist-meta.json`.
108
+
109
+ ## Fixes
110
+ - `device/add` sends `isanonrequired=false`. The web SDK has no anonymous mode, only the tracking statuses (with PII, without PII, none), which `devicestatus` carries; with the default status, usage tracking without PII, 2.0.0-beta.1 sent `true`.
111
+ - The device was registered again (`device/add`) on every page load when the server's answer carried no `anonymousid`, as sdk-apptics.zoho.in's does. A device with a `deviceid` counts as registered; `anonymousid` is optional.
112
+ - Start-up waits for stored data of another app to be cleared before calling `app/addversion`.
113
+
3
114
  # Apptics JS SDK 2.0.0-beta.1
4
115
  Published under the `beta` npm tag; `latest` stays on 1.0.2. **Breaking for 2.0.0-beta code**: the changes are listed below, each with what to use instead.
5
116
 
@@ -111,7 +222,7 @@ Breaking for 2.0.0-beta code: each call keeps its name and moves onto the object
111
222
  A rewrite of the web SDK in TypeScript, published on npm as ES modules, CommonJS and a minified browser build. Published under the `beta` npm tag; `latest` stays on 1.0.2. **`Apptics.init()` takes new config**: see "Migrating from 1.0.2 to 2.0.0-beta.1" in the README. Runs in Chrome 80+, Edge 80+, Firefox 74+ and Safari 14+.
112
223
 
113
224
  ## Initialization
114
- - **The Android SDK's names**: `Apptics.init(config)`, `AppticsEvents.addEvent`, `AppticsScreenTracker.inScreen` / `outScreen`, `AppticsApiTracker.startTrackApi` / `endTrackApi` / `configure`, `AppticsLogger.enable` / `disable` / `isEnabled` / `v` / `d` / `i` / `w` / `e`, `AppticsTrackError`, `AppticsSetUser`, and `AppticsRemoteConfig`. The `<script>` build defines them as globals too. 1.0.2's `apptics.init`, `apptics.trackEvent`, `apptics.trackScreen`, `apptics.trackError` and `apptics.setUser` are gone, so code calling them has to be renamed.
225
+ - **New names**: `Apptics.init(config)`, `AppticsEvents.addEvent`, `AppticsScreenTracker.inScreen` / `outScreen`, `AppticsApiTracker.startTrackApi` / `endTrackApi` / `configure`, `AppticsLogger.enable` / `disable` / `isEnabled` / `v` / `d` / `i` / `w` / `e`, `AppticsTrackError`, `AppticsSetUser`, and `AppticsRemoteConfig`. The `<script>` build defines them as globals too. 1.0.2's `apptics.init`, `apptics.trackEvent`, `apptics.trackScreen`, `apptics.trackError` and `apptics.setUser` are gone, so code calling them has to be renamed.
115
226
  - **New config**: `Apptics.init()` takes `serviceUrl`, `zak`, `identifier` and `appversion`, all required. The SDK gets `aaid`, the portal id and the project id from the server, so `aaid`, `zsoid` and `projectID` are no longer passed in. A missing key is named in a console warning and `Apptics.init()` returns `false`.
116
227
  - **`appversion` is required**: 1.0.2 defaulted it to `1.0`, which attributed every session, error and crash to a version that was never shipped.
117
228
  - **`appversion` takes a string or a number**: `'2.4.0'`, `'v2.4-build512'` or a build number such as `512`. It is sent as text: a string is trimmed, and a number keeps the digits JavaScript gives it (`1.10` is `'1.1'`), so pass a dotted version as a string. A blank value, or a snippet placeholder (`YOUR_APP_VERSION`, `YOUR_BUILD_OR_APP_VERSION`, `YOUR_APPVERSION`), is refused with a console warning and `Apptics.init()` returns `false`.
@@ -127,37 +238,37 @@ A rewrite of the web SDK in TypeScript, published on npm as ES modules, CommonJS
127
238
  - **License**: the Zoho Apptics JavaScript SDK license (see LICENSE) instead of MIT. It allows installing from npm or a CDN, bundling with your build tools and serving the SDK to your users as part of your web app.
128
239
 
129
240
  ## Events
130
- - **Defined events, as on Android**: `AppticsEvents.addEvent(DefinedEvents.AP_USER_LOGIN, props?)` logs Apptics' ready-made events under their own `AP_` groups.
241
+ - **Defined events**: `AppticsEvents.addEvent(DefinedEvents.AP_USER_LOGIN, props?)` logs Apptics' ready-made events under their own `AP_` groups.
131
242
  - **`ap_` / `AP_` is reserved**: an app's event, group or property key starting with it is not logged.
132
- - **An event with an invalid group is not logged**, as on Android, instead of being filed under `default`; an event with no group is still `default`.
243
+ - **An event with an invalid group is not logged**, instead of being filed under `default`; an event with no group is still `default`.
133
244
  - **Properties are judged one by one**: a bad key or an over-long value drops that property, and the event keeps the rest (it used to lose them all). Booleans are typed as Boolean and every number as Number (`1` and `0` were typed as Boolean); objects and arrays are sent as JSON text.
134
245
 
135
246
  ## Sessions
136
- - **`track_session: false`** turns automatic sessions off, as Android's `automaticSessionsTrackingStatus = false`; events and screens are still recorded.
247
+ - **`track_session: false`** turns automatic sessions off; events and screens are still recorded.
137
248
 
138
249
  ## Screen Tracking
139
- - **`trackScreen()` is renamed `AppticsScreenTracker.inScreen()`**, as in the Android SDK: same arguments, and it returns the view's id for `AppticsScreenTracker.outScreen(id)`. `trackScreen` no longer exists, so 1.0.2 code calling it has to be renamed.
140
- - **Screen views have a duration.** A view ends when the next screen starts, when the page is hidden (coming back starts a new view), or when its session ends. `AppticsScreenTracker.inScreen()` now returns the view's id, and `AppticsScreenTracker.outScreen(id)` ends it yourself, as Android's `outScreen`. Until now every view was recorded with no time spent.
250
+ - **`trackScreen()` is renamed `AppticsScreenTracker.inScreen()`**: same arguments, and it returns the view's id for `AppticsScreenTracker.outScreen(id)`. `trackScreen` no longer exists, so 1.0.2 code calling it has to be renamed.
251
+ - **Screen views have a duration.** A view ends when the next screen starts, when the page is hidden (coming back starts a new view), or when its session ends. `AppticsScreenTracker.inScreen()` now returns the view's id, and `AppticsScreenTracker.outScreen(id)` ends it yourself. Until now every view was recorded with no time spent.
141
252
  - **Automatic screen tracking, on by default**: the first page and every navigation (`pushState`, `replaceState`, back and forward, `#/` hash routes) are recorded as screens, named by the path without its query string. A `AppticsScreenTracker.inScreen()` from the router names a route your own way. A `AppticsScreenTracker.inScreen()` call within 300 ms of a navigation (from a router hook) replaces the automatic view, so the navigation counts once under the app's name; `track_screen: false` turns automatic tracking off.
142
253
  - **`setScreenName()` is removed.** Records are attributed to the screen `AppticsScreenTracker.inScreen()` or automatic tracking last named; heatmap records with neither get the page's name, made from its path the same way.
143
254
 
144
255
  ## Remote Logger
145
- - **`AppticsLogger`**: `AppticsLogger.v/d/i/w/e(tag, message, ...details)` sends the app's log lines to the Remote Logger page, as levels 1 to 5 in the Android and iOS order. Off until `AppticsLogger.enable()`; `AppticsLogger` in the `<script>` build. Each line carries the time it was logged and the function, file and line that logged it.
146
- - **Android's names too**: `AppticsLogger.v/d/i/w/e(tag, message)`, with the tag leading the message as `[tag]`, and `AppticsLogger.disable()`.
147
- - **`show_logs: true`** prints the app's lines to the browser console as well, as Android's `showLogs` does for Logcat.
148
- - **Offline storage is capped at 1 MB**, oldest lines dropped first, as on Android (instead of 200 lines).
256
+ - **`AppticsLogger`**: `AppticsLogger.v/d/i/w/e(tag, message, ...details)` sends the app's log lines to the Remote Logger page, as levels 1 to 5. Off until `AppticsLogger.enable()`; `AppticsLogger` in the `<script>` build. Each line carries the time it was logged and the function, file and line that logged it.
257
+ - **Tagged lines**: `AppticsLogger.v/d/i/w/e(tag, message)`, with the tag leading the message as `[tag]`, and `AppticsLogger.disable()`.
258
+ - **`show_logs: true`** prints the app's lines to the browser console as well.
259
+ - **Offline storage is capped at 1 MB**, oldest lines dropped first (instead of 200 lines).
149
260
  - **SDK diagnostics**: the SDK reports its own failures to the same page, tagged with the module it happened in. Off by default; `remote_log: true` turns it on, independently of `AppticsLogger`.
150
261
 
151
262
  ## API Tracking
152
- - **Path normalization, as on Android**: numeric ids, UUIDs and JWTs in a path become `*`, and the query string is removed, so calls group by endpoint (`/users/42/orders` → `/users/*/orders`).
153
- - **`AppticsApiTracker.configure(new ApiTrackingBuilder()...build())`** with Android's rules: `ignoreDomains`, `allowOnlyDomains`, `allowOnlyTLDs`, `ignoreTLDs`, `ignoreDomainPrefixes`, `ignoreDomainSuffixes`, `groupDomains`, `ignoreEndpoint`, `addPattern`, `preserveSegments`, `autoDetection`. They apply to every call.
154
- - **`AppticsApiTracker.startTrackApi(url, method)` / `AppticsApiTracker.endTrackApi(id, code)`** time and record a call, as on Android.
263
+ - **Path normalization**: numeric ids, UUIDs and JWTs in a path become `*`, and the query string is removed, so calls group by endpoint (`/users/42/orders` → `/users/*/orders`).
264
+ - **`AppticsApiTracker.configure(new ApiTrackingBuilder()...build())`** with rules: `ignoreDomains`, `allowOnlyDomains`, `allowOnlyTLDs`, `ignoreTLDs`, `ignoreDomainPrefixes`, `ignoreDomainSuffixes`, `groupDomains`, `ignoreEndpoint`, `addPattern`, `preserveSegments`, `autoDetection`. They apply to every call.
265
+ - **`AppticsApiTracker.startTrackApi(url, method)` / `AppticsApiTracker.endTrackApi(id, code)`** time and record a call.
155
266
  - **`track_api: true`** records every `fetch` and XHR call automatically (`enableApiTracking(on)` switches it later); a call is reported by hand with `AppticsApiTracker.startTrackApi` / `endTrackApi`. The SDK's own requests are never recorded. Host rules are set only through `AppticsApiTracker.configure`: the earlier `track_api_hosts` / `track_api_exclude_hosts` keys are gone, and `Apptics.init()` warns when it is given them.
156
267
 
157
268
  ## Remote Config
158
- - **`AppticsRemoteConfig`** from `@zoho_apptics/apptics-js-sdk/remote-config` (`AppticsRemoteConfig` in the `<script>` build): four calls, as on Android: `fetchValue(name)` and `fetchValues({ name: default })` read parameters, `setCustomConditionValue` and `setFallbackWithOfflineValue` (below). The rule set is stored and resolved on the device, and conditions on the user re-apply on their own after `AppticsSetUser`.
159
- - **`setCustomConditionValue(key, value)`**, as on Android: conditions on a custom criteria match this device's value. Kept across visits; works before `Apptics.init()`.
160
- - **`fetchValue(name)`** and **`fetchValues({ name: default })`**, as on Android: Promises, with an optional callback. A parameter the console doesn't have is `null`.
269
+ - **`AppticsRemoteConfig`** from `@zoho_apptics/apptics-js-sdk/remote-config` (`AppticsRemoteConfig` in the `<script>` build): four calls: `fetchValue(name)` and `fetchValues({ name: default })` read parameters, `setCustomConditionValue` and `setFallbackWithOfflineValue` (below). The rule set is stored and resolved on the device, and conditions on the user re-apply on their own after `AppticsSetUser`.
270
+ - **`setCustomConditionValue(key, value)`**: conditions on a custom criteria match this device's value. Kept across visits; works before `Apptics.init()`.
271
+ - **`fetchValue(name)`** and **`fetchValues({ name: default })`**: Promises, with an optional callback. A parameter the console doesn't have is `null`.
161
272
  - **Fetched on start-up**, so values are this session's without the app asking.
162
273
  - **A fetch from the last five minutes is reused**; `coldFetch` asks the server regardless, at most three times a minute.
163
274
  - **`setFallbackWithOfflineValue(false)`**: a failed fetch answers with `null` and defaults instead of the values fetched before (the default).