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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/CHANGELOG.md +80 -16
  2. package/README.md +187 -100
  3. package/dist/apptics.esm.min.js +2 -2
  4. package/dist/apptics.esm.min.js.map +1 -1
  5. package/dist/apptics.min.js +2 -2
  6. package/dist/apptics.min.js.map +1 -1
  7. package/dist/chunks/lifecycle-C6m1W7jo.min.js +3 -0
  8. package/dist/chunks/lifecycle-C6m1W7jo.min.js.map +1 -0
  9. package/dist/chunks/send-CgUO82ne.min.js +3 -0
  10. package/dist/chunks/send-CgUO82ne.min.js.map +1 -0
  11. package/dist/cjs/core/attempts.js +1 -1
  12. package/dist/cjs/core/batch.js +1 -2
  13. package/dist/cjs/core/consent.d.ts +13 -3
  14. package/dist/cjs/core/consent.js +24 -10
  15. package/dist/cjs/core/constants.d.ts +22 -17
  16. package/dist/cjs/core/constants.js +22 -19
  17. package/dist/cjs/core/db.js +1 -1
  18. package/dist/cjs/core/debug.js +1 -1
  19. package/dist/cjs/core/env.d.ts +0 -3
  20. package/dist/cjs/core/env.js +1 -9
  21. package/dist/cjs/core/framework-id.d.ts +1 -1
  22. package/dist/cjs/core/framework-id.js +3 -3
  23. package/dist/cjs/core/guard.js +1 -1
  24. package/dist/cjs/core/hooks.d.ts +5 -0
  25. package/dist/cjs/core/hooks.js +2 -1
  26. package/dist/cjs/core/locks.js +1 -1
  27. package/dist/cjs/core/logger.js +1 -1
  28. package/dist/cjs/core/state.d.ts +6 -4
  29. package/dist/cjs/core/state.js +2 -4
  30. package/dist/cjs/core/storage.js +1 -4
  31. package/dist/cjs/core/stylesheet.js +1 -1
  32. package/dist/cjs/core/transport.js +13 -16
  33. package/dist/cjs/core/utils.js +1 -1
  34. package/dist/cjs/core/validate.js +1 -1
  35. package/dist/cjs/device/appversion.d.ts +10 -1
  36. package/dist/cjs/device/appversion.js +26 -3
  37. package/dist/cjs/device/index.d.ts +17 -2
  38. package/dist/cjs/device/index.js +195 -27
  39. package/dist/cjs/engagement/api-rules.js +1 -1
  40. package/dist/cjs/engagement/auto-api.js +1 -1
  41. package/dist/cjs/engagement/auto-screen.js +1 -1
  42. package/dist/cjs/engagement/defined-events.js +1 -1
  43. package/dist/cjs/engagement/send.js +7 -3
  44. package/dist/cjs/engagement/session.d.ts +17 -0
  45. package/dist/cjs/engagement/session.js +95 -4
  46. package/dist/cjs/engagement/track.d.ts +4 -4
  47. package/dist/cjs/engagement/track.js +15 -12
  48. package/dist/cjs/errors/send.js +2 -2
  49. package/dist/cjs/errors/track.d.ts +2 -1
  50. package/dist/cjs/errors/track.js +6 -4
  51. package/dist/cjs/feedback/controls.d.ts +6 -0
  52. package/dist/cjs/feedback/controls.js +74 -25
  53. package/dist/cjs/feedback/index.js +1 -1
  54. package/dist/cjs/feedback/logs.d.ts +3 -6
  55. package/dist/cjs/feedback/logs.js +8 -18
  56. package/dist/cjs/feedback/quartz.js +1 -1
  57. package/dist/cjs/feedback/send.d.ts +2 -2
  58. package/dist/cjs/feedback/send.js +4 -27
  59. package/dist/cjs/feedback/styles.js +2 -2
  60. package/dist/cjs/feedback/template.d.ts +1 -1
  61. package/dist/cjs/feedback/template.js +9 -1
  62. package/dist/cjs/feedback/ui.d.ts +7 -0
  63. package/dist/cjs/feedback/ui.js +160 -25
  64. package/dist/cjs/heatmap/send.d.ts +2 -0
  65. package/dist/cjs/heatmap/send.js +3 -5
  66. package/dist/cjs/heatmap/track.js +1 -1
  67. package/dist/cjs/index.d.ts +1 -2
  68. package/dist/cjs/index.js +54 -17
  69. package/dist/cjs/lifecycle.d.ts +13 -2
  70. package/dist/cjs/lifecycle.js +122 -54
  71. package/dist/cjs/remoteconfig/country.js +1 -1
  72. package/dist/cjs/remoteconfig/custom.js +1 -1
  73. package/dist/cjs/remoteconfig/evaluate.js +1 -1
  74. package/dist/cjs/remoteconfig/fetch.d.ts +17 -10
  75. package/dist/cjs/remoteconfig/fetch.js +126 -31
  76. package/dist/cjs/remoteconfig/index.d.ts +13 -4
  77. package/dist/cjs/remoteconfig/index.js +36 -20
  78. package/dist/cjs/remoteconfig/store.d.ts +15 -7
  79. package/dist/cjs/remoteconfig/store.js +68 -35
  80. package/dist/cjs/remoteconfig/tz-countries.js +1 -1
  81. package/dist/cjs/{core → remotelog}/callsite.d.ts +5 -4
  82. package/dist/cjs/{core → remotelog}/callsite.js +6 -5
  83. package/dist/cjs/remotelog/gate.js +1 -1
  84. package/dist/cjs/remotelog/logger.js +2 -2
  85. package/dist/cjs/remotelog/send.js +2 -2
  86. package/dist/cjs/remotelogger/index.js +1 -1
  87. package/dist/cjs/scheduler.d.ts +3 -1
  88. package/dist/cjs/scheduler.js +24 -21
  89. package/dist/cjs/types.d.ts +61 -16
  90. package/dist/cjs/user/index.js +6 -2
  91. package/dist/esm/core/attempts.js +1 -1
  92. package/dist/esm/core/batch.js +1 -2
  93. package/dist/esm/core/consent.d.ts +13 -3
  94. package/dist/esm/core/consent.js +24 -11
  95. package/dist/esm/core/constants.d.ts +22 -17
  96. package/dist/esm/core/constants.js +22 -19
  97. package/dist/esm/core/db.js +1 -1
  98. package/dist/esm/core/debug.js +1 -1
  99. package/dist/esm/core/env.d.ts +0 -3
  100. package/dist/esm/core/env.js +2 -9
  101. package/dist/esm/core/framework-id.d.ts +1 -1
  102. package/dist/esm/core/framework-id.js +3 -3
  103. package/dist/esm/core/guard.js +1 -1
  104. package/dist/esm/core/hooks.d.ts +5 -0
  105. package/dist/esm/core/hooks.js +2 -1
  106. package/dist/esm/core/locks.js +1 -1
  107. package/dist/esm/core/logger.js +1 -1
  108. package/dist/esm/core/state.d.ts +6 -4
  109. package/dist/esm/core/state.js +2 -4
  110. package/dist/esm/core/storage.js +1 -4
  111. package/dist/esm/core/stylesheet.js +1 -1
  112. package/dist/esm/core/transport.js +13 -16
  113. package/dist/esm/core/utils.js +1 -1
  114. package/dist/esm/core/validate.js +1 -1
  115. package/dist/esm/device/appversion.d.ts +10 -1
  116. package/dist/esm/device/appversion.js +26 -4
  117. package/dist/esm/device/index.d.ts +17 -2
  118. package/dist/esm/device/index.js +195 -30
  119. package/dist/esm/engagement/api-rules.js +1 -1
  120. package/dist/esm/engagement/auto-api.js +1 -1
  121. package/dist/esm/engagement/auto-screen.js +1 -1
  122. package/dist/esm/engagement/defined-events.js +1 -1
  123. package/dist/esm/engagement/send.js +7 -3
  124. package/dist/esm/engagement/session.d.ts +17 -0
  125. package/dist/esm/engagement/session.js +93 -5
  126. package/dist/esm/engagement/track.d.ts +4 -4
  127. package/dist/esm/engagement/track.js +16 -13
  128. package/dist/esm/errors/send.js +2 -2
  129. package/dist/esm/errors/track.d.ts +2 -1
  130. package/dist/esm/errors/track.js +6 -4
  131. package/dist/esm/feedback/controls.d.ts +6 -0
  132. package/dist/esm/feedback/controls.js +74 -26
  133. package/dist/esm/feedback/index.js +1 -1
  134. package/dist/esm/feedback/logs.d.ts +3 -6
  135. package/dist/esm/feedback/logs.js +8 -18
  136. package/dist/esm/feedback/quartz.js +1 -1
  137. package/dist/esm/feedback/send.d.ts +2 -2
  138. package/dist/esm/feedback/send.js +6 -29
  139. package/dist/esm/feedback/styles.js +2 -2
  140. package/dist/esm/feedback/template.d.ts +1 -1
  141. package/dist/esm/feedback/template.js +9 -1
  142. package/dist/esm/feedback/ui.d.ts +7 -0
  143. package/dist/esm/feedback/ui.js +161 -26
  144. package/dist/esm/heatmap/send.d.ts +2 -0
  145. package/dist/esm/heatmap/send.js +3 -5
  146. package/dist/esm/heatmap/track.js +1 -1
  147. package/dist/esm/index.d.ts +1 -2
  148. package/dist/esm/index.js +57 -20
  149. package/dist/esm/lifecycle.d.ts +13 -2
  150. package/dist/esm/lifecycle.js +126 -60
  151. package/dist/esm/remoteconfig/country.js +1 -1
  152. package/dist/esm/remoteconfig/custom.js +1 -1
  153. package/dist/esm/remoteconfig/evaluate.js +1 -1
  154. package/dist/esm/remoteconfig/fetch.d.ts +17 -10
  155. package/dist/esm/remoteconfig/fetch.js +127 -32
  156. package/dist/esm/remoteconfig/index.d.ts +13 -4
  157. package/dist/esm/remoteconfig/index.js +36 -20
  158. package/dist/esm/remoteconfig/store.d.ts +15 -7
  159. package/dist/esm/remoteconfig/store.js +68 -36
  160. package/dist/esm/remoteconfig/tz-countries.js +1 -1
  161. package/dist/esm/{core → remotelog}/callsite.d.ts +5 -4
  162. package/dist/esm/{core → remotelog}/callsite.js +6 -5
  163. package/dist/esm/remotelog/gate.js +1 -1
  164. package/dist/esm/remotelog/logger.js +2 -2
  165. package/dist/esm/remotelog/send.js +2 -2
  166. package/dist/esm/remotelogger/index.js +1 -1
  167. package/dist/esm/scheduler.d.ts +3 -1
  168. package/dist/esm/scheduler.js +25 -23
  169. package/dist/esm/types.d.ts +61 -16
  170. package/dist/esm/user/index.js +7 -3
  171. package/dist/feedback.esm.min.js +2 -2
  172. package/dist/feedback.esm.min.js.map +1 -1
  173. package/dist/remoteconfig.esm.min.js +3 -0
  174. package/dist/remoteconfig.esm.min.js.map +1 -0
  175. package/dist/remotelogger.esm.min.js +3 -0
  176. package/dist/remotelogger.esm.min.js.map +1 -0
  177. package/package.json +3 -2
  178. package/dist/chunks/lifecycle-VYr43KcB.min.js +0 -3
  179. package/dist/chunks/lifecycle-VYr43KcB.min.js.map +0 -1
  180. package/dist/cjs/auto-init.d.ts +0 -8
  181. package/dist/cjs/auto-init.js +0 -32
  182. package/dist/esm/auto-init.d.ts +0 -8
  183. package/dist/esm/auto-init.js +0 -29
