@zoho_apptics/apptics-js-sdk 2.0.0-beta → 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 (236) hide show
  1. package/CHANGELOG.md +191 -21
  2. package/README.md +519 -333
  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 +2 -2
  13. package/dist/cjs/core/consent.d.ts +18 -4
  14. package/dist/cjs/core/consent.js +31 -15
  15. package/dist/cjs/core/constants.d.ts +57 -27
  16. package/dist/cjs/core/constants.js +52 -33
  17. package/dist/cjs/core/db.d.ts +12 -4
  18. package/dist/cjs/core/db.js +167 -34
  19. package/dist/cjs/core/debug.js +1 -1
  20. package/dist/cjs/core/env.d.ts +0 -3
  21. package/dist/cjs/core/env.js +1 -9
  22. package/dist/cjs/core/framework-id.d.ts +1 -1
  23. package/dist/cjs/core/framework-id.js +3 -3
  24. package/dist/cjs/core/guard.d.ts +9 -0
  25. package/dist/cjs/core/guard.js +27 -13
  26. package/dist/cjs/core/hooks.d.ts +7 -4
  27. package/dist/cjs/core/hooks.js +3 -3
  28. package/dist/cjs/core/locks.d.ts +9 -0
  29. package/dist/cjs/core/locks.js +22 -0
  30. package/dist/cjs/core/logger.d.ts +3 -4
  31. package/dist/cjs/core/logger.js +4 -40
  32. package/dist/cjs/core/state.d.ts +9 -6
  33. package/dist/cjs/core/state.js +3 -5
  34. package/dist/cjs/core/storage.d.ts +20 -5
  35. package/dist/cjs/core/storage.js +115 -20
  36. package/dist/cjs/core/stylesheet.d.ts +8 -0
  37. package/dist/cjs/core/stylesheet.js +29 -0
  38. package/dist/cjs/core/transport.d.ts +2 -0
  39. package/dist/cjs/core/transport.js +30 -18
  40. package/dist/cjs/core/utils.js +1 -1
  41. package/dist/cjs/core/validate.js +2 -2
  42. package/dist/cjs/device/appversion.d.ts +10 -6
  43. package/dist/cjs/device/appversion.js +38 -3
  44. package/dist/cjs/device/index.d.ts +28 -2
  45. package/dist/cjs/device/index.js +312 -44
  46. package/dist/cjs/engagement/api-rules.d.ts +32 -67
  47. package/dist/cjs/engagement/api-rules.js +144 -157
  48. package/dist/cjs/engagement/auto-api.js +2 -2
  49. package/dist/cjs/engagement/auto-screen.d.ts +2 -0
  50. package/dist/cjs/engagement/auto-screen.js +67 -3
  51. package/dist/cjs/engagement/defined-events.js +1 -1
  52. package/dist/cjs/engagement/send.js +12 -3
  53. package/dist/cjs/engagement/session.d.ts +29 -3
  54. package/dist/cjs/engagement/session.js +253 -26
  55. package/dist/cjs/engagement/track.d.ts +4 -4
  56. package/dist/cjs/engagement/track.js +58 -30
  57. package/dist/cjs/errors/send.js +2 -2
  58. package/dist/cjs/errors/track.d.ts +2 -1
  59. package/dist/cjs/errors/track.js +49 -7
  60. package/dist/cjs/feedback/controls.d.ts +12 -0
  61. package/dist/cjs/feedback/controls.js +104 -25
  62. package/dist/cjs/feedback/index.d.ts +8 -7
  63. package/dist/cjs/feedback/index.js +32 -13
  64. package/dist/cjs/feedback/logs.d.ts +13 -11
  65. package/dist/cjs/feedback/logs.js +57 -28
  66. package/dist/cjs/feedback/quartz.d.ts +18 -0
  67. package/dist/cjs/feedback/quartz.js +105 -0
  68. package/dist/cjs/feedback/send.d.ts +5 -2
  69. package/dist/cjs/feedback/send.js +30 -28
  70. package/dist/cjs/feedback/styles.d.ts +10 -0
  71. package/dist/cjs/feedback/styles.js +8 -0
  72. package/dist/cjs/feedback/template.d.ts +1 -1
  73. package/dist/cjs/feedback/template.js +20 -12
  74. package/dist/cjs/feedback/ui.d.ts +21 -6
  75. package/dist/cjs/feedback/ui.js +283 -70
  76. package/dist/cjs/heatmap/send.d.ts +2 -0
  77. package/dist/cjs/heatmap/send.js +3 -5
  78. package/dist/cjs/heatmap/track.d.ts +1 -1
  79. package/dist/cjs/heatmap/track.js +87 -16
  80. package/dist/cjs/index.d.ts +16 -63
  81. package/dist/cjs/index.js +144 -95
  82. package/dist/cjs/lifecycle.d.ts +21 -3
  83. package/dist/cjs/lifecycle.js +353 -89
  84. package/dist/cjs/remoteconfig/country.d.ts +4 -0
  85. package/dist/cjs/remoteconfig/country.js +73 -0
  86. package/dist/cjs/remoteconfig/custom.d.ts +7 -7
  87. package/dist/cjs/remoteconfig/custom.js +31 -51
  88. package/dist/cjs/remoteconfig/evaluate.d.ts +3 -3
  89. package/dist/cjs/remoteconfig/evaluate.js +56 -43
  90. package/dist/cjs/remoteconfig/fetch.d.ts +16 -9
  91. package/dist/cjs/remoteconfig/fetch.js +120 -39
  92. package/dist/cjs/remoteconfig/index.d.ts +19 -8
  93. package/dist/cjs/remoteconfig/index.js +81 -39
  94. package/dist/cjs/remoteconfig/store.d.ts +15 -7
  95. package/dist/cjs/remoteconfig/store.js +68 -35
  96. package/dist/cjs/remoteconfig/tz-countries.d.ts +8 -0
  97. package/dist/cjs/remoteconfig/tz-countries.js +13 -0
  98. package/dist/{esm/core → cjs/remotelog}/callsite.d.ts +11 -4
  99. package/dist/cjs/{core → remotelog}/callsite.js +30 -7
  100. package/dist/cjs/remotelog/gate.d.ts +2 -11
  101. package/dist/cjs/remotelog/gate.js +9 -35
  102. package/dist/cjs/remotelog/index.d.ts +4 -21
  103. package/dist/cjs/remotelog/logger.d.ts +11 -17
  104. package/dist/cjs/remotelog/logger.js +31 -59
  105. package/dist/cjs/remotelog/send.js +11 -11
  106. package/dist/cjs/remotelogger/index.d.ts +12 -0
  107. package/dist/cjs/remotelogger/index.js +18 -0
  108. package/dist/cjs/scheduler.d.ts +3 -1
  109. package/dist/cjs/scheduler.js +25 -22
  110. package/dist/cjs/types.d.ts +208 -90
  111. package/dist/cjs/user/index.js +16 -7
  112. package/dist/esm/core/attempts.js +1 -1
  113. package/dist/esm/core/batch.js +2 -2
  114. package/dist/esm/core/consent.d.ts +18 -4
  115. package/dist/esm/core/consent.js +32 -17
  116. package/dist/esm/core/constants.d.ts +57 -27
  117. package/dist/esm/core/constants.js +51 -33
  118. package/dist/esm/core/db.d.ts +12 -4
  119. package/dist/esm/core/db.js +164 -35
  120. package/dist/esm/core/debug.js +1 -1
  121. package/dist/esm/core/env.d.ts +0 -3
  122. package/dist/esm/core/env.js +2 -9
  123. package/dist/esm/core/framework-id.d.ts +1 -1
  124. package/dist/esm/core/framework-id.js +3 -3
  125. package/dist/esm/core/guard.d.ts +9 -0
  126. package/dist/esm/core/guard.js +27 -14
  127. package/dist/esm/core/hooks.d.ts +7 -4
  128. package/dist/esm/core/hooks.js +3 -3
  129. package/dist/esm/core/locks.d.ts +9 -0
  130. package/dist/esm/core/locks.js +20 -0
  131. package/dist/esm/core/logger.d.ts +3 -4
  132. package/dist/esm/core/logger.js +4 -40
  133. package/dist/esm/core/state.d.ts +9 -6
  134. package/dist/esm/core/state.js +3 -5
  135. package/dist/esm/core/storage.d.ts +20 -5
  136. package/dist/esm/core/storage.js +113 -21
  137. package/dist/esm/core/stylesheet.d.ts +8 -0
  138. package/dist/esm/core/stylesheet.js +27 -0
  139. package/dist/esm/core/transport.d.ts +2 -0
  140. package/dist/esm/core/transport.js +30 -19
  141. package/dist/esm/core/utils.js +1 -1
  142. package/dist/esm/core/validate.js +2 -2
  143. package/dist/esm/device/appversion.d.ts +10 -6
  144. package/dist/esm/device/appversion.js +37 -4
  145. package/dist/esm/device/index.d.ts +28 -2
  146. package/dist/esm/device/index.js +313 -49
  147. package/dist/esm/engagement/api-rules.d.ts +32 -67
  148. package/dist/esm/engagement/api-rules.js +143 -155
  149. package/dist/esm/engagement/auto-api.js +3 -3
  150. package/dist/esm/engagement/auto-screen.d.ts +2 -0
  151. package/dist/esm/engagement/auto-screen.js +67 -4
  152. package/dist/esm/engagement/defined-events.js +1 -1
  153. package/dist/esm/engagement/send.js +12 -3
  154. package/dist/esm/engagement/session.d.ts +29 -3
  155. package/dist/esm/engagement/session.js +251 -30
  156. package/dist/esm/engagement/track.d.ts +4 -4
  157. package/dist/esm/engagement/track.js +65 -37
  158. package/dist/esm/errors/send.js +2 -2
  159. package/dist/esm/errors/track.d.ts +2 -1
  160. package/dist/esm/errors/track.js +49 -7
  161. package/dist/esm/feedback/controls.d.ts +12 -0
  162. package/dist/esm/feedback/controls.js +103 -26
  163. package/dist/esm/feedback/index.d.ts +8 -7
  164. package/dist/esm/feedback/index.js +34 -13
  165. package/dist/esm/feedback/logs.d.ts +13 -11
  166. package/dist/esm/feedback/logs.js +59 -30
  167. package/dist/esm/feedback/quartz.d.ts +18 -0
  168. package/dist/esm/feedback/quartz.js +99 -0
  169. package/dist/esm/feedback/send.d.ts +5 -2
  170. package/dist/esm/feedback/send.js +31 -31
  171. package/dist/esm/feedback/styles.d.ts +10 -0
  172. package/dist/esm/feedback/styles.js +4 -0
  173. package/dist/esm/feedback/template.d.ts +1 -1
  174. package/dist/esm/feedback/template.js +20 -12
  175. package/dist/esm/feedback/ui.d.ts +21 -6
  176. package/dist/esm/feedback/ui.js +283 -71
  177. package/dist/esm/heatmap/send.d.ts +2 -0
  178. package/dist/esm/heatmap/send.js +3 -5
  179. package/dist/esm/heatmap/track.d.ts +1 -1
  180. package/dist/esm/heatmap/track.js +87 -16
  181. package/dist/esm/index.d.ts +16 -63
  182. package/dist/esm/index.js +148 -83
  183. package/dist/esm/lifecycle.d.ts +21 -3
  184. package/dist/esm/lifecycle.js +359 -98
  185. package/dist/esm/remoteconfig/country.d.ts +4 -0
  186. package/dist/esm/remoteconfig/country.js +70 -0
  187. package/dist/esm/remoteconfig/custom.d.ts +7 -7
  188. package/dist/esm/remoteconfig/custom.js +32 -52
  189. package/dist/esm/remoteconfig/evaluate.d.ts +3 -3
  190. package/dist/esm/remoteconfig/evaluate.js +57 -44
  191. package/dist/esm/remoteconfig/fetch.d.ts +16 -9
  192. package/dist/esm/remoteconfig/fetch.js +120 -39
  193. package/dist/esm/remoteconfig/index.d.ts +19 -8
  194. package/dist/esm/remoteconfig/index.js +82 -40
  195. package/dist/esm/remoteconfig/store.d.ts +15 -7
  196. package/dist/esm/remoteconfig/store.js +68 -36
  197. package/dist/esm/remoteconfig/tz-countries.d.ts +8 -0
  198. package/dist/esm/remoteconfig/tz-countries.js +11 -0
  199. package/dist/{cjs/core → esm/remotelog}/callsite.d.ts +11 -4
  200. package/dist/esm/{core → remotelog}/callsite.js +30 -8
  201. package/dist/esm/remotelog/gate.d.ts +2 -11
  202. package/dist/esm/remotelog/gate.js +10 -32
  203. package/dist/esm/remotelog/index.d.ts +4 -21
  204. package/dist/esm/remotelog/logger.d.ts +11 -17
  205. package/dist/esm/remotelog/logger.js +33 -61
  206. package/dist/esm/remotelog/send.js +13 -13
  207. package/dist/esm/remotelogger/index.d.ts +12 -0
  208. package/dist/esm/remotelogger/index.js +13 -0
  209. package/dist/esm/scheduler.d.ts +3 -1
  210. package/dist/esm/scheduler.js +26 -24
  211. package/dist/esm/types.d.ts +208 -90
  212. package/dist/esm/user/index.js +18 -8
  213. package/dist/feedback.esm.min.js +2 -2
  214. package/dist/feedback.esm.min.js.map +1 -1
  215. package/dist/remoteconfig.esm.min.js +3 -0
  216. package/dist/remoteconfig.esm.min.js.map +1 -0
  217. package/dist/remotelogger.esm.min.js +3 -0
  218. package/dist/remotelogger.esm.min.js.map +1 -0
  219. package/package.json +16 -17
  220. package/dist/chunks/batch-BU_mTpm1.min.js +0 -3
  221. package/dist/chunks/batch-BU_mTpm1.min.js.map +0 -1
  222. package/dist/chunks/logs-Bea5zUW_.min.js +0 -3
  223. package/dist/chunks/logs-Bea5zUW_.min.js.map +0 -1
  224. package/dist/cjs/auto-init.d.ts +0 -8
  225. package/dist/cjs/auto-init.js +0 -32
  226. package/dist/cjs/heatmap/index.d.ts +0 -16
  227. package/dist/cjs/heatmap/index.js +0 -22
  228. package/dist/cjs/remotelog/index.js +0 -55
  229. package/dist/esm/auto-init.d.ts +0 -8
  230. package/dist/esm/auto-init.js +0 -29
  231. package/dist/esm/heatmap/index.d.ts +0 -16
  232. package/dist/esm/heatmap/index.js +0 -17
  233. package/dist/esm/remotelog/index.js +0 -51
  234. package/dist/heatmap.esm.min.js +0 -3
  235. package/dist/heatmap.esm.min.js.map +0 -1
  236. package/dist/style.css +0 -1
