@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
@@ -8,6 +8,8 @@ import type { Dict, ServerResult } from '../types.js';
8
8
  *
9
9
  * Gated on the server's own heatmap flag (getsdkconfig module 18), not on engagement: an app may
10
10
  * want events while declining to have every click's coordinates recorded.
11
+ *
12
+ * The scheduler reaches it through hooks.sendHeatmaps, which src/index.ts sets.
11
13
  */
12
14
  export declare function sendHeatmapData(forget?: boolean): Promise<void>;
13
15
  export declare function requestToSendHeatmaps(_payload: Dict, forget?: boolean): Promise<ServerResult>;
@@ -1,4 +1,4 @@
1
- /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
2
2
  import { _ZAP } from '../core/state.js';
3
3
  import { Console, warnAlways } from '../core/logger.js';
4
4
  import { cloneObject } from '../core/utils.js';
@@ -7,7 +7,6 @@ import { is_apptics_disabled } from '../core/env.js';
7
7
  import { shouldTrackOrSendData } from '../core/consent.js';
8
8
  import { defer, clearDefer, withSendLock, freshItems, awaitUnlessClosing, sendBatch } from '../core/batch.js';
9
9
  import { isPermanentRefusal } from '../core/transport.js';
10
- import { hooks } from '../core/hooks.js';
11
10
 
12
11
  /**
13
12
  * Sends queued heatmap records to heatmap/add.
@@ -18,6 +17,8 @@ import { hooks } from '../core/hooks.js';
18
17
  *
19
18
  * Gated on the server's own heatmap flag (getsdkconfig module 18), not on engagement: an app may
20
19
  * want events while declining to have every click's coordinates recorded.
20
+ *
21
+ * The scheduler reaches it through hooks.sendHeatmaps, which src/index.ts sets.
21
22
  */
