@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
@@ -0,0 +1,20 @@
1
+ import './wms.js';
2
+ import type { PermissionAnswer } from './notify.js';
3
+ /** AppticsPushNotification: setEnabled, isEnabled, and the browser notification's requestPermission. */
4
+ export declare const AppticsPushNotification: {
5
+ /**
6
+ * setEnabled(true) registers this browser for push now; setEnabled(false) unregisters it and
7
+ * keeps it unregistered across visits until setEnabled(true). Resolves true once done, false
8
+ * when push is off for the app in the console.
9
+ */
10
+ setEnabled: (enabled: boolean) => Promise<boolean>;
11
+ /** Whether this browser holds a push session now. */
12
+ isEnabled: () => boolean;
13
+ /**
14
+ * Asks the visitor to allow browser notifications; call it from a click. Resolves with
15
+ * 'granted', 'denied', 'default' (dismissed) or 'unsupported'. Once granted, each message is
16
+ * also shown as a notification while a tab of the site is open.
17
+ */
18
+ requestPermission: () => Promise<PermissionAnswer>;
19
+ };
20
+ export default AppticsPushNotification;
@@ -0,0 +1,91 @@
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0 | (c) Zoho Corporation Private Limited | see LICENSE */
2
+ import { forward, guard } from '../core/guard.js';
3
+ import { warnAlways } from '../core/logger.js';
4
+ import { currentSession, whenStarted, registerPush, unregisterPush } from './session.js';
5
+ import './wms.js';
6
+ import { requestPermission as requestPermission$1 } from './notify.js';
7
+
8
+ /**
9
+ * Push notification, shipped as its own entry point:
10
+ * import { AppticsPushNotification } from '@zoho_apptics/apptics-js-sdk/push-notification';
11
+ *
12
+ * Importing it is enough for the SDK to register this browser on its own, whenever the console
13
+ * has push on for the app: getsdkconfig is asked about module 16, and its answer says where
14
+ * wmsliteapi.js loads from. Messages arrive over WMS while the page is open, and each shows as a
15
+ * browser notification.
16
+ *
17
+ * The visitor sees a browser notification for each message once they allow it, which
18
+ * requestPermission() asks for: call it from a click, as browsers require. A click on one focuses
19
+ * the tab and opens the message's url.
20
+ *
21
+ * setEnabled(true) registers by hand, and also undoes an earlier setEnabled(false), which
22
+ * otherwise holds across visits. While tracking is anonymous the browser registers by its
23
+ * anonymous id; with no tracking it does not register at all.
24
+ */
25
+ /**
26
+ * true registers this browser (and undoes an earlier false); false unregisters it, held across
27
+ * visits until true. Resolves true once done, false when it can't be (push off for the app, or
28
+ * the SDK didn't start).
29
+ */
30
+ function setEnabled(enabled) {
31
+ if (enabled !== true && enabled !== false) {
32
+ warnAlways('AppticsPushNotification.setEnabled: takes true (register this browser) or false (unregister it)'); // no i18n
33
+ return Promise.resolve(false);
34
+ }
35
+ return whenStarted().then(function (running) {
36
+ if (!running) {
37
+ return false;
38
+ }
39
+ return enabled ? registerPush(true).then(function (session) { return session !== null; }) : unregisterPush();
40
+ });
41
+ }
42
+ function isEnabled() {
43
+ return currentSession() !== null;
44
+ }
45
+ function requestPermission() {
46
+ return requestPermission$1();
47
+ }
48
+ // function onNotificationClick(callback: (click: NotificationClick) => void): () => void {
49
+ // if (typeof callback !== 'function') { // no i18n
50
+ // warnAlways('AppticsPushNotification.onNotificationClick: takes a function, called with the clicked message\'s data'); // no i18n
51
+ // return function () {};
52
+ // }
53
+ // return addClickListener(callback);
54
+ // }
55
+ const setEnabledGuarded = guard('AppticsPushNotification.setEnabled', setEnabled); // no i18n
56
+ const isEnabledGuarded = guard('AppticsPushNotification.isEnabled', isEnabled); // no i18n
57
+ const requestPermissionGuarded = guard('AppticsPushNotification.requestPermission', requestPermission); // no i18n
58
+ // const onNotificationClickGuarded = guard('AppticsPushNotification.onNotificationClick', onNotificationClick); // no i18n
59
+ /** AppticsPushNotification: setEnabled, isEnabled, and the browser notification's requestPermission. */
60
+ const AppticsPushNotification = {
61
+ /**
62
+ * setEnabled(true) registers this browser for push now; setEnabled(false) unregisters it and
63
+ * keeps it unregistered across visits until setEnabled(true). Resolves true once done, false
64
+ * when push is off for the app in the console.
65
+ */
66
+ setEnabled: function setEnabled(enabled) {
67
+ return forward(setEnabledGuarded, arguments);
68
+ },
69
+ /** Whether this browser holds a push session now. */
70
+ isEnabled: function isEnabled() {
71
+ return forward(isEnabledGuarded, arguments);
72
+ },
73
+ /**
74
+ * Asks the visitor to allow browser notifications; call it from a click. Resolves with
75
+ * 'granted', 'denied', 'default' (dismissed) or 'unsupported'. Once granted, each message is
76
+ * also shown as a notification while a tab of the site is open.
77
+ */
78
+ requestPermission: function requestPermission() {
79
+ return forward(requestPermissionGuarded, arguments);
80
+ },
81
+ // /**
82
+ // * Calls `callback` when the visitor clicks a notification, with { action, appticsPnID,
83
+ // * additional, data }: the button's action id ('' for the body), the message's id and its
84
+ // * additional key-values, and the message's data. Returns the function that stops it.
85
+ // */
86
+ // onNotificationClick: function onNotificationClick(callback: (click: NotificationClick) => void): () => void {
87
+ // return forward(onNotificationClickGuarded, arguments);
88
+ // },
89
+ };
90
+
91
+ export { AppticsPushNotification, AppticsPushNotification as default };
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Opens the service worker couldn't hand to a tab of the site: the click opened another site, and
3
+ * no tab of this one was open. The worker keeps them in IndexedDB (apptics-push / opens), which the
4
+ * page shares, and the SDK sends them as opened stats on the next visit.
5
+ */
6
+ export interface KeptOpen {
7
+ notificationid: string;
8
+ notificationnumber: number | null;
9
+ /** The button's action id, '' for the body. */
10
+ actionid: string;
11
+ timestamp: number;
12
+ /** The message's conversion event, which waits from the open. */
13
+ conversion: {
14
+ name: string;
15
+ group: string;
16
+ } | null;
17
+ /** The run's send time, for a recurring push without a run number. */
18
+ run?: string;
19
+ }
20
+ /** Keeps an open for the next visit. Resolves either way: losing one stat breaks nothing else. */
21
+ export declare function keepOpen(open: KeptOpen): Promise<void>;
22
+ /** Takes every kept open out of the store, in one transaction, so two tabs can't both send one. */
23
+ export declare function takeOpens(): Promise<KeptOpen[]>;
@@ -0,0 +1,62 @@
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0 | (c) Zoho Corporation Private Limited | see LICENSE */
2
+ /**
3
+ * Opens the service worker couldn't hand to a tab of the site: the click opened another site, and
4
+ * no tab of this one was open. The worker keeps them in IndexedDB (apptics-push / opens), which the
5
+ * page shares, and the SDK sends them as opened stats on the next visit.
6
+ */
7
+ const DB_NAME = 'apptics-push'; // no i18n
8
+ const STORE = 'opens'; // no i18n
9
+ function idb() {
10
+ return typeof indexedDB !== 'undefined' ? indexedDB : undefined; // no i18n
11
+ }
12
+ function openDb() {
13
+ var factory = idb();
14
+ if (!factory) {
15
+ return Promise.resolve(null);
16
+ }
17
+ return new Promise(function (resolve) {
18
+ try {
19
+ var req = factory.open(DB_NAME, 1);
20
+ req.onupgradeneeded = function () {
21
+ if (!req.result.objectStoreNames.contains(STORE)) {
22
+ req.result.createObjectStore(STORE, { autoIncrement: true });
23
+ }
24
+ };
25
+ req.onsuccess = function () { resolve(req.result); };
26
+ req.onerror = function () { resolve(null); };
27
+ req.onblocked = function () { resolve(null); };
28
+ }
29
+ catch (e) {
30
+ resolve(null);
31
+ }
32
+ });
33
+ }
34
+ /** Takes every kept open out of the store, in one transaction, so two tabs can't both send one. */
35
+ function takeOpens() {
36
+ return openDb().then(function (db) {
37
+ if (!db) {
38
+ return [];
39
+ }
40
+ return new Promise(function (resolve) {
41
+ try {
42
+ var tx = db.transaction(STORE, 'readwrite'); // no i18n
43
+ var store = tx.objectStore(STORE);
44
+ var got = [];
45
+ var all = store.getAll();
46
+ all.onsuccess = function () {
47
+ got = all.result;
48
+ store.clear();
49
+ };
50
+ tx.oncomplete = function () { db.close(); resolve(got); };
51
+ tx.onerror = function () { db.close(); resolve([]); };
52
+ tx.onabort = function () { db.close(); resolve([]); };
53
+ }
54
+ catch (e) {
55
+ db.close();
56
+ resolve([]);
57
+ }
58
+ });
59
+ });
60
+ }
61
+
62
+ export { takeOpens };
@@ -0,0 +1,45 @@
1
+ export type PermissionAnswer = NotificationPermission | 'unsupported';
2
+ type Message = Record<string, unknown>;
3
+ /** What the app's onNotificationClick gets. */
4
+ export interface NotificationClick {
5
+ /** The clicked button's action id, or '' for the notification's body. */
6
+ action: string;
7
+ appticsPnID: string;
8
+ /** addInfo.additional: the console's key-values. */
9
+ additional: Message;
10
+ /** The message's data as it arrived. */
11
+ data: Message;
12
+ }
13
+ /** How a url on this site is opened: a seam, since a test page cannot navigate. */
14
+ export declare const _openUrlForTest: {
15
+ assign: (url: string) => void;
16
+ };
17
+ /** Asks the browser for permission to show notifications; resolves with its answer. */
18
+ export declare function requestPermission(): Promise<PermissionAnswer>;
19
+ /** Calls `fn` when the visitor clicks a notification, with the button and the message. */
20
+ export declare function addClickListener(fn: (click: NotificationClick) => void): () => void;
21
+ /**
22
+ * A notification was clicked (a button's action id, or '' for the body): the opened stat, and the
23
+ * conversion event it waits for from now.
24
+ */
25
+ declare function opened(data: Message, action: string, run?: string): void;
26
+ /** Test seams: the click path, and listening again after a test stubs the worker container. */
27
+ export declare const _openedForTest: typeof opened;
28
+ export declare function _listenForTest(): void;
29
+ /** The Apptics service worker: the site's /apptics-pn-sw.js, which imports apptics-pn-sw.js. */
30
+ export declare const SERVICE_WORKER = "/apptics-pn-sw.js";
31
+ /**
32
+ * The site's /apptics-pn-sw.js registration, or null when there is none: the browser has no service
33
+ * workers, the site has no /apptics-pn-sw.js (a plain notification shows; only logged, as many sites
34
+ * won't have it), or another worker of the site's controls its root. Registered once.
35
+ */
36
+ export declare function serviceWorkerReady(): Promise<ServiceWorkerRegistration | null>;
37
+ /** Stops the timers of every notification, the worker's too. Disconnecting (and reset) calls it. */
38
+ export declare function stopAllNotifications(): void;
39
+ /**
40
+ * Shows the notification for a message's `data`, when the visitor has granted permission. It is
41
+ * tagged by addInfo.appticsPnID, else the envelope's `timestamp`, so the same message shown by two
42
+ * tabs appears once.
43
+ */
44
+ export declare function showNotification(data: Message, timestamp?: unknown): void;
45
+ export {};