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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (253) hide show
  1. package/CHANGELOG.md +127 -16
  2. package/README.md +357 -215
  3. package/dist/apptics-pn-sw.js +3 -0
  4. package/dist/apptics-pn-sw.js.map +1 -0
  5. package/dist/apptics.esm.min.js +2 -2
  6. package/dist/apptics.esm.min.js.map +1 -1
  7. package/dist/apptics.min.js +2 -2
  8. package/dist/apptics.min.js.map +1 -1
  9. package/dist/chunks/batch-Axq9sTzR.min.js +3 -0
  10. package/dist/chunks/batch-Axq9sTzR.min.js.map +1 -0
  11. package/dist/chunks/lifecycle-Cvg78jN_.min.js +3 -0
  12. package/dist/chunks/lifecycle-Cvg78jN_.min.js.map +1 -0
  13. package/dist/chunks/send-DBpesydB.min.js +3 -0
  14. package/dist/chunks/send-DBpesydB.min.js.map +1 -0
  15. package/dist/chunks/transport-B21X39p4.min.js +3 -0
  16. package/dist/chunks/transport-B21X39p4.min.js.map +1 -0
  17. package/dist/cjs/core/attempts.js +1 -1
  18. package/dist/cjs/core/batch.js +4 -4
  19. package/dist/cjs/core/consent.d.ts +17 -4
  20. package/dist/cjs/core/consent.js +81 -14
  21. package/dist/cjs/core/console-call.d.ts +23 -0
  22. package/dist/cjs/core/console-call.js +63 -0
  23. package/dist/cjs/core/constants.d.ts +66 -17
  24. package/dist/cjs/core/constants.js +76 -19
  25. package/dist/cjs/core/db.js +31 -7
  26. package/dist/cjs/core/debug.d.ts +6 -4
  27. package/dist/cjs/core/debug.js +36 -12
  28. package/dist/cjs/core/env.d.ts +0 -3
  29. package/dist/cjs/core/env.js +1 -9
  30. package/dist/cjs/core/framework-id.d.ts +1 -1
  31. package/dist/cjs/core/framework-id.js +3 -3
  32. package/dist/cjs/core/guard.js +19 -4
  33. package/dist/cjs/core/hooks.d.ts +29 -0
  34. package/dist/cjs/core/hooks.js +12 -1
  35. package/dist/cjs/core/locks.js +1 -1
  36. package/dist/cjs/core/logger.js +1 -1
  37. package/dist/cjs/core/shield.d.ts +31 -0
  38. package/dist/cjs/core/shield.js +129 -0
  39. package/dist/cjs/core/state.d.ts +11 -5
  40. package/dist/cjs/core/state.js +4 -4
  41. package/dist/cjs/core/storage.d.ts +7 -0
  42. package/dist/cjs/core/storage.js +28 -9
  43. package/dist/cjs/core/stylesheet.js +1 -1
  44. package/dist/cjs/core/transport.d.ts +15 -4
  45. package/dist/cjs/core/transport.js +72 -25
  46. package/dist/cjs/core/utils.js +1 -1
  47. package/dist/cjs/core/validate.js +6 -5
  48. package/dist/cjs/device/appversion.d.ts +10 -1
  49. package/dist/cjs/device/appversion.js +26 -3
  50. package/dist/cjs/device/index.d.ts +17 -2
  51. package/dist/cjs/device/index.js +251 -35
  52. package/dist/cjs/engagement/api-rules.js +1 -1
  53. package/dist/cjs/engagement/auto-api.js +4 -3
  54. package/dist/cjs/engagement/auto-screen.js +10 -6
  55. package/dist/cjs/engagement/defined-events.d.ts +2 -3
  56. package/dist/cjs/engagement/defined-events.js +10 -16
  57. package/dist/cjs/engagement/send.js +7 -3
  58. package/dist/cjs/engagement/session.d.ts +17 -0
  59. package/dist/cjs/engagement/session.js +154 -23
  60. package/dist/cjs/engagement/track.d.ts +4 -4
  61. package/dist/cjs/engagement/track.js +23 -17
  62. package/dist/cjs/errors/send.js +2 -2
  63. package/dist/cjs/errors/track.d.ts +2 -1
  64. package/dist/cjs/errors/track.js +8 -5
  65. package/dist/cjs/feedback/controls.d.ts +36 -4
  66. package/dist/cjs/feedback/controls.js +302 -67
  67. package/dist/cjs/feedback/i18n/index.d.ts +31 -0
  68. package/dist/cjs/feedback/i18n/index.js +187 -0
  69. package/dist/cjs/feedback/i18n/strings.d.ts +9 -0
  70. package/dist/cjs/feedback/i18n/strings.js +8 -0
  71. package/dist/cjs/feedback/index.js +1 -1
  72. package/dist/cjs/feedback/logs.d.ts +3 -6
  73. package/dist/cjs/feedback/logs.js +12 -21
  74. package/dist/cjs/feedback/quartz.js +5 -2
  75. package/dist/cjs/feedback/send.d.ts +6 -3
  76. package/dist/cjs/feedback/send.js +59 -41
  77. package/dist/cjs/feedback/styles.js +2 -2
  78. package/dist/cjs/feedback/template.d.ts +4 -2
  79. package/dist/cjs/feedback/template.js +73 -44
  80. package/dist/cjs/feedback/ui.d.ts +47 -4
  81. package/dist/cjs/feedback/ui.js +351 -97
  82. package/dist/cjs/heatmap/send.d.ts +2 -0
  83. package/dist/cjs/heatmap/send.js +3 -5
  84. package/dist/cjs/heatmap/track.js +13 -9
  85. package/dist/cjs/index.d.ts +1 -2
  86. package/dist/cjs/index.js +55 -18
  87. package/dist/cjs/lifecycle.d.ts +13 -2
  88. package/dist/cjs/lifecycle.js +233 -118
  89. package/dist/cjs/pushnotification/display.d.ts +65 -0
  90. package/dist/cjs/pushnotification/display.js +112 -0
  91. package/dist/cjs/pushnotification/index.d.ts +20 -0
  92. package/dist/cjs/pushnotification/index.js +96 -0
  93. package/dist/cjs/pushnotification/kept-opens.d.ts +23 -0
  94. package/dist/cjs/pushnotification/kept-opens.js +64 -0
  95. package/dist/cjs/pushnotification/notify.d.ts +45 -0
  96. package/dist/cjs/pushnotification/notify.js +476 -0
  97. package/dist/cjs/pushnotification/payload.d.ts +65 -0
  98. package/dist/cjs/pushnotification/payload.js +279 -0
  99. package/dist/cjs/pushnotification/session.d.ts +46 -0
  100. package/dist/cjs/pushnotification/session.js +413 -0
  101. package/dist/cjs/pushnotification/stats.d.ts +45 -0
  102. package/dist/cjs/pushnotification/stats.js +244 -0
  103. package/dist/cjs/pushnotification/wms.d.ts +30 -0
  104. package/dist/cjs/pushnotification/wms.js +374 -0
  105. package/dist/cjs/remoteconfig/country.js +1 -1
  106. package/dist/cjs/remoteconfig/custom.js +4 -3
  107. package/dist/cjs/remoteconfig/evaluate.js +1 -1
  108. package/dist/cjs/remoteconfig/fetch.d.ts +17 -10
  109. package/dist/cjs/remoteconfig/fetch.js +146 -32
  110. package/dist/cjs/remoteconfig/index.d.ts +9 -5
  111. package/dist/cjs/remoteconfig/index.js +24 -32
  112. package/dist/cjs/remoteconfig/store.d.ts +15 -7
  113. package/dist/cjs/remoteconfig/store.js +68 -35
  114. package/dist/cjs/remoteconfig/tz-countries.js +1 -1
  115. package/dist/cjs/{core → remotelog}/callsite.d.ts +5 -4
  116. package/dist/cjs/{core → remotelog}/callsite.js +6 -5
  117. package/dist/cjs/remotelog/gate.js +1 -1
  118. package/dist/cjs/remotelog/logger.js +2 -2
  119. package/dist/cjs/remotelog/send.js +6 -5
  120. package/dist/cjs/remotelogger/index.js +1 -1
  121. package/dist/cjs/scheduler.d.ts +3 -1
  122. package/dist/cjs/scheduler.js +34 -25
  123. package/dist/cjs/sw/apptics-pn-sw.d.ts +83 -0
  124. package/dist/cjs/sw/timers.d.ts +44 -0
  125. package/dist/cjs/types.d.ts +90 -29
  126. package/dist/cjs/user/index.d.ts +7 -0
  127. package/dist/cjs/user/index.js +25 -3
  128. package/dist/esm/core/attempts.js +1 -1
  129. package/dist/esm/core/batch.js +4 -4
  130. package/dist/esm/core/consent.d.ts +17 -4
  131. package/dist/esm/core/consent.js +84 -20
  132. package/dist/esm/core/console-call.d.ts +23 -0
  133. package/dist/esm/core/console-call.js +60 -0
  134. package/dist/esm/core/constants.d.ts +66 -17
  135. package/dist/esm/core/constants.js +73 -20
  136. package/dist/esm/core/db.js +31 -7
  137. package/dist/esm/core/debug.d.ts +6 -4
  138. package/dist/esm/core/debug.js +37 -13
  139. package/dist/esm/core/env.d.ts +0 -3
  140. package/dist/esm/core/env.js +2 -9
  141. package/dist/esm/core/framework-id.d.ts +1 -1
  142. package/dist/esm/core/framework-id.js +3 -3
  143. package/dist/esm/core/guard.js +19 -4
  144. package/dist/esm/core/hooks.d.ts +29 -0
  145. package/dist/esm/core/hooks.js +12 -1
  146. package/dist/esm/core/locks.js +1 -1
  147. package/dist/esm/core/logger.js +1 -1
  148. package/dist/esm/core/shield.d.ts +31 -0
  149. package/dist/esm/core/shield.js +119 -0
  150. package/dist/esm/core/state.d.ts +11 -5
  151. package/dist/esm/core/state.js +4 -4
  152. package/dist/esm/core/storage.d.ts +7 -0
  153. package/dist/esm/core/storage.js +28 -11
  154. package/dist/esm/core/stylesheet.js +1 -1
  155. package/dist/esm/core/transport.d.ts +15 -4
  156. package/dist/esm/core/transport.js +73 -28
  157. package/dist/esm/core/utils.js +1 -1
  158. package/dist/esm/core/validate.js +6 -5
  159. package/dist/esm/device/appversion.d.ts +10 -1
  160. package/dist/esm/device/appversion.js +26 -4
  161. package/dist/esm/device/index.d.ts +17 -2
  162. package/dist/esm/device/index.js +255 -42
  163. package/dist/esm/engagement/api-rules.js +1 -1
  164. package/dist/esm/engagement/auto-api.js +4 -3
  165. package/dist/esm/engagement/auto-screen.js +10 -6
  166. package/dist/esm/engagement/defined-events.d.ts +2 -3
  167. package/dist/esm/engagement/defined-events.js +10 -16
  168. package/dist/esm/engagement/send.js +7 -3
  169. package/dist/esm/engagement/session.d.ts +17 -0
  170. package/dist/esm/engagement/session.js +152 -24
  171. package/dist/esm/engagement/track.d.ts +4 -4
  172. package/dist/esm/engagement/track.js +24 -18
  173. package/dist/esm/errors/send.js +2 -2
  174. package/dist/esm/errors/track.d.ts +2 -1
  175. package/dist/esm/errors/track.js +8 -5
  176. package/dist/esm/feedback/controls.d.ts +36 -4
  177. package/dist/esm/feedback/controls.js +298 -68
  178. package/dist/esm/feedback/i18n/index.d.ts +31 -0
  179. package/dist/esm/feedback/i18n/index.js +178 -0
  180. package/dist/esm/feedback/i18n/strings.d.ts +9 -0
  181. package/dist/esm/feedback/i18n/strings.js +4 -0
  182. package/dist/esm/feedback/index.js +1 -1
  183. package/dist/esm/feedback/logs.d.ts +3 -6
  184. package/dist/esm/feedback/logs.js +12 -21
  185. package/dist/esm/feedback/quartz.js +5 -2
  186. package/dist/esm/feedback/send.d.ts +6 -3
  187. package/dist/esm/feedback/send.js +61 -44
  188. package/dist/esm/feedback/styles.js +2 -2
  189. package/dist/esm/feedback/template.d.ts +4 -2
  190. package/dist/esm/feedback/template.js +73 -44
  191. package/dist/esm/feedback/ui.d.ts +47 -4
  192. package/dist/esm/feedback/ui.js +353 -99
  193. package/dist/esm/heatmap/send.d.ts +2 -0
  194. package/dist/esm/heatmap/send.js +3 -5
  195. package/dist/esm/heatmap/track.js +13 -9
  196. package/dist/esm/index.d.ts +1 -2
  197. package/dist/esm/index.js +58 -21
  198. package/dist/esm/lifecycle.d.ts +13 -2
  199. package/dist/esm/lifecycle.js +238 -125
  200. package/dist/esm/pushnotification/display.d.ts +65 -0
  201. package/dist/esm/pushnotification/display.js +95 -0
  202. package/dist/esm/pushnotification/index.d.ts +20 -0
  203. package/dist/esm/pushnotification/index.js +91 -0
  204. package/dist/esm/pushnotification/kept-opens.d.ts +23 -0
  205. package/dist/esm/pushnotification/kept-opens.js +62 -0
  206. package/dist/esm/pushnotification/notify.d.ts +45 -0
  207. package/dist/esm/pushnotification/notify.js +469 -0
  208. package/dist/esm/pushnotification/payload.d.ts +65 -0
  209. package/dist/esm/pushnotification/payload.js +272 -0
  210. package/dist/esm/pushnotification/session.d.ts +46 -0
  211. package/dist/esm/pushnotification/session.js +402 -0
  212. package/dist/esm/pushnotification/stats.d.ts +45 -0
  213. package/dist/esm/pushnotification/stats.js +238 -0
  214. package/dist/esm/pushnotification/wms.d.ts +30 -0
  215. package/dist/esm/pushnotification/wms.js +368 -0
  216. package/dist/esm/remoteconfig/country.js +1 -1
  217. package/dist/esm/remoteconfig/custom.js +4 -3
  218. package/dist/esm/remoteconfig/evaluate.js +1 -1
  219. package/dist/esm/remoteconfig/fetch.d.ts +17 -10
  220. package/dist/esm/remoteconfig/fetch.js +147 -33
  221. package/dist/esm/remoteconfig/index.d.ts +9 -5
  222. package/dist/esm/remoteconfig/index.js +24 -32
  223. package/dist/esm/remoteconfig/store.d.ts +15 -7
  224. package/dist/esm/remoteconfig/store.js +68 -36
  225. package/dist/esm/remoteconfig/tz-countries.js +1 -1
  226. package/dist/esm/{core → remotelog}/callsite.d.ts +5 -4
  227. package/dist/esm/{core → remotelog}/callsite.js +6 -5
  228. package/dist/esm/remotelog/gate.js +1 -1
  229. package/dist/esm/remotelog/logger.js +2 -2
  230. package/dist/esm/remotelog/send.js +6 -5
  231. package/dist/esm/remotelogger/index.js +1 -1
  232. package/dist/esm/scheduler.d.ts +3 -1
  233. package/dist/esm/scheduler.js +35 -27
  234. package/dist/esm/sw/apptics-pn-sw.d.ts +83 -0
  235. package/dist/esm/sw/timers.d.ts +44 -0
  236. package/dist/esm/types.d.ts +90 -29
  237. package/dist/esm/user/index.d.ts +7 -0
  238. package/dist/esm/user/index.js +26 -5
  239. package/dist/feedback.esm.min.js +2 -2
  240. package/dist/feedback.esm.min.js.map +1 -1
  241. package/dist/pushnotification.esm.min.js +3 -0
  242. package/dist/pushnotification.esm.min.js.map +1 -0
  243. package/dist/remoteconfig.esm.min.js +3 -0
  244. package/dist/remoteconfig.esm.min.js.map +1 -0
  245. package/dist/remotelogger.esm.min.js +3 -0
  246. package/dist/remotelogger.esm.min.js.map +1 -0
  247. package/package.json +17 -3
  248. package/dist/chunks/lifecycle-VYr43KcB.min.js +0 -3
  249. package/dist/chunks/lifecycle-VYr43KcB.min.js.map +0 -1
  250. package/dist/cjs/auto-init.d.ts +0 -8
  251. package/dist/cjs/auto-init.js +0 -32
  252. package/dist/esm/auto-init.d.ts +0 -8
  253. package/dist/esm/auto-init.js +0 -29
