@zoho_apptics/apptics-js-sdk 1.0.1 → 2.0.0-beta

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 (226) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/LICENSE +13 -0
  3. package/README.md +747 -11
  4. package/dist/apptics.esm.min.js +3 -0
  5. package/dist/apptics.esm.min.js.map +1 -0
  6. package/dist/apptics.min.js +3 -0
  7. package/dist/apptics.min.js.map +1 -0
  8. package/dist/chunks/batch-BU_mTpm1.min.js +3 -0
  9. package/dist/chunks/batch-BU_mTpm1.min.js.map +1 -0
  10. package/dist/chunks/logs-Bea5zUW_.min.js +3 -0
  11. package/dist/chunks/logs-Bea5zUW_.min.js.map +1 -0
  12. package/dist/cjs/auto-init.d.ts +8 -0
  13. package/dist/cjs/auto-init.js +32 -0
  14. package/dist/cjs/core/attempts.d.ts +28 -0
  15. package/dist/cjs/core/attempts.js +113 -0
  16. package/dist/cjs/core/batch.d.ts +32 -0
  17. package/dist/cjs/core/batch.js +115 -0
  18. package/dist/cjs/core/callsite.d.ts +28 -0
  19. package/dist/cjs/core/callsite.js +93 -0
  20. package/dist/cjs/core/consent.d.ts +23 -0
  21. package/dist/cjs/core/consent.js +130 -0
  22. package/dist/cjs/core/constants.d.ts +212 -0
  23. package/dist/cjs/core/constants.js +299 -0
  24. package/dist/cjs/core/db.d.ts +40 -0
  25. package/dist/cjs/core/db.js +334 -0
  26. package/dist/cjs/core/debug.d.ts +22 -0
  27. package/dist/cjs/core/debug.js +88 -0
  28. package/dist/cjs/core/env.d.ts +28 -0
  29. package/dist/cjs/core/env.js +267 -0
  30. package/dist/cjs/core/framework-id.d.ts +1 -0
  31. package/dist/cjs/core/framework-id.js +9 -0
  32. package/dist/cjs/core/guard.d.ts +2 -0
  33. package/dist/cjs/core/guard.js +72 -0
  34. package/dist/cjs/core/hooks.d.ts +41 -0
  35. package/dist/cjs/core/hooks.js +23 -0
  36. package/dist/cjs/core/logger.d.ts +16 -0
  37. package/dist/cjs/core/logger.js +86 -0
  38. package/dist/cjs/core/state.d.ts +69 -0
  39. package/dist/cjs/core/state.js +78 -0
  40. package/dist/cjs/core/storage.d.ts +46 -0
  41. package/dist/cjs/core/storage.js +229 -0
  42. package/dist/cjs/core/transport.d.ts +83 -0
  43. package/dist/cjs/core/transport.js +441 -0
  44. package/dist/cjs/core/utils.d.ts +26 -0
  45. package/dist/cjs/core/utils.js +175 -0
  46. package/dist/cjs/core/validate.d.ts +18 -0
  47. package/dist/cjs/core/validate.js +233 -0
  48. package/dist/cjs/device/appversion.d.ts +20 -0
  49. package/dist/cjs/device/appversion.js +158 -0
  50. package/dist/cjs/device/index.d.ts +23 -0
  51. package/dist/cjs/device/index.js +372 -0
  52. package/dist/cjs/engagement/api-rules.d.ts +84 -0
  53. package/dist/cjs/engagement/api-rules.js +219 -0
  54. package/dist/cjs/engagement/auto-api.d.ts +7 -0
  55. package/dist/cjs/engagement/auto-api.js +200 -0
  56. package/dist/cjs/engagement/auto-screen.d.ts +16 -0
  57. package/dist/cjs/engagement/auto-screen.js +241 -0
  58. package/dist/cjs/engagement/defined-events.d.ts +23 -0
  59. package/dist/cjs/engagement/defined-events.js +58 -0
  60. package/dist/cjs/engagement/send.d.ts +6 -0
  61. package/dist/cjs/engagement/send.js +99 -0
  62. package/dist/cjs/engagement/session.d.ts +42 -0
  63. package/dist/cjs/engagement/session.js +327 -0
  64. package/dist/cjs/engagement/track.d.ts +56 -0
  65. package/dist/cjs/engagement/track.js +350 -0
  66. package/dist/cjs/errors/send.d.ts +6 -0
  67. package/dist/cjs/errors/send.js +73 -0
  68. package/dist/cjs/errors/track.d.ts +4 -0
  69. package/dist/cjs/errors/track.js +127 -0
  70. package/dist/cjs/feedback/controls.d.ts +31 -0
  71. package/dist/cjs/feedback/controls.js +286 -0
  72. package/dist/cjs/feedback/index.d.ts +8 -0
  73. package/dist/cjs/feedback/index.js +37 -0
  74. package/dist/cjs/feedback/logs.d.ts +40 -0
  75. package/dist/cjs/feedback/logs.js +202 -0
  76. package/dist/cjs/feedback/send.d.ts +25 -0
  77. package/dist/cjs/feedback/send.js +178 -0
  78. package/dist/cjs/feedback/template.d.ts +2 -0
  79. package/dist/cjs/feedback/template.js +162 -0
  80. package/dist/cjs/feedback/ui.d.ts +55 -0
  81. package/dist/cjs/feedback/ui.js +631 -0
  82. package/dist/cjs/heatmap/index.d.ts +16 -0
  83. package/dist/cjs/heatmap/index.js +22 -0
  84. package/dist/cjs/heatmap/send.d.ts +13 -0
  85. package/dist/cjs/heatmap/send.js +82 -0
  86. package/dist/cjs/heatmap/track.d.ts +4 -0
  87. package/dist/cjs/heatmap/track.js +377 -0
  88. package/dist/cjs/index.d.ts +68 -0
  89. package/dist/cjs/index.js +150 -0
  90. package/dist/cjs/lifecycle.d.ts +14 -0
  91. package/dist/cjs/lifecycle.js +538 -0
  92. package/dist/cjs/package.json +3 -0
  93. package/dist/cjs/remoteconfig/custom.d.ts +10 -0
  94. package/dist/cjs/remoteconfig/custom.js +78 -0
  95. package/dist/cjs/remoteconfig/evaluate.d.ts +24 -0
  96. package/dist/cjs/remoteconfig/evaluate.js +171 -0
  97. package/dist/cjs/remoteconfig/fetch.d.ts +24 -0
  98. package/dist/cjs/remoteconfig/fetch.js +214 -0
  99. package/dist/cjs/remoteconfig/index.d.ts +13 -0
  100. package/dist/cjs/remoteconfig/index.js +90 -0
  101. package/dist/cjs/remoteconfig/store.d.ts +18 -0
  102. package/dist/cjs/remoteconfig/store.js +98 -0
  103. package/dist/cjs/remotelog/gate.d.ts +11 -0
  104. package/dist/cjs/remotelog/gate.js +54 -0
  105. package/dist/cjs/remotelog/index.d.ts +25 -0
  106. package/dist/cjs/remotelog/index.js +55 -0
  107. package/dist/cjs/remotelog/logger.d.ts +28 -0
  108. package/dist/cjs/remotelog/logger.js +139 -0
  109. package/dist/cjs/remotelog/send.d.ts +13 -0
  110. package/dist/cjs/remotelog/send.js +153 -0
  111. package/dist/cjs/scheduler.d.ts +8 -0
  112. package/dist/cjs/scheduler.js +78 -0
  113. package/dist/cjs/types.d.ts +312 -0
  114. package/dist/cjs/user/index.d.ts +33 -0
  115. package/dist/cjs/user/index.js +178 -0
  116. package/dist/esm/auto-init.d.ts +8 -0
  117. package/dist/esm/auto-init.js +29 -0
  118. package/dist/esm/core/attempts.d.ts +28 -0
  119. package/dist/esm/core/attempts.js +106 -0
  120. package/dist/esm/core/batch.d.ts +32 -0
  121. package/dist/esm/core/batch.js +108 -0
  122. package/dist/esm/core/callsite.d.ts +28 -0
  123. package/dist/esm/core/callsite.js +89 -0
  124. package/dist/esm/core/consent.d.ts +23 -0
  125. package/dist/esm/core/consent.js +120 -0
  126. package/dist/esm/core/constants.d.ts +212 -0
  127. package/dist/esm/core/constants.js +277 -0
  128. package/dist/esm/core/db.d.ts +40 -0
  129. package/dist/esm/core/db.js +324 -0
  130. package/dist/esm/core/debug.d.ts +22 -0
  131. package/dist/esm/core/debug.js +81 -0
  132. package/dist/esm/core/env.d.ts +28 -0
  133. package/dist/esm/core/env.js +251 -0
  134. package/dist/esm/core/framework-id.d.ts +1 -0
  135. package/dist/esm/core/framework-id.js +7 -0
  136. package/dist/esm/core/guard.d.ts +2 -0
  137. package/dist/esm/core/guard.js +70 -0
  138. package/dist/esm/core/hooks.d.ts +41 -0
  139. package/dist/esm/core/hooks.js +21 -0
  140. package/dist/esm/core/logger.d.ts +16 -0
  141. package/dist/esm/core/logger.js +82 -0
  142. package/dist/esm/core/state.d.ts +69 -0
  143. package/dist/esm/core/state.js +73 -0
  144. package/dist/esm/core/storage.d.ts +46 -0
  145. package/dist/esm/core/storage.js +219 -0
  146. package/dist/esm/core/transport.d.ts +83 -0
  147. package/dist/esm/core/transport.js +425 -0
  148. package/dist/esm/core/utils.d.ts +26 -0
  149. package/dist/esm/core/utils.js +161 -0
  150. package/dist/esm/core/validate.d.ts +18 -0
  151. package/dist/esm/core/validate.js +226 -0
  152. package/dist/esm/device/appversion.d.ts +20 -0
  153. package/dist/esm/device/appversion.js +153 -0
  154. package/dist/esm/device/index.d.ts +23 -0
  155. package/dist/esm/device/index.js +362 -0
  156. package/dist/esm/engagement/api-rules.d.ts +84 -0
  157. package/dist/esm/engagement/api-rules.js +211 -0
  158. package/dist/esm/engagement/auto-api.d.ts +7 -0
  159. package/dist/esm/engagement/auto-api.js +198 -0
  160. package/dist/esm/engagement/auto-screen.d.ts +16 -0
  161. package/dist/esm/engagement/auto-screen.js +238 -0
  162. package/dist/esm/engagement/defined-events.d.ts +23 -0
  163. package/dist/esm/engagement/defined-events.js +55 -0
  164. package/dist/esm/engagement/send.d.ts +6 -0
  165. package/dist/esm/engagement/send.js +96 -0
  166. package/dist/esm/engagement/session.d.ts +42 -0
  167. package/dist/esm/engagement/session.js +315 -0
  168. package/dist/esm/engagement/track.d.ts +56 -0
  169. package/dist/esm/engagement/track.js +340 -0
  170. package/dist/esm/errors/send.d.ts +6 -0
  171. package/dist/esm/errors/send.js +70 -0
  172. package/dist/esm/errors/track.d.ts +4 -0
  173. package/dist/esm/errors/track.js +123 -0
  174. package/dist/esm/feedback/controls.d.ts +31 -0
  175. package/dist/esm/feedback/controls.js +280 -0
  176. package/dist/esm/feedback/index.d.ts +8 -0
  177. package/dist/esm/feedback/index.js +30 -0
  178. package/dist/esm/feedback/logs.d.ts +40 -0
  179. package/dist/esm/feedback/logs.js +188 -0
  180. package/dist/esm/feedback/send.d.ts +25 -0
  181. package/dist/esm/feedback/send.js +175 -0
  182. package/dist/esm/feedback/template.d.ts +2 -0
  183. package/dist/esm/feedback/template.js +159 -0
  184. package/dist/esm/feedback/ui.d.ts +55 -0
  185. package/dist/esm/feedback/ui.js +626 -0
  186. package/dist/esm/heatmap/index.d.ts +16 -0
  187. package/dist/esm/heatmap/index.js +17 -0
  188. package/dist/esm/heatmap/send.d.ts +13 -0
  189. package/dist/esm/heatmap/send.js +79 -0
  190. package/dist/esm/heatmap/track.d.ts +4 -0
  191. package/dist/esm/heatmap/track.js +374 -0
  192. package/dist/esm/index.d.ts +68 -0
  193. package/dist/esm/index.js +122 -0
  194. package/dist/esm/lifecycle.d.ts +14 -0
  195. package/dist/esm/lifecycle.js +534 -0
  196. package/dist/esm/package.json +3 -0
  197. package/dist/esm/remoteconfig/custom.d.ts +10 -0
  198. package/dist/esm/remoteconfig/custom.js +74 -0
  199. package/dist/esm/remoteconfig/evaluate.d.ts +24 -0
  200. package/dist/esm/remoteconfig/evaluate.js +166 -0
  201. package/dist/esm/remoteconfig/fetch.d.ts +24 -0
  202. package/dist/esm/remoteconfig/fetch.js +210 -0
  203. package/dist/esm/remoteconfig/index.d.ts +13 -0
  204. package/dist/esm/remoteconfig/index.js +85 -0
  205. package/dist/esm/remoteconfig/store.d.ts +18 -0
  206. package/dist/esm/remoteconfig/store.js +91 -0
  207. package/dist/esm/remotelog/gate.d.ts +11 -0
  208. package/dist/esm/remotelog/gate.js +48 -0
  209. package/dist/esm/remotelog/index.d.ts +25 -0
  210. package/dist/esm/remotelog/index.js +51 -0
  211. package/dist/esm/remotelog/logger.d.ts +28 -0
  212. package/dist/esm/remotelog/logger.js +136 -0
  213. package/dist/esm/remotelog/send.d.ts +13 -0
  214. package/dist/esm/remotelog/send.js +149 -0
  215. package/dist/esm/scheduler.d.ts +8 -0
  216. package/dist/esm/scheduler.js +74 -0
  217. package/dist/esm/types.d.ts +312 -0
  218. package/dist/esm/user/index.d.ts +33 -0
  219. package/dist/esm/user/index.js +170 -0
  220. package/dist/feedback.esm.min.js +3 -0
  221. package/dist/feedback.esm.min.js.map +1 -0
  222. package/dist/heatmap.esm.min.js +3 -0
  223. package/dist/heatmap.esm.min.js.map +1 -0
  224. package/dist/style.css +1 -0
  225. package/package.json +124 -7
  226. package/src/appticssdk.js +0 -3817
