@zoho_apptics/apptics-js-sdk 2.0.0-beta.2 → 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 (223) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/README.md +229 -174
  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 -3
  19. package/dist/cjs/core/consent.d.ts +9 -6
  20. package/dist/cjs/core/consent.js +63 -10
  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 +44 -0
  24. package/dist/cjs/core/constants.js +55 -1
  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.js +1 -1
  29. package/dist/cjs/core/framework-id.d.ts +1 -1
  30. package/dist/cjs/core/framework-id.js +3 -3
  31. package/dist/cjs/core/guard.js +19 -4
  32. package/dist/cjs/core/hooks.d.ts +25 -1
  33. package/dist/cjs/core/hooks.js +11 -1
  34. package/dist/cjs/core/locks.js +1 -1
  35. package/dist/cjs/core/logger.js +1 -1
  36. package/dist/cjs/core/shield.d.ts +31 -0
  37. package/dist/cjs/core/shield.js +129 -0
  38. package/dist/cjs/core/state.d.ts +5 -1
  39. package/dist/cjs/core/state.js +3 -1
  40. package/dist/cjs/core/storage.d.ts +7 -0
  41. package/dist/cjs/core/storage.js +28 -6
  42. package/dist/cjs/core/stylesheet.js +1 -1
  43. package/dist/cjs/core/transport.d.ts +15 -4
  44. package/dist/cjs/core/transport.js +63 -13
  45. package/dist/cjs/core/utils.js +1 -1
  46. package/dist/cjs/core/validate.js +6 -5
  47. package/dist/cjs/device/appversion.js +1 -1
  48. package/dist/cjs/device/index.js +63 -15
  49. package/dist/cjs/engagement/api-rules.js +1 -1
  50. package/dist/cjs/engagement/auto-api.js +4 -3
  51. package/dist/cjs/engagement/auto-screen.js +10 -6
  52. package/dist/cjs/engagement/defined-events.d.ts +2 -3
  53. package/dist/cjs/engagement/defined-events.js +10 -16
  54. package/dist/cjs/engagement/send.js +1 -1
  55. package/dist/cjs/engagement/session.js +77 -37
  56. package/dist/cjs/engagement/track.js +9 -6
  57. package/dist/cjs/errors/send.js +1 -1
  58. package/dist/cjs/errors/track.js +3 -2
  59. package/dist/cjs/feedback/controls.d.ts +30 -4
  60. package/dist/cjs/feedback/controls.js +237 -51
  61. package/dist/cjs/feedback/i18n/index.d.ts +31 -0
  62. package/dist/cjs/feedback/i18n/index.js +187 -0
  63. package/dist/cjs/feedback/i18n/strings.d.ts +9 -0
  64. package/dist/cjs/feedback/i18n/strings.js +8 -0
  65. package/dist/cjs/feedback/index.js +1 -1
  66. package/dist/cjs/feedback/logs.js +5 -4
  67. package/dist/cjs/feedback/quartz.js +5 -2
  68. package/dist/cjs/feedback/send.d.ts +4 -1
  69. package/dist/cjs/feedback/send.js +56 -15
  70. package/dist/cjs/feedback/styles.js +2 -2
  71. package/dist/cjs/feedback/template.d.ts +4 -2
  72. package/dist/cjs/feedback/template.js +67 -46
  73. package/dist/cjs/feedback/ui.d.ts +40 -4
  74. package/dist/cjs/feedback/ui.js +208 -89
  75. package/dist/cjs/heatmap/send.js +1 -1
  76. package/dist/cjs/heatmap/track.js +13 -9
  77. package/dist/cjs/index.js +2 -2
  78. package/dist/cjs/lifecycle.js +119 -72
  79. package/dist/cjs/pushnotification/display.d.ts +65 -0
  80. package/dist/cjs/pushnotification/display.js +112 -0
  81. package/dist/cjs/pushnotification/index.d.ts +20 -0
  82. package/dist/cjs/pushnotification/index.js +96 -0
  83. package/dist/cjs/pushnotification/kept-opens.d.ts +23 -0
  84. package/dist/cjs/pushnotification/kept-opens.js +64 -0
  85. package/dist/cjs/pushnotification/notify.d.ts +45 -0
  86. package/dist/cjs/pushnotification/notify.js +476 -0
  87. package/dist/cjs/pushnotification/payload.d.ts +65 -0
  88. package/dist/cjs/pushnotification/payload.js +279 -0
  89. package/dist/cjs/pushnotification/session.d.ts +46 -0
  90. package/dist/cjs/pushnotification/session.js +413 -0
  91. package/dist/cjs/pushnotification/stats.d.ts +45 -0
  92. package/dist/cjs/pushnotification/stats.js +244 -0
  93. package/dist/cjs/pushnotification/wms.d.ts +30 -0
  94. package/dist/cjs/pushnotification/wms.js +374 -0
  95. package/dist/cjs/remoteconfig/country.js +1 -1
  96. package/dist/cjs/remoteconfig/custom.js +4 -3
  97. package/dist/cjs/remoteconfig/evaluate.js +1 -1
  98. package/dist/cjs/remoteconfig/fetch.js +27 -8
  99. package/dist/cjs/remoteconfig/index.d.ts +1 -6
  100. package/dist/cjs/remoteconfig/index.js +4 -28
  101. package/dist/cjs/remoteconfig/store.js +1 -1
  102. package/dist/cjs/remoteconfig/tz-countries.js +1 -1
  103. package/dist/cjs/remotelog/callsite.js +1 -1
  104. package/dist/cjs/remotelog/gate.js +1 -1
  105. package/dist/cjs/remotelog/logger.js +1 -1
  106. package/dist/cjs/remotelog/send.js +5 -4
  107. package/dist/cjs/remotelogger/index.js +1 -1
  108. package/dist/cjs/scheduler.js +11 -5
  109. package/dist/cjs/sw/apptics-pn-sw.d.ts +83 -0
  110. package/dist/cjs/sw/timers.d.ts +44 -0
  111. package/dist/cjs/types.d.ts +31 -15
  112. package/dist/cjs/user/index.d.ts +7 -0
  113. package/dist/cjs/user/index.js +25 -7
  114. package/dist/esm/core/attempts.js +1 -1
  115. package/dist/esm/core/batch.js +4 -3
  116. package/dist/esm/core/consent.d.ts +9 -6
  117. package/dist/esm/core/consent.js +67 -16
  118. package/dist/esm/core/console-call.d.ts +23 -0
  119. package/dist/esm/core/console-call.js +60 -0
  120. package/dist/esm/core/constants.d.ts +44 -0
  121. package/dist/esm/core/constants.js +52 -2
  122. package/dist/esm/core/db.js +31 -7
  123. package/dist/esm/core/debug.d.ts +6 -4
  124. package/dist/esm/core/debug.js +37 -13
  125. package/dist/esm/core/env.js +1 -1
  126. package/dist/esm/core/framework-id.d.ts +1 -1
  127. package/dist/esm/core/framework-id.js +3 -3
  128. package/dist/esm/core/guard.js +19 -4
  129. package/dist/esm/core/hooks.d.ts +25 -1
  130. package/dist/esm/core/hooks.js +11 -1
  131. package/dist/esm/core/locks.js +1 -1
  132. package/dist/esm/core/logger.js +1 -1
  133. package/dist/esm/core/shield.d.ts +31 -0
  134. package/dist/esm/core/shield.js +119 -0
  135. package/dist/esm/core/state.d.ts +5 -1
  136. package/dist/esm/core/state.js +3 -1
  137. package/dist/esm/core/storage.d.ts +7 -0
  138. package/dist/esm/core/storage.js +28 -8
  139. package/dist/esm/core/stylesheet.js +1 -1
  140. package/dist/esm/core/transport.d.ts +15 -4
  141. package/dist/esm/core/transport.js +64 -16
  142. package/dist/esm/core/utils.js +1 -1
  143. package/dist/esm/core/validate.js +6 -5
  144. package/dist/esm/device/appversion.js +1 -1
  145. package/dist/esm/device/index.js +67 -19
  146. package/dist/esm/engagement/api-rules.js +1 -1
  147. package/dist/esm/engagement/auto-api.js +4 -3
  148. package/dist/esm/engagement/auto-screen.js +10 -6
  149. package/dist/esm/engagement/defined-events.d.ts +2 -3
  150. package/dist/esm/engagement/defined-events.js +10 -16
  151. package/dist/esm/engagement/send.js +1 -1
  152. package/dist/esm/engagement/session.js +77 -37
  153. package/dist/esm/engagement/track.js +9 -6
  154. package/dist/esm/errors/send.js +1 -1
  155. package/dist/esm/errors/track.js +3 -2
  156. package/dist/esm/feedback/controls.d.ts +30 -4
  157. package/dist/esm/feedback/controls.js +234 -52
  158. package/dist/esm/feedback/i18n/index.d.ts +31 -0
  159. package/dist/esm/feedback/i18n/index.js +178 -0
  160. package/dist/esm/feedback/i18n/strings.d.ts +9 -0
  161. package/dist/esm/feedback/i18n/strings.js +4 -0
  162. package/dist/esm/feedback/index.js +1 -1
  163. package/dist/esm/feedback/logs.js +5 -4
  164. package/dist/esm/feedback/quartz.js +5 -2
  165. package/dist/esm/feedback/send.d.ts +4 -1
  166. package/dist/esm/feedback/send.js +56 -16
  167. package/dist/esm/feedback/styles.js +2 -2
  168. package/dist/esm/feedback/template.d.ts +4 -2
  169. package/dist/esm/feedback/template.js +67 -46
  170. package/dist/esm/feedback/ui.d.ts +40 -4
  171. package/dist/esm/feedback/ui.js +210 -91
  172. package/dist/esm/heatmap/send.js +1 -1
  173. package/dist/esm/heatmap/track.js +13 -9
  174. package/dist/esm/index.js +2 -2
  175. package/dist/esm/lifecycle.js +120 -73
  176. package/dist/esm/pushnotification/display.d.ts +65 -0
  177. package/dist/esm/pushnotification/display.js +95 -0
  178. package/dist/esm/pushnotification/index.d.ts +20 -0
  179. package/dist/esm/pushnotification/index.js +91 -0
  180. package/dist/esm/pushnotification/kept-opens.d.ts +23 -0
  181. package/dist/esm/pushnotification/kept-opens.js +62 -0
  182. package/dist/esm/pushnotification/notify.d.ts +45 -0
  183. package/dist/esm/pushnotification/notify.js +469 -0
  184. package/dist/esm/pushnotification/payload.d.ts +65 -0
  185. package/dist/esm/pushnotification/payload.js +272 -0
  186. package/dist/esm/pushnotification/session.d.ts +46 -0
  187. package/dist/esm/pushnotification/session.js +402 -0
  188. package/dist/esm/pushnotification/stats.d.ts +45 -0
  189. package/dist/esm/pushnotification/stats.js +238 -0
  190. package/dist/esm/pushnotification/wms.d.ts +30 -0
  191. package/dist/esm/pushnotification/wms.js +368 -0
  192. package/dist/esm/remoteconfig/country.js +1 -1
  193. package/dist/esm/remoteconfig/custom.js +4 -3
  194. package/dist/esm/remoteconfig/evaluate.js +1 -1
  195. package/dist/esm/remoteconfig/fetch.js +27 -8
  196. package/dist/esm/remoteconfig/index.d.ts +1 -6
  197. package/dist/esm/remoteconfig/index.js +4 -28
  198. package/dist/esm/remoteconfig/store.js +1 -1
  199. package/dist/esm/remoteconfig/tz-countries.js +1 -1
  200. package/dist/esm/remotelog/callsite.js +1 -1
  201. package/dist/esm/remotelog/gate.js +1 -1
  202. package/dist/esm/remotelog/logger.js +1 -1
  203. package/dist/esm/remotelog/send.js +5 -4
  204. package/dist/esm/remotelogger/index.js +1 -1
  205. package/dist/esm/scheduler.js +11 -5
  206. package/dist/esm/sw/apptics-pn-sw.d.ts +83 -0
  207. package/dist/esm/sw/timers.d.ts +44 -0
  208. package/dist/esm/types.d.ts +31 -15
  209. package/dist/esm/user/index.d.ts +7 -0
  210. package/dist/esm/user/index.js +26 -9
  211. package/dist/feedback.esm.min.js +2 -2
  212. package/dist/feedback.esm.min.js.map +1 -1
  213. package/dist/pushnotification.esm.min.js +3 -0
  214. package/dist/pushnotification.esm.min.js.map +1 -0
  215. package/dist/remoteconfig.esm.min.js +2 -2
  216. package/dist/remoteconfig.esm.min.js.map +1 -1
  217. package/dist/remotelogger.esm.min.js +2 -2
  218. package/dist/remotelogger.esm.min.js.map +1 -1
  219. package/package.json +15 -2
  220. package/dist/chunks/lifecycle-C6m1W7jo.min.js +0 -3
  221. package/dist/chunks/lifecycle-C6m1W7jo.min.js.map +0 -1
  222. package/dist/chunks/send-CgUO82ne.min.js +0 -3
  223. package/dist/chunks/send-CgUO82ne.min.js.map +0 -1
