@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, isExpired } from './state.js';
3
3
  import { Console, warnAlways } from './logger.js';
4
4
  import { isEmptyObj, sizeof } from './utils.js';
@@ -6,13 +6,14 @@ import './db.js';
6
6
  import { shouldTrackOrSendData } from './consent.js';
7
7
  import { attemptsExhausted, MAX_ATTEMPTS, resetAttempts } from './attempts.js';
8
8
  import { rejectIfDisabled, rejectIfNoDeviceIds, getMetaObj, postKeepalive, apiHeaders, postToApptics } from './transport.js';
9
+ import { shield } from './shield.js';
9
10
 
10
11
  /** Retries `send` in 500 ms, replacing any retry already scheduled. */
11
12
  function defer(send) {
12
13
  if (_ZAP._deferSendTimer) {
13
14
  clearTimeout(_ZAP._deferSendTimer);
14
15
  }
15
- _ZAP._deferSendTimer = setTimeout(send, 500);
16
+ _ZAP._deferSendTimer = setTimeout(shield('deferred send', send), 500); // no i18n
16
17
  }
17
18
  function clearDefer() {
18
19
  if (_ZAP._deferSendTimer) {
@@ -70,7 +71,7 @@ function sendBatch(path, label, _payload, forget) {
70
71
  if (isEmptyObj(_payload)) {
71
72
  return Promise.reject(label + ': nothing to send'); // no i18n
72
73
  }
73
- var missing = rejectIfNoDeviceIds(label);
74
+ var missing = rejectIfNoDeviceIds(label, path);
74
75
  if (missing) {
75
76
  return missing;
76
77
  }
@@ -27,11 +27,14 @@ export declare function canTrackEngagement(caller: string, type: EngagementType)
27
27
  export declare function canTrackHeatmap(caller: string): boolean;
28
28
  /** canTrack plus the server's js_error module (15) from getsdkconfig. */
29
29
  export declare function canTrackErrors(caller: string): boolean;
30
- /**
31
- * Stores the visitor's tracking status without telling the server. True when it changed.
32
- * user/register uses this alone: the server learns of the user from that call, so a device/add
33
- * after it would only repeat a registration the device already has.
34
- */
30
+ /** Stores the visitor's tracking status without telling the server. True when it changed. */
35
31
  export declare function recordTrackingStatus(trackingState: TrackingStatus): boolean;
36
- export declare function setTrackingStatus(trackingState: TrackingStatus): void;
32
+ export declare function setTrackingStatus(value: TrackingStatus | number): void;
37
33
  export declare function getTrackingStatus(): TrackingStatus;
34
+ /**
35
+ * Whether the visitor chose anonymous tracking: the stored choice, not opt_in_status(), which
36
+ * answers NO_TRACKING while Do Not Track counts, and then nothing is sent to be named anyway.
37
+ */
38
+ export declare function isAnonymous(): boolean;
39
+ /** The server's device preference for a tracking status: devicestatus on device/add. */
40
+ export declare function deviceStatusFor(status: TrackingStatus): number;
@@ -1,10 +1,10 @@
1
- /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta.2 | (c) Zoho Corporation Private Limited | see LICENSE */
2
- import { AP_TRACKING_STATUS } from './constants.js';
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0 | (c) Zoho Corporation Private Limited | see LICENSE */
2
+ import { AP_TRACKING_STATUS, AP_DEVICE_STATUS } from './constants.js';
3
3
  import { _ZAP } from './state.js';
4
- import { Console } from './logger.js';
5
- import { isEmpty, isSuccess } from './utils.js';
6
- import { tracking_preference } from './storage.js';
7
- import { is_apptics_disabled, isDntOn } from './env.js';
4
+ import { Console, warnAlways } from './logger.js';
5
+ import { isSuccess, isEmpty } from './utils.js';
6
+ import { tracking_preference, trackingStatusFrom } from './storage.js';
7
+ import { isDntOn, is_apptics_disabled } from './env.js';
8
8
  import { hooks } from './hooks.js';
9
9
 
10
10
  /**
@@ -28,14 +28,14 @@ function opt_in_status() {
28
28
  return AP_TRACKING_STATUS.NO_TRACKING;
29
29
  }
30
30
  var status = tracking_preference.opt_in_status();
31
- if (status == -1) {
31
+ if (status === AP_TRACKING_STATUS.NO_TRACKING) {
32
32
  Console.warn('opt_in_status: You are opted out of Apptics tracking. This will prevent the our SDK from sending no data to our server.'); // no i18n
33
33
  }
34
34
  return status;
35
35
  }
36
36
  function shouldTrackOrSendData() {
37
37
  var optInStatus = opt_in_status();
38
- return optInStatus > -1 && _ZAP._shouldTrack;
38
+ return optInStatus !== AP_TRACKING_STATUS.NO_TRACKING && _ZAP._shouldTrack;
39
39
  }
40
40
  /**
41
41
  * The guard every tracking call starts with: init() has run, the client isn't a crawler,
@@ -92,11 +92,7 @@ function canTrackErrors(caller) {
92
92
  }
93
93
  return true;
94
94
  }
95
- /**
96
- * Stores the visitor's tracking status without telling the server. True when it changed.
97
- * user/register uses this alone: the server learns of the user from that call, so a device/add
98
- * after it would only repeat a registration the device already has.
99
- */
95
+ /** Stores the visitor's tracking status without telling the server. True when it changed. */
100
96
  function recordTrackingStatus(trackingState) {
101
97
  if (tracking_preference.opt_in_status() == trackingState) {
102
98
  return false;
@@ -105,14 +101,36 @@ function recordTrackingStatus(trackingState) {
105
101
  _ZAP._devicestatus = tracking_preference.opt_in_status();
106
102
  return true;
107
103
  }
108
- function setTrackingStatus(trackingState) {
109
- if (isEmpty(trackingState)) {
104
+ /**
105
+ * The status setTrackingStatus was given: one of AP_TRACKING_STATUS, or the number an app passed
106
+ * before the status had names, which still works and says so.
107
+ */
108
+ function requestedStatus(value) {
109
+ if (isEmpty(value)) {
110
110
  Console.warn('setTrackingStatus: trackingStatus is Empty'); // no i18n
111
+ return undefined;
112
+ }
113
+ var status = trackingStatusFrom(value);
114
+ if (status === undefined) {
115
+ warnAlways('AppticsSettings.setTrackingStatus: ' + String(value) + ' is not a tracking status; pass one of AppticsSettings.AP_TRACKING_STATUS'); // no i18n
116
+ }
117
+ else if (typeof value === 'number') { // no i18n
118
+ warnAlways('AppticsSettings.setTrackingStatus: the number ' + value + ' is deprecated; pass AppticsSettings.AP_TRACKING_STATUS.' + status); // no i18n
119
+ }
120
+ return status;
121
+ }
122
+ function setTrackingStatus(value) {
123
+ var trackingState = requestedStatus(value);
124
+ if (trackingState === undefined) {
111
125
  return;
112
126
  }
127
+ var previous = tracking_preference.opt_in_status();
113
128
  if (!recordTrackingStatus(trackingState)) {
114
129
  return;
115
130
  }
131
+ askServerSettingsForUser(previous, tracking_preference.opt_in_status());
132
+ // push registers by the id the new status goes by, or stops with no tracking
133
+ hooks.pushTrackingChanged();
116
134
  if (tracking_preference.opt_in_status() != AP_TRACKING_STATUS.NO_TRACKING) {
117
135
  Console.log('setTrackingStatus: Updating device info with new tracking status'); // no i18n
118
136
  hooks.updateDevice(_ZAP._device_info).then(function (result) {
@@ -128,8 +146,41 @@ function setTrackingStatus(trackingState) {
128
146
  });
129
147
  }
130
148
  }
149
+ /**
150
+ * getsdkconfig carries the user's ids only with PII. For a user whose customer group is not
151
+ * tracked, it answers every module off with them and for the device alone without them, so a
152
+ * change into or out of PII is asked about now rather than at the next check. Any other user,
153
+ * or a change to no tracking, asks nothing.
154
+ */
155
+ function askServerSettingsForUser(previous, current) {
156
+ if (current === AP_TRACKING_STATUS.NO_TRACKING || !hooks.activeUserGroupUntracked()) {
157
+ return;
158
+ }
159
+ var withPii = AP_TRACKING_STATUS.USAGE_TRACKING_WITH_PII;
160
+ if (current === withPii || previous === withPii) {
161
+ Console.log('setTrackingStatus: the user\'s customer group is not tracked, asking getsdkconfig'); // no i18n
162
+ hooks.askServerSettings();
163
+ }
164
+ }
131
165
  function getTrackingStatus() {
132
166
  return opt_in_status();
133
167
  }
168
+ /**
169
+ * Whether the visitor chose anonymous tracking: the stored choice, not opt_in_status(), which
170
+ * answers NO_TRACKING while Do Not Track counts, and then nothing is sent to be named anyway.
171
+ */
172
+ function isAnonymous() {
173
+ return tracking_preference.opt_in_status() === AP_TRACKING_STATUS.ANONYMOUS;
174
+ }
175
+ /** The server's device preference for a tracking status: devicestatus on device/add. */
176
+ function deviceStatusFor(status) {
177
+ if (status === AP_TRACKING_STATUS.ANONYMOUS) {
178
+ return AP_DEVICE_STATUS.ALL_ANONYMOUS;
179
+ }
180
+ if (status === AP_TRACKING_STATUS.NO_TRACKING) {
181
+ return AP_DEVICE_STATUS.TRACKING_OFF;
182
+ }
183
+ return AP_DEVICE_STATUS.ALL_WITH_PII;
184
+ }
134
185
 
135
- export { canTrack, canTrackEngagement, canTrackErrors, canTrackHeatmap, getTrackingStatus, hasDoNotTrackEnabled, opt_in_status, recordTrackingStatus, setTrackingStatus, shouldTrackOrSendData };
186
+ export { canTrack, canTrackEngagement, canTrackErrors, canTrackHeatmap, deviceStatusFor, getTrackingStatus, hasDoNotTrackEnabled, isAnonymous, opt_in_status, recordTrackingStatus, setTrackingStatus, shouldTrackOrSendData };
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Whether a call was typed into the browser's developer console rather than made by the page's
3
+ * own code. Debug mode is switched this way only (see debug.ts), so an app cannot ship with it on.
4
+ *
5
+ * The browser does not say who called, so this reads the call's stack. Its outermost frame is
6
+ * where the call started: for code that is a script file, an inline handler or an eval made by
7
+ * one, and each of those names a URL. A console call starts in the console's own input, which has
8
+ * none:
9
+ *
10
+ * Chrome, Edge `at <anonymous>:1:9`
11
+ * Firefox `@debugger eval code:1:1`
12
+ * Safari `global code`, then frames from `[native code]`
13
+ *
14
+ * It is a best guess, not a lock: a script can make a stack with no URL in it too (a Function()
15
+ * body some engines leave unnamed), so this keeps a switch out of shipped code, nothing more.
16
+ */
17
+ /** Whether a stack, as Error().stack gives it, started in the console. */
18
+ export declare function isConsoleStack(stack: string): boolean;
19
+ /**
20
+ * Whether the public call running now was typed into the console. A browser that gives no stack
21
+ * cannot be asked, and is let through rather than having the call stop working there.
22
+ */
23
+ export declare function calledFromConsole(): boolean;
@@ -0,0 +1,60 @@
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0 | (c) Zoho Corporation Private Limited | see LICENSE */
2
+ /**
3
+ * Whether a call was typed into the browser's developer console rather than made by the page's
4
+ * own code. Debug mode is switched this way only (see debug.ts), so an app cannot ship with it on.
5
+ *
6
+ * The browser does not say who called, so this reads the call's stack. Its outermost frame is
7
+ * where the call started: for code that is a script file, an inline handler or an eval made by
8
+ * one, and each of those names a URL. A console call starts in the console's own input, which has
9
+ * none:
10
+ *
11
+ * Chrome, Edge `at <anonymous>:1:9`
12
+ * Firefox `@debugger eval code:1:1`
13
+ * Safari `global code`, then frames from `[native code]`
14
+ *
15
+ * It is a best guess, not a lock: a script can make a stack with no URL in it too (a Function()
16
+ * body some engines leave unnamed), so this keeps a switch out of shipped code, nothing more.
17
+ */
18
+ /** A location with a scheme: https://, file://, blob:, webpack-internal:// and the like. */
19
+ const URL_RE = /[a-z][a-z0-9+.-]*:\/\//i;
20
+ /** Frames that are the engine's own, which say nothing about who called. */
21
+ function engineFrame(line) {
22
+ return line === '@' || line.indexOf('[native code]') !== -1; // no i18n
23
+ }
24
+ /** Whether a stack, as Error().stack gives it, started in the console. */
25
+ function isConsoleStack(stack) {
26
+ var frames = stack.split('\n').map(function (line) {
27
+ return line.trim();
28
+ }).filter(function (line) {
29
+ return line !== '' && !engineFrame(line);
30
+ });
31
+ // V8 heads its stack with the error's own name and message, which is no frame
32
+ if (frames.length && !/^at\s/.test(frames[0]) && frames[0].indexOf('@') === -1 && /^\w*Error\b/.test(frames[0])) {
33
+ frames.shift();
34
+ }
35
+ if (!frames.length) {
36
+ return false;
37
+ }
38
+ return !URL_RE.test(frames[frames.length - 1]);
39
+ }
40
+ /**
41
+ * Whether the public call running now was typed into the console. A browser that gives no stack
42
+ * cannot be asked, and is let through rather than having the call stop working there.
43
+ */
44
+ function calledFromConsole() {
45
+ // V8 keeps 10 frames unless told otherwise, which a deep enough call cuts off before the frame
46
+ // where it started; the whole stack is read, and the page's own limit put back
47
+ var E = Error;
48
+ var limit = E.stackTraceLimit;
49
+ var stack;
50
+ try {
51
+ E.stackTraceLimit = Infinity;
52
+ stack = new Error().stack;
53
+ }
54
+ finally {
55
+ E.stackTraceLimit = limit;
56
+ }
57
+ return typeof stack !== 'string' || stack === '' || isConsoleStack(stack); // no i18n
58
+ }
59
+
60
+ export { calledFromConsole, isConsoleStack };
@@ -14,11 +14,40 @@ export type ScreenRouteRule = {
14
14
  regex: RegExp;
15
15
  name: string;
16
16
  };
17
+ /**
18
+ * The visitor's tracking status: what setTrackingStatus takes and getTrackingStatus returns. Each
19
+ * value is its own name, so an app never deals in the numbers it is stored as (TRACKING_STATUS_CODE).
20
+ */
17
21
  export declare const AP_TRACKING_STATUS: Readonly<{
22
+ readonly USAGE_TRACKING_WITH_PII: "USAGE_TRACKING_WITH_PII";
23
+ readonly USAGE_TRACKING_WITHOUT_PII: "USAGE_TRACKING_WITHOUT_PII";
24
+ readonly ANONYMOUS: "ANONYMOUS";
25
+ readonly NO_TRACKING: "NO_TRACKING";
26
+ }>;
27
+ /**
28
+ * The number each tracking status is stored as, in trackinfo's tracking_status, and the number an
29
+ * app passed to setTrackingStatus before the status had names. These are the SDK's own values, not
30
+ * the server's device preference: deviceStatusFor() turns one into the devicestatus device/add
31
+ * sends. ANONYMOUS is 7, past the server's 1–6, because 4 is already stored by browsers that chose
32
+ * without PII and must keep meaning that.
33
+ */
34
+ export declare const TRACKING_STATUS_CODE: Readonly<{
18
35
  readonly USAGE_TRACKING_WITH_PII: 1;
19
36
  readonly USAGE_TRACKING_WITHOUT_PII: 4;
37
+ readonly ANONYMOUS: 7;
20
38
  readonly NO_TRACKING: -1;
21
39
  }>;
40
+ /**
41
+ * The server's device preferences, devicestatus on device/add. With and without PII are both
42
+ * "all tracking with PII" (1): without PII only means no user is attached to the data. ANONYMOUS
43
+ * is "all tracking, anonymous" (4). The usage-only and crash-only preferences (2, 3, 5, 6) have no
44
+ * SDK status yet.
45
+ */
46
+ export declare const AP_DEVICE_STATUS: Readonly<{
47
+ readonly ALL_WITH_PII: 1;
48
+ readonly ALL_ANONYMOUS: 4;
49
+ readonly TRACKING_OFF: -1;
50
+ }>;
22
51
  export declare const AP_FEEDBACK_TYPE: Readonly<{
23
52
  readonly BUG: 0;
24
53
  readonly FEEDBACK: 1;
@@ -47,6 +76,8 @@ export declare const DEFAULT_API_PATHS: Readonly<{
47
76
  readonly getupdates: "getupdates";
48
77
  readonly consolelog: "log/add";
49
78
  readonly heatmap: "heatmap/add";
79
+ readonly pushnotification: "pushnotification/device";
80
+ readonly pnstats: "channel/add";
50
81
  }>;
51
82
  /**
52
83
  * Which API version each path lives under.
@@ -86,6 +117,11 @@ export declare const SDK_MODULE: Readonly<{
86
117
  readonly SCREEN: "10";
87
118
  readonly SESSION: "11";
88
119
  readonly FEEDBACK: "12";
120
+ /**
121
+ * Push notification over WMS. getsdkconfig answers with the `wms` block only when it is asked
122
+ * for this id in `moduleids` and push is on for the app.
123
+ */
124
+ readonly PUSH_NOTIFICATION: "16";
89
125
  /** Uncaught and reported JavaScript errors: js_error. 13 (crash) and 14 (nonfatal) are the native SDKs'. */
90
126
  readonly JS_ERROR: "15";
91
127
  readonly REMOTE_LOGGER: "17";
@@ -118,6 +154,13 @@ export declare const REMOTE_LOG_LEVEL = 3;
118
154
  export declare const DEBUG_IDLE_MS: number;
119
155
  /** Minutes a tab can be inactive before its session ends. Lives on state, not in _config, but defaults here. */
120
156
  export declare const DEFAULT_INACTIVE_MINUTES = 30;
157
+ /**
158
+ * The range both session timings may be set in: min_session_duration (how long a visit must last
159
+ * before its session is recorded) and max_session_duration (how long a tab may be inactive before its
160
+ * session ends). 5 seconds to 30 minutes; a value outside it is ignored and the default kept.
161
+ */
162
+ export declare const SESSION_TIMING_MIN_MS: number;
163
+ export declare const SESSION_TIMING_MAX_MS: number;
121
164
  /** Global defaults. `state._config` holds a mutable copy per init. */
122
165
  export declare const AP_CONFIG: Readonly<{
123
166
  endpoint: "/sdk/web/";
@@ -187,6 +230,7 @@ export declare const AP_CONFIG: Readonly<{
187
230
  * debug stream is no use to whoever is reading it.
188
231
  */
189
232
  device_name: string;
233
+ /** Path of the site's service worker for push notifications (it imports apptics-pn-sw.js); '' for none. */
190
234
  /**
191
235
  * Most heatmap records one visit may produce. Clicks are cheap, but a page that scrolls a lot
192
236
  * can produce them faster than they are sent, and an unbounded queue is a memory leak on a tab
@@ -1,9 +1,38 @@
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
+ /**
3
+ * The visitor's tracking status: what setTrackingStatus takes and getTrackingStatus returns. Each
4
+ * value is its own name, so an app never deals in the numbers it is stored as (TRACKING_STATUS_CODE).
5
+ */
2
6
  const AP_TRACKING_STATUS = Object.freeze({
7
+ USAGE_TRACKING_WITH_PII: 'USAGE_TRACKING_WITH_PII', // no i18n
8
+ USAGE_TRACKING_WITHOUT_PII: 'USAGE_TRACKING_WITHOUT_PII', // no i18n
9
+ ANONYMOUS: 'ANONYMOUS', // no i18n
10
+ NO_TRACKING: 'NO_TRACKING', // no i18n
11
+ });
12
+ /**
13
+ * The number each tracking status is stored as, in trackinfo's tracking_status, and the number an
14
+ * app passed to setTrackingStatus before the status had names. These are the SDK's own values, not
15
+ * the server's device preference: deviceStatusFor() turns one into the devicestatus device/add
16
+ * sends. ANONYMOUS is 7, past the server's 1–6, because 4 is already stored by browsers that chose
17
+ * without PII and must keep meaning that.
18
+ */
19
+ const TRACKING_STATUS_CODE = Object.freeze({
3
20
  USAGE_TRACKING_WITH_PII: 1,
4
21
  USAGE_TRACKING_WITHOUT_PII: 4,
22
+ ANONYMOUS: 7,
5
23
  NO_TRACKING: -1,
6
24
  });
25
+ /**
26
+ * The server's device preferences, devicestatus on device/add. With and without PII are both
27
+ * "all tracking with PII" (1): without PII only means no user is attached to the data. ANONYMOUS
28
+ * is "all tracking, anonymous" (4). The usage-only and crash-only preferences (2, 3, 5, 6) have no
29
+ * SDK status yet.
30
+ */
31
+ const AP_DEVICE_STATUS = Object.freeze({
32
+ ALL_WITH_PII: 1,
33
+ ALL_ANONYMOUS: 4,
34
+ TRACKING_OFF: -1,
35
+ });
7
36
  const AP_FEEDBACK_TYPE = Object.freeze({
8
37
  BUG: 0,
9
38
  FEEDBACK: 1,
@@ -38,6 +67,10 @@ const DEFAULT_API_PATHS = Object.freeze({
38
67
  // v2 replaced console/addlog: one call now carries a batch of lines, not one line
39
68
  consolelog: 'log/add', // no i18n
40
69
  heatmap: 'heatmap/add', // no i18n
70
+ // registers this browser for push messages over WMS (status=register|unregister)
71
+ pushnotification: 'pushnotification/device', // no i18n
72
+ // push notification stats: received, opened, conversion
73
+ pnstats: 'channel/add', // no i18n
41
74
  });
42
75
  /**
43
76
  * Which API version each path lives under.
@@ -59,6 +92,8 @@ const API_VERSIONS = Object.freeze({
59
92
  getupdates: 'v2', // no i18n
60
93
  consolelog: 'v2', // no i18n
61
94
  heatmap: 'v2', // no i18n
95
+ pushnotification: 'v2', // no i18n
96
+ pnstats: 'v2', // no i18n
62
97
  });
63
98
  /**
64
99
  * The SDK subsystem a remote log line is about, as console/addlog's `module` param.
@@ -88,6 +123,11 @@ const SDK_MODULE = Object.freeze({
88
123
  SCREEN: '10', // no i18n
89
124
  SESSION: '11', // no i18n
90
125
  FEEDBACK: '12', // no i18n
126
+ /**
127
+ * Push notification over WMS. getsdkconfig answers with the `wms` block only when it is asked
128
+ * for this id in `moduleids` and push is on for the app.
129
+ */
130
+ PUSH_NOTIFICATION: '16', // no i18n
91
131
  /** Uncaught and reported JavaScript errors: js_error. 13 (crash) and 14 (nonfatal) are the native SDKs'. */
92
132
  JS_ERROR: '15', // no i18n
93
133
  REMOTE_LOGGER: '17', // no i18n
@@ -120,6 +160,13 @@ const REMOTE_LOG_LEVEL = 3;
120
160
  const DEBUG_IDLE_MS = 60 * 60 * 1000;
121
161
  /** Minutes a tab can be inactive before its session ends. Lives on state, not in _config, but defaults here. */
122
162
  const DEFAULT_INACTIVE_MINUTES = 30;
163
+ /**
164
+ * The range both session timings may be set in: min_session_duration (how long a visit must last
165
+ * before its session is recorded) and max_session_duration (how long a tab may be inactive before its
166
+ * session ends). 5 seconds to 30 minutes; a value outside it is ignored and the default kept.
167
+ */
168
+ const SESSION_TIMING_MIN_MS = 5 * 1000;
169
+ const SESSION_TIMING_MAX_MS = 30 * 60 * 1000;
123
170
  /** Global defaults. `state._config` holds a mutable copy per init. */
124
171
  const AP_CONFIG = Object.freeze({
125
172
  // the version is per path (API_VERSIONS); this is only the part before it
@@ -190,6 +237,7 @@ const AP_CONFIG = Object.freeze({
190
237
  * debug stream is no use to whoever is reading it.
191
238
  */
192
239
  device_name: '',
240
+ /** Path of the site's service worker for push notifications (it imports apptics-pn-sw.js); '' for none. */
193
241
  /**
194
242
  * Most heatmap records one visit may produce. Clicks are cheap, but a page that scrolls a lot
195
243
  * can produce them faster than they are sent, and an unbounded queue is a memory leak on a tab
@@ -245,6 +293,8 @@ const RETRY_CAPABLE_PATHS = Object.freeze({
245
293
  consolelog: true, // no i18n
246
294
  feedback: true, // no i18n
247
295
  getupdates: true, // no i18n
296
+ pushnotification: true, // no i18n
297
+ pnstats: true, // no i18n
248
298
  });
249
299
  /**
250
300
  * Paths that live directly under the version, with no org and project segments. app/addversion is
@@ -292,4 +342,4 @@ const BLOCKED_WS = Object.freeze([
292
342
  'storebot-google', // no i18n
293
343
  ]);
294
344
 
295
- export { API_VERSIONS, AP_CONFIG, AP_CONSTANTS, AP_FEEDBACK_TYPE, AP_LOG_MODULE, AP_TRACKING_STATUS, BLOCKED_WS, CONFIG_KEYS, CONSOLE_LOG_MAX_BODY, DEBUG_CAPABLE_PATHS, DEBUG_IDLE_MS, DEFAULT_API_PATHS, DEFAULT_INACTIVE_MINUTES, DEVICE_NAME_MAX, LOG_FILENAME_MAX, LOG_FUNCTION_MAX, PATHS_WITHOUT_ORG, REMOTE_LOG_LEVEL, REQUIRED_CONFIG, RETIRED_CONFIG_NAMES, RETRY_CAPABLE_PATHS, SDK_MODULE };
345
+ export { API_VERSIONS, AP_CONFIG, AP_CONSTANTS, AP_DEVICE_STATUS, AP_FEEDBACK_TYPE, AP_LOG_MODULE, AP_TRACKING_STATUS, BLOCKED_WS, CONFIG_KEYS, CONSOLE_LOG_MAX_BODY, DEBUG_CAPABLE_PATHS, DEBUG_IDLE_MS, DEFAULT_API_PATHS, DEFAULT_INACTIVE_MINUTES, DEVICE_NAME_MAX, LOG_FILENAME_MAX, LOG_FUNCTION_MAX, PATHS_WITHOUT_ORG, REMOTE_LOG_LEVEL, REQUIRED_CONFIG, RETIRED_CONFIG_NAMES, RETRY_CAPABLE_PATHS, SDK_MODULE, SESSION_TIMING_MAX_MS, SESSION_TIMING_MIN_MS, TRACKING_STATUS_CODE };
@@ -1,6 +1,7 @@
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 { Console } from './logger.js';
3
3
  import { nowMs } from './utils.js';
4
+ import { sdkFailed } from './shield.js';
4
5
 
5
6
  const DB_NAME = 'apptics'; // no i18n
6
7
  // 3 added the heatmaps store. 4 renamed: each record's order key `seq` to `queue`, the logs store
@@ -187,12 +188,33 @@ function recordType(storeName, item) {
187
188
  function putRecord(store, item, keepExisting) {
188
189
  const id = String(item.id);
189
190
  const lookup = store.get(id);
190
- lookup.onsuccess = function () {
191
+ lookup.onsuccess = inTransaction(store.transaction, function () {
191
192
  const existing = lookup.result;
192
193
  if (existing && keepExisting) {
193
194
  return;
194
195
  }
195
196
  store.put({ id: id, queue: existing ? existing.queue : nextQueue(), type: recordType(store.name, item), item: item });
197
+ });
198
+ }
199
+ /**
200
+ * An IndexedDB callback that never throws into the page (core/shield.ts). A throw in one aborts its
201
+ * transaction, which is how its caller hears that the write failed; that is kept, by aborting it here.
202
+ */
203
+ function inTransaction(tx, fn) {
204
+ return function () {
205
+ try {
206
+ fn();
207
+ }
208
+ catch (err) {
209
+ sdkFailed('storage', err); // no i18n
210
+ try {
211
+ if (tx)
212
+ tx.abort();
213
+ }
214
+ catch (e) {
215
+ // already finished: nothing left to undo
216
+ }
217
+ }
196
218
  };
197
219
  }
198
220
  /** Our stores, as created by onupgradeneeded. */
@@ -253,7 +275,9 @@ function openOnce(factory, timeoutMs) {
253
275
  return;
254
276
  }
255
277
  req.onupgradeneeded = function () {
256
- upgrade(req.result, req.transaction);
278
+ inTransaction(req.transaction, function () {
279
+ upgrade(req.result, req.transaction);
280
+ })();
257
281
  };
258
282
  req.onsuccess = function () {
259
283
  if (settled) {
@@ -331,7 +355,7 @@ function upgrade(db, tx) {
331
355
  /** Calls `each` for every record of `store`, then `done`, inside the transaction `store` is in. */
332
356
  function eachRecord(store, each, done) {
333
357
  const req = store.openCursor();
334
- req.onsuccess = function () {
358
+ req.onsuccess = inTransaction(store.transaction, function () {
335
359
  const cursor = req.result;
336
360
  if (!cursor) {
337
361
  if (done)
@@ -340,7 +364,7 @@ function eachRecord(store, each, done) {
340
364
  }
341
365
  each(cursor.value, cursor);
342
366
  cursor.continue();
343
- };
367
+ });
344
368
  }
345
369
  /** A version 3 record under version 4's names: `queue` for `seq`, and the feedback types renamed. */
346
370
  function renamedRecord(record, feedback, storeName) {
@@ -406,11 +430,11 @@ function createIndexedDBBackend(db) {
406
430
  const settingsStore = tx.objectStore('settings'); // no i18n
407
431
  Object.keys(settings).forEach(function (key) {
408
432
  const lookup = settingsStore.get(key);
409
- lookup.onsuccess = function () {
433
+ lookup.onsuccess = inTransaction(tx, function () {
410
434
  if (lookup.result === undefined) {
411
435
  settingsStore.put(settings[key], key);
412
436
  }
413
- };
437
+ });
414
438
  });
415
439
  QUEUES.forEach(function (name) {
416
440
  const objectStore = tx.objectStore(name);
@@ -13,10 +13,12 @@ export declare function noteDebugActivity(): void;
13
13
  export declare function expireDebugIfIdle(): void;
14
14
  /**
15
15
  * Turns debug mode on, at any time: before init(), during start-up or while the SDK runs. The
16
- * choice holds over `debug` in init() for the rest of the page's life.
16
+ * choice holds through init() and reset() for the rest of the page's life. Only from the console.
17
17
  */
18
18
  export declare function enableDebug(): void;
19
- /** Turns debug mode off, at any time, with the same hold over `debug` as enableDebug(). */
19
+ /**
20
+ * Turns debug mode off, at any time, holding as enableDebug() does. Only from the console.
21
+ */
20
22
  export declare function disableDebug(): void;
21
- /** What init() applies for `debug`: the config's value, unless the app has already chosen. */
22
- export declare function applyDebugConfig(configured: boolean): void;
23
+ /** What init() applies: off, unless enableDebug() or disableDebug() already chose. */
24
+ export declare function applyDebugConfig(): void;
@@ -1,7 +1,8 @@
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 { DEBUG_IDLE_MS } from './constants.js';
3
3
  import { _ZAP } from './state.js';
4
- import { Console } from './logger.js';
4
+ import { Console, warnAlways } from './logger.js';
5
+ import { calledFromConsole } from './console-call.js';
5
6
  import { nowMs } from './utils.js';
6
7
 
7
8
  /**
@@ -14,8 +15,8 @@ import { nowMs } from './utils.js';
14
15
  * not a deliberate switch-off. So the SDK closes it: an hour with nothing tracked turns debug
15
16
  * back off by itself, and anything tracked pushes that hour out again.
16
17
  *
17
- * It lives in core because every send asks it: `debug: true` in init(), or enableDebug(), is
18
- * enough to turn the twins on, and that alone must expire.
18
+ * It lives in core because every send asks it: enableDebug(), typed in the browser console, is
19
+ * the only way to turn the twins on, and that alone must expire.
19
20
  */
20
21
  /** Whether debug mode is on right now, idle hour included. */
21
22
  function debugEnabled() {
@@ -48,10 +49,9 @@ function expireDebugIfIdle() {
48
49
  setDebug(false);
49
50
  }
50
51
  /**
51
- * The app's own choice, from enableDebug() or disableDebug(). It wins over `debug` in init(),
52
- * so debug mode can be switched on or off with one call, before init() runs or while the SDK is
53
- * running, and an init() or reset() that comes after doesn't switch it back. null until the app
54
- * has chosen.
52
+ * The choice made in the console, by enableDebug() or disableDebug(): before init() runs or while
53
+ * the SDK is running, and an init() or reset() that comes after doesn't switch it back. null until
54
+ * one is called.
55
55
  */
56
56
  var chosen = null;
57
57
  /** Turning it on starts the idle hour; turning it off clears it, so the next on gets a whole hour. */
@@ -60,22 +60,46 @@ function setDebug(on) {
60
60
  _ZAP._debugUntil = on ? nowMs() + DEBUG_IDLE_MS : 0;
61
61
  Console.log('apptics: debug mode ' + (on ? 'on' : 'off')); // no i18n
62
62
  }
63
+ /** The calls already refused for coming from code: said once per page each, not once per call. */
64
+ var refusedSaid = {};
65
+ /**
66
+ * Whether `call` was typed into the browser console. A call from the page's code is ignored and
67
+ * said once, debug or not, so a debug switch left in an app's code does nothing in production.
68
+ */
69
+ function fromConsole(call) {
70
+ if (calledFromConsole()) {
71
+ return true;
72
+ }
73
+ if (!refusedSaid[call]) {
74
+ refusedSaid[call] = true;
75
+ warnAlways('apptics: ' + call + '() works only when typed in the browser console; this call from code is ignored'); // no i18n
76
+ }
77
+ return false;
78
+ }
63
79
  /**
64
80
  * Turns debug mode on, at any time: before init(), during start-up or while the SDK runs. The
65
- * choice holds over `debug` in init() for the rest of the page's life.
81
+ * choice holds through init() and reset() for the rest of the page's life. Only from the console.
66
82
  */
67
83
  function enableDebug() {
84
+ if (!fromConsole('Apptics.enableDebug')) { // no i18n
85
+ return;
86
+ }
68
87
  chosen = true;
69
88
  setDebug(true);
70
89
  }
71
- /** Turns debug mode off, at any time, with the same hold over `debug` as enableDebug(). */
90
+ /**
91
+ * Turns debug mode off, at any time, holding as enableDebug() does. Only from the console.
92
+ */
72
93
  function disableDebug() {
94
+ if (!fromConsole('Apptics.disableDebug')) { // no i18n
95
+ return;
96
+ }
73
97
  chosen = false;
74
98
  setDebug(false);
75
99
  }
76
- /** What init() applies for `debug`: the config's value, unless the app has already chosen. */
77
- function applyDebugConfig(configured) {
78
- setDebug(chosen !== null ? chosen : configured);
100
+ /** What init() applies: off, unless enableDebug() or disableDebug() already chose. */
101
+ function applyDebugConfig() {
102
+ setDebug(chosen === true);
79
103
  }
80
104
 
81
105
  export { applyDebugConfig, debugEnabled, disableDebug, enableDebug, expireDebugIfIdle, noteDebugActivity };
@@ -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 { BLOCKED_WS } from './constants.js';
3
3
  import { includes } from './utils.js';
4
4
 
@@ -1 +1 @@
1
- export declare const FRAMEWORK_ID = 6003;
1
+ export declare const FRAMEWORK_ID = 6012;