@@ -0,0 +1,251 @@
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta | (c) Zoho Corporation Private Limited | see LICENSE */
2
+ import { BLOCKED_WS } from './constants.js';
3
+ import { includes } from './utils.js';
4
+
5
+ function isBlockedWS(ua) {
6
+ var i;
7
+ ua = ua.toLowerCase();
8
+ for (i = 0; i < BLOCKED_WS.length; i++) {
9
+ if (ua.indexOf(BLOCKED_WS[i]) !== -1) {
10
+ return true;
11
+ }
12
+ }
13
+ return false;
14
+ }
15
+ /** Device RAM as the API wants it ("4 GB"). Chromium only; empty elsewhere. */
16
+ function getRam() {
17
+ var gb = navigator.deviceMemory;
18
+ return typeof gb === 'number' && gb > 0 ? gb + ' GB' : ''; // no i18n
19
+ }
20
+ function getConnectionType() {
21
+ var connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection || {};
22
+ return connection.effectiveType || connection.type || ''; // no i18n
23
+ }
24
+ function getNetworkStatus() {
25
+ return window.navigator.onLine ? 0 : -1;
26
+ }
27
+ /**
28
+ * The battery as a whole percentage, or null where the browser will not say.
29
+ *
30
+ * feedbackWebSDK types `battery` as an int and the console shows it next to a report, which is
31
+ * what makes "it died while I was filling this in" legible. The Battery Status API is behind a
32
+ * promise and is absent in Firefox and Safari entirely, so this answers null rather than 0 -
33
+ * a real 0% and "no answer" are different things, and only one of them belongs in a report.
34
+ */
35
+ function getBatteryPercent() {
36
+ try {
37
+ var getBattery = navigator.getBattery;
38
+ if (typeof getBattery !== 'function') { // no i18n
39
+ return Promise.resolve(null);
40
+ }
41
+ return getBattery.call(navigator).then(function (battery) {
42
+ var level = battery && typeof battery.level === 'number' ? battery.level : -1; // no i18n
43
+ return level >= 0 && level <= 1 ? Math.round(level * 100) : null;
44
+ }, function () {
45
+ return null;
46
+ });
47
+ }
48
+ catch (err) {
49
+ return Promise.resolve(null);
50
+ }
51
+ }
52
+ function getOrientation() {
53
+ var orientation = (window.screen && window.screen.orientation && window.screen.orientation.type) || ''; // no i18n
54
+ if (includes(orientation, 'portrait-primary')) { // no i18n
55
+ return 0;
56
+ }
57
+ if (includes(orientation, 'landscape-primary')) { // no i18n
58
+ return 1;
59
+ }
60
+ if (includes(orientation, 'landscape-secondary')) { // no i18n
61
+ return 2;
62
+ }
63
+ if (includes(orientation, 'portrait-secondary')) { // no i18n
64
+ return 3;
65
+ }
66
+ return -1;
67
+ }
68
+ function getDevice() {
69
+ var ua = navigator.userAgent;
70
+ if (/Windows/i.test(ua)) {
71
+ return (/Phone/.test(ua) || /WPDesktop/.test(ua)) ? 'Windows Phone' : 'Windows'; // no i18n
72
+ }
73
+ if (/iPad/.test(ua)) {
74
+ return 'iPad'; // no i18n
75
+ }
76
+ if (/iPod/.test(ua)) {
77
+ return 'iPod Touch'; // no i18n
78
+ }
79
+ if (/iPhone/.test(ua)) {
80
+ return 'iPhone'; // no i18n
81
+ }
82
+ if (/(BlackBerry|PlayBook|BB10)/i.test(ua)) {
83
+ return 'BlackBerry'; // no i18n
84
+ }
85
+ if (/Android/.test(ua)) {
86
+ return 'Android'; // no i18n
87
+ }
88
+ if (/Mac/i.test(ua)) {
89
+ return 'Mac'; // no i18n
90
+ }
91
+ if (/Linux/.test(ua)) {
92
+ return 'Linux'; // no i18n
93
+ }
94
+ if (/CrOS/.test(ua)) {
95
+ return 'Chrome'; // no i18n
96
+ }
97
+ return ''; // no i18n
98
+ }
99
+ function getOS() {
100
+ var ua = navigator.userAgent;
101
+ if (/Windows/i.test(ua)) {
102
+ return (/Phone/.test(ua) || /WPDesktop/.test(ua)) ? 'Windows Phone' : 'Windows'; // no i18n
103
+ }
104
+ if (/(iPhone|iPad|iPod)/.test(ua)) {
105
+ return 'iOS'; // no i18n
106
+ }
107
+ if (/Android/.test(ua)) {
108
+ return 'Android'; // no i18n
109
+ }
110
+ if (/(BlackBerry|PlayBook|BB10)/i.test(ua)) {
111
+ return 'BlackBerry'; // no i18n
112
+ }
113
+ if (/Mac/i.test(ua)) {
114
+ return 'Mac OS X'; // no i18n
115
+ }
116
+ if (/Linux/.test(ua)) {
117
+ return 'Linux'; // no i18n
118
+ }
119
+ if (/CrOS/.test(ua)) {
120
+ return 'Chrome OS'; // no i18n
121
+ }
122
+ return ''; // no i18n
123
+ }
124
+ function getBrowser() {
125
+ var ua = navigator.userAgent;
126
+ var vendor = navigator.vendor || ''; // no i18n // vendor is undefined for at least IE9
127
+ var opera = window.opera;
128
+ if (opera || includes(ua, ' OPR/')) { // no i18n
129
+ return (includes(ua, 'Mini')) ? 'Opera Mini' : 'Opera'; // no i18n
130
+ }
131
+ if (/(BlackBerry|PlayBook|BB10)/i.test(ua)) {
132
+ return 'BlackBerry'; // no i18n
133
+ }
134
+ if (includes(ua, 'IEMobile') || includes(ua, 'WPDesktop')) { // no i18n
135
+ return 'Internet Explorer Mobile'; // no i18n
136
+ }
137
+ if (includes(ua, 'SamsungBrowser/')) { // no i18n
138
+ return 'Samsung Internet'; // no i18n
139
+ }
140
+ if (includes(ua, 'Edge') || includes(ua, 'Edg/')) { // no i18n
141
+ return 'Microsoft Edge'; // no i18n
142
+ }
143
+ if (includes(ua, 'FBIOS')) { // no i18n
144
+ return 'Facebook Mobile'; // no i18n
145
+ }
146
+ if (includes(ua, 'Chrome')) { // no i18n
147
+ if (typeof ulaa == 'object') {
148
+ return 'Ulaa'; // no i18n
149
+ }
150
+ else if (window.navigator.brave != undefined && window.navigator.brave.isBrave.name == "isBrave") { // no i18n
151
+ return 'Brave'; // no i18n
152
+ }
153
+ else {
154
+ return 'Chrome'; // no i18n
155
+ }
156
+ }
157
+ if (includes(ua, 'CriOS')) { // no i18n
158
+ return 'Chrome iOS'; // no i18n
159
+ }
160
+ if (includes(ua, 'UCWEB') || includes(ua, 'UCBrowser')) { // no i18n
161
+ return 'UC Browser'; // no i18n
162
+ }
163
+ if (includes(ua, 'FxiOS')) { // no i18n
164
+ return 'Firefox iOS'; // no i18n
165
+ }
166
+ if (includes(vendor, 'Apple')) { // no i18n
167
+ return (includes(ua, 'Mobile')) ? 'Mobile Safari' : 'Safari'; // no i18n
168
+ }
169
+ if (includes(ua, 'Android')) { // no i18n
170
+ return 'Android Mobile'; // no i18n
171
+ }
172
+ if (includes(ua, 'Konqueror')) { // no i18n
173
+ return 'Konqueror'; // no i18n
174
+ }
175
+ if (includes(ua, 'Firefox')) { // no i18n
176
+ return 'Firefox'; // no i18n
177
+ }
178
+ if (includes(ua, 'MSIE') || includes(ua, 'Trident/')) { // no i18n
179
+ return 'Internet Explorer'; // no i18n
180
+ }
181
+ if (includes(ua, 'Gecko')) { // no i18n
182
+ return 'Mozilla'; // no i18n
183
+ }
184
+ return ''; // no i18n
185
+ }
186
+ function getBrowserVersion() {
187
+ var browser = getBrowser();
188
+ var ua = navigator.userAgent;
189
+ var versionRegexs = {
190
+ 'Internet Explorer Mobile': /rv:(\d+(\.\d+)?)/, // no i18n
191
+ 'Microsoft Edge': /Edg\/(\d+(\.\d+)?)/, // no i18n
192
+ 'Chrome': /Chrome\/(\d+(\.\d+)?)/, // no i18n
193
+ 'Brave': /Chrome\/(\d+(\.\d+)?)/, // no i18n
194
+ 'Chrome iOS': /CriOS\/(\d+(\.\d+)?)/, // no i18n
195
+ 'UC Browser': /(UCBrowser|UCWEB)\/(\d+(\.\d+)?)/, // no i18n
196
+ 'Safari': /Version\/(\d+(\.\d+)?)/, // no i18n
197
+ 'Mobile Safari': /Version\/(\d+(\.\d+)?)/, // no i18n
198
+ 'Opera': /(Opera|OPR)\/(\d+(\.\d+)?)/, // no i18n
199
+ 'Firefox': /Firefox\/(\d+(\.\d+)?)/, // no i18n
200
+ 'Firefox iOS': /FxiOS\/(\d+(\.\d+)?)/, // no i18n
201
+ 'Konqueror': /Konqueror:(\d+(\.\d+)?)/, // no i18n
202
+ 'BlackBerry': /BlackBerry (\d+(\.\d+)?)/, // no i18n
203
+ 'Android Mobile': /android\s(\d+(\.\d+)?)/, // no i18n
204
+ 'Internet Explorer': /(rv:|MSIE )(\d+(\.\d+)?)/, // no i18n
205
+ 'Mozilla': /rv:(\d+(\.\d+)?)/ // no i18n
206
+ };
207
+ // Check for Ulaa browser version
208
+ if (browser === 'Ulaa' && typeof ulaa === 'object') { // no i18n
209
+ return ulaa.getVersion();
210
+ }
211
+ var regex = versionRegexs[browser];
212
+ if (regex === undefined) {
213
+ return ''; // no i18n
214
+ }
215
+ var matches = ua.match(regex);
216
+ if (!matches) {
217
+ return ''; // no i18n
218
+ }
219
+ return parseFloat(matches[matches.length - 2]);
220
+ }
221
+ function getReferringURL() {
222
+ var split = String(window.location.href || '').split(window.location.pathname); // no i18n
223
+ if (split.length >= 2) {
224
+ return split[1].length > 500 ? split[1].substring(0, 500) : split[1];
225
+ }
226
+ return ''; // no i18n
227
+ }
228
+ function getTimeZone() {
229
+ return Intl.DateTimeFormat().resolvedOptions().timeZone;
230
+ }
231
+ /** True for crawlers and non-browser environments; the SDK does nothing for them. */
232
+ function is_apptics_disabled() {
233
+ return typeof navigator === 'undefined' || isBlockedWS(navigator.userAgent || ''); // no i18n
234
+ }
235
+ /** Pure DNT check (no side effects). consent.hasDoNotTrackEnabled() applies NO_TRACKING. */
236
+ function isDntOn() {
237
+ var nav = window.navigator || {};
238
+ var dntValues = [true, 1, '1', 'yes']; // no i18n
239
+ return [nav.doNotTrack, nav.msDoNotTrack, window.doNotTrack].some(function (dntValue) {
240
+ return includes(dntValues, dntValue);
241
+ });
242
+ }
243
+ /** The console snippet's config (window.appticssettings._defaultoptions), if the page defines one. */
244
+ function getSnippetOptions() {
245
+ if (typeof window === 'undefined' || !window.appticssettings) { // no i18n
246
+ return undefined;
247
+ }
248
+ return window.appticssettings._defaultoptions;
249
+ }
250
+
251
+ export { getBatteryPercent, getBrowser, getBrowserVersion, getConnectionType, getDevice, getNetworkStatus, getOS, getOrientation, getRam, getReferringURL, getSnippetOptions, getTimeZone, isBlockedWS, isDntOn, is_apptics_disabled };
@@ -0,0 +1 @@
1
+ export declare const FRAMEWORK_ID = 5996;
@@ -0,0 +1,7 @@
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta | (c) Zoho Corporation Private Limited | see LICENSE */
2
+ // Generated by scripts/register-version.mjs — do not edit by hand.
3
+ // The framework id Apptics issued for this SDK, from POST /sdk/web/v1/framework/addversion
4
+ // (version 2.0.0-beta, platform Browser). Regenerated on every npm pack.
5
+ const FRAMEWORK_ID = 5996;
6
+
7
+ export { FRAMEWORK_ID };
@@ -0,0 +1,2 @@
1
+ /** Public calls never throw into the host app, and are buffered until start-up finishes. */
2
+ export declare function guard<F extends (...args: any[]) => any>(name: string, fn: F): F;
@@ -0,0 +1,70 @@
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta | (c) Zoho Corporation Private Limited | see LICENSE */
2
+ import { _ZAP } from './state.js';
3
+ import { warnAlways, logFailure } from './logger.js';
4
+
5
+ /**
6
+ * Calls that run immediately while storage is loading. Everything else is buffered and replayed in order.
7
+ * getUser / getTrackingStatus answer from defaults until then; sendFeedback waits for ready() itself.
8
+ * The two log collectors run now so an entry keeps the time it actually happened.
9
+ */
10
+ const RUN_BEFORE_READY = {
11
+ 'Apptics.init': true, ready: true, reset: true, getUser: true, getTrackingStatus: true, sendFeedback: true,
12
+ addFeedbackLog: true, addDiagnosticsInfo: true,
13
+ // a switch, so it takes effect in order with the lines logged after it
14
+ 'AppticsLogger.enable': true, 'AppticsLogger.disable': true, 'AppticsLogger.isEnabled': true,
15
+ // a switch, and a call that hands back the id endTrackApi needs: neither can wait in a queue
16
+ 'AppticsApiTracker.configure': true, 'AppticsApiTracker.startTrackApi': true,
17
+ // these wait for ready() themselves, and a queued call would hand back undefined, not a Promise
18
+ 'AppticsRemoteConfig.fetchValue': true, 'AppticsRemoteConfig.fetchValues': true,
19
+ 'AppticsRemoteConfig.setFallbackWithOfflineValue': true, 'AppticsRemoteConfig.setCustomConditionValue': true,
20
+ enableDebug: true, disableDebug: true,
21
+ };
22
+ /**
23
+ * Calls that record or send something, and so are lost when the SDK hasn't started. Calls that only
24
+ * set a switch or read a value (enableDebug, AppticsLogger.enable, addFeedbackLog, getUser, …)
25
+ * work without Apptics.init() and are not listed.
26
+ */
27
+ const NEEDS_INIT = {
28
+ 'AppticsEvents.addEvent': true, 'AppticsScreenTracker.inScreen': true, 'AppticsScreenTracker.outScreen': true,
29
+ 'AppticsApiTracker.endTrackApi': true, AppticsTrackError: true, AppticsSetUser: true, flush: true,
30
+ AppticsLogger: true, sendFeedback: true, 'AppticsRemoteConfig.fetchValue': true,
31
+ 'AppticsRemoteConfig.fetchValues': true,
32
+ };
33
+ /** How a call is named in a message: `AppticsEvents.addEvent` as it is, `flush` as `apptics.flush`. */
34
+ function publicName(name) {
35
+ return name.indexOf('Apptics') === 0 ? name : 'apptics.' + name; // no i18n
36
+ }
37
+ /** Warned once per page: one line is a clue, a line per call would bury the console. */
38
+ var warnedNotStarted = false;
39
+ /** Public calls never throw into the host app, and are buffered until start-up finishes. */
40
+ function guard(name, fn) {
41
+ const guarded = function (...args) {
42
+ // not started: init() wasn't called, or it refused the config. Say so whether or not
43
+ // console_log is on, since console_log itself is only switched on by init()
44
+ if (!_ZAP._initialised && NEEDS_INIT[name] && !warnedNotStarted) {
45
+ warnedNotStarted = true;
46
+ warnAlways(publicName(name) + ': the SDK has not started, so this call is ignored. Call Apptics.init() first, and check its warnings if you did.'); // no i18n
47
+ }
48
+ if (_ZAP._initialised && !_ZAP._ready && !RUN_BEFORE_READY[name]) {
49
+ _ZAP._pending.push(function () {
50
+ guarded(...args);
51
+ });
52
+ return undefined;
53
+ }
54
+ try {
55
+ return fn(...args);
56
+ }
57
+ catch (err) {
58
+ // a public call swallowing its own exception into a debug-gated console line is how
59
+ // "the modal does not open" looks from the outside: nothing happens, nothing is said.
60
+ // The app is still shielded - the call returns undefined rather than throwing - but
61
+ // the failure is now visible without debug, and reaches the remote logger
62
+ warnAlways(publicName(name) + ' failed:', err); // no i18n
63
+ logFailure(name, err);
64
+ return undefined;
65
+ }
66
+ };
67
+ return guarded;
68
+ }
69
+
70
+ export { guard };
@@ -0,0 +1,41 @@
1
+ import type { CallSite } from './callsite.js';
2
+ import type { DeviceInfo, ServerResult } from '../types.js';
3
+ /**
4
+ * Late-bound calls from lower modules up to the modules above them (see spec §5). device.ts and
5
+ * remotelog/index.ts assign these when they are evaluated; the defaults only run if that module
6
+ * was never imported.
7
+ */
8
+ export declare const hooks: {
9
+ updateDevice: (deviceInfo: DeviceInfo) => Promise<ServerResult>;
10
+ refreshDeviceInfo: () => void;
11
+ /** Set by remotelog/index.ts. Here, not imported, so the logger doesn't depend on the sender. */
12
+ remoteLog: (module: string, message: unknown, site?: CallSite) => void;
13
+ /**
14
+ * Set by feedback/controls.ts: the user picked in the feedback form, or null for anonymous.
15
+ * Here so transport can read the choice without importing the modal.
16
+ */
17
+ feedbackUser: () => {
18
+ userid: string;
19
+ groupid: string;
20
+ } | null;
21
+ /**
22
+ * Set by heatmap/send.ts. Here so the scheduler can flush heatmap records without importing
23
+ * the module — an app that never imports the heatmap entry keeps the default no-op.
24
+ */
25
+ sendHeatmaps: (forget?: boolean) => Promise<void>;
26
+ /** Set by heatmap/track.ts, so init() and reset() can switch capture without importing it. */
27
+ enableHeatmap: (status?: boolean) => void;
28
+ /** Set by heatmap/track.ts: clears what this visit recorded, so the cap starts again. */
29
+ resetHeatmap: () => void;
30
+ /** Set by remoteconfig/fetch.ts, so reset() can forget the rule set without importing it. */
31
+ resetRemoteConfig: () => void;
32
+ /**
33
+ * Set by engagement/auto-screen.ts: the app called inScreen() itself. Here because
34
+ * auto-screen records through track.ts, so track.ts cannot import it back.
35
+ */
36
+ screenTrackedByApp: () => void;
37
+ /** Set by remoteconfig/fetch.ts: start-up has finished, so remote config fetches its values. */
38
+ remoteConfigStarted: () => void;
39
+ /** Set by remoteconfig/fetch.ts: AppticsSetUser changed who this is, so conditions on the user re-apply. */
40
+ remoteConfigUserChanged: () => void;
41
+ };
@@ -0,0 +1,21 @@
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta | (c) Zoho Corporation Private Limited | see LICENSE */
2
+ /**
3
+ * Late-bound calls from lower modules up to the modules above them (see spec §5). device.ts and
4
+ * remotelog/index.ts assign these when they are evaluated; the defaults only run if that module
5
+ * was never imported.
6
+ */
7
+ const hooks = {
8
+ updateDevice: () => Promise.reject('apptics: device module not loaded'), // no i18n
9
+ refreshDeviceInfo: () => { },
10
+ remoteLog: () => { },
11
+ feedbackUser: () => null,
12
+ sendHeatmaps: () => Promise.resolve(),
13
+ enableHeatmap: () => { },
14
+ resetHeatmap: () => { },
15
+ resetRemoteConfig: () => { },
16
+ screenTrackedByApp: () => { },
17
+ remoteConfigStarted: () => { },
18
+ remoteConfigUserChanged: () => { },
19
+ };
20
+
21
+ export { hooks };
@@ -0,0 +1,16 @@
1
+ export declare const Console: {
2
+ log: (...args: unknown[]) => void;
3
+ warn: (...args: unknown[]) => void;
4
+ error: (...args: unknown[]) => void;
5
+ info: (...args: unknown[]) => void;
6
+ dir(arg: unknown): void;
7
+ };
8
+ /** Warnings the integrator must see even with debug off (e.g. missing required config). */
9
+ export declare function warnAlways(...args: unknown[]): void;
10
+ /**
11
+ * A failure inside one of the SDK's own modules: logged to the console as usual, and sent to
12
+ * console/addlog so it can be read back from the Apptics console when the SDK misbehaves in the
13
+ * wild. `module` is one of AP_LOG_MODULE's values. The remote half does nothing until
14
+ * the remotelog module has been loaded and its own switch allows it.
15
+ */
16
+ export declare function logFailure(module: string, ...args: unknown[]): void;
@@ -0,0 +1,82 @@
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta | (c) Zoho Corporation Private Limited | see LICENSE */
2
+ import { _ZAP } from './state.js';
3
+ import { hooks } from './hooks.js';
4
+ import { each } from './utils.js';
5
+ import { callSiteFromStack, callSite } from './callsite.js';
6
+
7
+ const APConsole = typeof console !== 'undefined' ? console : null;
8
+ function gated(method) {
9
+ return function (...args) {
10
+ if (_ZAP._config.debug && APConsole) {
11
+ try {
12
+ APConsole[method].apply(APConsole, args);
13
+ }
14
+ catch (err) {
15
+ each(args, function (arg) {
16
+ APConsole[method](arg);
17
+ });
18
+ }
19
+ }
20
+ };
21
+ }
22
+ // Console override
23
+ const Console = {
24
+ log: gated('log'),
25
+ warn: gated('warn'),
26
+ error: gated('error'),
27
+ info: gated('info'),
28
+ dir(arg) {
29
+ if (_ZAP._config.debug && APConsole) {
30
+ APConsole.dir(arg);
31
+ }
32
+ },
33
+ };
34
+ /** Warnings the integrator must see even with debug off (e.g. missing required config). */
35
+ function warnAlways(...args) {
36
+ if (APConsole)
37
+ APConsole.warn(...args);
38
+ }
39
+ function safeJson(value) {
40
+ try {
41
+ return JSON.stringify(value) || String(value);
42
+ }
43
+ catch (err) {
44
+ return String(value);
45
+ }
46
+ }
47
+ /**
48
+ * A failure inside one of the SDK's own modules: logged to the console as usual, and sent to
49
+ * console/addlog so it can be read back from the Apptics console when the SDK misbehaves in the
50
+ * wild. `module` is one of AP_LOG_MODULE's values. The remote half does nothing until
51
+ * the remotelog module has been loaded and its own switch allows it.
52
+ */
53
+ function logFailure(module, ...args) {
54
+ Console.error.apply(null, args);
55
+ hooks.remoteLog(module, args.map(function (arg) {
56
+ if (arg instanceof Error) {
57
+ return arg.stack || (arg.name + ': ' + arg.message); // no i18n
58
+ }
59
+ return typeof arg === 'string' ? arg : safeJson(arg); // no i18n
60
+ }).join(' '), siteOf(args)); // no i18n
61
+ }
62
+ /**
63
+ * Where to say the failure happened. An Error knows where it was thrown, which is the place
64
+ * worth reporting; the alternative is where it was caught, which is usually a catch block three
65
+ * modules away. Only a frame we could actually read counts, so an Error with no usable stack
66
+ * falls through to logFailure's own caller.
67
+ */
68
+ function siteOf(args) {
69
+ for (var i = 0; i < args.length; i++) {
70
+ var arg = args[i];
71
+ if (arg instanceof Error) {
72
+ var thrownAt = callSiteFromStack(arg.stack, 0);
73
+ if (thrownAt.linenumber > 0) {
74
+ return thrownAt;
75
+ }
76
+ }
77
+ }
78
+ // past siteOf and logFailure, to whoever reported the failure
79
+ return callSite(2);
80
+ }
81
+
82
+ export { Console, logFailure, warnAlways };
@@ -0,0 +1,69 @@
1
+ import { type ApConfig } from './constants.js';
2
+ import type { DeviceInfo, Dict, TrackingStatus, UserInfo } from '../types.js';
3
+ /** Runtime state shared by every module (the former `_ZAP` object). */
4
+ export interface State {
5
+ _initialised: boolean;
6
+ /** Start-up finished (storage loaded, session open, timers running). */
7
+ _ready: boolean;
8
+ /** Public calls made after init() and before _ready, replayed in order. */
9
+ _pending: Array<() => void>;
10
+ _readyPromise: Promise<boolean> | null;
11
+ _regDeviceSending: boolean;
12
+ _regDeviceResolve: Array<(value: any) => void>;
13
+ _regDeviceReject: Array<(reason: any) => void>;
14
+ _sending: boolean;
15
+ _deferSendTimer: ReturnType<typeof setTimeout> | null;
16
+ _config: ApConfig;
17
+ _defaultoptions: Dict;
18
+ inactiveduration: number;
19
+ _token: string;
20
+ _frameworkID: number;
21
+ _platform: string;
22
+ _isanonrequired: boolean;
23
+ _devicestatus: TrackingStatus;
24
+ _uuid: string;
25
+ _apid: string;
26
+ _mapid: string;
27
+ _device_info: DeviceInfo;
28
+ _user_info: UserInfo;
29
+ _current_screen: Dict;
30
+ _current_session: Dict;
31
+ _properties: Dict;
32
+ _ignoreDnt: boolean;
33
+ _isGlobalErrorTracking: boolean;
34
+ _shouldTrack: boolean;
35
+ _engagementTracking: boolean;
36
+ _errorTracking: boolean;
37
+ /** getsdkconfig module 18. Heatmap has its own flag in v2; before that it rode engagement. */
38
+ _heatmapTracking: boolean;
39
+ /** getsdkconfig module 17. */
40
+ _remoteLoggerEnabled: boolean;
41
+ /** getsdkconfig's module flag for remote config, which is the authority on whether it runs. */
42
+ _remoteConfigEnabled: boolean;
43
+ /** What the last getupdates answer said, used only to stop asking about a module it reported off. */
44
+ _remoteConfigReported: boolean;
45
+ /** getsdkconfig module 12. */
46
+ _feedbackEnabled: boolean;
47
+ _quartzEnabled: boolean;
48
+ /** Epoch ms getsdkconfig asked us to wait until before asking again. 0 means no answer yet. */
49
+ _nextConfigCheck: number;
50
+ /**
51
+ * When debug mode switches itself off, as a timestamp; 0 while it is not running.
52
+ * Every tracked item pushes it back, so it only arrives after a genuinely idle hour.
53
+ */
54
+ _debugUntil: number;
55
+ _trackinfo: Dict;
56
+ }
57
+ export declare const _ZAP: State;
58
+ /** Restores every field to its default. The object identity is kept, since modules hold a reference to it. */
59
+ export declare function resetState(): void;
60
+ export declare function getConfig<K extends keyof ApConfig>(key: K): ApConfig[K];
61
+ /** The oldest timestamp still worth keeping: now minus batch_request_timeout days. */
62
+ export declare function oldestKeptTime(): number;
63
+ /**
64
+ * True for an item too old (or dated far enough in the future to be nonsense) to be worth
65
+ * sending. Queues use it to drop such items on the way in, and the sender uses it to drop the
66
+ * ones already stored. A minute of slack absorbs clock differences between tabs and machines,
67
+ * so an item a few milliseconds ahead of this clock is still kept.
68
+ */
69
+ export declare function isExpired(time: unknown): boolean;
@@ -0,0 +1,73 @@
1
+ /*! @zoho_apptics/apptics-js-sdk v2.0.0-beta | (c) Zoho Corporation Private Limited | see LICENSE */
2
+ import { AP_TRACKING_STATUS, AP_CONSTANTS, DEFAULT_INACTIVE_MINUTES, AP_CONFIG } from './constants.js';
3
+ import { nowMs } from './utils.js';
4
+ import { FRAMEWORK_ID } from './framework-id.js';
5
+
6
+ function initialState() {
7
+ return {
8
+ _initialised: false,
9
+ _ready: false,
10
+ _pending: [],
11
+ _readyPromise: null,
12
+ _regDeviceSending: false,
13
+ _regDeviceResolve: [],
14
+ _regDeviceReject: [],
15
+ _sending: false,
16
+ _deferSendTimer: null,
17
+ _config: { ...AP_CONFIG },
18
+ _defaultoptions: {},
19
+ inactiveduration: DEFAULT_INACTIVE_MINUTES,
20
+ _token: '', // no i18n
21
+ // issued by Apptics at pack time; see scripts/register-version.mjs
22
+ _frameworkID: FRAMEWORK_ID,
23
+ _platform: AP_CONSTANTS.BROWSER,
24
+ _isanonrequired: true,
25
+ _devicestatus: AP_TRACKING_STATUS.USAGE_TRACKING_WITHOUT_PII,
26
+ _uuid: '', // no i18n
27
+ _apid: '', // no i18n
28
+ _mapid: '', // no i18n
29
+ _device_info: {},
30
+ _user_info: {},
31
+ _current_screen: {},
32
+ _current_session: {},
33
+ _properties: {},
34
+ _ignoreDnt: false,
35
+ _isGlobalErrorTracking: true,
36
+ _shouldTrack: true,
37
+ _engagementTracking: true,
38
+ _heatmapTracking: true,
39
+ _remoteLoggerEnabled: true,
40
+ _remoteConfigEnabled: true,
41
+ _remoteConfigReported: true,
42
+ _feedbackEnabled: true,
43
+ _nextConfigCheck: 0,
44
+ _debugUntil: 0,
45
+ _errorTracking: true,
46
+ _quartzEnabled: true,
47
+ _trackinfo: {},
48
+ };
49
+ }
50
+ const _ZAP = initialState();
51
+ function getConfig(key) {
52
+ return _ZAP._config[key];
53
+ }
54
+ /** The oldest timestamp still worth keeping: now minus batch_request_timeout days. */
55
+ function oldestKeptTime() {
56
+ return nowMs() - getConfig('batch_request_timeout') * 24 * 60 * 60 * 1000; // no i18n
57
+ }
58
+ /** How far ahead of this clock a timestamp may be before it counts as nonsense. */
59
+ const CLOCK_SKEW_MS = 60 * 1000;
60
+ /**
61
+ * True for an item too old (or dated far enough in the future to be nonsense) to be worth
62
+ * sending. Queues use it to drop such items on the way in, and the sender uses it to drop the
63
+ * ones already stored. A minute of slack absorbs clock differences between tabs and machines,
64
+ * so an item a few milliseconds ahead of this clock is still kept.
65
+ */
66
+ function isExpired(time) {
67
+ if (typeof time !== 'number' || !isFinite(time)) {
68
+ return false; // no usable timestamp: leave it to the caller's own rules
69
+ }
70
+ return time < oldestKeptTime() || time > nowMs() + CLOCK_SKEW_MS;
71
+ }
72
+
73
+ export { _ZAP, getConfig, isExpired, oldestKeptTime };