@@ -1,3 +1,4 @@
1
+ import { type EngagementType } from './constants.js';
1
2
  import type { TrackingStatus } from '../types.js';
2
3
  /**
3
4
  * DNT counts only when not ignored; while it counts, tracking is NO_TRACKING (opt_in_status).
@@ -12,8 +13,11 @@ export declare function shouldTrackOrSendData(): boolean;
12
13
  * and consent / server flags allow tracking.
13
14
  */
14
15
  export declare function canTrack(caller: string): boolean;
15
- /** canTrack plus the server's `engagementtracking` flag from getupdates (events, screens, sessions, api calls). */
16
- export declare function canTrackEngagement(caller: string): boolean;
16
+ /**
17
+ * canTrack plus the server's flag for this kind of item: getsdkconfig's event (5), api (6),
18
+ * screen (10) and session (11) modules, each switched on its own.
19
+ */
20
+ export declare function canTrackEngagement(caller: string, type: EngagementType): boolean;
17
21
  /**
18
22
  * canTrack plus the server's heatmap flag (getsdkconfig module 18).
19
23
  *
@@ -21,7 +25,13 @@ export declare function canTrackEngagement(caller: string): boolean;
21
25
  * well want events while declining to have every click's coordinates recorded.
22
26
  */
23
27
  export declare function canTrackHeatmap(caller: string): boolean;