@@ -1,5 +1,10 @@
1
+ import { type EngagementType } from './constants.js';
1
2
  import type { TrackingStatus } from '../types.js';
2
- /** DNT counts only when not ignored; when it counts, tracking switches to NO_TRACKING. */
3
+ /**
4
+ * DNT counts only when not ignored; while it counts, tracking is NO_TRACKING (opt_in_status).
5
+ * Decided on every visit and never stored: storing it made one visit with DNT on look like the
6
+ * visitor's own choice, so tracking stayed off after DNT was turned off or ignore_do_not_track set.
7
+ */
3
8
  export declare function hasDoNotTrackEnabled(): boolean;
4
9
  export declare function opt_in_status(): TrackingStatus;
5
10
  export declare function shouldTrackOrSendData(): boolean;
@@ -8,8 +13,11 @@ export declare function shouldTrackOrSendData(): boolean;
8
13
  * and consent / server flags allow tracking.
9
14
  */
10
15
  export declare function canTrack(caller: string): boolean;
11
- /** canTrack plus the server's `engagementtracking` flag from getupdates (events, screens, sessions, api calls). */
12
- 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;
13
21
  /**
14
22
  * canTrack plus the server's heatmap flag (getsdkconfig module 18).
15
23
  *
@@ -17,7 +25,13 @@ export declare function canTrackEngagement(caller: string): boolean;
17
25
  * well want events while declining to have every click's coordinates recorded.
18
26
  */