@@ -1,4 +1,4 @@
1
- /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.1 | (c) Zoho Corporation Private Limited | see LICENSE */
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0 | (c) Zoho Corporation Private Limited | see LICENSE */
2
2
  'use strict';
3
3
 
4
4
  var constants = require('./core/constants.js');
@@ -21,6 +21,7 @@ var send = require('./remotelog/send.js');
21
21
  var index$1 = require('./user/index.js');
22
22
  var attempts = require('./core/attempts.js');
23
23
  var frameworkId = require('./core/framework-id.js');
24
+ var shield = require('./core/shield.js');
24
25
 
25
26
  let listenersAttached = false;
26
27
  /** The config init() was last called with; reset() starts again from it. */
@@ -116,10 +117,15 @@ var previousAppVersion = ''; // no i18n
116
117
  /**
117
118
  * Data stored for another app on this origin is discarded before anything else reads it,
118
119
  * including the stored app/addversion answer that would otherwise hand out that app's ids.
120
+ *
121
+ * Another app is a different base_url, app_domain or auth_key from the ones the stored data was
122
+ * registered with. Everything goes, the queues included, and start-up runs as on a first visit:
123
+ * app/addversion, device/add and the rest. Resolves once the store is empty.
119
124
  */
120
125
  function discardOtherAppData(settings) {
121
- // which app it is, and which version, are in app_version_info (serviceUrl, identifier and
122
- // appversion): no keys of their own. 2.0.0-beta's appkey and appversion are read this once
126
+ // which app it is, and which version, are in app_version_info (serviceUrl, identifier, a
127
+ // fingerprint of zak, and appversion): no keys of their own. 2.0.0-beta's appkey and
128
+ // appversion are read this once
123
129
  var info = storage.user_defaults.item('app_version_info') || {}; // no i18n
124
130
  var stored = !utils.isEmpty(info.serviceUrl) && !utils.isEmpty(info.identifier)
125
131
  ? appKey(info)
@@ -127,11 +133,17 @@ function discardOtherAppData(settings) {
127
133
  previousAppVersion = String((!utils.isEmpty(info.appversion) ? info.appversion : storage.user_defaults.item('appversion')) || ''); // no i18n
128
134
  storage.user_defaults.add('appkey', undefined); // no i18n
129
135
  storage.user_defaults.add('appversion', undefined); // no i18n
130
- if (!utils.isEmpty(stored) && stored !== appKey(settings)) {
131
- logger.Console.log('init: stored data belongs to another app, resetting'); // no i18n
132
- clearStorage();
133
- previousAppVersion = ''; // no i18n
134
- }
136
+ var otherApp = !utils.isEmpty(stored) && stored !== appKey(settings);
137
+ // a build that kept no fingerprint cannot tell: hasAppVersion() registers again, and records one
138
+ var otherKey = !utils.isEmpty(info.zakhash) && info.zakhash !== appversion.keyFingerprint(settings.zak);
139
+ if (!otherApp && !otherKey) {
140
+ return Promise.resolve();
141
+ }
142
+ logger.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
143
+ previousAppVersion = ''; // no i18n
144
+ // the remote config values read from the store, which is about to go
145
+ hooks.hooks.resetRemoteConfig();
146
+ return clearStorage();
135
147
  }
136
148
  /**
137
149
  * Timing an app may tune in init(). Each has a range: a value outside it is ignored with a
@@ -142,7 +154,7 @@ const TUNABLE = Object.freeze([
142
154
  { key: 'getupdates_interval', min: 10000, max: 86400000 }, // no i18n
143
155
  { key: 'batch_size', min: 1, max: 500 }, // no i18n
144
156
  { key: 'batch_request_timeout', min: 1, max: 30 }, // no i18n
145
- { key: 'min_session_duration', min: 0, max: 60000 }, // no i18n
157
+ { key: 'min_session_duration', min: constants.SESSION_TIMING_MIN_MS, max: constants.SESSION_TIMING_MAX_MS }, // no i18n
146
158
  { key: 'heatmap_max_per_session', min: 0, max: 10000 }, // no i18n
147
159
  ]);
148
160
  /** Reads the tunable timings out of the config. Anything missing goes back to its default. */
@@ -162,28 +174,45 @@ function applyIntervals(config) {
162
174
  state._ZAP._config[rule.key] = num;
163
175
  logger.Console.log('Apptics.init: ' + rule.key + ' set to ' + num); // no i18n
164
176
  });