24
- /** canTrack plus the server's `errortracking` flag from getupdates. */
28
+ /** canTrack plus the server's js_error module (15) from getsdkconfig. */
25
29
  export declare function canTrackErrors(caller: string): boolean;
30
+ /**
31
+ * Stores the visitor's tracking status without telling the server. True when it changed.
32
+ * user/register uses this alone: the server learns of the user from that call, so a device/add
33
+ * after it would only repeat a registration the device already has.
34
+ */
35
+ export declare function recordTrackingStatus(trackingState: TrackingStatus): boolean;
26
36
  export declare function setTrackingStatus(trackingState: TrackingStatus): void;
27
37
  export declare function getTrackingStatus(): TrackingStatus;
@@ -1,4 +1,4 @@
1
- /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
2
2
  'use strict';
3
3
 
4
4
  var constants = require('./constants.js');
@@ -53,13 +53,16 @@ function canTrack(caller) {
53
53
  }
54
54
  return shouldTrackOrSendData();
55
55
  }
56
- /** canTrack plus the server's `engagementtracking` flag from getupdates (events, screens, sessions, api calls). */
57
- 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) {
58
61
  if (!canTrack(caller)) {
59
62
  return false;
60
63
  }
61
- if (!state._ZAP._engagementTracking) {
62
- 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
63
66
  return false;
64
67
  }
65
68
  return true;
@@ -80,7 +83,7 @@ function canTrackHeatmap(caller) {
80
83
  }
81
84
  return true;
82
85
  }