19
27
  export declare function canTrackHeatmap(caller: string): boolean;
20
- /** canTrack plus the server's `errortracking` flag from getupdates. */
28
+ /** canTrack plus the server's js_error module (15) from getsdkconfig. */
21
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;
22
36
  export declare function setTrackingStatus(trackingState: TrackingStatus): void;
23
37
  export declare function getTrackingStatus(): TrackingStatus;
@@ -1,4 +1,4 @@
1
- /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta | (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('./constants.js');
@@ -9,15 +9,17 @@ var storage = require('./storage.js');
9
9
  var env = require('./env.js');
10
10
  var hooks = require('./hooks.js');
11
11
 
12
- /** DNT counts only when not ignored; when it counts, tracking switches to NO_TRACKING. */
12
+ /**
13
+ * DNT counts only when not ignored; while it counts, tracking is NO_TRACKING (opt_in_status).
14
+ * Decided on every visit and never stored: storing it made one visit with DNT on look like the
15
+ * visitor's own choice, so tracking stayed off after DNT was turned off or ignore_do_not_track set.
16
+ */
13
17
  function hasDoNotTrackEnabled() {
14
18
  if (state._ZAP._ignoreDnt) {
15
19
  return false;
16
20
  }
17
21
  if (env.isDntOn()) {
18
- logger.Console.warn('hasDoNotTrackEnabled: DoNotTrack is enabled'); // no i18n
19
- setTrackingStatus(constants.AP_TRACKING_STATUS.NO_TRACKING);
20
- logger.Console.log('hasDoNotTrackEnabled: Setting tracking status to NO_TRACKING'); // no i18n
22
+ logger.Console.warn('hasDoNotTrackEnabled: DoNotTrack is enabled, so nothing is tracked'); // no i18n
21
23
  return true;
22
24
  }
23
25
  return false;
@@ -43,7 +45,7 @@ function shouldTrackOrSendData() {
43
45
  */
44
46
  function canTrack(caller) {
45
47
  if (!state._ZAP._token) {
46
- logger.Console.warn('apptics.' + caller + ': You must call apptics.init() first'); // no i18n
48
+ logger.Console.warn('apptics.' + caller + ': You must call Apptics.init() first'); // no i18n
47
49
  return false;
48
50
  }
49
51
  if (env.is_apptics_disabled()) {
@@ -51,13 +53,16 @@ function canTrack(caller) {
51
53
  }
52
54
  return shouldTrackOrSendData();
53
55
  }
54
- /** canTrack plus the server's `engagementtracking` flag from getupdates (events, screens, sessions, api calls). */
55
- function canTrackEngagement(caller) {
56
+ /**
57
+ * canTrack plus the server's flag for this kind of item: getsdkconfig's event (5), api (6),
58
+ * screen (10) and session (11) modules, each switched on its own.
59
+ */
60
+ function canTrackEngagement(caller, type) {
56
61
  if (!canTrack(caller)) {
57
62
  return false;
58
63
  }
59
- if (!state._ZAP._engagementTracking) {
60
- logger.Console.log('apptics.' + caller + ': engagement tracking is turned off by the server'); // no i18n
64
+ if (!state._ZAP._engagementTracking[type]) {
65
+ logger.Console.log('apptics.' + caller + ': ' + type + ' tracking is turned off by the server'); // no i18n
61
66
  return false;
62
67
  }
63
68
  return true;
@@ -78,7 +83,7 @@ function canTrackHeatmap(caller) {
78
83
  }
79
84
  return true;
80
85
  }
81
- /** canTrack plus the server's `errortracking` flag from getupdates. */
86
+ /** canTrack plus the server's js_error module (15) from getsdkconfig. */
82
87
  function canTrackErrors(caller) {
83
88
  if (!canTrack(caller)) {
84
89
  return false;
@@ -89,17 +94,27 @@ function canTrackErrors(caller) {
89
94
  }
90
95
  return true;
91
96
  }
97
+ /**
98
+ * Stores the visitor's tracking status without telling the server. True when it changed.
99
+ * user/register uses this alone: the server learns of the user from that call, so a device/add
100
+ * after it would only repeat a registration the device already has.
101
+ */
102
+ function recordTrackingStatus(trackingState) {
103
+ if (storage.tracking_preference.opt_in_status() == trackingState) {
104
+ return false;
105
+ }
106
+ storage.tracking_preference.update_status(trackingState);
107
+ state._ZAP._devicestatus = storage.tracking_preference.opt_in_status();
108
+ return true;
109
+ }
92
110
  function setTrackingStatus(trackingState) {
93
111
  if (utils.isEmpty(trackingState)) {
94
112
  logger.Console.warn('setTrackingStatus: trackingStatus is Empty'); // no i18n
95
113
  return;
96
114
  }
97
- if (storage.tracking_preference.opt_in_status() == trackingState) {
115
+ if (!recordTrackingStatus(trackingState)) {
98
116
  return;
99
117
  }
100
- storage.tracking_preference.update_status(trackingState);
101
- state._ZAP._devicestatus = storage.tracking_preference.opt_in_status();
102
- state._ZAP._isanonrequired = storage.tracking_preference.opt_in_status() == constants.AP_TRACKING_STATUS.USAGE_TRACKING_WITH_PII ? false : state._ZAP._isanonrequired;
103
118
  if (storage.tracking_preference.opt_in_status() != constants.AP_TRACKING_STATUS.NO_TRACKING) {
104
119
  logger.Console.log('setTrackingStatus: Updating device info with new tracking status'); // no i18n
105
120
  hooks.hooks.updateDevice(state._ZAP._device_info).then(function (result) {
@@ -126,5 +141,6 @@ exports.canTrackHeatmap = canTrackHeatmap;
126
141
  exports.getTrackingStatus = getTrackingStatus;
127
142
  exports.hasDoNotTrackEnabled = hasDoNotTrackEnabled;
128
143
  exports.opt_in_status = opt_in_status;
144
+ exports.recordTrackingStatus = recordTrackingStatus;
129
145
  exports.setTrackingStatus = setTrackingStatus;
130
146
  exports.shouldTrackOrSendData = shouldTrackOrSendData;
@@ -1,3 +1,19 @@
1
+ /**
2
+ * A screen_routes entry as init() keeps it, ready to match: a route pattern, or an exact path or a
3
+ * regular expression with the name it records.
4
+ */
5
+ export type ScreenRouteRule = {
6
+ kind: 'pattern';
7
+ pattern: string;
8
+ } | {
9
+ kind: 'equals';
10
+ path: string;
11
+ name: string;
12
+ } | {
13
+ kind: 'regex';
14
+ regex: RegExp;
15
+ name: string;
16
+ };
1
17
  export declare const AP_TRACKING_STATUS: Readonly<{
2
18
  readonly USAGE_TRACKING_WITH_PII: 1;
3
19
  readonly USAGE_TRACKING_WITHOUT_PII: 4;
@@ -18,6 +34,8 @@ export declare const AP_CONSTANTS: Readonly<{
18
34
  readonly SUCCESS: "success";
19
35
  readonly BROWSER: "Browser";
20
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';
21
39
  export declare const DEFAULT_API_PATHS: Readonly<{
22
40
  readonly addversion: "app/addversion";
23
41
  readonly regdevice: "device/add";
@@ -63,9 +81,13 @@ export declare const SDK_MODULE: Readonly<{
63
81
  * authority. Where they disagree, getsdkconfig wins.
64
82
  */
65
83
  readonly REMOTE_CONFIG: "2";
84
+ readonly EVENT: "5";
85
+ readonly API: "6";
86
+ readonly SCREEN: "10";
66
87
  readonly SESSION: "11";
67
88
  readonly FEEDBACK: "12";
68
- 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";
69
91
  readonly REMOTE_LOGGER: "17";
70
92
  readonly HEATMAP: "18";
71
93
  }>;
@@ -81,9 +103,10 @@ export declare const LOG_FILENAME_MAX = 100;
81
103
  */
82
104
  export declare const DEVICE_NAME_MAX = 100;
83
105
  /**
84
- * The `level` every line goes out with. Everything the remote logger carries is a failure inside
85
- * the SDK — logFailure is its only caller — so the level never varies. 3 is what the v2 reference
86
- * shows in its only example; the scale itself is not documented anywhere we can see.
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.
87
110
  */
88
111
  export declare const REMOTE_LOG_LEVEL = 3;
89
112
  /**
@@ -93,31 +116,18 @@ export declare const REMOTE_LOG_LEVEL = 3;
93
116
  * enough that a tab left open overnight is not still sending every call to its debug twin.
94
117
  */
95
118
  export declare const DEBUG_IDLE_MS: number;
96
- /** 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. */
97
120
  export declare const DEFAULT_INACTIVE_MINUTES = 30;
98
121
  /** Global defaults. `state._config` holds a mutable copy per init. */
99
122
  export declare const AP_CONFIG: Readonly<{
100
123
  endpoint: "/sdk/web/";
101
124
  method: "POST";
102
- transport: "XHR";
103
- track_link_timeout: 300;
104
- cookie_expiration_days: 365;
105
- storage_type: "localStorage";
106
- enable_batch_requests: true;
107
125
  batch_size: 50;
108
126
  batch_flush_interval: 30000;
109
127
  getupdates_interval: 120000;
110
128
  batch_request_timeout: 7;
111
- auto_starts_batch: true;
112
- mode: 1;
113
- default_group_name: "default";
114
- default_optin_status: number;
115
- enable_pageview_tracking: false;
116
- save_referrer: true;
117
129
  debug: boolean;
118
- track_by_default: true;
119
130
  ignore_do_not_track: boolean;
120
- remote_log: boolean;
121
131
  /**
122
132
  * Wrap XHR and fetch to record the app's API calls without it calling startTrackApi(). Off by
123
133
  * default: the hostnames and paths of every request an app makes is a wider grant than events
@@ -130,15 +140,26 @@ export declare const AP_CONFIG: Readonly<{
130
140
  */
131
141
  track_screen: boolean;
132
142
  /**
133
- * Print each app logger line to the browser console as well, as Android's showLogs prints to
134
- * Logcat. Off by default; console_log is the SDK's own activity, this is the app's lines.
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.
135
145
  */
136
- show_logs: boolean;
146
+ track_error: boolean;
137
147
  /**
138
- * Record sessions automatically. On by default; false is Android's
139
- * automaticSessionsTrackingStatus = false: no sessions, while events and screens still are.
148
+ * Record clicks on elements tagged `apeventaction` (or `data-apeventaction`) as events. On by
149
+ * default; AppticsEvent.setClickTracking() switches it later.
140
150
  */
141
- track_session: boolean;
151
+ track_click: boolean;
152
+ /**
153
+ * How automatic screen tracking names a path, as init() keeps the config's screen_routes: route
154
+ * patterns (`/users/{id}/orders`, each id recorded as a star), exact paths and regular
155
+ * expressions with a name. Tried in order; a path none matches keeps its own name.
156
+ */
157
+ screen_routes: ScreenRouteRule[];
158
+ /**
159
+ * The feedback form's theme: 'light', 'dark', or 'auto' to follow the visitor's system setting.
160
+ * 'auto' by default.
161
+ */
162
+ feedback_theme: "light" | "dark" | "auto";
142
163
  /**
143
164
  * How long a visit must last before its session is stored, in milliseconds. A shorter visit with
144
165
  * nothing tracked in it is dropped: a bounce or a crawler is not a session. Anything tracked
@@ -187,7 +208,13 @@ export type ApConfig = {
187
208
  * What init() must be given. Everything else the SDK needs — aaid, the portal and project ids that
188
209
  * go in every url — comes back from app/addversion, which these four are enough to call.
189
210
  */
190
- export declare const REQUIRED_CONFIG: readonly ["serviceUrl", "zak", "identifier", "appversion"];
211
+ export declare const REQUIRED_CONFIG: readonly ["base_url", "auth_key", "app_domain", "appversion"];
212
+ /**
213
+ * The init() keys and the names the SDK keeps them under inside (and in app_version_info, which
214
+ * already-visited browsers have stored): base_url is the host, auth_key the `zak` header, and
215
+ * app_domain the app's identifier.
216
+ */
217
+ export declare const CONFIG_KEYS: Readonly<Record<string, string>>;
191
218
  /**
192
219
  * Paths with a `debug/` twin. The debug endpoints take the same body and answer with a request id
193
220
  * and a link to the server-side logs for that request, which is how a payload is traced end to
@@ -207,6 +234,9 @@ export declare const RETRY_CAPABLE_PATHS: Readonly<Record<string, boolean>>;
207
234
  * called before those ids are known, so it cannot carry them.
208
235
  */
209
236
  export declare const PATHS_WITHOUT_ORG: Readonly<Record<string, boolean>>;
210
- /** Console-snippet names accepted for the canonical keys above. */
211
- export declare const CONFIG_ALIASES: Readonly<Record<string, string>>;
237
+ /**
238
+ * Earlier names of the init() keys: 2.0.0-beta's serviceUrl, zak and identifier, and the 1.x
239
+ * console snippet's base_domain and token. Still read, with a warning naming the key to use.
240
+ */
241
+ export declare const RETIRED_CONFIG_NAMES: Readonly<Record<string, string>>;
212
242
  export declare const BLOCKED_WS: readonly string[];
@@ -1,4 +1,4 @@
1
- /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta | (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
  const AP_TRACKING_STATUS = Object.freeze({
@@ -85,9 +85,13 @@ const SDK_MODULE = Object.freeze({
85
85
  * authority. Where they disagree, getsdkconfig wins.
86
86
  */
87
87
  REMOTE_CONFIG: '2', // no i18n
88
+ EVENT: '5', // no i18n
89
+ API: '6', // no i18n
90
+ SCREEN: '10', // no i18n
88
91
  SESSION: '11', // no i18n
89
92
  FEEDBACK: '12', // no i18n
90
- CRASH: '13', // no i18n
93
+ /** Uncaught and reported JavaScript errors: js_error. 13 (crash) and 14 (nonfatal) are the native SDKs'. */
94
+ JS_ERROR: '15', // no i18n
91
95
  REMOTE_LOGGER: '17', // no i18n
92
96
  HEATMAP: '18', // no i18n
93
97
  });
@@ -103,9 +107,10 @@ const LOG_FILENAME_MAX = 100;
103
107
  */
104
108
  const DEVICE_NAME_MAX = 100;
105
109
  /**
106
- * The `level` every line goes out with. Everything the remote logger carries is a failure inside
107
- * the SDK — logFailure is its only caller — so the level never varies. 3 is what the v2 reference
108
- * shows in its only example; the scale itself is not documented anywhere we can see.
110
+ * The `level` a remote log line goes out with when it has none of its own: 3, Info. Every line an
111
+ * app writes with AppticsLogger carries its level (1 verbose to 5 error, see LOG_LEVEL in
112
+ * remotelog/logger.ts). Only a line an older SDK stored, when the SDK logged its own failures
113
+ * there, has none; it is sent as Info rather than having the batch refused for a missing level.
109
114
  */
110
115
  const REMOTE_LOG_LEVEL = 3;
111
116
  /**
@@ -115,33 +120,19 @@ const REMOTE_LOG_LEVEL = 3;
115
120
  * enough that a tab left open overnight is not still sending every call to its debug twin.
116
121
  */
117
122
  const DEBUG_IDLE_MS = 60 * 60 * 1000;
118
- /** Idle minutes that end a session. Lives on state, not in _config, but defaults here. */
123
+ /** Minutes a tab can be inactive before its session ends. Lives on state, not in _config, but defaults here. */
119
124
  const DEFAULT_INACTIVE_MINUTES = 30;
120
125
  /** Global defaults. `state._config` holds a mutable copy per init. */
121
126
  const AP_CONFIG = Object.freeze({
122
127
  // the version is per path (API_VERSIONS); this is only the part before it
123
128
  endpoint: '/sdk/web/', // no i18n
124
129
  method: 'POST', // no i18n
125
- transport: 'XHR', // no i18n
126
- track_link_timeout: 300,
127
- cookie_expiration_days: 365,
128
- storage_type: 'localStorage', // no i18n
129
- enable_batch_requests: true,
130
130
  batch_size: 50,
131
131
  batch_flush_interval: 30000,
132
- getupdates_interval: 120000, // 2 minutes in milliseconds
132
+ getupdates_interval: 120000, // 2 minutes in milliseconds, when getsdkconfig gives no next_check_after
133
133
  batch_request_timeout: 7,
134
- auto_starts_batch: true,
135
- mode: 1,
136
- default_group_name: 'default', // no i18n
137
- default_optin_status: AP_TRACKING_STATUS.USAGE_TRACKING_WITHOUT_PII,
138
- enable_pageview_tracking: false,
139
- save_referrer: true,
140
134
  debug: false,
141
- track_by_default: true,
142
135
  ignore_do_not_track: false,
143
- // the SDK's own failure reports to the Remote Logger page: off unless the app passes remote_log: true
144
- remote_log: false,
145
136
  /**
146
137
  * Wrap XHR and fetch to record the app's API calls without it calling startTrackApi(). Off by
147
138
  * default: the hostnames and paths of every request an app makes is a wider grant than events
@@ -154,15 +145,26 @@ const AP_CONFIG = Object.freeze({
154
145
  */
155
146
  track_screen: true,
156
147
  /**
157
- * Print each app logger line to the browser console as well, as Android's showLogs prints to
158
- * Logcat. Off by default; console_log is the SDK's own activity, this is the app's lines.
148
+ * Record uncaught errors and unhandled promise rejections, from the window's `error` and
149
+ * `unhandledrejection` events. On by default; AppticsError.setErrorTracking() switches it later.
159
150
  */
160
- show_logs: false,
151
+ track_error: true,
161
152
  /**
162
- * Record sessions automatically. On by default; false is Android's
163
- * automaticSessionsTrackingStatus = false: no sessions, while events and screens still are.
153
+ * Record clicks on elements tagged `apeventaction` (or `data-apeventaction`) as events. On by
154
+ * default; AppticsEvent.setClickTracking() switches it later.
164
155
  */
165
- track_session: true,
156
+ track_click: true,
157
+ /**
158
+ * How automatic screen tracking names a path, as init() keeps the config's screen_routes: route
159
+ * patterns (`/users/{id}/orders`, each id recorded as a star), exact paths and regular
160
+ * expressions with a name. Tried in order; a path none matches keeps its own name.
161
+ */
162
+ screen_routes: [],
163
+ /**
164
+ * The feedback form's theme: 'light', 'dark', or 'auto' to follow the visitor's system setting.
165
+ * 'auto' by default.
166
+ */
167
+ feedback_theme: 'auto',
166
168
  /**
167
169
  * How long a visit must last before its session is stored, in milliseconds. A shorter visit with
168
170
  * nothing tracked in it is dropped: a bounce or a crawler is not a session. Anything tracked
@@ -208,7 +210,17 @@ const AP_CONFIG = Object.freeze({
208
210
  * What init() must be given. Everything else the SDK needs — aaid, the portal and project ids that
209
211
  * go in every url — comes back from app/addversion, which these four are enough to call.
210
212
  */
211
- const REQUIRED_CONFIG = Object.freeze(['serviceUrl', 'zak', 'identifier', 'appversion']); // no i18n
213
+ const REQUIRED_CONFIG = Object.freeze(['base_url', 'auth_key', 'app_domain', 'appversion']); // no i18n
214
+ /**
215
+ * The init() keys and the names the SDK keeps them under inside (and in app_version_info, which
216
+ * already-visited browsers have stored): base_url is the host, auth_key the `zak` header, and
217
+ * app_domain the app's identifier.
218
+ */
219
+ const CONFIG_KEYS = Object.freeze({
220
+ base_url: 'serviceUrl', // no i18n
221
+ auth_key: 'zak', // no i18n
222
+ app_domain: 'identifier', // no i18n
223
+ });
212
224
  /**
213
225
  * Paths with a `debug/` twin. The debug endpoints take the same body and answer with a request id
214
226
  * and a link to the server-side logs for that request, which is how a payload is traced end to
@@ -243,10 +255,16 @@ const RETRY_CAPABLE_PATHS = Object.freeze({
243
255
  const PATHS_WITHOUT_ORG = Object.freeze({
244
256
  addversion: true, // no i18n
245
257
  });
246
- /** Console-snippet names accepted for the canonical keys above. */
247
- const CONFIG_ALIASES = Object.freeze({
248
- serviceUrl: 'base_domain', // no i18n
249
- zak: 'token', // no i18n
258
+ /**
259
+ * Earlier names of the init() keys: 2.0.0-beta's serviceUrl, zak and identifier, and the 1.x
260
+ * console snippet's base_domain and token. Still read, with a warning naming the key to use.
261
+ */
262
+ const RETIRED_CONFIG_NAMES = Object.freeze({
263
+ serviceUrl: 'base_url', // no i18n
264
+ base_domain: 'base_url', // no i18n
265
+ zak: 'auth_key', // no i18n
266
+ token: 'auth_key', // no i18n
267
+ identifier: 'app_domain', // no i18n
250
268
  });
251
269
  // crawlers reference
252
270
  // https://developers.google.com/search/docs/advanced/crawling/overview-google-crawlers
@@ -283,7 +301,7 @@ exports.AP_FEEDBACK_TYPE = AP_FEEDBACK_TYPE;
283
301
  exports.AP_LOG_MODULE = AP_LOG_MODULE;
284
302
  exports.AP_TRACKING_STATUS = AP_TRACKING_STATUS;
285
303
  exports.BLOCKED_WS = BLOCKED_WS;
286
- exports.CONFIG_ALIASES = CONFIG_ALIASES;
304
+ exports.CONFIG_KEYS = CONFIG_KEYS;
287
305
  exports.CONSOLE_LOG_MAX_BODY = CONSOLE_LOG_MAX_BODY;
288
306
  exports.DEBUG_CAPABLE_PATHS = DEBUG_CAPABLE_PATHS;
289
307
  exports.DEBUG_IDLE_MS = DEBUG_IDLE_MS;
@@ -295,5 +313,6 @@ exports.LOG_FUNCTION_MAX = LOG_FUNCTION_MAX;
295
313
  exports.PATHS_WITHOUT_ORG = PATHS_WITHOUT_ORG;
296
314
  exports.REMOTE_LOG_LEVEL = REMOTE_LOG_LEVEL;
297
315
  exports.REQUIRED_CONFIG = REQUIRED_CONFIG;
316
+ exports.RETIRED_CONFIG_NAMES = RETIRED_CONFIG_NAMES;
298
317
  exports.RETRY_CAPABLE_PATHS = RETRY_CAPABLE_PATHS;
299
318
  exports.SDK_MODULE = SDK_MODULE;
@@ -1,10 +1,12 @@
1
1
  import type { Dict, QueueItem } from '../types.js';
2
- export type QueueName = 'engagements' | 'errors' | 'logs' | 'consolelogs' | 'heatmaps';
2
+ export type QueueName = 'engagements' | 'errors' | 'feedbacklogs' | 'remotelogs' | 'heatmaps';
3
3
  /** One storage implementation. storage.ts talks only to this interface. */
4
4
  export interface Backend {
5
5
  readonly kind: 'indexeddb' | 'localstorage';
6
6
  loadSettings(): Promise<Dict>;
7
7
  putSetting(key: string, value: unknown): Promise<void>;
8
+ /** Removes the key itself, so it is no longer in storage at all. */
9
+ deleteSetting(key: string): Promise<void>;
8
10
  clearSettings(): Promise<void>;
9
11
  /** Items in insertion order. */
10
12
  queueAll(store: QueueName): Promise<QueueItem[]>;
@@ -16,16 +18,22 @@ export interface Backend {
16
18
  importAll?(settings: Dict, queues: Record<QueueName, QueueItem[]>): Promise<void>;
17
19
  }
18
20
  export declare const DB_NAME = "apptics";
19
- export declare const DB_VERSION = 3;
20
- /** 1.x localStorage keys; also the layout of the localStorage backend. */
21
+ export declare const DB_VERSION = 4;
22
+ /** The types a feedback entry is stored under: an addFeedbackLog() line, an addDiagnosticsInfo() entry. */
23
+ export declare const FEEDBACK_LOG = "feedbacklog";
24
+ export declare const FEEDBACK_DIAGNOSTICS = "feedbackdiagnostics";
25
+ /** A feedback entry from 1.x or 2.0.0-beta, with the type it is stored under now. */
26
+ export declare function renameFeedbackType(item: QueueItem): QueueItem;
27
+ /** 1.x localStorage keys, read once to bring 1.x data into IndexedDB (see migrateLegacy). */
21
28
  export declare const LEGACY_KEYS: Readonly<{
22
29
  readonly settings: "apptics-device-info";
23
30
  readonly engagements: "apptics-engagements-transactions";
24
31
  readonly errors: "apptics-errors-transactions";
25
32
  readonly logs: "apptics-log-transactions";
26
33
  readonly consolelogs: "apptics-consolelog-transactions";
27
- readonly heatmaps: "apptics-heatmap-transactions";
28
34
  }>;
35
+ /** The localStorage backend's layout, for a browser where IndexedDB will not open. */
36
+ export declare const LOCAL_KEYS: Readonly<Record<'settings' | QueueName, string>>;
29
37
  /** Shape guards shared by both backends and the 1.x migration. */
30
38
  export declare function asList(value: unknown): QueueItem[];
31
39
  export declare function asDict(value: unknown): Dict;