22
23
  function sendHeatmapData(forget) {
23
24
  if (is_apptics_disabled() || !shouldTrackOrSendData() || !_ZAP._heatmapTracking) {
@@ -72,8 +73,5 @@ function requestToSendHeatmaps(_payload, forget) {
72
73
  var label = 'requestToSendHeatmaps'; // no i18n
73
74
  return sendBatch('heatmap', label, _payload, forget); // no i18n
74
75
  }
75
- // the scheduler flushes through this, so importing the heatmap entry is what puts heatmap
76
- // records on the flush timer at all
77
- hooks.sendHeatmaps = sendHeatmapData;
78
76
 
79
77
  export { requestToSendHeatmaps, sendHeatmapData };
@@ -1,4 +1,4 @@
1
- /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
2
2
  import { AP_LOG_MODULE, AP_CONFIG, AP_TRACKING_STATUS } from '../core/constants.js';
3
3
  import { getConfig, _ZAP } from '../core/state.js';
4
4
  import { Console, logFailure } from '../core/logger.js';
@@ -1,4 +1,3 @@
1
- import './heatmap/send.js';
2
1
  import type { AppticsSdk } from './types.js';
3
2
  export type { AppticsSdk, AppticsConfig, ErrorLike, FeedbackType, Properties, TrackingStatus, UserInfo, UserValidationResult, } from './types.js';
4
3
  /** Android's Apptics: starting the SDK, and what applies to all of it. */
@@ -14,7 +13,7 @@ export type { ApiTrackingConfig } from './engagement/api-rules.js';
14
13
  export declare const AppticsError: AppticsSdk['AppticsError'];
15
14
  /** Android's AppticsUser: the signed-in user, and the builder for their properties. */
16
15
  export declare const AppticsUser: AppticsSdk['AppticsUser'];
17
- /** Heatmap capture: AppticsHeatmap.trackHeatmap() starts or stops recording clicks and scrolls. */
16
+ /** Heatmap capture: AppticsHeatmap.setHeatmapTracking() starts or stops recording clicks and scrolls. */
18
17
  export declare const AppticsHeatmap: AppticsSdk['AppticsHeatmap'];
19
18
  /** Android's AppticsSettings: what the SDK may track for this visitor. */
20
19
  export declare const AppticsSettings: AppticsSdk['AppticsSettings'];
package/dist/esm/index.js CHANGED
@@ -1,29 +1,35 @@
1
- /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
2
2
  import { AP_TRACKING_STATUS } from './core/constants.js';
3
3
  import { forward, guard } from './core/guard.js';
4
- import { reset, ready, init } from './lifecycle.js';
4
+ import { warnAlways } from './core/logger.js';
5
+ import { reset, ready, init, setClickTracking, setScreenTracking } from './lifecycle.js';
5
6
  import { enableApiTracking } from './engagement/auto-api.js';
6
7
  import { endTrackApiAt, outScreenAt, inScreenAt, startTrackApi, trackEvent } from './engagement/track.js';
7
8
  import { DefinedEvents } from './engagement/defined-events.js';
8
9
  import { nowMs, getNewUUID } from './core/utils.js';
9
10
  import { validateScreenName } from './core/validate.js';
10
11
  import { ApiTrackingBuilder, configureApiTracking } from './engagement/api-rules.js';
11
- import { trackGlobalErrorHandler, trackError } from './errors/track.js';
12
+ import { setErrorTracking, trackError } from './errors/track.js';
12
13
  import { UserBuilder, getUser, setUser } from './user/index.js';
13
14
  import { getTrackingStatus, setTrackingStatus } from './core/consent.js';
14
- import { flush } from './scheduler.js';
15
+ import { calledFlush } from './scheduler.js';
15
16
  import { trackHeatmap } from './heatmap/track.js';
16
- import './heatmap/send.js';
17
- import { scheduleAutoInit } from './auto-init.js';
17
+ import { sendHeatmapData } from './heatmap/send.js';
18
+ import { hooks } from './core/hooks.js';
18
19
  import { disableDebug, enableDebug } from './core/debug.js';
19
20
 
21
+ // flush() and the flush timer send heatmap records through this hook. Set here, from a named
22
+ // import, rather than by heatmap/send.ts on being imported: the package's sideEffects list names
23
+ // only the CDN bundle, so a bundler drops a bare `import './heatmap/send.js'`, and with it every
24
+ // heatmap send, while capture carries on filling the queue
25
+ hooks.sendHeatmaps = sendHeatmapData;
20
26
  /*
21
27
  * Every public call below is a function of its own, with the parameter names the console shows
22
28
  * on hover, forwarding to its guard()ed implementation (see forward).
23
29
  */
24
30
  const initGuarded = guard('Apptics.init', init); // no i18n
25
31
  const readyGuarded = guard('Apptics.ready', ready); // no i18n
26
- const flushGuarded = guard('Apptics.flush', flush); // no i18n
32
+ const flushGuarded = guard('Apptics.flush', calledFlush); // no i18n
27
33
  const resetGuarded = guard('Apptics.reset', reset); // no i18n
28
34
  /**
29
35
  * Debug mode, on or off; works before init(), and wins over `debug` in init(). On, engagement,
@@ -33,13 +39,23 @@ const resetGuarded = guard('Apptics.reset', reset); // no i18n
33
39
  */
34
40
  const enableDebugGuarded = guard('Apptics.enableDebug', enableDebug); // no i18n
35
41
  const disableDebugGuarded = guard('Apptics.disableDebug', disableDebug); // no i18n
42
+ /** The renamed calls already warned about: once per page each, not once per call. */
43
+ var warnedRenamed = {};
44
+ /** An earlier name of a call still works, with a console warning naming the call to use. */
45
+ function renamed(old, current) {
46
+ if (warnedRenamed[old]) {
47
+ return;
48
+ }
49
+ warnedRenamed[old] = true;
50
+ warnAlways(old + ' is now ' + current + '; rename it in your code'); // no i18n
51
+ }
36
52
  /** Android's Apptics: starting the SDK, and what applies to all of it. */
37
53
  const Apptics = {
38
- /** Starts the SDK. The config object is required; the console snippet supplies it via auto-init. */
54
+ /** Starts the SDK with the app's config object, which is required. */
39
55
  init: function init(config) { return forward(initGuarded, arguments); },
40
56
  /** Resolves true once the SDK is running, false if it can't start. */
41
57
  ready: function ready() { return forward(readyGuarded, arguments); },
42
- /** Sends stored engagements, errors and heatmap records now. */
58
+ /** Sends stored engagements, errors and heatmap records now; at most once every 15 seconds. */
43
59
  flush: function flush() { return forward(flushGuarded, arguments); },
44
60
  /** Clears stored identity, queued data and remote config values, then starts again. */
45
61
  reset: function reset() { return forward(resetGuarded, arguments); },
@@ -47,19 +63,23 @@ const Apptics = {
47
63
  disableDebug: function disableDebug() { return forward(disableDebugGuarded, arguments); },
48
64
  };
49
65
  /**
50
- * Android's AppticsEvents: `addEvent(name, group?, properties?)`, or
66
+ * Android's AppticsEvents: `addEvent(name, group, properties?)`, or
51
67
  * `addEvent(AppticsEvent.DefinedEvents.X, properties?)`.
52
68
  */
53
69
  const addEventGuarded = guard('AppticsEvent.addEvent', trackEvent); // no i18n
70
+ const setClickTrackingGuarded = guard('AppticsEvent.setClickTracking', setClickTracking); // no i18n
54
71
  const AppticsEvent = {
55
72
  /** Apptics' defined events, as Android's DefinedEvents, to log with addEvent. */
56
73
  DefinedEvents: DefinedEvents,
57
74
  addEvent: function addEvent(eventName, groupName, properties) {
58
75
  return forward(addEventGuarded, arguments);
59
76
  },
77
+ /** Turns click tracking from markup (apeventaction) on or off; the `track_click` config flag sets it at start-up. */
78
+ setClickTracking: function setClickTracking(enabled) { return forward(setClickTrackingGuarded, arguments); },
60
79
  };
61
80
  const inScreenGuarded = guard('AppticsScreen.inScreen', inScreenAt); // no i18n
62
81
  const outScreenGuarded = guard('AppticsScreen.outScreen', outScreenAt); // no i18n
82
+ const setScreenTrackingGuarded = guard('AppticsScreen.setScreenTracking', setScreenTracking); // no i18n
63
83
  /** Android's AppticsScreenTracker: inScreen(name) returns the view's id, outScreen(id) ends it. */
64
84
  const AppticsScreen = {
65
85
  /**
@@ -81,11 +101,13 @@ const AppticsScreen = {
81
101
  outScreen: function outScreen(id) {
82
102
  outScreenGuarded(id, nowMs());
83
103
  },
104
+ /** Turns automatic screen tracking on or off; the `track_screen` config flag sets it at start-up. */
105
+ setScreenTracking: function setScreenTracking(enabled) { return forward(setScreenTrackingGuarded, arguments); },
84
106
  };
85
107
  const endTrackApiGuarded = guard('AppticsApi.endTrackApi', endTrackApiAt); // no i18n
86
108
  const startTrackApiGuarded = guard('AppticsApi.startTrackApi', startTrackApi); // no i18n
87
109
  const configureGuarded = guard('AppticsApi.configure', configureApiTracking); // no i18n
88
- const enableApiTrackingGuarded = guard('AppticsApi.enableApiTracking', enableApiTracking); // no i18n
110
+ const setApiTrackingGuarded = guard('AppticsApi.setApiTracking', enableApiTracking); // no i18n
89
111
  /** Android's AppticsApiTracker: startTrackApi / endTrackApi, and configure for the rules. */
90
112
  const AppticsApi = {
91
113
  /** Begins timing one call: returns the id endTrackApi takes. */
@@ -99,17 +121,27 @@ const AppticsApi = {
99
121
  ApiTrackingBuilder: ApiTrackingBuilder,
100
122
  /** The rules API tracking records by, from ApiTrackingBuilder. Works before Apptics.init(). */
101
123
  configure: function configure(config) { return forward(configureGuarded, arguments); },
102
- /** Turns automatic API tracking on or off; the `track_api` config flag is the usual way to set it. */
103
- enableApiTracking: function enableApiTracking(enabled) { return forward(enableApiTrackingGuarded, arguments); },
124
+ /** Turns automatic API tracking on or off; the `track_api` config flag sets it at start-up. */
125
+ setApiTracking: function setApiTracking(enabled) { return forward(setApiTrackingGuarded, arguments); },
126
+ /** @deprecated the earlier name of setApiTracking, which it calls, with a warning */
127
+ enableApiTracking: function enableApiTracking(enabled) {
128
+ renamed('AppticsApi.enableApiTracking', 'AppticsApi.setApiTracking'); // no i18n
129
+ return forward(setApiTrackingGuarded, arguments);
130
+ },
104
131
  };
105
132
  const trackErrorGuarded = guard('AppticsError.trackError', trackError); // no i18n
106
- const trackGlobalErrorHandlerGuarded = guard('AppticsError.trackGlobalErrorHandler', trackGlobalErrorHandler); // no i18n
133
+ const setErrorTrackingGuarded = guard('AppticsError.setErrorTracking', setErrorTracking); // no i18n
107
134
  /** Errors: the ones the app caught, and the switch for the uncaught ones tracked on their own. */
108
135
  const AppticsError = {
109
136
  /** Reports an error the app caught, or an `error` / `unhandledrejection` event. */
110
137
  trackError: function trackError(error, properties) { return forward(trackErrorGuarded, arguments); },
111
- /** Turns the automatic tracking of uncaught errors and unhandled rejections on or off. */
112
- trackGlobalErrorHandler: function trackGlobalErrorHandler(enabled) { return forward(trackGlobalErrorHandlerGuarded, arguments); },
138
+ /** Turns the automatic tracking of uncaught errors and unhandled rejections on or off; the `track_error` config flag sets it at start-up. */
139
+ setErrorTracking: function setErrorTracking(enabled) { return forward(setErrorTrackingGuarded, arguments); },
140
+ /** @deprecated the earlier name of setErrorTracking, which it calls, with a warning */
141
+ trackGlobalErrorHandler: function trackGlobalErrorHandler(enabled) {
142
+ renamed('AppticsError.trackGlobalErrorHandler', 'AppticsError.setErrorTracking'); // no i18n
143
+ return forward(setErrorTrackingGuarded, arguments);
144
+ },
113
145
  };
114
146
  const setUserGuarded = guard('AppticsUser.setUser', setUser); // no i18n
115
147
  const getUserGuarded = guard('AppticsUser.getUser', getUser); // no i18n
@@ -121,10 +153,16 @@ const AppticsUser = {
121
153
  getUser: function getUser() { return forward(getUserGuarded, arguments); },
122
154
  UserBuilder: UserBuilder,
123
155
  };
124
- const trackHeatmapGuarded = guard('AppticsHeatmap.trackHeatmap', trackHeatmap); // no i18n
125
- /** Heatmap capture: AppticsHeatmap.trackHeatmap() starts or stops recording clicks and scrolls. */
156
+ const setHeatmapTrackingGuarded = guard('AppticsHeatmap.setHeatmapTracking', trackHeatmap); // no i18n
157
+ /** Heatmap capture: AppticsHeatmap.setHeatmapTracking() starts or stops recording clicks and scrolls. */
126
158
  const AppticsHeatmap = {
127
- trackHeatmap: function trackHeatmap(on) { return forward(trackHeatmapGuarded, arguments); },
159
+ /** Starts or stops recording clicks and scrolls; the `track_heatmap` config flag sets it at start-up. */
160
+ setHeatmapTracking: function setHeatmapTracking(enabled) { return forward(setHeatmapTrackingGuarded, arguments); },
161
+ /** @deprecated the earlier name of setHeatmapTracking, which it calls, with a warning */
162
+ trackHeatmap: function trackHeatmap(on) {
163
+ renamed('AppticsHeatmap.trackHeatmap', 'AppticsHeatmap.setHeatmapTracking'); // no i18n
164
+ return forward(setHeatmapTrackingGuarded, arguments);
165
+ },
128
166
  };
129
167
  const setTrackingStatusGuarded = guard('AppticsSettings.setTrackingStatus', setTrackingStatus); // no i18n
130
168
  const getTrackingStatusGuarded = guard('AppticsSettings.getTrackingStatus', getTrackingStatus); // no i18n
@@ -145,6 +183,5 @@ const apptics = {
145
183
  AppticsSettings,
146
184
  AppticsHeatmap,
147
185
  };
148
- scheduleAutoInit(Apptics);
149
186
 
150
187
  export { Apptics, AppticsApi, AppticsError, AppticsEvent, AppticsHeatmap, AppticsScreen, AppticsSettings, AppticsUser, apptics as default };
@@ -1,8 +1,7 @@
1
1
  import { type ScreenRouteRule } from './core/constants.js';
2
2
  import type { AppticsConfig } from './types.js';
3
3
  /**
4
- * Starts the SDK. The config object is required: pass it directly, or let the console snippet
5
- * supply it (auto-init reads window.appticssettings._defaultoptions and calls init with it).
4
+ * Starts the SDK. The config object is required: the SDK starts only when the app calls this.
6
5
  * Returns true when the config has base_url, auth_key, app_domain and appversion and start-up has
7
6
  * begun (see ready()), false when it was already running, the config is missing or incomplete, or
8
7
  * there is no browser. Start-up calls app/addversion with those four, which answers with aaid, the
@@ -19,3 +18,15 @@ export declare function screenRouteRules(routes: unknown): ScreenRouteRule[];
19
18
  export declare function ready(): Promise<boolean>;
20
19
  /** Clears stored identity and queues, then starts again from the snippet. */
21
20
  export declare function reset(): void;
21
+ /**
22
+ * AppticsEvent.setClickTracking: click tracking from markup on or off, as the `track_click`
23
+ * config sets it. The listener stays; it checks the switch on every click.
24
+ */
25
+ export declare function setClickTracking(enabled?: boolean): void;
26
+ /**
27
+ * AppticsScreen.setScreenTracking: automatic screen tracking on or off, as the `track_screen`
28
+ * config sets it. Applied now once the SDK is running; before that it is only noted, and start()
29
+ * switches tracking to it. Like the other switches, the next init() (a reset() too) goes back to
30
+ * what its config says.
31
+ */
32
+ export declare function setScreenTracking(enabled?: boolean): void;
@@ -1,17 +1,17 @@
1
- /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
2
2
  import { REQUIRED_CONFIG, CONFIG_KEYS, AP_CONFIG, RETIRED_CONFIG_NAMES, DEFAULT_INACTIVE_MINUTES } from './core/constants.js';
3
3
  import { _ZAP } from './core/state.js';
4
4
  import { Console, warnAlways } from './core/logger.js';
5
5
  import { isEmpty, isSuccess } from './core/utils.js';
6
- import { storageReady, user_defaults, engagement_transactions, error_transactions, tracking_preference } from './core/storage.js';
6
+ import { storageReady, user_defaults, engagement_transactions, error_transactions, heatmap_transactions, remotelog_transactions, feedbacklog_transactions, tracking_preference } from './core/storage.js';
7
7
  import { hooks } from './core/hooks.js';
8
8
  import { applyDebugConfig } from './core/debug.js';
9
9
  import { getConnectionType, getOrientation } from './core/env.js';
10
- import { restoreServerSettings, prepareDevice, updateDeviceWithApptics, refreshServerSettings, needsDevice, deviceReady } from './device/index.js';
11
- import { clearAppVersion, registerAppVersion, appVersionFailedForNetwork } from './device/appversion.js';
12
- import { holdTabLock, checkAndUpdateSession, updateLastActiveTimeOfSession, updateScreenWithEndtime, endCurrentSession } from './engagement/session.js';
10
+ import { restoreServerSettings, prepareDevice, startServerSettingChecks, updateDeviceWithApptics, needsDevice, deviceReady } from './device/index.js';
11
+ import { clearAppVersion, keyFingerprint, registerAppVersion, appVersionFailedForNetwork } from './device/appversion.js';
12
+ import { holdTabLock, checkAndUpdateSession, markTabInactive, markTabActive, updateScreenWithEndtime, endCurrentSession, resetInactivity } from './engagement/session.js';
13
13
  import { enableApiTracking } from './engagement/auto-api.js';
14
- import { routePath, enableScreenTracking } from './engagement/auto-screen.js';
14
+ import { enableScreenTracking, routePath } from './engagement/auto-screen.js';
15
15
  import { resumeScreen, trackEvent } from './engagement/track.js';
16
16
  import { trackError } from './errors/track.js';
17
17
  import { startTimers, flush, stopTimers } from './scheduler.js';
@@ -114,10 +114,15 @@ var previousAppVersion = ''; // no i18n
114
114
  /**
115
115
  * Data stored for another app on this origin is discarded before anything else reads it,
116
116
  * including the stored app/addversion answer that would otherwise hand out that app's ids.
117
+ *
118
+ * Another app is a different base_url, app_domain or auth_key from the ones the stored data was
119
+ * registered with. Everything goes, the queues included, and start-up runs as on a first visit:
120
+ * app/addversion, device/add and the rest. Resolves once the store is empty.
117
121
  */
118
122
  function discardOtherAppData(settings) {
119
- // which app it is, and which version, are in app_version_info (serviceUrl, identifier and
120
- // appversion): no keys of their own. 2.0.0-beta's appkey and appversion are read this once
123
+ // which app it is, and which version, are in app_version_info (serviceUrl, identifier, a
124
+ // fingerprint of zak, and appversion): no keys of their own. 2.0.0-beta's appkey and
125
+ // appversion are read this once
121
126
  var info = user_defaults.item('app_version_info') || {}; // no i18n
122
127
  var stored = !isEmpty(info.serviceUrl) && !isEmpty(info.identifier)
123
128
  ? appKey(info)
@@ -125,11 +130,17 @@ function discardOtherAppData(settings) {
125
130
  previousAppVersion = String((!isEmpty(info.appversion) ? info.appversion : user_defaults.item('appversion')) || ''); // no i18n
126
131
  user_defaults.add('appkey', undefined); // no i18n
127
132
  user_defaults.add('appversion', undefined); // no i18n
128
- if (!isEmpty(stored) && stored !== appKey(settings)) {
129
- Console.log('init: stored data belongs to another app, resetting'); // no i18n
130
- clearStorage();
131
- previousAppVersion = ''; // no i18n
132
- }
133
+ var otherApp = !isEmpty(stored) && stored !== appKey(settings);
134
+ // a build that kept no fingerprint cannot tell: hasAppVersion() registers again, and records one
135
+ var otherKey = !isEmpty(info.zakhash) && info.zakhash !== keyFingerprint(settings.zak);
136
+ if (!otherApp && !otherKey) {
137
+ return Promise.resolve();
138
+ }
139
+ Console.log('init: stored data was registered with another ' + (otherApp ? 'base_url or app_domain' : 'auth_key') + ', clearing it and starting as a first visit'); // no i18n
140
+ previousAppVersion = ''; // no i18n
141
+ // the remote config values read from the store, which is about to go
142
+ hooks.resetRemoteConfig();
143
+ return clearStorage();
133
144
  }
134
145
  /**
135
146
  * Timing an app may tune in init(). Each has a range: a value outside it is ignored with a
@@ -173,15 +184,20 @@ function applyIntervals(config) {
173
184
  }
174
185
  }
175
186
  }
187
+ /** Everything the SDK stores: settings, ids and every queue. Resolves once it is all gone. */
176
188
  function clearStorage() {
177
189
  clearAttempts();
178
190
  user_defaults.clear();
179
- engagement_transactions.clear();
180
- error_transactions.clear();
191
+ return Promise.all([
192
+ engagement_transactions, error_transactions, heatmap_transactions, remotelog_transactions, feedbacklog_transactions,
193
+ ].map(function (queue) {
194
+ return queue.clear();
195
+ })).then(function () {
196
+ return undefined;
197
+ });
181
198
  }
182
199
  /**
183
- * Starts the SDK. The config object is required: pass it directly, or let the console snippet
184
- * supply it (auto-init reads window.appticssettings._defaultoptions and calls init with it).
200
+ * Starts the SDK. The config object is required: the SDK starts only when the app calls this.
185
201
  * Returns true when the config has base_url, auth_key, app_domain and appversion and start-up has
186
202
  * begun (see ready()), false when it was already running, the config is missing or incomplete, or
187
203
  * there is no browser. Start-up calls app/addversion with those four, which answers with aaid, the
@@ -279,6 +295,10 @@ function init(config) {
279
295
  // screen view can be stored
280
296
  _ZAP._config.track_screen = typeof config.track_screen === 'boolean' ? config.track_screen : AP_CONFIG.track_screen; // no i18n
281
297
  _ZAP._config.screen_routes = screenRouteRules(config.screen_routes);
298
+ // uncaught errors and tagged clicks, on unless the config says false: the listeners check
299
+ // these as each error or click happens
300
+ _ZAP._config.track_error = typeof config.track_error === 'boolean' ? config.track_error : AP_CONFIG.track_error; // no i18n
301
+ _ZAP._config.track_click = typeof config.track_click === 'boolean' ? config.track_click : AP_CONFIG.track_click; // no i18n
282
302
  // a theme in the config wins; without one, what AppticsFeedback.setFeedbackTheme set stays
283
303
  if (config.feedback_theme === 'light' || config.feedback_theme === 'dark' || config.feedback_theme === 'auto') { // no i18n
284
304
  _ZAP._config.feedback_theme = config.feedback_theme;
@@ -300,39 +320,11 @@ function init(config) {
300
320
  _ZAP._pending = [];
301
321
  return false;
302
322
  }
303
- discardOtherAppData(_ZAP._defaultoptions);
304
- // app/addversion is the first call and everything waits on it: it is what turns the four
305
- // values init() was given into aaid, the portal and project ids every url carries, and
306
- // appreleaseversionid, which metaWebSDKV2 refuses a payload without
307
- return registerAppVersion().then(function (registered) {
323
+ return discardOtherAppData(_ZAP._defaultoptions).then(function () {
308
324
  if (myGeneration !== generation) {
309
325
  return false;
310
326
  }
311
- if (!registered && appVersionFailedForNetwork()) {
312
- // a first visit with no network: start once it is back, keeping what the app
313
- // tracks until then queued, rather than giving up for the rest of the page
314
- warnAlways('Apptics.init: offline, so app/addversion is tried again when the browser is back online; calls made until then are kept'); // no i18n
315
- return registerWhenOnline(myGeneration).then(function (ok) {
316
- if (myGeneration !== generation) {
317
- return false;
318
- }
319
- if (!ok) {
320
- _ZAP._initialised = false;
321
- _ZAP._token = ''; // no i18n
322
- _ZAP._pending = [];
323
- return false;
324
- }
325
- return start(config, myGeneration);
326
- });
327
- }
328
- if (!registered) {
329
- warnAlways('Apptics.init: app/addversion did not return the app ids, not starting'); // no i18n
330
- _ZAP._initialised = false;
331
- _ZAP._token = ''; // no i18n
332
- _ZAP._pending = [];
333
- return false;
334
- }
335
- return start(config, myGeneration);
327
+ return startUp(config, myGeneration);
336
328
  });
337
329
  }).catch(function (err) {
338
330
  Console.error('Apptics.init: start-up failed', err); // no i18n
@@ -340,6 +332,42 @@ function init(config) {
340
332
  });
341
333
  return true;
342
334
  }
335
+ /** Start-up from app/addversion on, once the store holds only this app's data. */
336
+ function startUp(config, myGeneration) {
337
+ // app/addversion is the first call and everything waits on it: it is what turns the four
338
+ // values init() was given into aaid, the portal and project ids every url carries, and
339
+ // appreleaseversionid, which metaWebSDKV2 refuses a payload without
340
+ return registerAppVersion().then(function (registered) {
341
+ if (myGeneration !== generation) {
342
+ return false;
343
+ }
344
+ if (!registered && appVersionFailedForNetwork()) {
345
+ // a first visit with no network: start once it is back, keeping what the app
346
+ // tracks until then queued, rather than giving up for the rest of the page
347
+ warnAlways('Apptics.init: offline, so app/addversion is tried again when the browser is back online; calls made until then are kept'); // no i18n
348
+ return registerWhenOnline(myGeneration).then(function (ok) {
349
+ if (myGeneration !== generation) {
350
+ return false;
351
+ }
352
+ if (!ok) {
353
+ _ZAP._initialised = false;
354
+ _ZAP._token = ''; // no i18n
355
+ _ZAP._pending = [];
356
+ return false;
357
+ }
358
+ return start(config, myGeneration);
359
+ });
360
+ }
361
+ if (!registered) {
362
+ warnAlways('Apptics.init: app/addversion did not return the app ids, not starting'); // no i18n
363
+ _ZAP._initialised = false;
364
+ _ZAP._token = ''; // no i18n
365
+ _ZAP._pending = [];
366
+ return false;
367
+ }
368
+ return start(config, myGeneration);
369
+ });
370
+ }
343
371
  /** How often a start-up waiting on the network tries app/addversion again, besides on `online`. */
344
372
  const OFFLINE_RETRY_MS = 60 * 1000;
345
373
  /**
@@ -446,6 +474,8 @@ function start(config, myGeneration) {
446
474
  _ZAP._token = String(_ZAP._defaultoptions.aaid);
447
475
  // last known server settings (getupdates) apply before anything is tracked
448
476
  restoreServerSettings();
477
+ // the user this browser was tracking as, before getsdkconfig is asked: it carries their ids
478
+ getUserInfo();
449
479
  // a new release of the app, against the version the stored data was for (see
450
480
  // discardOtherAppData): a first visit has none, and is no change
451
481
  var appVersionChanged = previousAppVersion !== '' && previousAppVersion != _ZAP._defaultoptions.appversion; // no i18n
@@ -464,9 +494,11 @@ function start(config, myGeneration) {
464
494
  }
465
495
  /** The rest of start-up, once the device is set up. */
466
496
  function startTracking(appVersionChanged, myGeneration) {
467
- // no getsdkconfig here, straight after app/addversion: it is asked for once device/add has
468
- // succeeded (registerDeviceWithApptics), then every getupdates_interval. A returning visit
469
- // starts from the settings saved by the last one (restoreServerSettings, in start())
497
+ // getsdkconfig, once per page load and then at each answer's next_check_after. A first visit
498
+ // asked as soon as device/add succeeded (registerDeviceWithApptics) and this does nothing; a
499
+ // returning visit, whose device is registered, asks now, after app/addversion. Until it
500
+ // answers, the settings saved by the last visit apply (restoreServerSettings, in start())
501
+ startServerSettingChecks();
470
502
  if (appVersionChanged) {
471
503
  _ZAP._device_info.appversionid = ''; // no i18n
472
504
  updateDeviceWithApptics(_ZAP._device_info).then(function (result) {
@@ -481,7 +513,6 @@ function startTracking(appVersionChanged, myGeneration) {
481
513
  _ZAP._device_info.connectionType = getConnectionType();
482
514
  attachListeners();
483
515
  _ZAP._properties.orientation = getOrientation();
484
- getUserInfo();
485
516
  return checkAndUpdateSession().then(function () {
486
517
  if (myGeneration !== generation) {
487
518
  return false;
@@ -516,6 +547,7 @@ function startTracking(appVersionChanged, myGeneration) {
516
547
  function reset() {
517
548
  generation++;
518
549
  stopTimers();
550
+ resetInactivity();
519
551
  // the wrappers come off with everything else; the init() below puts them back if the config
520
552
  // asked for them, so a reset that has no config to restore leaves XHR and fetch untouched
521
553
  enableApiTracking(false);
@@ -546,6 +578,26 @@ function reset() {
546
578
  function isActive() {
547
579
  return _ZAP._ready;
548
580
  }
581
+ /**
582
+ * AppticsEvent.setClickTracking: click tracking from markup on or off, as the `track_click`
583
+ * config sets it. The listener stays; it checks the switch on every click.
584
+ */
585
+ function setClickTracking(enabled) {
586
+ _ZAP._config.track_click = typeof enabled === 'boolean' ? enabled : true; // no i18n
587
+ Console.log('click tracking: ' + (_ZAP._config.track_click ? 'on' : 'off')); // no i18n
588
+ }
589
+ /**
590
+ * AppticsScreen.setScreenTracking: automatic screen tracking on or off, as the `track_screen`
591
+ * config sets it. Applied now once the SDK is running; before that it is only noted, and start()
592
+ * switches tracking to it. Like the other switches, the next init() (a reset() too) goes back to
593
+ * what its config says.
594
+ */
595
+ function setScreenTracking(enabled) {
596
+ _ZAP._config.track_screen = typeof enabled === 'boolean' ? enabled : true; // no i18n
597
+ if (isActive()) {
598
+ enableScreenTracking(_ZAP._config.track_screen);
599
+ }
600
+ }
549
601
  /**
550
602
  * A click-tracking attribute, in either spelling: `apeventaction`, or `data-apeventaction`, which
551
603
  * is valid HTML and what React and TypeScript accept without declaring the attribute.
@@ -561,7 +613,7 @@ function trackingSelector(name) {
561
613
  // Declarative click tracking: <el apeventaction="name" apeventprops='{"k":"v"}'> inside <el apgroupaction="group">,
562
614
  // or the same attributes with a data- prefix
563
615
  function onDocumentClick(event) {
564
- if (!window.appticsReadyStatus || !isActive()) {
616
+ if (!window.appticsReadyStatus || !isActive() || !_ZAP._config.track_click) {
565
617
  return;
566
618
  }
567
619
  var start = event.target;
@@ -577,7 +629,8 @@ function onDocumentClick(event) {
577
629
  }
578
630
  var eventName = trackingAttribute(targetElem, 'apeventaction') || ''; // no i18n
579
631
  var groupElem = targetElem.closest(trackingSelector('apgroupaction')); // no i18n
580
- var groupName = (groupElem && trackingAttribute(groupElem, 'apgroupaction')) || AP_CONFIG.default_group_name; // no i18n
632
+ // no apgroupaction around it: trackEvent refuses it and says the group is missing
633
+ var groupName = (groupElem && trackingAttribute(groupElem, 'apgroupaction')) || undefined; // no i18n
581
634
  var eventProps = {};
582
635
  var rawProps = trackingAttribute(targetElem, 'apeventprops'); // no i18n
583
636
  if (!isEmpty(rawProps)) {
@@ -601,10 +654,18 @@ function onDocumentClick(event) {
601
654
  function onPageHidden() {
602
655
  if (!isActive())
603
656
  return;
657
+ // the moment the user left: the session ends at it if they are not back within inactiveduration
658
+ markTabInactive(sendEndedSession);
604
659
  updateScreenWithEndtime();
605
660
  flush(true);
606
661
  Console.log('page hidden: closing the open screen and flushing'); // no i18n
607
662
  }
663
+ /** A session that inactivity ended while the tab was away: sent now, not when the user returns. */
664
+ function sendEndedSession() {
665
+ if (!isActive())
666
+ return;
667
+ flush();
668
+ }
608
669
  /**
609
670
  * The tab is closing, or the page is being replaced or frozen into the back/forward cache.
610
671
  * The session ends here, and everything queued goes out by keepalive, since a normal
@@ -636,14 +697,18 @@ function attachListeners() {
636
697
  window.addEventListener('blur', function () {
637
698
  if (!isActive())
638
699
  return;
700
+ // focus moving into an iframe on the page blurs the window too, and the user is still here
701
+ if (document.activeElement && document.activeElement.tagName === 'IFRAME')
702
+ return; // no i18n
639
703
  Console.log('Window lost focus, user switched to another window or application'); // no i18n
640
- updateLastActiveTimeOfSession();
704
+ markTabInactive(sendEndedSession);
641
705
  });
642
706
  // Track when the window gains focus (user switches back to the window)
643
707
  window.addEventListener('focus', function () {
644
708
  if (!isActive())
645
709
  return;
646
710
  Console.log('Window regained focus, user switched back to the window'); // no i18n
711
+ markTabActive();
647
712
  checkAndUpdateSession();
648
713
  startTimers();
649
714
  });
@@ -654,6 +719,7 @@ function attachListeners() {
654
719
  if (!isActive() || !event.persisted)
655
720
  return;
656
721
  Console.log('restored from the back/forward cache: starting a new session'); // no i18n
722
+ markTabActive();
657
723
  // the screen the page was left on starts a new view, in the new session
658
724
  checkAndUpdateSession().then(resumeScreen);
659
725
  startTimers();
@@ -665,12 +731,12 @@ function attachListeners() {
665
731
  onPageHidden();
666
732
  return;
667
733
  }
668
- // back in view: the server's tracking flags may have changed while we were away
669
- Console.log('page visible: refreshing the server settings'); // no i18n
734
+ // back in view. getsdkconfig is not asked here: only at its next_check_after, on a tab's
735
+ // first page load, and when a user is registered or getupdates reports a change
736
+ markTabActive();
670
737
  // hiding ended the screen view; the screen the user is back on starts a new one, after the
671
738
  // session is settled so the view belongs to the right one
672
739
  checkAndUpdateSession().then(resumeScreen);
673
- refreshServerSettings();
674
740
  });
675
741
  // if we are running in cordova use ondeviceready otherwise onload
676
742
  window.addEventListener(window.cordova ? 'deviceready' : 'load', function () {
@@ -704,7 +770,7 @@ function attachListeners() {
704
770
  });
705
771
  }
706
772
  window.addEventListener('unhandledrejection', function (event) {
707
- if (isActive() && _ZAP._isGlobalErrorTracking) {
773
+ if (isActive() && _ZAP._config.track_error) {
708
774
  trackError(event);
709
775
  }
710
776
  });
@@ -712,7 +778,7 @@ function attachListeners() {
712
778
  // element, and it does not bubble, so a bubbling listener never hears of it. One listener
713
779
  // hears both kinds, the window's own errors included, so none is counted twice
714
780
  window.addEventListener('error', function (event) {
715
- if (!isActive() || !_ZAP._isGlobalErrorTracking) {
781
+ if (!isActive() || !_ZAP._config.track_error) {
716
782
  return;
717
783
  }
718
784
  var target = event.target;
@@ -726,4 +792,4 @@ function attachListeners() {
726
792
  window.addEventListener('click', onDocumentClick, true); // no i18n
727
793
  }
728
794
 
729
- export { init, ready, reset, screenRouteRules };
795
+ export { init, ready, reset, screenRouteRules, setClickTracking, setScreenTracking };
@@ -1,4 +1,4 @@
1
- /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
2
2
  import { _ZAP } from '../core/state.js';
3
3
  import { getTimeZone } from '../core/env.js';
4
4
  import { TZ_COUNTRIES } from './tz-countries.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
  import { storageReady } from '../core/storage.js';
3
3
  import { Console } from '../core/logger.js';
4
4
  import { reresolve } from './store.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
  import { Console } from '../core/logger.js';
3
3
  import { _ZAP } from '../core/state.js';
4
4
  import { isEmpty } from '../core/utils.js';