@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
  'use strict';
3
3
 
4
4
  var state = require('../core/state.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
  'use strict';
3
3
 
4
4
  var constants = require('../core/constants.js');
@@ -12,6 +12,7 @@ var consent = require('../core/consent.js');
12
12
  var track = require('../engagement/track.js');
13
13
  var hooks = require('../core/hooks.js');
14
14
  var debug = require('../core/debug.js');
15
+ var shield = require('../core/shield.js');
15
16
 
16
17
  /**
17
18
  * Where people click and how far they scroll.
@@ -221,7 +222,7 @@ function store(record) {
221
222
  recorded++;
222
223
  debug.noteDebugActivity();
223
224
  // a heatmap record is worth a session in the same way an event is
224
- session.commitPendingSession();
225
+ shield.quietly('session', session.commitPendingSession()); // no i18n
225
226
  storage.heatmap_transactions.add(record);
226
227
  logger.Console.dir(record);
227
228
  }
@@ -282,13 +283,13 @@ function watchForDeadClick(record, target) {
282
283
  catch (err) {
283
284
  return;
284
285
  }
285
- setTimeout(function () {
286
+ setTimeout(shield.shield('heatmap dead click', function () {
286
287
  observer.disconnect();
287
288
  if (!changed && window.location.href === url) {
288
289
  record.is_dead_click = 1;
289
290
  storage.heatmap_transactions.update(record);
290
291
  }
291
- }, DEAD_CLICK_MS);
292
+ }), DEAD_CLICK_MS);
292
293
  }
293
294
  /**
294
295
  * What a scroll event moved, as a gesture counts it: null for the window (the event's target is
@@ -345,7 +346,7 @@ function onScroll(event) {
345
346
  else {
346
347
  clearTimeout(scrollTimer);
347
348
  }
348
- scrollTimer = setTimeout(endScrollGesture, SCROLL_IDLE_MS);
349
+ scrollTimer = setTimeout(shield.shield('heatmap scroll', endScrollGesture), SCROLL_IDLE_MS); // no i18n
349
350
  }
350
351
  /** One record for the whole burst, once the page has been still for SCROLL_IDLE_MS. */
351
352
  function endScrollGesture() {
@@ -404,6 +405,9 @@ function endScrollGesture() {
404
405
  logger.logFailure(constants.AP_LOG_MODULE.HEATMAP, 'apptics.heatmap: scroll capture failed: ' + String(err)); // no i18n
405
406
  }
406
407
  }
408
+ // the listeners as added, so the same functions come off again
409
+ const pointerListener = shield.shield('heatmap click', onPointerDown); // no i18n
410
+ const scrollListener = shield.shield('heatmap scroll', onScroll); // no i18n
407
411
  /** Turns capture on or off. Listeners are passive, so they never delay a click or a scroll. */
408
412
  function trackHeatmap(status) {
409
413
  var wanted = typeof status === 'boolean' ? status : true; // no i18n
@@ -414,14 +418,14 @@ function trackHeatmap(status) {
414
418
  // where the page already is, so the first gesture is measured from here and not from 0
415
419
  lastX = Math.round(window.scrollX || 0);
416
420
  lastY = Math.round(window.scrollY || 0);
417
- window.addEventListener('pointerdown', onPointerDown, { capture: true, passive: true }); // no i18n
418
- window.addEventListener('scroll', onScroll, { capture: true, passive: true }); // no i18n
421
+ window.addEventListener('pointerdown', pointerListener, { capture: true, passive: true }); // no i18n
422
+ window.addEventListener('scroll', scrollListener, { capture: true, passive: true }); // no i18n
419
423
  installed = true;
420
424
  logger.Console.log('apptics.heatmap: capturing clicks and scrolls'); // no i18n
421
425
  return;
422
426
  }
423
- window.removeEventListener('pointerdown', onPointerDown, true); // no i18n
424
- window.removeEventListener('scroll', onScroll, true); // no i18n
427
+ window.removeEventListener('pointerdown', pointerListener, true); // no i18n
428
+ window.removeEventListener('scroll', scrollListener, true); // no i18n
425
429
  // a gesture still settling when capture stops (a single-page app leaving a heatmap page) is
426
430
  // recorded as it stands, not dropped: it was the visitor's last scroll on that page
427
431
  if (scrollTimer !== null) {
package/dist/cjs/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
  'use strict';
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
@@ -172,7 +172,7 @@ const setTrackingStatusGuarded = guard.guard('AppticsSettings.setTrackingStatus'
172
172
  const getTrackingStatusGuarded = guard.guard('AppticsSettings.getTrackingStatus', consent.getTrackingStatus); // no i18n
173
173
  /** Android's AppticsSettings: what the SDK may track for this visitor. */
174
174
  const AppticsSettings = {
175
- /** The states setTrackingStatus takes: USAGE_TRACKING_WITH_PII, USAGE_TRACKING_WITHOUT_PII, NO_TRACKING. */
175
+ /** The states setTrackingStatus takes: USAGE_TRACKING_WITH_PII, USAGE_TRACKING_WITHOUT_PII, ANONYMOUS, NO_TRACKING. */
176
176
  AP_TRACKING_STATUS: constants.AP_TRACKING_STATUS,
177
177
  setTrackingStatus: function setTrackingStatus(status) { return guard.forward(setTrackingStatusGuarded, arguments); },
178
178
  getTrackingStatus: function getTrackingStatus() { return guard.forward(getTrackingStatusGuarded, arguments); },
@@ -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
  '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. */
@@ -153,7 +154,7 @@ const TUNABLE = Object.freeze([
153
154
  { key: 'getupdates_interval', min: 10000, max: 86400000 }, // no i18n
154
155
  { key: 'batch_size', min: 1, max: 500 }, // no i18n
155
156
  { key: 'batch_request_timeout', min: 1, max: 30 }, // no i18n
156
- { 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
157
158
  { key: 'heatmap_max_per_session', min: 0, max: 10000 }, // no i18n
158
159
  ]);
159
160
  /** Reads the tunable timings out of the config. Anything missing goes back to its default. */
@@ -173,18 +174,30 @@ function applyIntervals(config) {
173
174
  state._ZAP._config[rule.key] = num;
174
175
  logger.Console.log('Apptics.init: ' + rule.key + ' set to ' + num); // no i18n
175
176
  });
176
- // 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
177
181
  state._ZAP.inactiveduration = constants.DEFAULT_INACTIVE_MINUTES;
178
- if (!utils.isEmpty(config.inactiveduration)) {
179
- var minutes = Number(config.inactiveduration);
180
- if (!isFinite(minutes) || minutes < 1 || minutes > 1440) {
181
- logger.warnAlways('Apptics.init: inactiveduration must be between 1 and 1440 minutes, keeping ' + state._ZAP.inactiveduration); // no i18n
182
- }
183
- else {
184
- state._ZAP.inactiveduration = minutes;
185
- logger.Console.log('Apptics.init: inactiveduration set to ' + minutes); // no i18n
186
- }
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;
187
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;
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
188
201
  }
189
202
  /** Everything the SDK stores: settings, ids and every queue. Resolves once it is all gone. */
190
203
  function clearStorage() {
@@ -245,15 +258,21 @@ function init(config) {
245
258
  if (typeof config.ignore_do_not_track === 'boolean') { // no i18n
246
259
  state._ZAP._config.ignore_do_not_track = config.ignore_do_not_track;
247
260
  }
248
- // debug: debug mode, the debug endpoints. Same payloads, but the answer says where to trace the
249
- // request. debug_api is its earlier name and still works; debug wins when both are given
250
- state._ZAP._config.debug_api = typeof config.debug === 'boolean' ? config.debug // no i18n
251
- : typeof config.debug_api === 'boolean' ? config.debug_api : constants.AP_CONFIG.debug_api; // no i18n
252
- // starts (or clears) the idle hour that closes debug mode on its own
253
- // an enableDebug() or disableDebug() call the app already made wins over the config
254
- 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();
255
270
  // what to call this device in the debug stream; see devicename in core/transport.ts
256
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
+ }
257
276
  // the SDK no longer reports its own failures to the Remote Logger page: only the lines an app
258
277
  // logs with AppticsLogger go there
259
278
  if (config.remote_log !== undefined) {
@@ -332,6 +351,8 @@ function init(config) {
332
351
  logger.Console.error('Apptics.init: start-up failed', err); // no i18n
333
352
  return false;
334
353
  });
354
+ // push calls made before init() wait on this start-up, success or not
355
+ hooks.hooks.pushInitCalled();
335
356
  return true;
336
357
  }
337
358
  /** Start-up from app/addversion on, once the store holds only this app's data. */
@@ -387,7 +408,7 @@ function registerWhenOnline(myGeneration) {
387
408
  clearInterval(timer);
388
409
  resolve(ok);
389
410
  }
390
- function attempt() {
411
+ function tryRegister() {
391
412
  if (myGeneration !== generation) {
392
413
  done(false);
393
414
  return;
@@ -396,7 +417,7 @@ function registerWhenOnline(myGeneration) {
396
417
  return;
397
418
  }
398
419
  trying = true;
399
- appversion.registerAppVersion().then(function (registered) {
420
+ shield.quietly('app/addversion retry', appversion.registerAppVersion().then(function (registered) {
400
421
  trying = false;
401
422
  if (registered) {
402
423
  done(true);
@@ -405,8 +426,12 @@ function registerWhenOnline(myGeneration) {
405
426
  logger.warnAlways('Apptics.init: app/addversion did not return the app ids, not starting'); // no i18n
406
427
  done(false);
407
428
  }
408
- });
429
+ }, function (err) {
430
+ trying = false;
431
+ throw err;
432
+ }));
409
433
  }
434
+ var attempt = shield.shield('app/addversion retry', tryRegister); // no i18n
410
435
  window.addEventListener('online', attempt); // no i18n
411
436
  timer = setInterval(attempt, OFFLINE_RETRY_MS);
412
437
  });
@@ -502,7 +527,9 @@ function startTracking(appVersionChanged, myGeneration) {
502
527
  // answers, the settings saved by the last visit apply (restoreServerSettings, in start())
503
528
  index.startServerSettingChecks();
504
529
  if (appVersionChanged) {
505
- 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
506
533
  index.updateDeviceWithApptics(state._ZAP._device_info).then(function (result) {
507
534
  if (utils.isSuccess(result)) {
508
535
  logger.Console.log('init: appversion updated to ' + state._ZAP._defaultoptions.appversion); // no i18n
@@ -520,7 +547,7 @@ function startTracking(appVersionChanged, myGeneration) {
520
547
  return false;
521
548
  }
522
549
  scheduler.startTimers();
523
- send.sendStoredLogs();
550
+ shield.quietly('sending stored logs', send.sendStoredLogs()); // no i18n
524
551
  state._ZAP._ready = true;
525
552
  // replay calls made while storage was loading, in order
526
553
  var pending = state._ZAP._pending;
@@ -538,8 +565,11 @@ function startTracking(appVersionChanged, myGeneration) {
538
565
  autoScreen.enableScreenTracking(state._ZAP._config.track_screen);
539
566
  // a no-op unless the remote-config entry was imported, which sets the hook
540
567
  hooks.hooks.remoteConfigStarted();
568
+ // the same for push notification: a no-op unless its entry was imported
569
+ hooks.hooks.pushStarted();
541
570
  window.appticsReadyStatus = true;
542
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
543
573
  window.appticsReady();
544
574
  }
545
575
  return true;
@@ -558,7 +588,10 @@ function reset() {
558
588
  hooks.hooks.trackHeatmap(false);
559
589
  hooks.hooks.resetHeatmap();
560
590
  hooks.hooks.resetRemoteConfig();
561
- clearStorage();
591
+ hooks.hooks.resetPush();
592
+ state._ZAP._pushEnabled = false;
593
+ state._ZAP._wmsConfig = null;
594
+ shield.quietly('clearing storage', clearStorage()); // no i18n
562
595
  state._ZAP._initialised = false;
563
596
  state._ZAP._ready = false;
564
597
  state._ZAP._pending = [];
@@ -656,33 +689,33 @@ function onDocumentClick(event) {
656
689
  function onPageHidden() {
657
690
  if (!isActive())
658
691
  return;
659
- // the moment the user left: the session ends at it if they are not back within inactiveduration
660
- session.markTabInactive(sendEndedSession);
661
- session.updateScreenWithEndtime();
662
- 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
663
696
  logger.Console.log('page hidden: closing the open screen and flushing'); // no i18n
664
697
  }
665
698
  /** A session that inactivity ended while the tab was away: sent now, not when the user returns. */
666
- function sendEndedSession() {
699
+ const sendEndedSession = shield.shield('sending the ended session', function () {
667
700
  if (!isActive())
668
701
  return;
669
- scheduler.flush();
670
- }
702
+ shield.quietly('sending the ended session', scheduler.flush()); // no i18n
703
+ });
671
704
  /**
672
705
  * The tab is closing, or the page is being replaced or frozen into the back/forward cache.
673
706
  * The session ends here, and everything queued goes out by keepalive, since a normal
674
707
  * request would be cancelled with the page.
675
708
  */
676
- function onPageClosing() {
709
+ const onPageClosing = shield.shield('page closing', function () {
677
710
  if (!isActive())
678
711
  return;
679
712
  logger.Console.log('page closing: ending the session and sending what is queued'); // no i18n
680
- session.updateScreenWithEndtime();
681
- send.forgetStoredLogs();
682
- 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 () {
683
716
  return scheduler.flush(true);
684
- });
685
- }
717
+ }));
718
+ });
686
719
  function attachListeners() {
687
720
  if (listenersAttached) {
688
721
  return;
@@ -691,42 +724,42 @@ function attachListeners() {
691
724
  // listen for connection change events (only available in w3c implementation)
692
725
  var connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection;
693
726
  if (connection && connection.addEventListener) {
694
- connection.addEventListener('change', function () {
727
+ connection.addEventListener('change', shield.shield('connection change', function () {
695
728
  state._ZAP._device_info.connectionType = env.getConnectionType();
696
- });
729
+ }));
697
730
  }
698
731
  // Track when the window loses focus (user switches to another window or application)
699
- window.addEventListener('blur', function () {
732
+ window.addEventListener('blur', shield.shield('window blur', function () {
700
733
  if (!isActive())
701
734
  return;
702
735
  // focus moving into an iframe on the page blurs the window too, and the user is still here
703
736
  if (document.activeElement && document.activeElement.tagName === 'IFRAME')
704
737
  return; // no i18n
705
738
  logger.Console.log('Window lost focus, user switched to another window or application'); // no i18n
706
- session.markTabInactive(sendEndedSession);
707
- });
739
+ shield.quietly('window blur', session.markTabInactive(sendEndedSession)); // no i18n
740
+ }));
708
741
  // Track when the window gains focus (user switches back to the window)
709
- window.addEventListener('focus', function () {
742
+ window.addEventListener('focus', shield.shield('window focus', function () {
710
743
  if (!isActive())
711
744
  return;
712
745
  logger.Console.log('Window regained focus, user switched back to the window'); // no i18n
713
746
  session.markTabActive();
714
- session.checkAndUpdateSession();
747
+ shield.quietly('window focus', session.checkAndUpdateSession()); // no i18n
715
748
  scheduler.startTimers();
716
- });
749
+ }));
717
750
  // IndexedDB writes are async, so unload work starts on pagehide rather than beforeunload
718
751
  window.addEventListener('pagehide', onPageClosing); // no i18n
719
752
  // back/forward cache: pagehide ended the session, so coming back starts a new one
720
- window.addEventListener('pageshow', function (event) {
753
+ window.addEventListener('pageshow', shield.shield('page show', function (event) {
721
754
  if (!isActive() || !event.persisted)
722
755
  return;
723
756
  logger.Console.log('restored from the back/forward cache: starting a new session'); // no i18n
724
757
  session.markTabActive();
725
758
  // the screen the page was left on starts a new view, in the new session
726
- session.checkAndUpdateSession().then(track.resumeScreen);
759
+ shield.quietly('page show', session.checkAndUpdateSession().then(track.resumeScreen)); // no i18n
727
760
  scheduler.startTimers();
728
- });
729
- document.addEventListener('visibilitychange', function () {
761
+ }));
762
+ document.addEventListener('visibilitychange', shield.shield('visibility change', function () {
730
763
  if (!isActive())
731
764
  return;
732
765
  if (document.visibilityState === 'hidden') { // no i18n
@@ -738,15 +771,15 @@ function attachListeners() {
738
771
  session.markTabActive();
739
772
  // hiding ended the screen view; the screen the user is back on starts a new one, after the
740
773
  // session is settled so the view belongs to the right one
741
- session.checkAndUpdateSession().then(track.resumeScreen);
742
- });
774
+ shield.quietly('visibility change', session.checkAndUpdateSession().then(track.resumeScreen)); // no i18n
775
+ }));
743
776
  // if we are running in cordova use ondeviceready otherwise onload
744
- window.addEventListener(window.cordova ? 'deviceready' : 'load', function () {
777
+ window.addEventListener(window.cordova ? 'deviceready' : 'load', shield.shield('page load', function () {
745
778
  if (isActive())
746
- session.checkAndUpdateSession();
747
- }, { passive: true });
779
+ shield.quietly('page load', session.checkAndUpdateSession()); // no i18n
780
+ }), { passive: true });
748
781
  // Always send pending requests when the connection comes back online
749
- window.addEventListener('online', function () {
782
+ window.addEventListener('online', shield.shield('back online', function () {
750
783
  if (!isActive())
751
784
  return;
752
785
  // a first visit that started offline has no device ids yet, and nothing can be sent
@@ -754,44 +787,58 @@ function attachListeners() {
754
787
  if (index.needsDevice()) {
755
788
  logger.Console.log('back online: registering this device before sending'); // no i18n
756
789
  // the same locked path as start-up, so two tabs coming back online register it once
757
- index.prepareDevice().then(index.deviceReady).then(function () {
790
+ shield.quietly('back online', index.prepareDevice().then(index.deviceReady).then(function () {
758
791
  if (!isActive())
759
792
  return;
760
- scheduler.flush();
793
+ shield.quietly('back online', scheduler.flush()); // no i18n
761
794
  // the lines logged while offline are waiting too, and log/add needs the same ids
762
- send.sendStoredLogs();
763
- });
795
+ shield.quietly('back online', send.sendStoredLogs()); // no i18n
796
+ }));
764
797
  return;
765
798
  }
766
- scheduler.flush();
767
- send.sendStoredLogs();
768
- }, { passive: true });
799
+ shield.quietly('back online', scheduler.flush()); // no i18n
800
+ shield.quietly('back online', send.sendStoredLogs()); // no i18n
801
+ }), { passive: true });
769
802
  if (window.screen && window.screen.orientation && typeof window.screen.orientation.addEventListener === 'function') { // no i18n
770
- window.screen.orientation.addEventListener('change', function () {
803
+ window.screen.orientation.addEventListener('change', shield.shield('orientation change', function () {
771
804
  state._ZAP._properties.orientation = env.getOrientation();
772
- });
805
+ }));
773
806
  }
774
- window.addEventListener('unhandledrejection', function (event) {
775
- if (isActive() && state._ZAP._config.track_error) {
776
- track$1.trackError(event);
807
+ window.addEventListener('unhandledrejection', shield.shield('error tracking', function (event) {
808
+ if (!isActive() || !state._ZAP._config.track_error) {
809
+ return;
777
810
  }
778
- });
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
+ }));
779
817
  // in the capture phase: a <script>, <img> or <link> that fails to load fires `error` on the
780
818
  // element, and it does not bubble, so a bubbling listener never hears of it. One listener
781
819
  // hears both kinds, the window's own errors included, so none is counted twice
782
- window.addEventListener('error', function (event) {
820
+ window.addEventListener('error', shield.shield('error tracking', function (event) {
783
821
  if (!isActive() || !state._ZAP._config.track_error) {
784
822
  return;
785
823
  }
786
824
  var target = event.target;
787
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
+ }
788
831
  // named by describeTarget: Event "error" on <script src="...">
789
832
  track$1.trackError({ type: 'error', reason: event }); // no i18n
790
833
  return;
791
834
  }
835
+ // thrown by the SDK's <script> file or the Quartz recorder it loaded
836
+ if (shield.isSdkScript(event.filename)) {
837
+ return;
838
+ }
792
839
  track$1.trackError(event);
793
- }, true);
794
- window.addEventListener('click', onDocumentClick, true); // no i18n
840
+ }), true);
841
+ window.addEventListener('click', shield.shield('click tracking', onDocumentClick), true); // no i18n
795
842
  }
796
843
 
797
844
  exports.init = init;
@@ -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,112 @@
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0 | (c) Zoho Corporation Private Limited | see LICENSE */
2
+ 'use strict';
3
+
4
+ var payload = require('./payload.js');
5
+
6
+ /** What the service worker posts to the site's tabs. */
7
+ const CLICK_MESSAGE = 'apptics-notification-click'; // no i18n
8
+ const CLOSE_MESSAGE = 'apptics-notification-close'; // no i18n
9
+ /** Prev / Next pressed: the page stops that notification's auto-scroll, as the visitor took over. */
10
+ const STEP_MESSAGE = 'apptics-notification-step'; // no i18n
11
+ /** The worker gives back the timers it could not finish in its time: an open tab runs the rest. */
12
+ const HANDOFF_MESSAGE = 'apptics-notification-handoff'; // no i18n
13
+ /** What a tab posts to the service worker: run this notification's timers; stop them (one tag, or all). */
14
+ const TIMERS_MESSAGE = 'apptics-notification-timers'; // no i18n
15
+ const STOP_TIMERS_MESSAGE = 'apptics-notification-stop'; // no i18n
16
+ /** The worker's answer to TIMERS_MESSAGE, on the port it came with: it runs them. */
17
+ const TIMERS_TAKEN = 'apptics-notification-timers-taken'; // no i18n
18
+ const ACTION_PREV = 'apptics-prev'; // no i18n
19
+ const ACTION_NEXT = 'apptics-next'; // no i18n
20
+ const ACTION_BUTTON = 'apptics-btn-'; // no i18n
21
+ /** The browser's labels for the carousel's two buttons, as the console's preview shows them. */
22
+ const PREV_LABEL = 'Prev'; // no i18n
23
+ const NEXT_LABEL = 'Next'; // no i18n
24
+ function isCarousel(view) {
25
+ return view.images.length > 1;
26
+ }
27
+ /** The title shown for slide `index`: the slide number is added for a carousel. */
28
+ function titleFor(view, index) {
29
+ return isCarousel(view) ? view.title + ' (' + (index + 1) + ' / ' + view.images.length + ')' : view.title; // no i18n
30
+ }
31
+ /**
32
+ * The options for showing `shown` at its slide. `update` is a re-show of one already on screen
33
+ * (a carousel step, a countdown tick): it makes no sound.
34
+ */
35
+ function optionsFor(shown, update, nowMs) {
36
+ var view = shown.view;
37
+ var body = view.text;
38
+ if (view.countdownTo > 0) {
39
+ body += (body ? '\n' : '') + payload.formatCountdown(view.countdownTo, nowMs); // no i18n
40
+ }
41
+ var options = {
42
+ body: body,
43
+ tag: shown.tag,
44
+ requireInteraction: view.requireInteraction,
45
+ silent: view.silent || update,
46
+ // a new message alerts even when it replaces one still on screen under the same tag (the
47
+ // same appticsPnID); the SDK's own updates (a slide, a countdown tick) replace it quietly
48
+ renotify: !update,
49
+ data: shown,
50
+ };
51
+ var image = view.images[shown.index] || view.images[0];
52
+ if (image && !supportsImage()) {
53
+ // no large image here (Chrome on macOS goes through the system's notifications, which have
54
+ // no slot for one): the slide shows as the icon, so a carousel still visibly changes
55
+ options.icon = image;
56
+ }
57
+ else {
58
+ if (view.icon) {
59
+ options.icon = view.icon;
60
+ }
61
+ if (image) {
62
+ options.image = image;
63
+ }
64
+ }
65
+ if (isCarousel(view)) {
66
+ options.actions = [{ action: ACTION_PREV, title: PREV_LABEL }, { action: ACTION_NEXT, title: NEXT_LABEL }];
67
+ }
68
+ else if (view.buttons.length > 0) {
69
+ options.actions = view.buttons.map(function (b, i) {
70
+ var action = { action: ACTION_BUTTON + i, title: b.label };
71
+ if (b.icon) {
72
+ action.icon = b.icon;
73
+ }
74
+ return action;
75
+ });
76
+ }
77
+ return options;
78
+ }
79
+ /**
80
+ * Whether this browser shows a notification's large image. Notification.prototype has `image`
81
+ * where it does; Chrome on macOS has none. Asked the same way in the page and the worker.
82
+ */
83
+ function supportsImage() {
84
+ var N = typeof Notification !== 'undefined' ? Notification : undefined; // no i18n
85
+ return !N || !N.prototype || 'image' in N.prototype; // no i18n
86
+ }
87
+ /** Whether a notification's data is one the SDK showed. */
88
+ function isOurs(data) {
89
+ return !!data && typeof data === 'object' && data.apptics === 1; // no i18n
90
+ }
91
+ /** The slide after `index` by `step` (+1 / -1), wrapping. */
92
+ function stepIndex(view, index, step) {
93
+ var n = view.images.length;
94
+ return n > 0 ? ((index + step) % n + n) % n : 0;
95
+ }
96
+
97
+ exports.ACTION_BUTTON = ACTION_BUTTON;
98
+ exports.ACTION_NEXT = ACTION_NEXT;
99
+ exports.ACTION_PREV = ACTION_PREV;
100
+ exports.CLICK_MESSAGE = CLICK_MESSAGE;
101
+ exports.CLOSE_MESSAGE = CLOSE_MESSAGE;
102
+ exports.HANDOFF_MESSAGE = HANDOFF_MESSAGE;
103
+ exports.STEP_MESSAGE = STEP_MESSAGE;
104
+ exports.STOP_TIMERS_MESSAGE = STOP_TIMERS_MESSAGE;
105
+ exports.TIMERS_MESSAGE = TIMERS_MESSAGE;
106
+ exports.TIMERS_TAKEN = TIMERS_TAKEN;
107
+ exports.isCarousel = isCarousel;
108
+ exports.isOurs = isOurs;
109
+ exports.optionsFor = optionsFor;
110
+ exports.stepIndex = stepIndex;
111
+ exports.supportsImage = supportsImage;
112
+ exports.titleFor = titleFor;