83
- /** canTrack plus the server's `errortracking` flag from getupdates. */
86
+ /** canTrack plus the server's js_error module (15) from getsdkconfig. */
84
87
  function canTrackErrors(caller) {
85
88
  if (!canTrack(caller)) {
86
89
  return false;
@@ -91,17 +94,27 @@ function canTrackErrors(caller) {
91
94
  }
92
95
  return true;
93
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
+ }
94
110
  function setTrackingStatus(trackingState) {
95
111
  if (utils.isEmpty(trackingState)) {
96
112
  logger.Console.warn('setTrackingStatus: trackingStatus is Empty'); // no i18n
97
113
  return;
98
114
  }
99
- if (storage.tracking_preference.opt_in_status() == trackingState) {
115
+ if (!recordTrackingStatus(trackingState)) {
100
116
  return;
101
117
  }
102
- storage.tracking_preference.update_status(trackingState);
103
- state._ZAP._devicestatus = storage.tracking_preference.opt_in_status();
104
- state._ZAP._isanonrequired = storage.tracking_preference.opt_in_status() == constants.AP_TRACKING_STATUS.USAGE_TRACKING_WITH_PII ? false : state._ZAP._isanonrequired;
105
118
  if (storage.tracking_preference.opt_in_status() != constants.AP_TRACKING_STATUS.NO_TRACKING) {
106
119
  logger.Console.log('setTrackingStatus: Updating device info with new tracking status'); // no i18n
107
120
  hooks.hooks.updateDevice(state._ZAP._device_info).then(function (result) {
@@ -128,5 +141,6 @@ exports.canTrackHeatmap = canTrackHeatmap;
128
141
  exports.getTrackingStatus = getTrackingStatus;
129
142
  exports.hasDoNotTrackEnabled = hasDoNotTrackEnabled;
130
143
  exports.opt_in_status = opt_in_status;
144
+ exports.recordTrackingStatus = recordTrackingStatus;
131
145
  exports.setTrackingStatus = setTrackingStatus;
132
146
  exports.shouldTrackOrSendData = shouldTrackOrSendData;
@@ -34,6 +34,8 @@ export declare const AP_CONSTANTS: Readonly<{
34
34
  readonly SUCCESS: "success";
35
35
  readonly BROWSER: "Browser";
36
36
  }>;
37
+ /** The kinds of engagement item, each with its own getsdkconfig module: AP_CONSTANTS' type values. */
38
+ export type EngagementType = 'event' | 'screen' | 'session' | 'api';
37
39
  export declare const DEFAULT_API_PATHS: Readonly<{
38
40
  readonly addversion: "app/addversion";
39
41
  readonly regdevice: "device/add";
@@ -79,9 +81,13 @@ export declare const SDK_MODULE: Readonly<{
79
81
  * authority. Where they disagree, getsdkconfig wins.
80
82
  */
81
83
  readonly REMOTE_CONFIG: "2";
84
+ readonly EVENT: "5";
85
+ readonly API: "6";
86
+ readonly SCREEN: "10";
82
87
  readonly SESSION: "11";
83
88
  readonly FEEDBACK: "12";
84
- readonly CRASH: "13";
89
+ /** Uncaught and reported JavaScript errors: js_error. 13 (crash) and 14 (nonfatal) are the native SDKs'. */
90
+ readonly JS_ERROR: "15";
85
91
  readonly REMOTE_LOGGER: "17";
86
92
  readonly HEATMAP: "18";
87
93
  }>;
@@ -97,9 +103,10 @@ export declare const LOG_FILENAME_MAX = 100;
97
103
  */
98
104
  export declare const DEVICE_NAME_MAX = 100;
99
105
  /**
100
- * The `level` every line goes out with. Everything the remote logger carries is a failure inside
101
- * the SDK — logFailure is its only caller — so the level never varies. 3 is what the v2 reference
102
- * shows in its only example; the scale itself is not documented anywhere we can see.
106
+ * The `level` a remote log line goes out with when it has none of its own: 3, Info. Every line an
107
+ * app writes with AppticsLogger carries its level (1 verbose to 5 error, see LOG_LEVEL in
108
+ * remotelog/logger.ts). Only a line an older SDK stored, when the SDK logged its own failures
109
+ * there, has none; it is sent as Info rather than having the batch refused for a missing level.
103
110
  */
104
111
  export declare const REMOTE_LOG_LEVEL = 3;
105
112
  /**
@@ -109,29 +116,17 @@ export declare const REMOTE_LOG_LEVEL = 3;
109
116
  * enough that a tab left open overnight is not still sending every call to its debug twin.
110
117
  */
111
118
  export declare const DEBUG_IDLE_MS: number;
112
- /** Idle minutes that end a session. Lives on state, not in _config, but defaults here. */
119
+ /** Minutes a tab can be inactive before its session ends. Lives on state, not in _config, but defaults here. */
113
120
  export declare const DEFAULT_INACTIVE_MINUTES = 30;
114
121
  /** Global defaults. `state._config` holds a mutable copy per init. */
115
122
  export declare const AP_CONFIG: Readonly<{
116
123
  endpoint: "/sdk/web/";
117
124
  method: "POST";
118
- transport: "XHR";
119
- track_link_timeout: 300;
120
- cookie_expiration_days: 365;
121
- storage_type: "localStorage";
122
- enable_batch_requests: true;
123
125
  batch_size: 50;
124
126
  batch_flush_interval: 30000;
125
127
  getupdates_interval: 120000;
126
128
  batch_request_timeout: 7;
127
- auto_starts_batch: true;
128
- mode: 1;
129
- default_group_name: "default";
130
- default_optin_status: number;
131
- enable_pageview_tracking: false;
132
- save_referrer: true;
133
129
  debug: boolean;
134
- track_by_default: true;
135
130
  ignore_do_not_track: boolean;
136
131
  /**
137
132
  * Wrap XHR and fetch to record the app's API calls without it calling startTrackApi(). Off by
@@ -144,6 +139,16 @@ export declare const AP_CONFIG: Readonly<{
144
139
  * default; the app's own inScreen() during a navigation replaces that navigation's view.
145
140
  */
146
141
  track_screen: boolean;
142
+ /**
143
+ * Record uncaught errors and unhandled promise rejections, from the window's `error` and
144
+ * `unhandledrejection` events. On by default; AppticsError.setErrorTracking() switches it later.
145
+ */
146
+ track_error: boolean;
147
+ /**
148
+ * Record clicks on elements tagged `apeventaction` (or `data-apeventaction`) as events. On by
149
+ * default; AppticsEvent.setClickTracking() switches it later.
150
+ */
151
+ track_click: boolean;
147
152
  /**
148
153
  * How automatic screen tracking names a path, as init() keeps the config's screen_routes: route
149
154
  * patterns (`/users/{id}/orders`, each id recorded as a star), exact paths and regular
@@ -1,4 +1,4 @@
1
- /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
2
2
  '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,30 +120,18 @@ 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
136
  /**
144
137
  * Wrap XHR and fetch to record the app's API calls without it calling startTrackApi(). Off by
@@ -151,6 +144,16 @@ const AP_CONFIG = Object.freeze({
151
144
  * default; the app's own inScreen() during a navigation replaces that navigation's view.
152
145
  */
153
146
  track_screen: true,
147
+ /**
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.
150
+ */
151
+ track_error: true,
152
+ /**
153
+ * Record clicks on elements tagged `apeventaction` (or `data-apeventaction`) as events. On by
154
+ * default; AppticsEvent.setClickTracking() switches it later.
155
+ */
156
+ track_click: true,
154
157
  /**
155
158
  * How automatic screen tracking names a path, as init() keeps the config's screen_routes: route
156
159
  * patterns (`/users/{id}/orders`, each id recorded as a star), exact paths and regular
@@ -1,4 +1,4 @@
1
- /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
2
2
  'use strict';
3
3
 
4
4
  var logger = require('./logger.js');
@@ -1,4 +1,4 @@
1
- /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
2
2
  'use strict';
3
3
 
4
4
  var constants = require('./constants.js');
@@ -1,4 +1,3 @@
1
- import type { AppticsConfig } from '../types.js';
2
1
  export declare function isBlockedWS(ua: string): boolean;
3
2
  /** Device RAM as the API wants it ("4 GB"). Chromium only; empty elsewhere. */
4
3
  export declare function getRam(): string;
@@ -24,5 +23,3 @@ export declare function getTimeZone(): string;
24
23
  export declare function is_apptics_disabled(): boolean;
25
24
  /** Pure DNT check (no side effects). consent.hasDoNotTrackEnabled() applies NO_TRACKING. */
26
25
  export declare function isDntOn(): boolean;
27
- /** The console snippet's config (window.appticssettings._defaultoptions), if the page defines one. */
28
- export declare function getSnippetOptions(): AppticsConfig | undefined;
@@ -1,4 +1,4 @@
1
- /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
2
2
  'use strict';
3
3
 
4
4
  var constants = require('./constants.js');
@@ -242,13 +242,6 @@ function isDntOn() {
242
242
  return utils.includes(dntValues, dntValue);
243
243
  });
244
244
  }
245
- /** The console snippet's config (window.appticssettings._defaultoptions), if the page defines one. */
246
- function getSnippetOptions() {
247
- if (typeof window === 'undefined' || !window.appticssettings) { // no i18n
248
- return undefined;
249
- }
250
- return window.appticssettings._defaultoptions;
251
- }
252
245
 
253
246
  exports.getBatteryPercent = getBatteryPercent;
254
247
  exports.getBrowser = getBrowser;
@@ -260,7 +253,6 @@ exports.getOS = getOS;
260
253
  exports.getOrientation = getOrientation;
261
254
  exports.getRam = getRam;
262
255
  exports.getReferringURL = getReferringURL;
263
- exports.getSnippetOptions = getSnippetOptions;
264
256
  exports.getTimeZone = getTimeZone;
265
257
  exports.isBlockedWS = isBlockedWS;
266
258
  exports.isDntOn = isDntOn;
@@ -1 +1 @@
1
- export declare const FRAMEWORK_ID = 6002;
1
+ export declare const FRAMEWORK_ID = 6003;
@@ -1,9 +1,9 @@
1
- /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
2
2
  'use strict';
3
3
 
4
4
  // Generated by scripts/register-version.mjs — do not edit by hand.
5
5
  // The framework id Apptics issued for this SDK, from POST /sdk/web/v1/framework/addversion
6
- // (version 2.0.0-beta.1, platform Browser). Regenerated on every npm pack.
7
- const FRAMEWORK_ID = 6002;
6
+ // (version 2.0.0-beta.2, platform Browser). Regenerated on every npm pack.
7
+ const FRAMEWORK_ID = 6003;
8
8
 
9
9
  exports.FRAMEWORK_ID = FRAMEWORK_ID;
@@ -1,4 +1,4 @@
1
- /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
2
2
  'use strict';
3
3
 
4
4
  var state = require('./state.js');
@@ -36,4 +36,9 @@ export declare const hooks: {
36
36
  remoteConfigStarted: () => void;
37
37
  /** Set by remoteconfig/fetch.ts: AppticsUser.setUser changed who this is, so conditions on the user re-apply. */
38
38
  remoteConfigUserChanged: () => void;
39
+ /**
40
+ * Set by device/index.ts: getsdkconfig is asked now, outside its next_check_after. setUser calls
41
+ * it once a user is registered, and remote config when getupdates reports a module changed.
42
+ */
43
+ askServerSettings: () => void;
39
44
  };
@@ -1,4 +1,4 @@
1
- /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
2
2
  'use strict';
3
3
 
4
4
  /**
@@ -17,6 +17,7 @@ const hooks = {
17
17
  screenTrackedByApp: () => { },
18
18
  remoteConfigStarted: () => { },
19
19
  remoteConfigUserChanged: () => { },
20
+ askServerSettings: () => { },
20
21
  };
21
22
 
22
23
  exports.hooks = hooks;
@@ -1,4 +1,4 @@
1
- /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
2
2
  'use strict';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
2
2
  'use strict';
3
3
 
4
4
  var state = require('./state.js');
@@ -1,4 +1,4 @@
1
- import { type ApConfig } from './constants.js';
1
+ import { type ApConfig, type EngagementType } from './constants.js';
2
2
  import type { DeviceInfo, Dict, QuartzSettings, TrackingStatus, UserInfo } from '../types.js';
3
3
  /** Runtime state shared by every module (the former `_ZAP` object). */
4
4
  export interface State {
@@ -19,7 +19,6 @@ export interface State {
19
19
  _token: string;
20
20
  _frameworkID: number;
21
21
  _platform: string;
22
- _isanonrequired: boolean;
23
22
  _devicestatus: TrackingStatus;
24
23
  _uuid: string;
25
24
  _apid: string;
@@ -30,9 +29,12 @@ export interface State {
30
29
  _current_session: Dict;
31
30
  _properties: Dict;
32
31
  _ignoreDnt: boolean;
33
- _isGlobalErrorTracking: boolean;
34
32
  _shouldTrack: boolean;
35
- _engagementTracking: boolean;
33
+ /**
34
+ * getsdkconfig's engagement modules, one per kind of item, keyed by the item's type: event (5),
35
+ * api (6), screen (10) and session (11).
36
+ */
37
+ _engagementTracking: Record<EngagementType, boolean>;
36
38
  _errorTracking: boolean;
37
39
  /** getsdkconfig module 18. Heatmap has its own flag in v2; before that it rode engagement. */
38
40
  _heatmapTracking: boolean;
@@ -1,4 +1,4 @@
1
- /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
2
2
  'use strict';
3
3
 
4
4
  var constants = require('./constants.js');
@@ -23,7 +23,6 @@ function initialState() {
23
23
  // issued by Apptics at pack time; see scripts/register-version.mjs
24
24
  _frameworkID: frameworkId.FRAMEWORK_ID,
25
25
  _platform: constants.AP_CONSTANTS.BROWSER,
26
- _isanonrequired: true,
27
26
  _devicestatus: constants.AP_TRACKING_STATUS.USAGE_TRACKING_WITHOUT_PII,
28
27
  _uuid: '', // no i18n
29
28
  _apid: '', // no i18n
@@ -34,9 +33,8 @@ function initialState() {
34
33
  _current_session: {},
35
34
  _properties: {},
36
35
  _ignoreDnt: false,
37
- _isGlobalErrorTracking: true,
38
36
  _shouldTrack: true,
39
- _engagementTracking: true,
37
+ _engagementTracking: { event: true, screen: true, session: true, api: true },
40
38
  _heatmapTracking: true,
41
39
  _remoteLoggerEnabled: true,
42
40
  _remoteConfigEnabled: true,
@@ -1,4 +1,4 @@
1
- /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
2
2
  'use strict';
3
3
 
4
4
  var constants = require('./constants.js');
@@ -293,9 +293,6 @@ const tracking_preference = {
293
293
  },
294
294
  update_status(tracking_status) {
295
295
  state._ZAP._devicestatus = tracking_status;
296
- // Legacy order kept: this reads the status *before* the write below (setTrackingStatus recomputes it after).
297
- state._ZAP._isanonrequired =
298
- tracking_preference.opt_in_status() == constants.AP_TRACKING_STATUS.USAGE_TRACKING_WITH_PII ? false : state._ZAP._isanonrequired;
299
296
  var track = Object.assign({}, settings.trackinfo && typeof settings.trackinfo === 'object' ? settings.trackinfo : {}); // no i18n
300
297
  track.tracking_status = tracking_status;
301
298
  if (state._ZAP._trackinfo && typeof state._ZAP._trackinfo === 'object') { // no i18n
@@ -1,4 +1,4 @@
1
- /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
2
2
  'use strict';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
2
2
  'use strict';
3
3
 
4
4
  var constants = require('./constants.js');
@@ -141,19 +141,17 @@ function getParameters(path) {
141
141
  // v2 device/add declares neither identifier, platform nor appversion: the build is already
142
142
  // known from app/addversion, and sending an undeclared param is refused as EXTRA_PARAM_FOUND.
143
143
  // What it does declare as mandatory is appversionid, which v1 treated as optional.
144
+ // isanonrequired is always false: the web SDK has no anonymous mode, only the tracking
145
+ // statuses (with PII, without PII, none), which devicestatus carries.
144
146
  if (path == 'regdevice') { // no i18n
145
- returnVal = '?isanonrequired=' + state._ZAP._isanonrequired + '&devicestatus=' + state._ZAP._devicestatus; // no i18n
147
+ returnVal = '?isanonrequired=false&devicestatus=' + state._ZAP._devicestatus; // no i18n
146
148
  if (!utils.isEmpty(state._ZAP._device_info.deviceid)) {
147
149
  returnVal += '&deviceid=' + encodeURIComponent(String(state._ZAP._device_info.deviceid)); // no i18n
148
150
  }
149
151
  return returnVal + mandatoryParams(returnVal);
150
152
  }
151
- // getsdkconfig is the one call that must NOT carry deviceid: it declares the param with
152
- // decrypt-label="authenticate", which a web SDK cannot satisfy, and sending it is answered
153
- // with NOT_AUTHENTICATED. getupdates declares the same param with plain paramdecrypt, so it
154
- // does carry one. It still needs appversionid and frameworkid, added at the end.
155
- var identifiesDevice = path != 'sdkconfig'; // no i18n
156
- if (identifiesDevice) {
153
+ // getsdkconfig carries no deviceid: the user's ids below are what it answers for
154
+ if (path != 'sdkconfig') { // no i18n
157
155
  if (utils.isEmpty(state._ZAP._device_info.deviceid)) {
158
156
  hooks.hooks.refreshDeviceInfo();
159
157
  // the device is missing, but appversionid and frameworkid are mandatory regardless:
@@ -178,14 +176,13 @@ function getParameters(path) {
178
176
  // them, and refuses userid as EXTRA_PARAM_FOUND; it has no use for them either, since remote
179
177
  // config conditions on the user are evaluated here, against the rule set it answers with
180
178
  var carriesUser = path != 'reguser' && path != 'getupdates'; // no i18n
181
- if (carriesUser && identifiesDevice) {
182
- if (consent.opt_in_status() == constants.AP_TRACKING_STATUS.USAGE_TRACKING_WITH_PII) {
183
- if (state._ZAP._user_info.hasOwnProperty('userid') && !utils.isEmpty(state._ZAP._user_info.userid)) { // no i18n
184
- returnVal += '&userid=' + encodeURIComponent(String(state._ZAP._user_info.userid)); // no i18n
185
- }
186
- if (state._ZAP._user_info.hasOwnProperty('groupid') && !utils.isEmpty(state._ZAP._user_info.groupid)) { // no i18n
187
- returnVal += '&customergroupid=' + encodeURIComponent(String(state._ZAP._user_info.groupid)); // no i18n
188
- }
179
+ if (carriesUser && consent.opt_in_status() == constants.AP_TRACKING_STATUS.USAGE_TRACKING_WITH_PII) {
180
+ if (state._ZAP._user_info.hasOwnProperty('userid') && !utils.isEmpty(state._ZAP._user_info.userid)) { // no i18n
181
+ // getsdkconfig has no deviceid before it, so its userid starts the query
182
+ returnVal += (returnVal === '' ? '?' : '&') + 'userid=' + encodeURIComponent(String(state._ZAP._user_info.userid)); // no i18n
183
+ }
184
+ if (state._ZAP._user_info.hasOwnProperty('groupid') && !utils.isEmpty(state._ZAP._user_info.groupid)) { // no i18n
185
+ returnVal += (returnVal === '' ? '?' : '&') + 'customergroupid=' + encodeURIComponent(String(state._ZAP._user_info.groupid)); // no i18n
189
186
  }
190
187
  }
191
188
  returnVal += deviceNameParam(path, returnVal);
@@ -1,4 +1,4 @@
1
- /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
2
2
  'use strict';
3
3
 
4
4
  var constants = require('./constants.js');
@@ -1,4 +1,4 @@
1
- /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
2
2
  'use strict';
3
3
 
4
4
  var logger = require('./logger.js');
@@ -1,4 +1,13 @@
1
- /** Whether we already hold usable ids for the app and version running now. */
1
+ /**
2
+ * A fingerprint of the auth key, which is what is stored to tell one key from another: enough to
3
+ * notice that init() was given a different one, without keeping a second copy of the key itself.
4
+ * FNV-1a, 32 bits, as hex; '' for no key.
5
+ */
6
+ export declare function keyFingerprint(key: unknown): string;
7
+ /**
8
+ * Whether we already hold usable ids for the app, auth key and version running now. Ids stored by
9
+ * a build that kept no key fingerprint register again once, and the answer then records it.
10
+ */
2
11
  export declare function hasAppVersion(): boolean;
3
12
  export declare function appVersionFailedForNetwork(): boolean;
4
13
  export declare function registerAppVersion(): Promise<boolean>;
@@ -1,4 +1,4 @@
1
- /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
2
2
  'use strict';
3
3
 
4
4
  var state = require('../core/state.js');
@@ -39,13 +39,34 @@ const REQUIRED_KEYS = ['aaid', 'portalid', 'projectid', 'apid', 'mapid', 'appver
39
39
  function missingKeys(data) {
40
40
  return REQUIRED_KEYS.filter(function (key) { return utils.isEmpty(data[key]); });
41
41
  }
42
- /** Whether we already hold usable ids for the app and version running now. */
42
+ /**
43
+ * A fingerprint of the auth key, which is what is stored to tell one key from another: enough to
44
+ * notice that init() was given a different one, without keeping a second copy of the key itself.
45
+ * FNV-1a, 32 bits, as hex; '' for no key.
46
+ */
47
+ function keyFingerprint(key) {
48
+ var text = utils.isEmpty(key) ? '' : String(key); // no i18n
49
+ if (text === '') { // no i18n
50
+ return ''; // no i18n
51
+ }
52
+ var hash = 0x811c9dc5;
53
+ for (var i = 0; i < text.length; i++) {
54
+ hash ^= text.charCodeAt(i);
55
+ hash = Math.imul(hash, 0x01000193) >>> 0;
56
+ }
57
+ return ('0000000' + hash.toString(16)).slice(-8); // no i18n
58
+ }
59
+ /**
60
+ * Whether we already hold usable ids for the app, auth key and version running now. Ids stored by
61
+ * a build that kept no key fingerprint register again once, and the answer then records it.
62
+ */
43
63
  function hasAppVersion() {
44
64
  var saved = stored();
45
65
  return missingKeys(saved).length === 0
46
66
  && saved.appversion === state._ZAP._defaultoptions.appversion
47
67
  && saved.identifier === state._ZAP._defaultoptions.identifier
48
- && saved.serviceUrl === state._ZAP._defaultoptions.serviceUrl;
68
+ && saved.serviceUrl === state._ZAP._defaultoptions.serviceUrl
69
+ && saved.zakhash === keyFingerprint(state._ZAP._defaultoptions.zak);
49
70
  }
50
71
  /** Puts the ids where the rest of the SDK reads them from. */
51
72
  function apply(data) {
@@ -126,6 +147,7 @@ function registerAppVersion() {
126
147
  appversion: state._ZAP._defaultoptions.appversion,
127
148
  identifier: state._ZAP._defaultoptions.identifier,
128
149
  serviceUrl: state._ZAP._defaultoptions.serviceUrl,
150
+ zakhash: keyFingerprint(state._ZAP._defaultoptions.zak),
129
151
  };
130
152
  RESULT_KEYS.forEach(function (key) {
131
153
  if (!utils.isEmpty(data[key])) {
@@ -167,4 +189,5 @@ exports.appVersionFailedForNetwork = appVersionFailedForNetwork;
167
189
  exports.applyStoredAppVersion = applyStoredAppVersion;
168
190
  exports.clearAppVersion = clearAppVersion;
169
191
  exports.hasAppVersion = hasAppVersion;
192
+ exports.keyFingerprint = keyFingerprint;
170
193
  exports.registerAppVersion = registerAppVersion;