165
- // inactiveduration lives on state, not in _config
177
+ // max_session_duration: how long a tab may be inactive before its session ends, in
178
+ // milliseconds like min_session_duration. Kept on state in minutes (_ZAP.inactiveduration),
179
+ // which is how the session code counts it. The retired inactiveduration, in minutes, is still
180
+ // read when max_session_duration is not given
166
181
  state._ZAP.inactiveduration = constants.DEFAULT_INACTIVE_MINUTES;
167
- if (!utils.isEmpty(config.inactiveduration)) {
168
- var minutes = Number(config.inactiveduration);
169
- if (!isFinite(minutes) || minutes < 1 || minutes > 1440) {
170
- logger.warnAlways('Apptics.init: inactiveduration must be between 1 and 1440 minutes, keeping ' + state._ZAP.inactiveduration); // no i18n
171
- }
172
- else {
173
- state._ZAP.inactiveduration = minutes;
174
- logger.Console.log('Apptics.init: inactiveduration set to ' + minutes); // no i18n
175
- }
182
+ var keyName = 'max_session_duration'; // no i18n
183
+ var ms = NaN;
184
+ if (!utils.isEmpty(config.max_session_duration)) {
185
+ ms = Number(config.max_session_duration);
186
+ }
187
+ else if (!utils.isEmpty(config.inactiveduration)) {
188
+ logger.warnAlways('Apptics.init: inactiveduration is now max_session_duration, in milliseconds; rename it in your config'); // no i18n
189
+ keyName = 'inactiveduration'; // no i18n
190
+ ms = Math.round(Number(config.inactiveduration) * 60 * 1000);
191
+ }
192
+ else {
193
+ return;
194
+ }
195
+ if (!isFinite(ms) || ms < constants.SESSION_TIMING_MIN_MS || ms > constants.SESSION_TIMING_MAX_MS) {
196
+ logger.warnAlways('Apptics.init: ' + keyName + ' must be between 5 seconds and 30 minutes (' + constants.SESSION_TIMING_MIN_MS + ' to ' + constants.SESSION_TIMING_MAX_MS + ' ms), keeping ' + (constants.DEFAULT_INACTIVE_MINUTES * 60 * 1000) + ' ms'); // no i18n
197
+ return;
176
198
  }
199
+ state._ZAP.inactiveduration = keyName === 'inactiveduration' ? Number(config.inactiveduration) : ms / (60 * 1000); // no i18n
200
+ logger.Console.log('Apptics.init: max_session_duration set to ' + ms + ' ms'); // no i18n
177
201
  }