@@ -1,4 +1,4 @@
1
- /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (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
  import { _ZAP } from '../core/state.js';
3
3
  import { Console, warnAlways } from '../core/logger.js';
4
4
  import { cloneObject } from '../core/utils.js';
@@ -1,4 +1,4 @@
1
- /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (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
  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';
@@ -10,6 +10,7 @@ import { canTrackHeatmap, getTrackingStatus } from '../core/consent.js';
10
10
  import { screenForRecord } from '../engagement/track.js';
11
11
  import { hooks } from '../core/hooks.js';
12
12
  import { noteDebugActivity } from '../core/debug.js';
13
+ import { shield, quietly } from '../core/shield.js';
13
14
 
14
15
  /**
15
16
  * Where people click and how far they scroll.
@@ -219,7 +220,7 @@ function store(record) {
219
220
  recorded++;
220
221
  noteDebugActivity();
221
222
  // a heatmap record is worth a session in the same way an event is
222
- commitPendingSession();
223
+ quietly('session', commitPendingSession()); // no i18n
223
224
  heatmap_transactions.add(record);
224
225
  Console.dir(record);
225
226
  }
@@ -280,13 +281,13 @@ function watchForDeadClick(record, target) {
280
281
  catch (err) {
281
282
  return;
282
283
  }
283
- setTimeout(function () {
284
+ setTimeout(shield('heatmap dead click', function () {
284
285
  observer.disconnect();
285
286
  if (!changed && window.location.href === url) {
286
287
  record.is_dead_click = 1;
287
288
  heatmap_transactions.update(record);
288
289
  }
289
- }, DEAD_CLICK_MS);
290
+ }), DEAD_CLICK_MS);
290
291
  }
291
292
  /**
292
293
  * What a scroll event moved, as a gesture counts it: null for the window (the event's target is
@@ -343,7 +344,7 @@ function onScroll(event) {
343
344
  else {
344
345
  clearTimeout(scrollTimer);
345
346
  }
346
- scrollTimer = setTimeout(endScrollGesture, SCROLL_IDLE_MS);
347
+ scrollTimer = setTimeout(shield('heatmap scroll', endScrollGesture), SCROLL_IDLE_MS); // no i18n
347
348
  }
348
349
  /** One record for the whole burst, once the page has been still for SCROLL_IDLE_MS. */
349
350
  function endScrollGesture() {
@@ -402,6 +403,9 @@ function endScrollGesture() {
402
403
  logFailure(AP_LOG_MODULE.HEATMAP, 'apptics.heatmap: scroll capture failed: ' + String(err)); // no i18n
403
404
  }
404
405
  }
406
+ // the listeners as added, so the same functions come off again
407
+ const pointerListener = shield('heatmap click', onPointerDown); // no i18n
408
+ const scrollListener = shield('heatmap scroll', onScroll); // no i18n
405
409
  /** Turns capture on or off. Listeners are passive, so they never delay a click or a scroll. */
406
410
  function trackHeatmap(status) {
407
411
  var wanted = typeof status === 'boolean' ? status : true; // no i18n
@@ -412,14 +416,14 @@ function trackHeatmap(status) {
412
416
  // where the page already is, so the first gesture is measured from here and not from 0
413
417
  lastX = Math.round(window.scrollX || 0);
414
418
  lastY = Math.round(window.scrollY || 0);
415
- window.addEventListener('pointerdown', onPointerDown, { capture: true, passive: true }); // no i18n
416
- window.addEventListener('scroll', onScroll, { capture: true, passive: true }); // no i18n
419
+ window.addEventListener('pointerdown', pointerListener, { capture: true, passive: true }); // no i18n
420
+ window.addEventListener('scroll', scrollListener, { capture: true, passive: true }); // no i18n
417
421
  installed = true;
418
422
  Console.log('apptics.heatmap: capturing clicks and scrolls'); // no i18n
419
423
  return;
420
424
  }
421
- window.removeEventListener('pointerdown', onPointerDown, true); // no i18n
422
- window.removeEventListener('scroll', onScroll, true); // no i18n
425
+ window.removeEventListener('pointerdown', pointerListener, true); // no i18n
426
+ window.removeEventListener('scroll', scrollListener, true); // no i18n
423
427
  // a gesture still settling when capture stops (a single-page app leaving a heatmap page) is
424
428
  // recorded as it stands, not dropped: it was the visitor's last scroll on that page
425
429
  if (scrollTimer !== null) {
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (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
  import { AP_TRACKING_STATUS } from './core/constants.js';
3
3
  import { forward, guard } from './core/guard.js';
4
4
  import { warnAlways } from './core/logger.js';
@@ -168,7 +168,7 @@ const setTrackingStatusGuarded = guard('AppticsSettings.setTrackingStatus', setT
168
168
  const getTrackingStatusGuarded = guard('AppticsSettings.getTrackingStatus', getTrackingStatus); // no i18n
169
169
  /** Android's AppticsSettings: what the SDK may track for this visitor. */
170
170
  const AppticsSettings = {
171
- /** The states setTrackingStatus takes: USAGE_TRACKING_WITH_PII, USAGE_TRACKING_WITHOUT_PII, NO_TRACKING. */
171
+ /** The states setTrackingStatus takes: USAGE_TRACKING_WITH_PII, USAGE_TRACKING_WITHOUT_PII, ANONYMOUS, NO_TRACKING. */
172
172
  AP_TRACKING_STATUS: AP_TRACKING_STATUS,
173
173
  setTrackingStatus: function setTrackingStatus(status) { return forward(setTrackingStatusGuarded, arguments); },
174
174
  getTrackingStatus: function getTrackingStatus() { return forward(getTrackingStatusGuarded, arguments); },
@@ -1,5 +1,5 @@
1
- /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
2
- import { REQUIRED_CONFIG, CONFIG_KEYS, AP_CONFIG, RETIRED_CONFIG_NAMES, DEFAULT_INACTIVE_MINUTES } from './core/constants.js';
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0 | (c) Zoho Corporation Private Limited | see LICENSE */
2
+ import { REQUIRED_CONFIG, CONFIG_KEYS, AP_CONFIG, RETIRED_CONFIG_NAMES, DEFAULT_INACTIVE_MINUTES, SESSION_TIMING_MIN_MS, SESSION_TIMING_MAX_MS } 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';
@@ -19,6 +19,7 @@ import { sendStoredLogs, forgetStoredLogs } from './remotelog/send.js';
19
19
  import { getUserInfo } from './user/index.js';
20
20
  import { clearAttempts } from './core/attempts.js';
21
21
  import { FRAMEWORK_ID } from './core/framework-id.js';
22
+ import { quietly, shield, isSdkRejection, isSdkElement, isSdkScript } from './core/shield.js';
22
23
 
23
24
  let listenersAttached = false;
24
25
  /** The config init() was last called with; reset() starts again from it. */
@@ -151,7 +152,7 @@ const TUNABLE = Object.freeze([
151
152
  { key: 'getupdates_interval', min: 10000, max: 86400000 }, // no i18n
152
153
  { key: 'batch_size', min: 1, max: 500 }, // no i18n
153
154
  { key: 'batch_request_timeout', min: 1, max: 30 }, // no i18n
154
- { key: 'min_session_duration', min: 0, max: 60000 }, // no i18n
155
+ { key: 'min_session_duration', min: SESSION_TIMING_MIN_MS, max: SESSION_TIMING_MAX_MS }, // no i18n
155
156
  { key: 'heatmap_max_per_session', min: 0, max: 10000 }, // no i18n
156
157
  ]);
157
158
  /** Reads the tunable timings out of the config. Anything missing goes back to its default. */
@@ -171,18 +172,30 @@ function applyIntervals(config) {
171
172
  _ZAP._config[rule.key] = num;
172
173
  Console.log('Apptics.init: ' + rule.key + ' set to ' + num); // no i18n
173
174
  });
174
- // inactiveduration lives on state, not in _config
175
+ // max_session_duration: how long a tab may be inactive before its session ends, in
176
+ // milliseconds like min_session_duration. Kept on state in minutes (_ZAP.inactiveduration),
177
+ // which is how the session code counts it. The retired inactiveduration, in minutes, is still
178
+ // read when max_session_duration is not given
175
179
  _ZAP.inactiveduration = DEFAULT_INACTIVE_MINUTES;
176
- if (!isEmpty(config.inactiveduration)) {
177
- var minutes = Number(config.inactiveduration);
178
- if (!isFinite(minutes) || minutes < 1 || minutes > 1440) {
179
- warnAlways('Apptics.init: inactiveduration must be between 1 and 1440 minutes, keeping ' + _ZAP.inactiveduration); // no i18n
180
- }
181
- else {
182
- _ZAP.inactiveduration = minutes;
183
- Console.log('Apptics.init: inactiveduration set to ' + minutes); // no i18n
184
- }
180
+ var keyName = 'max_session_duration'; // no i18n
181
+ var ms = NaN;
182
+ if (!isEmpty(config.max_session_duration)) {
183
+ ms = Number(config.max_session_duration);
184
+ }
185
+ else if (!isEmpty(config.inactiveduration)) {
186
+ warnAlways('Apptics.init: inactiveduration is now max_session_duration, in milliseconds; rename it in your config'); // no i18n
187
+ keyName = 'inactiveduration'; // no i18n
188
+ ms = Math.round(Number(config.inactiveduration) * 60 * 1000);
189
+ }
190
+ else {
191
+ return;
185
192
  }
193
+ if (!isFinite(ms) || ms < SESSION_TIMING_MIN_MS || ms > SESSION_TIMING_MAX_MS) {
194
+ warnAlways('Apptics.init: ' + keyName + ' must be between 5 seconds and 30 minutes (' + SESSION_TIMING_MIN_MS + ' to ' + SESSION_TIMING_MAX_MS + ' ms), keeping ' + (DEFAULT_INACTIVE_MINUTES * 60 * 1000) + ' ms'); // no i18n
195
+ return;
196
+ }
197
+ _ZAP.inactiveduration = keyName === 'inactiveduration' ? Number(config.inactiveduration) : ms / (60 * 1000); // no i18n
198
+ Console.log('Apptics.init: max_session_duration set to ' + ms + ' ms'); // no i18n
186
199
  }
187
200
  /** Everything the SDK stores: settings, ids and every queue. Resolves once it is all gone. */
188
201
  function clearStorage() {
@@ -243,15 +256,21 @@ function init(config) {
243
256
  if (typeof config.ignore_do_not_track === 'boolean') { // no i18n
244
257
  _ZAP._config.ignore_do_not_track = config.ignore_do_not_track;
245
258
  }
246
- // debug: debug mode, the debug endpoints. Same payloads, but the answer says where to trace the
247
- // request. debug_api is its earlier name and still works; debug wins when both are given
248
- _ZAP._config.debug_api = typeof config.debug === 'boolean' ? config.debug // no i18n
249
- : typeof config.debug_api === 'boolean' ? config.debug_api : AP_CONFIG.debug_api; // no i18n
250
- // starts (or clears) the idle hour that closes debug mode on its own
251
- // an enableDebug() or disableDebug() call the app already made wins over the config
252
- applyDebugConfig(_ZAP._config.debug_api);
259
+ // debug mode is switched from the browser console only (Apptics.enableDebug()), never from
260
+ // config, so an app cannot ship with it on
261
+ ['debug', 'debug_api'].forEach(function (key) {
262
+ if (config[key] !== undefined) {
263
+ 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
264
+ }
265
+ });
266
+ // off, unless enableDebug() was already called; starts (or clears) the idle hour
267
+ applyDebugConfig();
253
268
  // what to call this device in the debug stream; see devicename in core/transport.ts
254
269
  _ZAP._config.device_name = typeof config.device_name === 'string' ? config.device_name : AP_CONFIG.device_name; // no i18n
270
+ // push notifications always use the site's /apptics-pn-sw.js
271
+ if (config.push_service_worker !== undefined) {
272
+ 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
273
+ }
255
274
  // the SDK no longer reports its own failures to the Remote Logger page: only the lines an app
256
275
  // logs with AppticsLogger go there
257
276
  if (config.remote_log !== undefined) {
@@ -330,6 +349,8 @@ function init(config) {
330
349
  Console.error('Apptics.init: start-up failed', err); // no i18n
331
350
  return false;
332
351
  });
352
+ // push calls made before init() wait on this start-up, success or not
353
+ hooks.pushInitCalled();
333
354
  return true;
334
355
  }
335
356
  /** Start-up from app/addversion on, once the store holds only this app's data. */
@@ -385,7 +406,7 @@ function registerWhenOnline(myGeneration) {
385
406
  clearInterval(timer);
386
407
  resolve(ok);
387
408
  }
388
- function attempt() {
409
+ function tryRegister() {
389
410
  if (myGeneration !== generation) {
390
411
  done(false);
391
412
  return;
@@ -394,7 +415,7 @@ function registerWhenOnline(myGeneration) {
394
415
  return;
395
416
  }
396
417
  trying = true;
397
- registerAppVersion().then(function (registered) {
418
+ quietly('app/addversion retry', registerAppVersion().then(function (registered) {
398
419
  trying = false;
399
420
  if (registered) {
400
421
  done(true);
@@ -403,8 +424,12 @@ function registerWhenOnline(myGeneration) {
403
424
  warnAlways('Apptics.init: app/addversion did not return the app ids, not starting'); // no i18n
404
425
  done(false);
405
426
  }
406
- });
427
+ }, function (err) {
428
+ trying = false;
429
+ throw err;
430
+ }));
407
431
  }
432
+ var attempt = shield('app/addversion retry', tryRegister); // no i18n
408
433
  window.addEventListener('online', attempt); // no i18n
409
434
  timer = setInterval(attempt, OFFLINE_RETRY_MS);
410
435
  });
@@ -500,7 +525,9 @@ function startTracking(appVersionChanged, myGeneration) {
500
525
  // answers, the settings saved by the last visit apply (restoreServerSettings, in start())
501
526
  startServerSettingChecks();
502
527
  if (appVersionChanged) {
503
- _ZAP._device_info.appversionid = ''; // no i18n
528
+ // the device is told its new appversionid, which app/addversion has just answered for this
529
+ // release and device/add declares mandatory: sent empty, the update was refused, and every
530
+ // call after it went without the id
504
531
  updateDeviceWithApptics(_ZAP._device_info).then(function (result) {
505
532
  if (isSuccess(result)) {
506
533
  Console.log('init: appversion updated to ' + _ZAP._defaultoptions.appversion); // no i18n
@@ -518,7 +545,7 @@ function startTracking(appVersionChanged, myGeneration) {
518
545
  return false;
519
546
  }
520
547
  startTimers();
521
- sendStoredLogs();
548
+ quietly('sending stored logs', sendStoredLogs()); // no i18n
522
549
  _ZAP._ready = true;
523
550
  // replay calls made while storage was loading, in order
524
551
  var pending = _ZAP._pending;
@@ -536,8 +563,11 @@ function startTracking(appVersionChanged, myGeneration) {
536
563
  enableScreenTracking(_ZAP._config.track_screen);
537
564
  // a no-op unless the remote-config entry was imported, which sets the hook
538
565
  hooks.remoteConfigStarted();
566
+ // the same for push notification: a no-op unless its entry was imported
567
+ hooks.pushStarted();
539
568
  window.appticsReadyStatus = true;
540
569
  if (typeof window.appticsReady == 'function') { // no i18n
570
+ // the app's own callback: what it throws is the app's, so it is not caught here
541
571
  window.appticsReady();
542
572
  }
543
573
  return true;
@@ -556,7 +586,10 @@ function reset() {
556
586
  hooks.trackHeatmap(false);
557
587
  hooks.resetHeatmap();
558
588
  hooks.resetRemoteConfig();
559
- clearStorage();
589
+ hooks.resetPush();
590
+ _ZAP._pushEnabled = false;
591
+ _ZAP._wmsConfig = null;
592
+ quietly('clearing storage', clearStorage()); // no i18n
560
593
  _ZAP._initialised = false;
561
594
  _ZAP._ready = false;
562
595
  _ZAP._pending = [];
@@ -654,33 +687,33 @@ function onDocumentClick(event) {
654
687
  function onPageHidden() {
655
688
  if (!isActive())
656
689
  return;
657
- // the moment the user left: the session ends at it if they are not back within inactiveduration
658
- markTabInactive(sendEndedSession);
659
- updateScreenWithEndtime();
660
- flush(true);
690
+ // the moment the user left: the session ends at it if they are not back within max_session_duration
691
+ quietly('closing the screen', markTabInactive(sendEndedSession)); // no i18n
692
+ quietly('closing the screen', updateScreenWithEndtime()); // no i18n
693
+ quietly('sending on page hide', flush(true)); // no i18n
661
694
  Console.log('page hidden: closing the open screen and flushing'); // no i18n
662
695
  }
663
696
  /** A session that inactivity ended while the tab was away: sent now, not when the user returns. */
664
- function sendEndedSession() {
697
+ const sendEndedSession = shield('sending the ended session', function () {
665
698
  if (!isActive())
666
699
  return;
667
- flush();
668
- }
700
+ quietly('sending the ended session', flush()); // no i18n
701
+ });
669
702
  /**
670
703
  * The tab is closing, or the page is being replaced or frozen into the back/forward cache.
671
704
  * The session ends here, and everything queued goes out by keepalive, since a normal
672
705
  * request would be cancelled with the page.
673
706
  */
674
- function onPageClosing() {
707
+ const onPageClosing = shield('page closing', function () {
675
708
  if (!isActive())
676
709
  return;
677
710
  Console.log('page closing: ending the session and sending what is queued'); // no i18n
678
- updateScreenWithEndtime();
679
- forgetStoredLogs();
680
- endCurrentSession().then(function () {
711
+ quietly('page closing', updateScreenWithEndtime()); // no i18n
712
+ quietly('page closing', forgetStoredLogs()); // no i18n
713
+ quietly('page closing', endCurrentSession().then(function () {
681
714
  return flush(true);
682
- });
683
- }
715
+ }));
716
+ });
684
717
  function attachListeners() {
685
718
  if (listenersAttached) {
686
719
  return;
@@ -689,42 +722,42 @@ function attachListeners() {
689
722
  // listen for connection change events (only available in w3c implementation)
690
723
  var connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection;
691
724
  if (connection && connection.addEventListener) {
692
- connection.addEventListener('change', function () {
725
+ connection.addEventListener('change', shield('connection change', function () {
693
726
  _ZAP._device_info.connectionType = getConnectionType();
694
- });
727
+ }));
695
728
  }
696
729
  // Track when the window loses focus (user switches to another window or application)
697
- window.addEventListener('blur', function () {
730
+ window.addEventListener('blur', shield('window blur', function () {
698
731
  if (!isActive())
699
732
  return;
700
733
  // focus moving into an iframe on the page blurs the window too, and the user is still here
701
734
  if (document.activeElement && document.activeElement.tagName === 'IFRAME')
702
735
  return; // no i18n
703
736
  Console.log('Window lost focus, user switched to another window or application'); // no i18n
704
- markTabInactive(sendEndedSession);
705
- });
737
+ quietly('window blur', markTabInactive(sendEndedSession)); // no i18n
738
+ }));
706
739
  // Track when the window gains focus (user switches back to the window)
707
- window.addEventListener('focus', function () {
740
+ window.addEventListener('focus', shield('window focus', function () {
708
741
  if (!isActive())
709
742
  return;
710
743
  Console.log('Window regained focus, user switched back to the window'); // no i18n
711
744
  markTabActive();
712
- checkAndUpdateSession();
745
+ quietly('window focus', checkAndUpdateSession()); // no i18n
713
746
  startTimers();
714
- });
747
+ }));
715
748
  // IndexedDB writes are async, so unload work starts on pagehide rather than beforeunload
716
749
  window.addEventListener('pagehide', onPageClosing); // no i18n
717
750
  // back/forward cache: pagehide ended the session, so coming back starts a new one
718
- window.addEventListener('pageshow', function (event) {
751
+ window.addEventListener('pageshow', shield('page show', function (event) {
719
752
  if (!isActive() || !event.persisted)
720
753
  return;
721
754
  Console.log('restored from the back/forward cache: starting a new session'); // no i18n
722
755
  markTabActive();
723
756
  // the screen the page was left on starts a new view, in the new session
724
- checkAndUpdateSession().then(resumeScreen);
757
+ quietly('page show', checkAndUpdateSession().then(resumeScreen)); // no i18n
725
758
  startTimers();
726
- });
727
- document.addEventListener('visibilitychange', function () {
759
+ }));
760
+ document.addEventListener('visibilitychange', shield('visibility change', function () {
728
761
  if (!isActive())
729
762
  return;
730
763
  if (document.visibilityState === 'hidden') { // no i18n
@@ -736,15 +769,15 @@ function attachListeners() {
736
769
  markTabActive();
737
770
  // hiding ended the screen view; the screen the user is back on starts a new one, after the
738
771
  // session is settled so the view belongs to the right one
739
- checkAndUpdateSession().then(resumeScreen);
740
- });
772
+ quietly('visibility change', checkAndUpdateSession().then(resumeScreen)); // no i18n
773
+ }));
741
774
  // if we are running in cordova use ondeviceready otherwise onload
742
- window.addEventListener(window.cordova ? 'deviceready' : 'load', function () {
775
+ window.addEventListener(window.cordova ? 'deviceready' : 'load', shield('page load', function () {
743
776
  if (isActive())
744
- checkAndUpdateSession();
745
- }, { passive: true });
777
+ quietly('page load', checkAndUpdateSession()); // no i18n
778
+ }), { passive: true });
746
779
  // Always send pending requests when the connection comes back online
747
- window.addEventListener('online', function () {
780
+ window.addEventListener('online', shield('back online', function () {
748
781
  if (!isActive())
749
782
  return;
750
783
  // a first visit that started offline has no device ids yet, and nothing can be sent
@@ -752,44 +785,58 @@ function attachListeners() {
752
785
  if (needsDevice()) {
753
786
  Console.log('back online: registering this device before sending'); // no i18n
754
787
  // the same locked path as start-up, so two tabs coming back online register it once
755
- prepareDevice().then(deviceReady).then(function () {
788
+ quietly('back online', prepareDevice().then(deviceReady).then(function () {
756
789
  if (!isActive())
757
790
  return;
758
- flush();
791
+ quietly('back online', flush()); // no i18n
759
792
  // the lines logged while offline are waiting too, and log/add needs the same ids
760
- sendStoredLogs();
761
- });
793
+ quietly('back online', sendStoredLogs()); // no i18n
794
+ }));
762
795
  return;
763
796
  }
764
- flush();
765
- sendStoredLogs();
766
- }, { passive: true });
797
+ quietly('back online', flush()); // no i18n
798
+ quietly('back online', sendStoredLogs()); // no i18n
799
+ }), { passive: true });
767
800
  if (window.screen && window.screen.orientation && typeof window.screen.orientation.addEventListener === 'function') { // no i18n
768
- window.screen.orientation.addEventListener('change', function () {
801
+ window.screen.orientation.addEventListener('change', shield('orientation change', function () {
769
802
  _ZAP._properties.orientation = getOrientation();
770
- });
803
+ }));
771
804
  }
772
- window.addEventListener('unhandledrejection', function (event) {
773
- if (isActive() && _ZAP._config.track_error) {
774
- trackError(event);
805
+ window.addEventListener('unhandledrejection', shield('error tracking', function (event) {
806
+ if (!isActive() || !_ZAP._config.track_error) {
807
+ return;
775
808
  }
776
- });
809
+ // a promise the SDK handed the app, rejected and left unhandled: the SDK's failure
810
+ if (isSdkRejection(event.reason)) {
811
+ return;
812
+ }
813
+ trackError(event);
814
+ }));
777
815
  // in the capture phase: a <script>, <img> or <link> that fails to load fires `error` on the
778
816
  // element, and it does not bubble, so a bubbling listener never hears of it. One listener
779
817
  // hears both kinds, the window's own errors included, so none is counted twice
780
- window.addEventListener('error', function (event) {
818
+ window.addEventListener('error', shield('error tracking', function (event) {
781
819
  if (!isActive() || !_ZAP._config.track_error) {
782
820
  return;
783
821
  }
784
822
  var target = event.target;
785
823
  if (target && target !== window && typeof target.tagName === 'string') { // no i18n
824
+ // the SDK's own elements (its style, the Quartz script, the feedback form and its
825
+ // preview video, the recording timer) are not the app's
826
+ if (isSdkElement(target)) {
827
+ return;
828
+ }
786
829
  // named by describeTarget: Event "error" on <script src="...">
787
830
  trackError({ type: 'error', reason: event }); // no i18n
788
831
  return;
789
832
  }
833
+ // thrown by the SDK's <script> file or the Quartz recorder it loaded
834
+ if (isSdkScript(event.filename)) {
835
+ return;
836
+ }
790
837
  trackError(event);
791
- }, true);
792
- window.addEventListener('click', onDocumentClick, true); // no i18n
838
+ }), true);
839
+ window.addEventListener('click', shield('click tracking', onDocumentClick), true); // no i18n
793
840
  }
794
841
 
795
842
  export { init, ready, reset, screenRouteRules, setClickTracking, setScreenTracking };
@@ -0,0 +1,65 @@
1
+ import type { WebNotification } from './payload.js';
2
+ /**
3
+ * How a push notification is shown, for the page and the service worker alike: the title, the
4
+ * options for showNotification(), and what the notification carries in its data so the worker
5
+ * can step a carousel and open a button's URL after the tab has closed.
6
+ */
7
+ /** What a shown notification carries in its data. `apptics: 1` marks it as the SDK's. */
8
+ export interface ShownNotification {
9
+ apptics: 1;
10
+ view: WebNotification;
11
+ /** The carousel slide on show. */
12
+ index: number;
13
+ tag: string;
14
+ /** The message's data as it arrived, for the app's click callback. */
15
+ message: Record<string, unknown>;
16
+ /**
17
+ * Which run of the message this is: the envelope's timestamp, the server's send time. A
18
+ * recurring push sends the same appticsPnID every run, and without a notificationNumber this is
19
+ * what tells the runs' stats apart. Never sent.
20
+ */
21
+ run?: string;
22
+ }
23
+ /** Notification options with the parts some DOM typings leave out. */
24
+ export type ShowOptions = NotificationOptions & {
25
+ actions?: Array<{
26
+ action: string;
27
+ title: string;
28
+ icon?: string;
29
+ }>;
30
+ image?: string;
31
+ renotify?: boolean;
32
+ data?: ShownNotification;
33
+ };
34
+ /** What the service worker posts to the site's tabs. */
35
+ export declare const CLICK_MESSAGE = "apptics-notification-click";
36
+ export declare const CLOSE_MESSAGE = "apptics-notification-close";
37
+ /** Prev / Next pressed: the page stops that notification's auto-scroll, as the visitor took over. */
38
+ export declare const STEP_MESSAGE = "apptics-notification-step";
39
+ /** The worker gives back the timers it could not finish in its time: an open tab runs the rest. */
40
+ export declare const HANDOFF_MESSAGE = "apptics-notification-handoff";
41
+ /** What a tab posts to the service worker: run this notification's timers; stop them (one tag, or all). */
42
+ export declare const TIMERS_MESSAGE = "apptics-notification-timers";
43
+ export declare const STOP_TIMERS_MESSAGE = "apptics-notification-stop";
44
+ /** The worker's answer to TIMERS_MESSAGE, on the port it came with: it runs them. */
45
+ export declare const TIMERS_TAKEN = "apptics-notification-timers-taken";
46
+ export declare const ACTION_PREV = "apptics-prev";
47
+ export declare const ACTION_NEXT = "apptics-next";
48
+ export declare const ACTION_BUTTON = "apptics-btn-";
49
+ export declare function isCarousel(view: WebNotification): boolean;
50
+ /** The title shown for slide `index`: the slide number is added for a carousel. */
51
+ export declare function titleFor(view: WebNotification, index: number): string;
52
+ /**
53
+ * The options for showing `shown` at its slide. `update` is a re-show of one already on screen
54
+ * (a carousel step, a countdown tick): it makes no sound.
55
+ */
56
+ export declare function optionsFor(shown: ShownNotification, update: boolean, nowMs: number): ShowOptions;
57
+ /**
58
+ * Whether this browser shows a notification's large image. Notification.prototype has `image`
59
+ * where it does; Chrome on macOS has none. Asked the same way in the page and the worker.
60
+ */
61
+ export declare function supportsImage(): boolean;
62
+ /** Whether a notification's data is one the SDK showed. */
63
+ export declare function isOurs(data: unknown): data is ShownNotification;
64
+ /** The slide after `index` by `step` (+1 / -1), wrapping. */
65
+ export declare function stepIndex(view: WebNotification, index: number, step: number): number;
@@ -0,0 +1,95 @@
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0 | (c) Zoho Corporation Private Limited | see LICENSE */
2
+ import { formatCountdown } from './payload.js';
3
+
4
+ /** What the service worker posts to the site's tabs. */
5
+ const CLICK_MESSAGE = 'apptics-notification-click'; // no i18n
6
+ const CLOSE_MESSAGE = 'apptics-notification-close'; // no i18n
7
+ /** Prev / Next pressed: the page stops that notification's auto-scroll, as the visitor took over. */
8
+ const STEP_MESSAGE = 'apptics-notification-step'; // no i18n
9
+ /** The worker gives back the timers it could not finish in its time: an open tab runs the rest. */
10
+ const HANDOFF_MESSAGE = 'apptics-notification-handoff'; // no i18n
11
+ /** What a tab posts to the service worker: run this notification's timers; stop them (one tag, or all). */
12
+ const TIMERS_MESSAGE = 'apptics-notification-timers'; // no i18n
13
+ const STOP_TIMERS_MESSAGE = 'apptics-notification-stop'; // no i18n
14
+ /** The worker's answer to TIMERS_MESSAGE, on the port it came with: it runs them. */
15
+ const TIMERS_TAKEN = 'apptics-notification-timers-taken'; // no i18n
16
+ const ACTION_PREV = 'apptics-prev'; // no i18n
17
+ const ACTION_NEXT = 'apptics-next'; // no i18n
18
+ const ACTION_BUTTON = 'apptics-btn-'; // no i18n
19
+ /** The browser's labels for the carousel's two buttons, as the console's preview shows them. */
20
+ const PREV_LABEL = 'Prev'; // no i18n
21
+ const NEXT_LABEL = 'Next'; // no i18n
22
+ function isCarousel(view) {
23
+ return view.images.length > 1;
24
+ }
25
+ /** The title shown for slide `index`: the slide number is added for a carousel. */
26
+ function titleFor(view, index) {
27
+ return isCarousel(view) ? view.title + ' (' + (index + 1) + ' / ' + view.images.length + ')' : view.title; // no i18n
28
+ }
29
+ /**
30
+ * The options for showing `shown` at its slide. `update` is a re-show of one already on screen
31
+ * (a carousel step, a countdown tick): it makes no sound.
32
+ */
33
+ function optionsFor(shown, update, nowMs) {
34
+ var view = shown.view;
35
+ var body = view.text;
36
+ if (view.countdownTo > 0) {
37
+ body += (body ? '\n' : '') + formatCountdown(view.countdownTo, nowMs); // no i18n
38
+ }
39
+ var options = {
40
+ body: body,
41
+ tag: shown.tag,
42
+ requireInteraction: view.requireInteraction,
43
+ silent: view.silent || update,
44
+ // a new message alerts even when it replaces one still on screen under the same tag (the
45
+ // same appticsPnID); the SDK's own updates (a slide, a countdown tick) replace it quietly
46
+ renotify: !update,
47
+ data: shown,
48
+ };
49
+ var image = view.images[shown.index] || view.images[0];
50
+ if (image && !supportsImage()) {
51
+ // no large image here (Chrome on macOS goes through the system's notifications, which have
52
+ // no slot for one): the slide shows as the icon, so a carousel still visibly changes
53
+ options.icon = image;
54
+ }
55
+ else {
56
+ if (view.icon) {
57
+ options.icon = view.icon;
58
+ }
59
+ if (image) {
60
+ options.image = image;
61
+ }
62
+ }
63
+ if (isCarousel(view)) {
64
+ options.actions = [{ action: ACTION_PREV, title: PREV_LABEL }, { action: ACTION_NEXT, title: NEXT_LABEL }];
65
+ }
66
+ else if (view.buttons.length > 0) {
67
+ options.actions = view.buttons.map(function (b, i) {
68
+ var action = { action: ACTION_BUTTON + i, title: b.label };
69
+ if (b.icon) {
70
+ action.icon = b.icon;
71
+ }
72
+ return action;
73
+ });
74
+ }
75
+ return options;
76
+ }
77
+ /**
78
+ * Whether this browser shows a notification's large image. Notification.prototype has `image`
79
+ * where it does; Chrome on macOS has none. Asked the same way in the page and the worker.
80
+ */
81
+ function supportsImage() {
82
+ var N = typeof Notification !== 'undefined' ? Notification : undefined; // no i18n
83
+ return !N || !N.prototype || 'image' in N.prototype; // no i18n
84
+ }
85
+ /** Whether a notification's data is one the SDK showed. */
86
+ function isOurs(data) {
87
+ return !!data && typeof data === 'object' && data.apptics === 1; // no i18n
88
+ }
89
+ /** The slide after `index` by `step` (+1 / -1), wrapping. */
90
+ function stepIndex(view, index, step) {
91
+ var n = view.images.length;
92
+ return n > 0 ? ((index + step) % n + n) % n : 0;
93
+ }
94
+
95
+ export { ACTION_BUTTON, ACTION_NEXT, ACTION_PREV, CLICK_MESSAGE, CLOSE_MESSAGE, HANDOFF_MESSAGE, STEP_MESSAGE, STOP_TIMERS_MESSAGE, TIMERS_MESSAGE, TIMERS_TAKEN, isCarousel, isOurs, optionsFor, stepIndex, supportsImage, titleFor };