202
+ /** Everything the SDK stores: settings, ids and every queue. Resolves once it is all gone. */
178
203
  function clearStorage() {
179
204
  attempts.clearAttempts();
180
205
  storage.user_defaults.clear();
181
- storage.engagement_transactions.clear();
182
- storage.error_transactions.clear();
206
+ return Promise.all([
207
+ storage.engagement_transactions, storage.error_transactions, storage.heatmap_transactions, storage.remotelog_transactions, storage.feedbacklog_transactions,
208
+ ].map(function (queue) {
209
+ return queue.clear();
210
+ })).then(function () {
211
+ return undefined;
212
+ });
183
213
  }
184
214
  /**
185
- * Starts the SDK. The config object is required: pass it directly, or let the console snippet
186
- * supply it (auto-init reads window.appticssettings._defaultoptions and calls init with it).
215
+ * Starts the SDK. The config object is required: the SDK starts only when the app calls this.
187
216
  * Returns true when the config has base_url, auth_key, app_domain and appversion and start-up has
188
217
  * begun (see ready()), false when it was already running, the config is missing or incomplete, or
189
218
  * there is no browser. Start-up calls app/addversion with those four, which answers with aaid, the
@@ -229,15 +258,21 @@ function init(config) {
229
258
  if (typeof config.ignore_do_not_track === 'boolean') { // no i18n
230
259
  state._ZAP._config.ignore_do_not_track = config.ignore_do_not_track;
231
260
  }
232
- // debug: debug mode, the debug endpoints. Same payloads, but the answer says where to trace the
233
- // request. debug_api is its earlier name and still works; debug wins when both are given
234
- state._ZAP._config.debug_api = typeof config.debug === 'boolean' ? config.debug // no i18n
235
- : typeof config.debug_api === 'boolean' ? config.debug_api : constants.AP_CONFIG.debug_api; // no i18n
236
- // starts (or clears) the idle hour that closes debug mode on its own
237
- // an enableDebug() or disableDebug() call the app already made wins over the config
238
- debug.applyDebugConfig(state._ZAP._config.debug_api);
261
+ // debug mode is switched from the browser console only (Apptics.enableDebug()), never from
262
+ // config, so an app cannot ship with it on
263
+ ['debug', 'debug_api'].forEach(function (key) {
264
+ if (config[key] !== undefined) {
265
+ logger.warnAlways('Apptics.init: ' + key + ' is no longer an init option and is ignored; type Apptics.enableDebug() in the browser console to turn debug mode on'); // no i18n
266
+ }
267
+ });
268
+ // off, unless enableDebug() was already called; starts (or clears) the idle hour
269
+ debug.applyDebugConfig();
239
270
  // what to call this device in the debug stream; see devicename in core/transport.ts
240
271
  state._ZAP._config.device_name = typeof config.device_name === 'string' ? config.device_name : constants.AP_CONFIG.device_name; // no i18n
272
+ // push notifications always use the site's /apptics-pn-sw.js
273
+ if (config.push_service_worker !== undefined) {
274
+ logger.warnAlways('Apptics.init: push_service_worker is no longer an init option and is ignored; push notifications use your site\'s /apptics-pn-sw.js'); // no i18n
275
+ }
241
276
  // the SDK no longer reports its own failures to the Remote Logger page: only the lines an app
242
277
  // logs with AppticsLogger go there
243
278
  if (config.remote_log !== undefined) {
@@ -281,6 +316,10 @@ function init(config) {
281
316
  // screen view can be stored
282
317
  state._ZAP._config.track_screen = typeof config.track_screen === 'boolean' ? config.track_screen : constants.AP_CONFIG.track_screen; // no i18n
283
318
  state._ZAP._config.screen_routes = screenRouteRules(config.screen_routes);
319
+ // uncaught errors and tagged clicks, on unless the config says false: the listeners check
320
+ // these as each error or click happens
321
+ state._ZAP._config.track_error = typeof config.track_error === 'boolean' ? config.track_error : constants.AP_CONFIG.track_error; // no i18n
322
+ state._ZAP._config.track_click = typeof config.track_click === 'boolean' ? config.track_click : constants.AP_CONFIG.track_click; // no i18n
284
323
  // a theme in the config wins; without one, what AppticsFeedback.setFeedbackTheme set stays
285
324
  if (config.feedback_theme === 'light' || config.feedback_theme === 'dark' || config.feedback_theme === 'auto') { // no i18n
286
325
  state._ZAP._config.feedback_theme = config.feedback_theme;
@@ -302,46 +341,56 @@ function init(config) {
302
341
  state._ZAP._pending = [];
303
342
  return false;
304
343
  }
305
- discardOtherAppData(state._ZAP._defaultoptions);
306
- // app/addversion is the first call and everything waits on it: it is what turns the four
307
- // values init() was given into aaid, the portal and project ids every url carries, and
308
- // appreleaseversionid, which metaWebSDKV2 refuses a payload without
309
- return appversion.registerAppVersion().then(function (registered) {
344
+ return discardOtherAppData(state._ZAP._defaultoptions).then(function () {
310
345
  if (myGeneration !== generation) {
311
346
  return false;
312
347
  }
313
- if (!registered && appversion.appVersionFailedForNetwork()) {
314
- // a first visit with no network: start once it is back, keeping what the app
315
- // tracks until then queued, rather than giving up for the rest of the page
316
- logger.warnAlways('Apptics.init: offline, so app/addversion is tried again when the browser is back online; calls made until then are kept'); // no i18n
317
- return registerWhenOnline(myGeneration).then(function (ok) {
318
- if (myGeneration !== generation) {
319
- return false;
320
- }
321
- if (!ok) {
322
- state._ZAP._initialised = false;
323
- state._ZAP._token = ''; // no i18n
324
- state._ZAP._pending = [];
325
- return false;
326
- }
327
- return start(config, myGeneration);
328
- });
329
- }
330
- if (!registered) {
331
- logger.warnAlways('Apptics.init: app/addversion did not return the app ids, not starting'); // no i18n
332
- state._ZAP._initialised = false;
333
- state._ZAP._token = ''; // no i18n
334
- state._ZAP._pending = [];
335
- return false;
336
- }
337
- return start(config, myGeneration);
348
+ return startUp(config, myGeneration);
338
349
  });
339
350
  }).catch(function (err) {
340
351
  logger.Console.error('Apptics.init: start-up failed', err); // no i18n
341
352
  return false;
342
353
  });
354
+ // push calls made before init() wait on this start-up, success or not
355
+ hooks.hooks.pushInitCalled();
343
356
  return true;
344
357
  }
358
+ /** Start-up from app/addversion on, once the store holds only this app's data. */
359
+ function startUp(config, myGeneration) {
360
+ // app/addversion is the first call and everything waits on it: it is what turns the four
361
+ // values init() was given into aaid, the portal and project ids every url carries, and
362
+ // appreleaseversionid, which metaWebSDKV2 refuses a payload without
363
+ return appversion.registerAppVersion().then(function (registered) {
364
+ if (myGeneration !== generation) {
365
+ return false;
366
+ }
367
+ if (!registered && appversion.appVersionFailedForNetwork()) {
368
+ // a first visit with no network: start once it is back, keeping what the app
369
+ // tracks until then queued, rather than giving up for the rest of the page
370
+ logger.warnAlways('Apptics.init: offline, so app/addversion is tried again when the browser is back online; calls made until then are kept'); // no i18n
371
+ return registerWhenOnline(myGeneration).then(function (ok) {
372
+ if (myGeneration !== generation) {
373
+ return false;
374
+ }
375
+ if (!ok) {
376
+ state._ZAP._initialised = false;
377
+ state._ZAP._token = ''; // no i18n
378
+ state._ZAP._pending = [];
379
+ return false;
380
+ }
381
+ return start(config, myGeneration);
382
+ });
383
+ }
384
+ if (!registered) {
385
+ logger.warnAlways('Apptics.init: app/addversion did not return the app ids, not starting'); // no i18n
386
+ state._ZAP._initialised = false;
387
+ state._ZAP._token = ''; // no i18n
388
+ state._ZAP._pending = [];
389
+ return false;
390
+ }
391
+ return start(config, myGeneration);
392
+ });
393
+ }
345
394
  /** How often a start-up waiting on the network tries app/addversion again, besides on `online`. */
346
395
  const OFFLINE_RETRY_MS = 60 * 1000;
347
396
  /**
@@ -359,7 +408,7 @@ function registerWhenOnline(myGeneration) {
359
408
  clearInterval(timer);
360
409
  resolve(ok);
361
410
  }
362
- function attempt() {
411
+ function tryRegister() {
363
412
  if (myGeneration !== generation) {
364
413
  done(false);
365
414
  return;
@@ -368,7 +417,7 @@ function registerWhenOnline(myGeneration) {
368
417
  return;
369
418
  }
370
419
  trying = true;
371
- appversion.registerAppVersion().then(function (registered) {
420
+ shield.quietly('app/addversion retry', appversion.registerAppVersion().then(function (registered) {
372
421
  trying = false;
373
422
  if (registered) {
374
423
  done(true);
@@ -377,8 +426,12 @@ function registerWhenOnline(myGeneration) {
377
426
  logger.warnAlways('Apptics.init: app/addversion did not return the app ids, not starting'); // no i18n
378
427
  done(false);
379
428
  }
380
- });
429
+ }, function (err) {
430
+ trying = false;
431
+ throw err;
432
+ }));
381
433
  }
434
+ var attempt = shield.shield('app/addversion retry', tryRegister); // no i18n
382
435
  window.addEventListener('online', attempt); // no i18n
383
436
  timer = setInterval(attempt, OFFLINE_RETRY_MS);
384
437
  });
@@ -448,6 +501,8 @@ function start(config, myGeneration) {
448
501
  state._ZAP._token = String(state._ZAP._defaultoptions.aaid);
449
502
  // last known server settings (getupdates) apply before anything is tracked
450
503
  index.restoreServerSettings();
504
+ // the user this browser was tracking as, before getsdkconfig is asked: it carries their ids
505
+ index$1.getUserInfo();
451
506
  // a new release of the app, against the version the stored data was for (see
452
507
  // discardOtherAppData): a first visit has none, and is no change
453
508
  var appVersionChanged = previousAppVersion !== '' && previousAppVersion != state._ZAP._defaultoptions.appversion; // no i18n
@@ -466,11 +521,15 @@ function start(config, myGeneration) {
466
521
  }
467
522
  /** The rest of start-up, once the device is set up. */
468
523
  function startTracking(appVersionChanged, myGeneration) {
469
- // no getsdkconfig here, straight after app/addversion: it is asked for once device/add has
470
- // succeeded (registerDeviceWithApptics), then every getupdates_interval. A returning visit
471
- // starts from the settings saved by the last one (restoreServerSettings, in start())
524
+ // getsdkconfig, once per page load and then at each answer's next_check_after. A first visit
525
+ // asked as soon as device/add succeeded (registerDeviceWithApptics) and this does nothing; a
526
+ // returning visit, whose device is registered, asks now, after app/addversion. Until it
527
+ // answers, the settings saved by the last visit apply (restoreServerSettings, in start())
528
+ index.startServerSettingChecks();
472
529
  if (appVersionChanged) {
473
- state._ZAP._device_info.appversionid = ''; // no i18n
530
+ // the device is told its new appversionid, which app/addversion has just answered for this
531
+ // release and device/add declares mandatory: sent empty, the update was refused, and every
532
+ // call after it went without the id
474
533
  index.updateDeviceWithApptics(state._ZAP._device_info).then(function (result) {
475
534
  if (utils.isSuccess(result)) {
476
535
  logger.Console.log('init: appversion updated to ' + state._ZAP._defaultoptions.appversion); // no i18n
@@ -483,13 +542,12 @@ function startTracking(appVersionChanged, myGeneration) {
483
542
  state._ZAP._device_info.connectionType = env.getConnectionType();
484
543
  attachListeners();
485
544
  state._ZAP._properties.orientation = env.getOrientation();
486
- index$1.getUserInfo();
487
545
  return session.checkAndUpdateSession().then(function () {
488
546
  if (myGeneration !== generation) {
489
547
  return false;
490
548
  }
491
549
  scheduler.startTimers();
492
- send.sendStoredLogs();
550
+ shield.quietly('sending stored logs', send.sendStoredLogs()); // no i18n
493
551
  state._ZAP._ready = true;
494
552
  // replay calls made while storage was loading, in order
495
553
  var pending = state._ZAP._pending;
@@ -507,8 +565,11 @@ function startTracking(appVersionChanged, myGeneration) {
507
565
  autoScreen.enableScreenTracking(state._ZAP._config.track_screen);
508
566
  // a no-op unless the remote-config entry was imported, which sets the hook
509
567
  hooks.hooks.remoteConfigStarted();
568
+ // the same for push notification: a no-op unless its entry was imported
569
+ hooks.hooks.pushStarted();
510
570
  window.appticsReadyStatus = true;
511
571
  if (typeof window.appticsReady == 'function') { // no i18n
572
+ // the app's own callback: what it throws is the app's, so it is not caught here
512
573
  window.appticsReady();
513
574
  }
514
575
  return true;
@@ -518,6 +579,7 @@ function startTracking(appVersionChanged, myGeneration) {
518
579
  function reset() {
519
580
  generation++;
520
581
  scheduler.stopTimers();
582
+ session.resetInactivity();
521
583
  // the wrappers come off with everything else; the init() below puts them back if the config
522
584
  // asked for them, so a reset that has no config to restore leaves XHR and fetch untouched
523
585
  autoApi.enableApiTracking(false);
@@ -526,7 +588,10 @@ function reset() {
526
588
  hooks.hooks.trackHeatmap(false);
527
589
  hooks.hooks.resetHeatmap();
528
590
  hooks.hooks.resetRemoteConfig();
529
- clearStorage();
591
+ hooks.hooks.resetPush();
592
+ state._ZAP._pushEnabled = false;
593
+ state._ZAP._wmsConfig = null;
594
+ shield.quietly('clearing storage', clearStorage()); // no i18n
530
595
  state._ZAP._initialised = false;
531
596
  state._ZAP._ready = false;
532
597
  state._ZAP._pending = [];
@@ -548,6 +613,26 @@ function reset() {
548
613
  function isActive() {
549
614
  return state._ZAP._ready;
550
615
  }
616
+ /**
617
+ * AppticsEvent.setClickTracking: click tracking from markup on or off, as the `track_click`
618
+ * config sets it. The listener stays; it checks the switch on every click.
619
+ */
620
+ function setClickTracking(enabled) {
621
+ state._ZAP._config.track_click = typeof enabled === 'boolean' ? enabled : true; // no i18n
622
+ logger.Console.log('click tracking: ' + (state._ZAP._config.track_click ? 'on' : 'off')); // no i18n
623
+ }
624
+ /**
625
+ * AppticsScreen.setScreenTracking: automatic screen tracking on or off, as the `track_screen`
626
+ * config sets it. Applied now once the SDK is running; before that it is only noted, and start()
627
+ * switches tracking to it. Like the other switches, the next init() (a reset() too) goes back to
628
+ * what its config says.
629
+ */
630
+ function setScreenTracking(enabled) {
631
+ state._ZAP._config.track_screen = typeof enabled === 'boolean' ? enabled : true; // no i18n
632
+ if (isActive()) {
633
+ autoScreen.enableScreenTracking(state._ZAP._config.track_screen);
634
+ }
635
+ }
551
636
  /**
552
637
  * A click-tracking attribute, in either spelling: `apeventaction`, or `data-apeventaction`, which
553
638
  * is valid HTML and what React and TypeScript accept without declaring the attribute.
@@ -563,7 +648,7 @@ function trackingSelector(name) {
563
648
  // Declarative click tracking: <el apeventaction="name" apeventprops='{"k":"v"}'> inside <el apgroupaction="group">,
564
649
  // or the same attributes with a data- prefix
565
650
  function onDocumentClick(event) {
566
- if (!window.appticsReadyStatus || !isActive()) {
651
+ if (!window.appticsReadyStatus || !isActive() || !state._ZAP._config.track_click) {
567
652
  return;
568
653
  }
569
654
  var start = event.target;
@@ -579,7 +664,8 @@ function onDocumentClick(event) {
579
664
  }
580
665
  var eventName = trackingAttribute(targetElem, 'apeventaction') || ''; // no i18n
581
666
  var groupElem = targetElem.closest(trackingSelector('apgroupaction')); // no i18n
582
- var groupName = (groupElem && trackingAttribute(groupElem, 'apgroupaction')) || constants.AP_CONFIG.default_group_name; // no i18n
667
+ // no apgroupaction around it: trackEvent refuses it and says the group is missing
668
+ var groupName = (groupElem && trackingAttribute(groupElem, 'apgroupaction')) || undefined; // no i18n
583
669
  var eventProps = {};
584
670
  var rawProps = trackingAttribute(targetElem, 'apeventprops'); // no i18n
585
671
  if (!utils.isEmpty(rawProps)) {
@@ -603,25 +689,33 @@ function onDocumentClick(event) {
603
689
  function onPageHidden() {
604
690
  if (!isActive())
605
691
  return;
606
- session.updateScreenWithEndtime();
607
- scheduler.flush(true);
692
+ // the moment the user left: the session ends at it if they are not back within max_session_duration
693
+ shield.quietly('closing the screen', session.markTabInactive(sendEndedSession)); // no i18n
694
+ shield.quietly('closing the screen', session.updateScreenWithEndtime()); // no i18n
695
+ shield.quietly('sending on page hide', scheduler.flush(true)); // no i18n
608
696
  logger.Console.log('page hidden: closing the open screen and flushing'); // no i18n
609
697
  }
698
+ /** A session that inactivity ended while the tab was away: sent now, not when the user returns. */
699
+ const sendEndedSession = shield.shield('sending the ended session', function () {
700
+ if (!isActive())
701
+ return;
702
+ shield.quietly('sending the ended session', scheduler.flush()); // no i18n
703
+ });
610
704
  /**
611
705
  * The tab is closing, or the page is being replaced or frozen into the back/forward cache.
612
706
  * The session ends here, and everything queued goes out by keepalive, since a normal
613
707
  * request would be cancelled with the page.
614
708
  */
615
- function onPageClosing() {
709
+ const onPageClosing = shield.shield('page closing', function () {
616
710
  if (!isActive())
617
711
  return;
618
712
  logger.Console.log('page closing: ending the session and sending what is queued'); // no i18n
619
- session.updateScreenWithEndtime();
620
- send.forgetStoredLogs();
621
- session.endCurrentSession().then(function () {
713
+ shield.quietly('page closing', session.updateScreenWithEndtime()); // no i18n
714
+ shield.quietly('page closing', send.forgetStoredLogs()); // no i18n
715
+ shield.quietly('page closing', session.endCurrentSession().then(function () {
622
716
  return scheduler.flush(true);
623
- });
624
- }
717
+ }));
718
+ });
625
719
  function attachListeners() {
626
720
  if (listenersAttached) {
627
721
  return;
@@ -630,57 +724,62 @@ function attachListeners() {
630
724
  // listen for connection change events (only available in w3c implementation)
631
725
  var connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection;
632
726
  if (connection && connection.addEventListener) {
633
- connection.addEventListener('change', function () {
727
+ connection.addEventListener('change', shield.shield('connection change', function () {
634
728
  state._ZAP._device_info.connectionType = env.getConnectionType();
635
- });
729
+ }));
636
730
  }
637
731
  // Track when the window loses focus (user switches to another window or application)
638
- window.addEventListener('blur', function () {
732
+ window.addEventListener('blur', shield.shield('window blur', function () {
639
733
  if (!isActive())
640
734
  return;
735
+ // focus moving into an iframe on the page blurs the window too, and the user is still here
736
+ if (document.activeElement && document.activeElement.tagName === 'IFRAME')
737
+ return; // no i18n
641
738
  logger.Console.log('Window lost focus, user switched to another window or application'); // no i18n
642
- session.updateLastActiveTimeOfSession();
643
- });
739
+ shield.quietly('window blur', session.markTabInactive(sendEndedSession)); // no i18n
740
+ }));
644
741
  // Track when the window gains focus (user switches back to the window)
645
- window.addEventListener('focus', function () {
742
+ window.addEventListener('focus', shield.shield('window focus', function () {
646
743
  if (!isActive())
647
744
  return;
648
745
  logger.Console.log('Window regained focus, user switched back to the window'); // no i18n
649
- session.checkAndUpdateSession();
746
+ session.markTabActive();
747
+ shield.quietly('window focus', session.checkAndUpdateSession()); // no i18n
650
748
  scheduler.startTimers();
651
- });
749
+ }));
652
750
  // IndexedDB writes are async, so unload work starts on pagehide rather than beforeunload
653
751
  window.addEventListener('pagehide', onPageClosing); // no i18n
654
752
  // back/forward cache: pagehide ended the session, so coming back starts a new one
655
- window.addEventListener('pageshow', function (event) {
753
+ window.addEventListener('pageshow', shield.shield('page show', function (event) {
656
754
  if (!isActive() || !event.persisted)
657
755
  return;
658
756
  logger.Console.log('restored from the back/forward cache: starting a new session'); // no i18n
757
+ session.markTabActive();
659
758
  // the screen the page was left on starts a new view, in the new session
660
- session.checkAndUpdateSession().then(track.resumeScreen);
759
+ shield.quietly('page show', session.checkAndUpdateSession().then(track.resumeScreen)); // no i18n
661
760
  scheduler.startTimers();
662
- });
663
- document.addEventListener('visibilitychange', function () {
761
+ }));
762
+ document.addEventListener('visibilitychange', shield.shield('visibility change', function () {
664
763
  if (!isActive())
665
764
  return;
666
765
  if (document.visibilityState === 'hidden') { // no i18n
667
766
  onPageHidden();
668
767
  return;
669
768
  }
670
- // back in view: the server's tracking flags may have changed while we were away
671
- logger.Console.log('page visible: refreshing the server settings'); // no i18n
769
+ // back in view. getsdkconfig is not asked here: only at its next_check_after, on a tab's
770
+ // first page load, and when a user is registered or getupdates reports a change
771
+ session.markTabActive();
672
772
  // hiding ended the screen view; the screen the user is back on starts a new one, after the
673
773
  // session is settled so the view belongs to the right one
674
- session.checkAndUpdateSession().then(track.resumeScreen);
675
- index.refreshServerSettings();
676
- });
774
+ shield.quietly('visibility change', session.checkAndUpdateSession().then(track.resumeScreen)); // no i18n
775
+ }));
677
776
  // if we are running in cordova use ondeviceready otherwise onload
678
- window.addEventListener(window.cordova ? 'deviceready' : 'load', function () {
777
+ window.addEventListener(window.cordova ? 'deviceready' : 'load', shield.shield('page load', function () {
679
778
  if (isActive())
680
- session.checkAndUpdateSession();
681
- }, { passive: true });
779
+ shield.quietly('page load', session.checkAndUpdateSession()); // no i18n
780
+ }), { passive: true });
682
781
  // Always send pending requests when the connection comes back online
683
- window.addEventListener('online', function () {
782
+ window.addEventListener('online', shield.shield('back online', function () {
684
783
  if (!isActive())
685
784
  return;
686
785
  // a first visit that started offline has no device ids yet, and nothing can be sent
@@ -688,47 +787,63 @@ function attachListeners() {
688
787
  if (index.needsDevice()) {
689
788
  logger.Console.log('back online: registering this device before sending'); // no i18n
690
789
  // the same locked path as start-up, so two tabs coming back online register it once
691
- index.prepareDevice().then(index.deviceReady).then(function () {
790
+ shield.quietly('back online', index.prepareDevice().then(index.deviceReady).then(function () {
692
791
  if (!isActive())
693
792
  return;
694
- scheduler.flush();
793
+ shield.quietly('back online', scheduler.flush()); // no i18n
695
794
  // the lines logged while offline are waiting too, and log/add needs the same ids
696
- send.sendStoredLogs();
697
- });
795
+ shield.quietly('back online', send.sendStoredLogs()); // no i18n
796
+ }));
698
797
  return;
699
798
  }
700
- scheduler.flush();
701
- send.sendStoredLogs();
702
- }, { passive: true });
799
+ shield.quietly('back online', scheduler.flush()); // no i18n
800
+ shield.quietly('back online', send.sendStoredLogs()); // no i18n
801
+ }), { passive: true });
703
802
  if (window.screen && window.screen.orientation && typeof window.screen.orientation.addEventListener === 'function') { // no i18n
704
- window.screen.orientation.addEventListener('change', function () {
803
+ window.screen.orientation.addEventListener('change', shield.shield('orientation change', function () {
705
804
  state._ZAP._properties.orientation = env.getOrientation();
706
- });
805
+ }));
707
806
  }
708
- window.addEventListener('unhandledrejection', function (event) {
709
- if (isActive() && state._ZAP._isGlobalErrorTracking) {
710
- track$1.trackError(event);
807
+ window.addEventListener('unhandledrejection', shield.shield('error tracking', function (event) {
808
+ if (!isActive() || !state._ZAP._config.track_error) {
809
+ return;
711
810
  }
712
- });
811
+ // a promise the SDK handed the app, rejected and left unhandled: the SDK's failure
812
+ if (shield.isSdkRejection(event.reason)) {
813
+ return;
814
+ }
815
+ track$1.trackError(event);
816
+ }));
713
817
  // in the capture phase: a <script>, <img> or <link> that fails to load fires `error` on the
714
818
  // element, and it does not bubble, so a bubbling listener never hears of it. One listener
715
819
  // hears both kinds, the window's own errors included, so none is counted twice
716
- window.addEventListener('error', function (event) {
717
- if (!isActive() || !state._ZAP._isGlobalErrorTracking) {
820
+ window.addEventListener('error', shield.shield('error tracking', function (event) {
821
+ if (!isActive() || !state._ZAP._config.track_error) {
718
822
  return;
719
823
  }
720
824
  var target = event.target;
721
825
  if (target && target !== window && typeof target.tagName === 'string') { // no i18n
826
+ // the SDK's own elements (its style, the Quartz script, the feedback form and its
827
+ // preview video, the recording timer) are not the app's
828
+ if (shield.isSdkElement(target)) {
829
+ return;
830
+ }
722
831
  // named by describeTarget: Event "error" on <script src="...">
723
832
  track$1.trackError({ type: 'error', reason: event }); // no i18n
724
833
  return;
725
834
  }
835
+ // thrown by the SDK's <script> file or the Quartz recorder it loaded
836
+ if (shield.isSdkScript(event.filename)) {
837
+ return;
838
+ }
726
839
  track$1.trackError(event);
727
- }, true);
728
- window.addEventListener('click', onDocumentClick, true); // no i18n
840
+ }), true);
841
+ window.addEventListener('click', shield.shield('click tracking', onDocumentClick), true); // no i18n
729
842
  }
730
843
 
731
844
  exports.init = init;
732
845
  exports.ready = ready;
733
846
  exports.reset = reset;
734
847
  exports.screenRouteRules = screenRouteRules;
848
+ exports.setClickTracking = setClickTracking;
849
+ exports.setScreenTracking = setScreenTracking;