@amplitude/analytics-core 2.5.6 → 2.6.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 (389) hide show
  1. package/lib/cjs/analytics-connector.d.ts +5 -0
  2. package/lib/cjs/analytics-connector.d.ts.map +1 -0
  3. package/lib/cjs/analytics-connector.js +20 -0
  4. package/lib/cjs/analytics-connector.js.map +1 -0
  5. package/lib/cjs/config.d.ts +107 -3
  6. package/lib/cjs/config.d.ts.map +1 -1
  7. package/lib/cjs/config.js +3 -3
  8. package/lib/cjs/config.js.map +1 -1
  9. package/lib/cjs/cookie-name.d.ts +3 -0
  10. package/lib/cjs/cookie-name.d.ts.map +1 -0
  11. package/lib/cjs/cookie-name.js +15 -0
  12. package/lib/cjs/cookie-name.js.map +1 -0
  13. package/lib/cjs/core-client.d.ts +154 -14
  14. package/lib/cjs/core-client.d.ts.map +1 -1
  15. package/lib/cjs/core-client.js +1 -1
  16. package/lib/cjs/core-client.js.map +1 -1
  17. package/lib/cjs/event-bridge/event-bridge-channel.d.ts +4 -3
  18. package/lib/cjs/event-bridge/event-bridge-channel.d.ts.map +1 -1
  19. package/lib/cjs/event-bridge/event-bridge-channel.js.map +1 -1
  20. package/lib/cjs/event-bridge/event-bridge-container.d.ts +1 -1
  21. package/lib/cjs/event-bridge/event-bridge-container.d.ts.map +1 -1
  22. package/lib/cjs/event-bridge/event-bridge-container.js.map +1 -1
  23. package/lib/cjs/event-bridge/event-bridge.d.ts +9 -2
  24. package/lib/cjs/event-bridge/event-bridge.d.ts.map +1 -1
  25. package/lib/cjs/event-bridge/event-bridge.js.map +1 -1
  26. package/lib/cjs/global-scope.d.ts +2 -0
  27. package/lib/cjs/global-scope.d.ts.map +1 -0
  28. package/lib/cjs/global-scope.js +28 -0
  29. package/lib/cjs/global-scope.js.map +1 -0
  30. package/lib/cjs/identify.d.ts +48 -1
  31. package/lib/cjs/identify.d.ts.map +1 -1
  32. package/lib/cjs/identify.js +32 -16
  33. package/lib/cjs/identify.js.map +1 -1
  34. package/lib/cjs/index.d.ts +37 -8
  35. package/lib/cjs/index.d.ts.map +1 -1
  36. package/lib/cjs/index.js +39 -6
  37. package/lib/cjs/index.js.map +1 -1
  38. package/lib/cjs/language.d.ts +2 -0
  39. package/lib/cjs/language.d.ts.map +1 -0
  40. package/lib/cjs/language.js +13 -0
  41. package/lib/cjs/language.js.map +1 -0
  42. package/lib/cjs/logger.d.ts +27 -1
  43. package/lib/cjs/logger.d.ts.map +1 -1
  44. package/lib/cjs/logger.js +8 -8
  45. package/lib/cjs/logger.js.map +1 -1
  46. package/lib/cjs/plugins/destination.d.ts +14 -3
  47. package/lib/cjs/plugins/destination.d.ts.map +1 -1
  48. package/lib/cjs/plugins/destination.js +8 -8
  49. package/lib/cjs/plugins/destination.js.map +1 -1
  50. package/lib/cjs/plugins/identity.d.ts +11 -0
  51. package/lib/cjs/plugins/identity.d.ts.map +1 -0
  52. package/lib/cjs/plugins/identity.js +37 -0
  53. package/lib/cjs/plugins/identity.js.map +1 -0
  54. package/lib/cjs/query-params.d.ts +3 -0
  55. package/lib/cjs/query-params.d.ts.map +1 -0
  56. package/lib/cjs/query-params.js +36 -0
  57. package/lib/cjs/query-params.js.map +1 -0
  58. package/lib/cjs/revenue.d.ts +43 -1
  59. package/lib/cjs/revenue.d.ts.map +1 -1
  60. package/lib/cjs/revenue.js +28 -8
  61. package/lib/cjs/revenue.js.map +1 -1
  62. package/lib/cjs/session.d.ts +2 -0
  63. package/lib/cjs/session.d.ts.map +1 -0
  64. package/lib/cjs/session.js +11 -0
  65. package/lib/cjs/session.js.map +1 -0
  66. package/lib/cjs/storage/cookie.d.ts +13 -0
  67. package/lib/cjs/storage/cookie.d.ts.map +1 -0
  68. package/lib/cjs/storage/cookie.js +172 -0
  69. package/lib/cjs/storage/cookie.js.map +1 -0
  70. package/lib/cjs/storage/helpers.d.ts +2 -0
  71. package/lib/cjs/storage/helpers.d.ts.map +1 -0
  72. package/lib/cjs/storage/helpers.js +11 -0
  73. package/lib/cjs/storage/helpers.js.map +1 -0
  74. package/lib/cjs/storage/memory.d.ts +1 -1
  75. package/lib/cjs/storage/memory.d.ts.map +1 -1
  76. package/lib/cjs/storage/memory.js.map +1 -1
  77. package/lib/cjs/timeline.d.ts +8 -3
  78. package/lib/cjs/timeline.d.ts.map +1 -1
  79. package/lib/cjs/timeline.js.map +1 -1
  80. package/lib/cjs/transports/base.d.ts +4 -1
  81. package/lib/cjs/transports/base.d.ts.map +1 -1
  82. package/lib/cjs/transports/base.js +13 -16
  83. package/lib/cjs/transports/base.js.map +1 -1
  84. package/lib/cjs/transports/fetch.d.ts +8 -0
  85. package/lib/cjs/transports/fetch.d.ts.map +1 -0
  86. package/lib/cjs/transports/fetch.js +50 -0
  87. package/lib/cjs/transports/fetch.js.map +1 -0
  88. package/lib/cjs/types/browser-client.d.ts +131 -0
  89. package/lib/cjs/types/browser-client.d.ts.map +1 -0
  90. package/lib/cjs/types/browser-client.js +3 -0
  91. package/lib/cjs/types/browser-client.js.map +1 -0
  92. package/lib/cjs/types/browser-config.d.ts +216 -0
  93. package/lib/cjs/types/browser-config.d.ts.map +1 -0
  94. package/lib/cjs/types/browser-config.js +3 -0
  95. package/lib/cjs/types/browser-config.js.map +1 -0
  96. package/lib/cjs/types/constants.d.ts.map +1 -0
  97. package/lib/cjs/types/constants.js.map +1 -0
  98. package/lib/cjs/types/element-interactions.d.ts +73 -0
  99. package/lib/cjs/types/element-interactions.d.ts.map +1 -0
  100. package/lib/cjs/types/element-interactions.js +34 -0
  101. package/lib/cjs/types/element-interactions.js.map +1 -0
  102. package/lib/cjs/types/event/base-event.d.ts +64 -0
  103. package/lib/cjs/types/event/base-event.d.ts.map +1 -0
  104. package/lib/cjs/types/event/base-event.js +3 -0
  105. package/lib/cjs/types/event/base-event.js.map +1 -0
  106. package/lib/cjs/types/event/event.d.ts +68 -0
  107. package/lib/cjs/types/event/event.d.ts.map +1 -0
  108. package/lib/cjs/types/event/event.js +31 -0
  109. package/lib/cjs/types/event/event.js.map +1 -0
  110. package/lib/cjs/types/event/ingestion-metadata.d.ts +19 -0
  111. package/lib/cjs/types/event/ingestion-metadata.d.ts.map +1 -0
  112. package/lib/cjs/types/event/ingestion-metadata.js +3 -0
  113. package/lib/cjs/types/event/ingestion-metadata.js.map +1 -0
  114. package/lib/cjs/types/event/plan.d.ts +14 -0
  115. package/lib/cjs/types/event/plan.d.ts.map +1 -0
  116. package/lib/cjs/types/event/plan.js +3 -0
  117. package/lib/cjs/types/event/plan.js.map +1 -0
  118. package/lib/cjs/types/event-callback.d.ts +3 -0
  119. package/lib/cjs/types/event-callback.d.ts.map +1 -0
  120. package/lib/cjs/types/event-callback.js +3 -0
  121. package/lib/cjs/types/event-callback.js.map +1 -0
  122. package/lib/cjs/types/loglevel.d.ts +8 -0
  123. package/lib/cjs/types/loglevel.d.ts.map +1 -0
  124. package/lib/cjs/types/loglevel.js +12 -0
  125. package/lib/cjs/types/loglevel.js.map +1 -0
  126. package/lib/cjs/types/messages.d.ts.map +1 -0
  127. package/lib/cjs/types/messages.js.map +1 -0
  128. package/lib/cjs/types/offline.d.ts +2 -0
  129. package/lib/cjs/types/offline.d.ts.map +1 -0
  130. package/lib/cjs/types/offline.js +5 -0
  131. package/lib/cjs/types/offline.js.map +1 -0
  132. package/lib/cjs/types/page-view-tracking.d.ts +9 -0
  133. package/lib/cjs/types/page-view-tracking.d.ts.map +1 -0
  134. package/lib/cjs/types/page-view-tracking.js +3 -0
  135. package/lib/cjs/types/page-view-tracking.js.map +1 -0
  136. package/lib/cjs/types/payload.d.ts +13 -0
  137. package/lib/cjs/types/payload.d.ts.map +1 -0
  138. package/lib/cjs/types/payload.js +3 -0
  139. package/lib/cjs/types/payload.js.map +1 -0
  140. package/lib/cjs/types/plugin.d.ts +30 -0
  141. package/lib/cjs/types/plugin.d.ts.map +1 -0
  142. package/lib/cjs/types/plugin.js +3 -0
  143. package/lib/cjs/types/plugin.js.map +1 -0
  144. package/lib/cjs/types/response.d.ts +81 -0
  145. package/lib/cjs/types/response.d.ts.map +1 -0
  146. package/lib/cjs/types/response.js +3 -0
  147. package/lib/cjs/types/response.js.map +1 -0
  148. package/lib/cjs/types/result.d.ts +7 -0
  149. package/lib/cjs/types/result.d.ts.map +1 -0
  150. package/lib/cjs/types/result.js +3 -0
  151. package/lib/cjs/types/result.js.map +1 -0
  152. package/lib/cjs/types/server-zone.d.ts +9 -0
  153. package/lib/cjs/types/server-zone.d.ts.map +1 -0
  154. package/lib/cjs/types/server-zone.js +12 -0
  155. package/lib/cjs/types/server-zone.js.map +1 -0
  156. package/lib/cjs/types/status.d.ts +22 -0
  157. package/lib/cjs/types/status.d.ts.map +1 -0
  158. package/lib/cjs/types/status.js +26 -0
  159. package/lib/cjs/types/status.js.map +1 -0
  160. package/lib/cjs/types/storage.d.ts +16 -0
  161. package/lib/cjs/types/storage.d.ts.map +1 -0
  162. package/lib/cjs/types/storage.js +3 -0
  163. package/lib/cjs/types/storage.js.map +1 -0
  164. package/lib/cjs/types/transport.d.ts +7 -0
  165. package/lib/cjs/types/transport.d.ts.map +1 -0
  166. package/lib/cjs/types/transport.js +3 -0
  167. package/lib/cjs/types/transport.js.map +1 -0
  168. package/lib/cjs/types/user-session.d.ts +11 -0
  169. package/lib/cjs/types/user-session.d.ts.map +1 -0
  170. package/lib/cjs/types/user-session.js +3 -0
  171. package/lib/cjs/types/user-session.js.map +1 -0
  172. package/lib/cjs/utils/debug.d.ts +1 -1
  173. package/lib/cjs/utils/debug.d.ts.map +1 -1
  174. package/lib/cjs/utils/debug.js +2 -6
  175. package/lib/cjs/utils/debug.js.map +1 -1
  176. package/lib/cjs/utils/event-builder.d.ts +5 -2
  177. package/lib/cjs/utils/event-builder.d.ts.map +1 -1
  178. package/lib/cjs/utils/event-builder.js +5 -5
  179. package/lib/cjs/utils/event-builder.js.map +1 -1
  180. package/lib/cjs/utils/result-builder.d.ts +2 -1
  181. package/lib/cjs/utils/result-builder.d.ts.map +1 -1
  182. package/lib/cjs/utils/result-builder.js +2 -2
  183. package/lib/cjs/utils/result-builder.js.map +1 -1
  184. package/lib/cjs/utils/return-wrapper.d.ts +3 -1
  185. package/lib/cjs/utils/return-wrapper.d.ts.map +1 -1
  186. package/lib/cjs/utils/return-wrapper.js.map +1 -1
  187. package/lib/esm/analytics-connector.d.ts +5 -0
  188. package/lib/esm/analytics-connector.d.ts.map +1 -0
  189. package/lib/esm/analytics-connector.js +14 -0
  190. package/lib/esm/analytics-connector.js.map +1 -0
  191. package/lib/esm/config.d.ts +107 -3
  192. package/lib/esm/config.d.ts.map +1 -1
  193. package/lib/esm/config.js +2 -2
  194. package/lib/esm/config.js.map +1 -1
  195. package/lib/esm/cookie-name.d.ts +3 -0
  196. package/lib/esm/cookie-name.d.ts.map +1 -0
  197. package/lib/esm/cookie-name.js +10 -0
  198. package/lib/esm/cookie-name.js.map +1 -0
  199. package/lib/esm/core-client.d.ts +154 -14
  200. package/lib/esm/core-client.d.ts.map +1 -1
  201. package/lib/esm/core-client.js +1 -1
  202. package/lib/esm/core-client.js.map +1 -1
  203. package/lib/esm/event-bridge/event-bridge-channel.d.ts +4 -3
  204. package/lib/esm/event-bridge/event-bridge-channel.d.ts.map +1 -1
  205. package/lib/esm/event-bridge/event-bridge-channel.js.map +1 -1
  206. package/lib/esm/event-bridge/event-bridge-container.d.ts +1 -1
  207. package/lib/esm/event-bridge/event-bridge-container.d.ts.map +1 -1
  208. package/lib/esm/event-bridge/event-bridge-container.js.map +1 -1
  209. package/lib/esm/event-bridge/event-bridge.d.ts +9 -2
  210. package/lib/esm/event-bridge/event-bridge.d.ts.map +1 -1
  211. package/lib/esm/event-bridge/event-bridge.js.map +1 -1
  212. package/lib/esm/global-scope.d.ts +2 -0
  213. package/lib/esm/global-scope.d.ts.map +1 -0
  214. package/lib/esm/global-scope.js +24 -0
  215. package/lib/esm/global-scope.js.map +1 -0
  216. package/lib/esm/identify.d.ts +48 -1
  217. package/lib/esm/identify.d.ts.map +1 -1
  218. package/lib/esm/identify.js +18 -2
  219. package/lib/esm/identify.js.map +1 -1
  220. package/lib/esm/index.d.ts +37 -8
  221. package/lib/esm/index.d.ts.map +1 -1
  222. package/lib/esm/index.js +16 -2
  223. package/lib/esm/index.js.map +1 -1
  224. package/lib/esm/language.d.ts +2 -0
  225. package/lib/esm/language.d.ts.map +1 -0
  226. package/lib/esm/language.js +9 -0
  227. package/lib/esm/language.js.map +1 -0
  228. package/lib/esm/logger.d.ts +27 -1
  229. package/lib/esm/logger.d.ts.map +1 -1
  230. package/lib/esm/logger.js +1 -1
  231. package/lib/esm/logger.js.map +1 -1
  232. package/lib/esm/plugins/destination.d.ts +14 -3
  233. package/lib/esm/plugins/destination.d.ts.map +1 -1
  234. package/lib/esm/plugins/destination.js +3 -3
  235. package/lib/esm/plugins/destination.js.map +1 -1
  236. package/lib/esm/plugins/identity.d.ts +11 -0
  237. package/lib/esm/plugins/identity.d.ts.map +1 -0
  238. package/lib/esm/plugins/identity.js +34 -0
  239. package/lib/esm/plugins/identity.js.map +1 -0
  240. package/lib/esm/query-params.d.ts +3 -0
  241. package/lib/esm/query-params.d.ts.map +1 -0
  242. package/lib/esm/query-params.js +31 -0
  243. package/lib/esm/query-params.js.map +1 -0
  244. package/lib/esm/revenue.d.ts +43 -1
  245. package/lib/esm/revenue.d.ts.map +1 -1
  246. package/lib/esm/revenue.js +21 -1
  247. package/lib/esm/revenue.js.map +1 -1
  248. package/lib/esm/session.d.ts +2 -0
  249. package/lib/esm/session.d.ts.map +1 -0
  250. package/lib/esm/session.js +7 -0
  251. package/lib/esm/session.js.map +1 -0
  252. package/lib/esm/storage/cookie.d.ts +13 -0
  253. package/lib/esm/storage/cookie.d.ts.map +1 -0
  254. package/lib/esm/storage/cookie.js +169 -0
  255. package/lib/esm/storage/cookie.js.map +1 -0
  256. package/lib/esm/storage/helpers.d.ts +2 -0
  257. package/lib/esm/storage/helpers.d.ts.map +1 -0
  258. package/lib/esm/storage/helpers.js +7 -0
  259. package/lib/esm/storage/helpers.js.map +1 -0
  260. package/lib/esm/storage/memory.d.ts +1 -1
  261. package/lib/esm/storage/memory.d.ts.map +1 -1
  262. package/lib/esm/storage/memory.js.map +1 -1
  263. package/lib/esm/timeline.d.ts +8 -3
  264. package/lib/esm/timeline.d.ts.map +1 -1
  265. package/lib/esm/timeline.js.map +1 -1
  266. package/lib/esm/transports/base.d.ts +4 -1
  267. package/lib/esm/transports/base.d.ts.map +1 -1
  268. package/lib/esm/transports/base.js +1 -4
  269. package/lib/esm/transports/base.js.map +1 -1
  270. package/lib/esm/transports/fetch.d.ts +8 -0
  271. package/lib/esm/transports/fetch.d.ts.map +1 -0
  272. package/lib/esm/transports/fetch.js +47 -0
  273. package/lib/esm/transports/fetch.js.map +1 -0
  274. package/lib/esm/types/browser-client.d.ts +131 -0
  275. package/lib/esm/types/browser-client.d.ts.map +1 -0
  276. package/lib/esm/types/browser-client.js +2 -0
  277. package/lib/esm/types/browser-client.js.map +1 -0
  278. package/lib/esm/types/browser-config.d.ts +216 -0
  279. package/lib/esm/types/browser-config.d.ts.map +1 -0
  280. package/lib/esm/types/browser-config.js +2 -0
  281. package/lib/esm/types/browser-config.js.map +1 -0
  282. package/lib/esm/types/constants.d.ts.map +1 -0
  283. package/lib/esm/types/constants.js.map +1 -0
  284. package/lib/esm/types/element-interactions.d.ts +73 -0
  285. package/lib/esm/types/element-interactions.d.ts.map +1 -0
  286. package/lib/esm/types/element-interactions.js +31 -0
  287. package/lib/esm/types/element-interactions.js.map +1 -0
  288. package/lib/esm/types/event/base-event.d.ts +64 -0
  289. package/lib/esm/types/event/base-event.d.ts.map +1 -0
  290. package/lib/esm/types/event/base-event.js +2 -0
  291. package/lib/esm/types/event/base-event.js.map +1 -0
  292. package/lib/esm/types/event/event.d.ts +68 -0
  293. package/lib/esm/types/event/event.d.ts.map +1 -0
  294. package/lib/esm/types/event/event.js +28 -0
  295. package/lib/esm/types/event/event.js.map +1 -0
  296. package/lib/esm/types/event/ingestion-metadata.d.ts +19 -0
  297. package/lib/esm/types/event/ingestion-metadata.d.ts.map +1 -0
  298. package/lib/esm/types/event/ingestion-metadata.js +2 -0
  299. package/lib/esm/types/event/ingestion-metadata.js.map +1 -0
  300. package/lib/esm/types/event/plan.d.ts +14 -0
  301. package/lib/esm/types/event/plan.d.ts.map +1 -0
  302. package/lib/esm/types/event/plan.js +2 -0
  303. package/lib/esm/types/event/plan.js.map +1 -0
  304. package/lib/esm/types/event-callback.d.ts +3 -0
  305. package/lib/esm/types/event-callback.d.ts.map +1 -0
  306. package/lib/esm/types/event-callback.js +2 -0
  307. package/lib/esm/types/event-callback.js.map +1 -0
  308. package/lib/esm/types/loglevel.d.ts +8 -0
  309. package/lib/esm/types/loglevel.d.ts.map +1 -0
  310. package/lib/esm/types/loglevel.js +9 -0
  311. package/lib/esm/types/loglevel.js.map +1 -0
  312. package/lib/esm/types/messages.d.ts.map +1 -0
  313. package/lib/esm/types/messages.js.map +1 -0
  314. package/lib/esm/types/offline.d.ts +2 -0
  315. package/lib/esm/types/offline.d.ts.map +1 -0
  316. package/lib/esm/types/offline.js +2 -0
  317. package/lib/esm/types/offline.js.map +1 -0
  318. package/lib/esm/types/page-view-tracking.d.ts +9 -0
  319. package/lib/esm/types/page-view-tracking.d.ts.map +1 -0
  320. package/lib/esm/types/page-view-tracking.js +2 -0
  321. package/lib/esm/types/page-view-tracking.js.map +1 -0
  322. package/lib/esm/types/payload.d.ts +13 -0
  323. package/lib/esm/types/payload.d.ts.map +1 -0
  324. package/lib/esm/types/payload.js +2 -0
  325. package/lib/esm/types/payload.js.map +1 -0
  326. package/lib/esm/types/plugin.d.ts +30 -0
  327. package/lib/esm/types/plugin.d.ts.map +1 -0
  328. package/lib/esm/types/plugin.js +2 -0
  329. package/lib/esm/types/plugin.js.map +1 -0
  330. package/lib/esm/types/response.d.ts +81 -0
  331. package/lib/esm/types/response.d.ts.map +1 -0
  332. package/lib/esm/types/response.js +2 -0
  333. package/lib/esm/types/response.js.map +1 -0
  334. package/lib/esm/types/result.d.ts +7 -0
  335. package/lib/esm/types/result.d.ts.map +1 -0
  336. package/lib/esm/types/result.js +2 -0
  337. package/lib/esm/types/result.js.map +1 -0
  338. package/lib/esm/types/server-zone.d.ts +9 -0
  339. package/lib/esm/types/server-zone.d.ts.map +1 -0
  340. package/lib/esm/types/server-zone.js +9 -0
  341. package/lib/esm/types/server-zone.js.map +1 -0
  342. package/lib/esm/types/status.d.ts +22 -0
  343. package/lib/esm/types/status.d.ts.map +1 -0
  344. package/lib/esm/types/status.js +23 -0
  345. package/lib/esm/types/status.js.map +1 -0
  346. package/lib/esm/types/storage.d.ts +16 -0
  347. package/lib/esm/types/storage.d.ts.map +1 -0
  348. package/lib/esm/types/storage.js +2 -0
  349. package/lib/esm/types/storage.js.map +1 -0
  350. package/lib/esm/types/transport.d.ts +7 -0
  351. package/lib/esm/types/transport.d.ts.map +1 -0
  352. package/lib/esm/types/transport.js +2 -0
  353. package/lib/esm/types/transport.js.map +1 -0
  354. package/lib/esm/types/user-session.d.ts +11 -0
  355. package/lib/esm/types/user-session.d.ts.map +1 -0
  356. package/lib/esm/types/user-session.js +2 -0
  357. package/lib/esm/types/user-session.js.map +1 -0
  358. package/lib/esm/utils/debug.d.ts +1 -1
  359. package/lib/esm/utils/debug.d.ts.map +1 -1
  360. package/lib/esm/utils/debug.js +1 -5
  361. package/lib/esm/utils/debug.js.map +1 -1
  362. package/lib/esm/utils/event-builder.d.ts +5 -2
  363. package/lib/esm/utils/event-builder.d.ts.map +1 -1
  364. package/lib/esm/utils/event-builder.js +1 -1
  365. package/lib/esm/utils/event-builder.js.map +1 -1
  366. package/lib/esm/utils/result-builder.d.ts +2 -1
  367. package/lib/esm/utils/result-builder.d.ts.map +1 -1
  368. package/lib/esm/utils/result-builder.js +1 -1
  369. package/lib/esm/utils/result-builder.js.map +1 -1
  370. package/lib/esm/utils/return-wrapper.d.ts +3 -1
  371. package/lib/esm/utils/return-wrapper.d.ts.map +1 -1
  372. package/lib/esm/utils/return-wrapper.js.map +1 -1
  373. package/package.json +2 -3
  374. package/lib/cjs/constants.d.ts.map +0 -1
  375. package/lib/cjs/constants.js.map +0 -1
  376. package/lib/cjs/messages.d.ts.map +0 -1
  377. package/lib/cjs/messages.js.map +0 -1
  378. package/lib/esm/constants.d.ts.map +0 -1
  379. package/lib/esm/constants.js.map +0 -1
  380. package/lib/esm/messages.d.ts.map +0 -1
  381. package/lib/esm/messages.js.map +0 -1
  382. /package/lib/cjs/{constants.d.ts → types/constants.d.ts} +0 -0
  383. /package/lib/cjs/{constants.js → types/constants.js} +0 -0
  384. /package/lib/cjs/{messages.d.ts → types/messages.d.ts} +0 -0
  385. /package/lib/cjs/{messages.js → types/messages.js} +0 -0
  386. /package/lib/esm/{constants.d.ts → types/constants.d.ts} +0 -0
  387. /package/lib/esm/{constants.js → types/constants.js} +0 -0
  388. /package/lib/esm/{messages.d.ts → types/messages.d.ts} +0 -0
  389. /package/lib/esm/{messages.js → types/messages.js} +0 -0
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CookieStorage = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var global_scope_1 = require("../global-scope");
6
+ var CookieStorage = /** @class */ (function () {
7
+ function CookieStorage(options) {
8
+ this.options = tslib_1.__assign({}, options);
9
+ }
10
+ CookieStorage.prototype.isEnabled = function () {
11
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
12
+ var testStrorage, testKey, value, _a;
13
+ return tslib_1.__generator(this, function (_b) {
14
+ switch (_b.label) {
15
+ case 0:
16
+ /* istanbul ignore if */
17
+ if (!(0, global_scope_1.getGlobalScope)()) {
18
+ return [2 /*return*/, false];
19
+ }
20
+ CookieStorage.testValue = String(Date.now());
21
+ testStrorage = new CookieStorage(this.options);
22
+ testKey = 'AMP_TEST';
23
+ _b.label = 1;
24
+ case 1:
25
+ _b.trys.push([1, 4, 5, 7]);
26
+ return [4 /*yield*/, testStrorage.set(testKey, CookieStorage.testValue)];
27
+ case 2:
28
+ _b.sent();
29
+ return [4 /*yield*/, testStrorage.get(testKey)];
30
+ case 3:
31
+ value = _b.sent();
32
+ return [2 /*return*/, value === CookieStorage.testValue];
33
+ case 4:
34
+ _a = _b.sent();
35
+ /* istanbul ignore next */
36
+ return [2 /*return*/, false];
37
+ case 5: return [4 /*yield*/, testStrorage.remove(testKey)];
38
+ case 6:
39
+ _b.sent();
40
+ return [7 /*endfinally*/];
41
+ case 7: return [2 /*return*/];
42
+ }
43
+ });
44
+ });
45
+ };
46
+ CookieStorage.prototype.get = function (key) {
47
+ var _a;
48
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
49
+ var value, decodedValue;
50
+ return tslib_1.__generator(this, function (_b) {
51
+ switch (_b.label) {
52
+ case 0: return [4 /*yield*/, this.getRaw(key)];
53
+ case 1:
54
+ value = _b.sent();
55
+ if (!value) {
56
+ return [2 /*return*/, undefined];
57
+ }
58
+ try {
59
+ decodedValue = (_a = decodeCookiesAsDefault(value)) !== null && _a !== void 0 ? _a : decodeCookiesWithDoubleUrlEncoding(value);
60
+ if (decodedValue === undefined) {
61
+ console.error("Amplitude Logger [Error]: Failed to decode cookie value for key: ".concat(key, ", value: ").concat(value));
62
+ return [2 /*return*/, undefined];
63
+ }
64
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
65
+ return [2 /*return*/, JSON.parse(decodedValue)];
66
+ }
67
+ catch (_c) {
68
+ console.error("Amplitude Logger [Error]: Failed to parse cookie value for key: ".concat(key, ", value: ").concat(value));
69
+ return [2 /*return*/, undefined];
70
+ }
71
+ return [2 /*return*/];
72
+ }
73
+ });
74
+ });
75
+ };
76
+ CookieStorage.prototype.getRaw = function (key) {
77
+ var _a, _b;
78
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
79
+ var globalScope, cookie, match;
80
+ return tslib_1.__generator(this, function (_c) {
81
+ globalScope = (0, global_scope_1.getGlobalScope)();
82
+ cookie = (_b = (_a = globalScope === null || globalScope === void 0 ? void 0 : globalScope.document) === null || _a === void 0 ? void 0 : _a.cookie.split('; ')) !== null && _b !== void 0 ? _b : [];
83
+ match = cookie.find(function (c) { return c.indexOf(key + '=') === 0; });
84
+ if (!match) {
85
+ return [2 /*return*/, undefined];
86
+ }
87
+ return [2 /*return*/, match.substring(key.length + 1)];
88
+ });
89
+ });
90
+ };
91
+ CookieStorage.prototype.set = function (key, value) {
92
+ var _a;
93
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
94
+ var expirationDays, expires, expireDate, date, str, globalScope, errorMessage;
95
+ return tslib_1.__generator(this, function (_b) {
96
+ try {
97
+ expirationDays = (_a = this.options.expirationDays) !== null && _a !== void 0 ? _a : 0;
98
+ expires = value !== null ? expirationDays : -1;
99
+ expireDate = undefined;
100
+ if (expires) {
101
+ date = new Date();
102
+ date.setTime(date.getTime() + expires * 24 * 60 * 60 * 1000);
103
+ expireDate = date;
104
+ }
105
+ str = "".concat(key, "=").concat(btoa(encodeURIComponent(JSON.stringify(value))));
106
+ if (expireDate) {
107
+ str += "; expires=".concat(expireDate.toUTCString());
108
+ }
109
+ str += '; path=/';
110
+ if (this.options.domain) {
111
+ str += "; domain=".concat(this.options.domain);
112
+ }
113
+ if (this.options.secure) {
114
+ str += '; Secure';
115
+ }
116
+ if (this.options.sameSite) {
117
+ str += "; SameSite=".concat(this.options.sameSite);
118
+ }
119
+ globalScope = (0, global_scope_1.getGlobalScope)();
120
+ if (globalScope) {
121
+ globalScope.document.cookie = str;
122
+ }
123
+ }
124
+ catch (error) {
125
+ errorMessage = error instanceof Error ? error.message : String(error);
126
+ console.error("Amplitude Logger [Error]: Failed to set cookie for key: ".concat(key, ". Error: ").concat(errorMessage));
127
+ }
128
+ return [2 /*return*/];
129
+ });
130
+ });
131
+ };
132
+ CookieStorage.prototype.remove = function (key) {
133
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
134
+ return tslib_1.__generator(this, function (_a) {
135
+ switch (_a.label) {
136
+ case 0: return [4 /*yield*/, this.set(key, null)];
137
+ case 1:
138
+ _a.sent();
139
+ return [2 /*return*/];
140
+ }
141
+ });
142
+ });
143
+ };
144
+ CookieStorage.prototype.reset = function () {
145
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
146
+ return tslib_1.__generator(this, function (_a) {
147
+ return [2 /*return*/];
148
+ });
149
+ });
150
+ };
151
+ return CookieStorage;
152
+ }());
153
+ exports.CookieStorage = CookieStorage;
154
+ var decodeCookiesAsDefault = function (value) {
155
+ try {
156
+ return decodeURIComponent(atob(value));
157
+ }
158
+ catch (_a) {
159
+ return undefined;
160
+ }
161
+ };
162
+ var decodeCookiesWithDoubleUrlEncoding = function (value) {
163
+ // Modern Ruby (v7+) automatically encodes cookies with URL encoding by
164
+ // https://api.rubyonrails.org/classes/ActionDispatch/Cookies.html
165
+ try {
166
+ return decodeURIComponent(atob(decodeURIComponent(value)));
167
+ }
168
+ catch (_a) {
169
+ return undefined;
170
+ }
171
+ };
172
+ //# sourceMappingURL=cookie.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cookie.js","sourceRoot":"","sources":["../../../src/storage/cookie.ts"],"names":[],"mappings":";;;;AACA,gDAAiD;AAEjD;IAIE,uBAAY,OAA8B;QACxC,IAAI,CAAC,OAAO,wBAAQ,OAAO,CAAE,CAAC;IAChC,CAAC;IAEK,iCAAS,GAAf;;;;;;wBACE,wBAAwB;wBACxB,IAAI,CAAC,IAAA,6BAAc,GAAE,EAAE;4BACrB,sBAAO,KAAK,EAAC;yBACd;wBAED,aAAa,CAAC,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;wBACvC,YAAY,GAAG,IAAI,aAAa,CAAS,IAAI,CAAC,OAAO,CAAC,CAAC;wBACvD,OAAO,GAAG,UAAU,CAAC;;;;wBAEzB,qBAAM,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,EAAA;;wBAAxD,SAAwD,CAAC;wBAC3C,qBAAM,YA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I,qBAAc,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAE,CAAC;qBAC9C;oBACK,WAAW,GAAG,IAAA,6BAAc,GAAE,CAAC;oBACrC,IAAI,WAAW,EAAE;wBACf,WAAW,CAAC,QAAQ,CAAC,MAAM,GAAG,GAAG,CAAC;qBACnC;iBACF;gBAAC,OAAO,KAAK,EAAE;oBACR,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;oBAC5E,OAAO,CAAC,KAAK,CAAC,kEAA2D,GAAG,sBAAY,YAAY,CAAE,CAAC,CAAC;iBACzG;;;;KACF;IAEK,8BAAM,GAAZ,UAAa,GAAW;;;;4BACtB,qBAAM,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,EAAA;;wBAAzB,SAAyB,CAAC;;;;;KAC3B;IAEK,6BAAK,GAAX;;;gBACE,sBAAO;;;KACR;IACH,oBAAC;AAAD,CAAC,AAnGD,IAmGC;AAnGY,sCAAa;AAqG1B,IAAM,sBAAsB,GAAG,UAAC,KAAa;IAC3C,IAAI;QACF,OAAO,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;KACxC;IAAC,WAAM;QACN,OAAO,SAAS,CAAC;KAClB;AACH,CAAC,CAAC;AAEF,IAAM,kCAAkC,GAAG,UAAC,KAAa;IACvD,uEAAuE;IACvE,kEAAkE;IAClE,IAAI;QACF,OAAO,kBAAkB,CAAC,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KAC5D;IAAC,WAAM;QACN,OAAO,SAAS,CAAC;KAClB;AACH,CAAC,CAAC","sourcesContent":["import { Storage, CookieStorageOptions } from '../types/storage';\nimport { getGlobalScope } from '../global-scope';\n\nexport class CookieStorage<T> implements Storage<T> {\n options: CookieStorageOptions;\n private static testValue: undefined | string;\n\n constructor(options?: CookieStorageOptions) {\n this.options = { ...options };\n }\n\n async isEnabled(): Promise<boolean> {\n /* istanbul ignore if */\n if (!getGlobalScope()) {\n return false;\n }\n\n CookieStorage.testValue = String(Date.now());\n const testStrorage = new CookieStorage<string>(this.options);\n const testKey = 'AMP_TEST';\n try {\n await testStrorage.set(testKey, CookieStorage.testValue);\n const value = await testStrorage.get(testKey);\n return value === CookieStorage.testValue;\n } catch {\n /* istanbul ignore next */\n return false;\n } finally {\n await testStrorage.remove(testKey);\n }\n }\n\n async get(key: string): Promise<T | undefined> {\n const value = await this.getRaw(key);\n if (!value) {\n return undefined;\n }\n try {\n const decodedValue = decodeCookiesAsDefault(value) ?? decodeCookiesWithDoubleUrlEncoding(value);\n if (decodedValue === undefined) {\n console.error(`Amplitude Logger [Error]: Failed to decode cookie value for key: ${key}, value: ${value}`);\n return undefined;\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return JSON.parse(decodedValue);\n } catch {\n console.error(`Amplitude Logger [Error]: Failed to parse cookie value for key: ${key}, value: ${value}`);\n return undefined;\n }\n }\n\n async getRaw(key: string): Promise<string | undefined> {\n const globalScope = getGlobalScope();\n const cookie = globalScope?.document?.cookie.split('; ') ?? [];\n const match = cookie.find((c) => c.indexOf(key + '=') === 0);\n if (!match) {\n return undefined;\n }\n return match.substring(key.length + 1);\n }\n\n async set(key: string, value: T | null): Promise<void> {\n try {\n const expirationDays = this.options.expirationDays ?? 0;\n const expires = value !== null ? expirationDays : -1;\n let expireDate: Date | undefined = undefined;\n if (expires) {\n const date = new Date();\n date.setTime(date.getTime() + expires * 24 * 60 * 60 * 1000);\n expireDate = date;\n }\n let str = `${key}=${btoa(encodeURIComponent(JSON.stringify(value)))}`;\n if (expireDate) {\n str += `; expires=${expireDate.toUTCString()}`;\n }\n str += '; path=/';\n if (this.options.domain) {\n str += `; domain=${this.options.domain}`;\n }\n if (this.options.secure) {\n str += '; Secure';\n }\n if (this.options.sameSite) {\n str += `; SameSite=${this.options.sameSite}`;\n }\n const globalScope = getGlobalScope();\n if (globalScope) {\n globalScope.document.cookie = str;\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n console.error(`Amplitude Logger [Error]: Failed to set cookie for key: ${key}. Error: ${errorMessage}`);\n }\n }\n\n async remove(key: string): Promise<void> {\n await this.set(key, null);\n }\n\n async reset(): Promise<void> {\n return;\n }\n}\n\nconst decodeCookiesAsDefault = (value: string): string | undefined => {\n try {\n return decodeURIComponent(atob(value));\n } catch {\n return undefined;\n }\n};\n\nconst decodeCookiesWithDoubleUrlEncoding = (value: string): string | undefined => {\n // Modern Ruby (v7+) automatically encodes cookies with URL encoding by\n // https://api.rubyonrails.org/classes/ActionDispatch/Cookies.html\n try {\n return decodeURIComponent(atob(decodeURIComponent(value)));\n } catch {\n return undefined;\n }\n};\n"]}
@@ -0,0 +1,2 @@
1
+ export declare const getStorageKey: (apiKey: string, postKey?: string, limit?: number) => string;
2
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/storage/helpers.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,WAAY,MAAM,6CAE3C,CAAC"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getStorageKey = void 0;
4
+ var constants_1 = require("../types/constants");
5
+ var getStorageKey = function (apiKey, postKey, limit) {
6
+ if (postKey === void 0) { postKey = ''; }
7
+ if (limit === void 0) { limit = 10; }
8
+ return [constants_1.AMPLITUDE_PREFIX, postKey, apiKey.substring(0, limit)].filter(Boolean).join('_');
9
+ };
10
+ exports.getStorageKey = getStorageKey;
11
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/storage/helpers.ts"],"names":[],"mappings":";;;AAAA,gDAAsD;AAE/C,IAAM,aAAa,GAAG,UAAC,MAAc,EAAE,OAAY,EAAE,KAAU;IAAxB,wBAAA,EAAA,YAAY;IAAE,sBAAA,EAAA,UAAU;IACpE,OAAO,CAAC,4BAAgB,EAAE,OAAO,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC3F,CAAC,CAAC;AAFW,QAAA,aAAa,iBAExB","sourcesContent":["import { AMPLITUDE_PREFIX } from '../types/constants';\n\nexport const getStorageKey = (apiKey: string, postKey = '', limit = 10) => {\n return [AMPLITUDE_PREFIX, postKey, apiKey.substring(0, limit)].filter(Boolean).join('_');\n};\n"]}
@@ -1,4 +1,4 @@
1
- import { Storage } from '@amplitude/analytics-types';
1
+ import { Storage } from '../types/storage';
2
2
  export declare class MemoryStorage<T> implements Storage<T> {
3
3
  memoryStorage: Map<string, T>;
4
4
  isEnabled(): Promise<boolean>;
@@ -1 +1 @@
1
- {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../src/storage/memory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAErD,qBAAa,aAAa,CAAC,CAAC,CAAE,YAAW,OAAO,CAAC,CAAC,CAAC;IACjD,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAa;IAEpC,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;IAI7B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAIxC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAKhD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAIzC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
1
+ {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../src/storage/memory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,qBAAa,aAAa,CAAC,CAAC,CAAE,YAAW,OAAO,CAAC,CAAC,CAAC;IACjD,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAa;IAEpC,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;IAI7B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAIxC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAKhD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAIzC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
@@ -1 +1 @@
1
- {"version":3,"file":"memory.js","sourceRoot":"","sources":["../../../src/storage/memory.ts"],"names":[],"mappings":";;;;AAEA;IAAA;QACE,kBAAa,GAAmB,IAAI,GAAG,EAAE,CAAC;IA0B5C,CAAC;IAxBO,iCAAS,GAAf;;;gBACE,sBAAO,IAAI,EAAC;;;KACb;IAEK,2BAAG,GAAT,UAAU,GAAW;;;gBACnB,sBAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,EAAC;;;KACpC;IAEK,8BAAM,GAAZ,UAAa,GAAW;;;;;4BACR,qBAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAA;;wBAA3B,KAAK,GAAG,SAAmB;wBACjC,sBAAO,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,EAAC;;;;KAClD;IAEK,2BAAG,GAAT,UAAU,GAAW,EAAE,KAAQ;;;gBAC7B,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;;;;KACpC;IAEK,8BAAM,GAAZ,UAAa,GAAW;;;gBACtB,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;;;;KAChC;IAEK,6BAAK,GAAX;;;gBACE,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;;;;KAC5B;IACH,oBAAC;AAAD,CAAC,AA3BD,IA2BC;AA3BY,sCAAa","sourcesContent":["import { Storage } from '@amplitude/analytics-types';\n\nexport class MemoryStorage<T> implements Storage<T> {\n memoryStorage: Map<string, T> = new Map();\n\n async isEnabled(): Promise<boolean> {\n return true;\n }\n\n async get(key: string): Promise<T | undefined> {\n return this.memoryStorage.get(key);\n }\n\n async getRaw(key: string): Promise<string | undefined> {\n const value = await this.get(key);\n return value ? JSON.stringify(value) : undefined;\n }\n\n async set(key: string, value: T): Promise<void> {\n this.memoryStorage.set(key, value);\n }\n\n async remove(key: string): Promise<void> {\n this.memoryStorage.delete(key);\n }\n\n async reset(): Promise<void> {\n this.memoryStorage.clear();\n }\n}\n"]}
1
+ {"version":3,"file":"memory.js","sourceRoot":"","sources":["../../../src/storage/memory.ts"],"names":[],"mappings":";;;;AAEA;IAAA;QACE,kBAAa,GAAmB,IAAI,GAAG,EAAE,CAAC;IA0B5C,CAAC;IAxBO,iCAAS,GAAf;;;gBACE,sBAAO,IAAI,EAAC;;;KACb;IAEK,2BAAG,GAAT,UAAU,GAAW;;;gBACnB,sBAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,EAAC;;;KACpC;IAEK,8BAAM,GAAZ,UAAa,GAAW;;;;;4BACR,qBAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAA;;wBAA3B,KAAK,GAAG,SAAmB;wBACjC,sBAAO,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,EAAC;;;;KAClD;IAEK,2BAAG,GAAT,UAAU,GAAW,EAAE,KAAQ;;;gBAC7B,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;;;;KACpC;IAEK,8BAAM,GAAZ,UAAa,GAAW;;;gBACtB,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;;;;KAChC;IAEK,6BAAK,GAAX;;;gBACE,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;;;;KAC5B;IACH,oBAAC;AAAD,CAAC,AA3BD,IA2BC;AA3BY,sCAAa","sourcesContent":["import { Storage } from '../types/storage';\n\nexport class MemoryStorage<T> implements Storage<T> {\n memoryStorage: Map<string, T> = new Map();\n\n async isEnabled(): Promise<boolean> {\n return true;\n }\n\n async get(key: string): Promise<T | undefined> {\n return this.memoryStorage.get(key);\n }\n\n async getRaw(key: string): Promise<string | undefined> {\n const value = await this.get(key);\n return value ? JSON.stringify(value) : undefined;\n }\n\n async set(key: string, value: T): Promise<void> {\n this.memoryStorage.set(key, value);\n }\n\n async remove(key: string): Promise<void> {\n this.memoryStorage.delete(key);\n }\n\n async reset(): Promise<void> {\n this.memoryStorage.clear();\n }\n}\n"]}
@@ -1,12 +1,17 @@
1
- import { Config, CoreClient, Event, EventCallback, Plugin, Result } from '@amplitude/analytics-types';
1
+ import { Plugin } from './types/plugin';
2
+ import { CoreClient } from './core-client';
3
+ import { IConfig } from './config';
4
+ import { EventCallback } from './types/event-callback';
5
+ import { Event } from './types/event/event';
6
+ import { Result } from './types/result';
2
7
  export declare class Timeline {
3
8
  private client;
4
9
  queue: [Event, EventCallback][];
5
10
  applying: boolean;
6
11
  plugins: Plugin[];
7
12
  constructor(client: CoreClient);
8
- register(plugin: Plugin, config: Config): Promise<void>;
9
- deregister(pluginName: string, config: Config): Promise<void>;
13
+ register(plugin: Plugin, config: IConfig): Promise<void>;
14
+ deregister(pluginName: string, config: IConfig): Promise<void>;
10
15
  reset(client: CoreClient): void;
11
16
  push(event: Event): Promise<Result>;
12
17
  scheduleApply(timeout: number): void;
@@ -1 +1 @@
1
- {"version":3,"file":"timeline.d.ts","sourceRoot":"","sources":["../../src/timeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EACN,UAAU,EAGV,KAAK,EACL,aAAa,EACb,MAAM,EACN,MAAM,EACP,MAAM,4BAA4B,CAAC;AAIpC,qBAAa,QAAQ;IAQP,OAAO,CAAC,MAAM;IAP1B,KAAK,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC,EAAE,CAAM;IAErC,QAAQ,UAAS;IAGjB,OAAO,EAAE,MAAM,EAAE,CAAM;gBAEH,MAAM,EAAE,UAAU;IAEhC,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAmBvC,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAWnD,KAAK,CAAC,MAAM,EAAE,UAAU;IAQxB,IAAI,CAAC,KAAK,EAAE,KAAK;IAOjB,aAAa,CAAC,OAAO,EAAE,MAAM;IAavB,KAAK,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC,GAAG,SAAS;IAgE9C,KAAK;CAgBZ"}
1
+ {"version":3,"file":"timeline.d.ts","sourceRoot":"","sources":["../../src/timeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqD,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC3F,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAg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AAAD,CAAC,AApJD,IAoJC;AApJY,4BAAQ","sourcesContent":["import {\n BeforePlugin,\n Config,\n CoreClient,\n DestinationPlugin,\n EnrichmentPlugin,\n Event,\n EventCallback,\n Plugin,\n Result,\n} from '@amplitude/analytics-types';\nimport { buildResult } from './utils/result-builder';\nimport { UUID } from './utils/uuid';\n\nexport class Timeline {\n queue: [Event, EventCallback][] = [];\n // Flag to guarantee one schedule apply is running\n applying = false;\n // Flag indicates whether timeline is ready to process event\n // Events collected before timeline is ready will stay in the queue to be processed later\n plugins: Plugin[] = [];\n\n constructor(private client: CoreClient) {}\n\n async register(plugin: Plugin, config: Config) {\n if (this.plugins.some((existingPlugin) => existingPlugin.name === plugin.name)) {\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n config.loggerProvider.warn(`Plugin with name ${plugin.name} already exists, skipping registration`);\n return;\n }\n\n if (plugin.name === undefined) {\n plugin.name = UUID();\n config.loggerProvider.warn(`Plugin name is undefined. \n Generating a random UUID for plugin name: ${plugin.name}. \n Set a name for the plugin to prevent it from being added multiple times.`);\n }\n\n plugin.type = plugin.type ?? 'enrichment';\n await plugin.setup?.(config, this.client);\n this.plugins.push(plugin);\n }\n\n async deregister(pluginName: string, config: Config) {\n const index = this.plugins.findIndex((plugin) => plugin.name === pluginName);\n if (index === -1) {\n config.loggerProvider.warn(`Plugin with name ${pluginName} does not exist, skipping deregistration`);\n return;\n }\n const plugin = this.plugins[index];\n this.plugins.splice(index, 1);\n await plugin.teardown?.();\n }\n\n reset(client: CoreClient) {\n this.applying = false;\n const plugins = this.plugins;\n plugins.map((plugin) => plugin.teardown?.());\n this.plugins = [];\n this.client = client;\n }\n\n push(event: Event) {\n return new Promise<Result>((resolve) => {\n this.queue.push([event, resolve]);\n this.scheduleApply(0);\n });\n }\n\n scheduleApply(timeout: number) {\n if (this.applying) return;\n this.applying = true;\n setTimeout(() => {\n void this.apply(this.queue.shift()).then(() => {\n this.applying = false;\n if (this.queue.length > 0) {\n this.scheduleApply(0);\n }\n });\n }, timeout);\n }\n\n async apply(item: [Event, EventCallback] | undefined) {\n if (!item) {\n return;\n }\n\n let [event] = item;\n const [, resolve] = item;\n\n const before = this.plugins.filter<BeforePlugin>(\n (plugin: Plugin): plugin is BeforePlugin => plugin.type === 'before',\n );\n\n for (const plugin of before) {\n /* istanbul ignore if */\n if (!plugin.execute) {\n // do nothing\n continue;\n }\n const e = await plugin.execute({ ...event });\n if (e === null) {\n resolve({ event, code: 0, message: '' });\n return;\n } else {\n event = e;\n }\n }\n\n const enrichment = this.plugins.filter<EnrichmentPlugin>(\n (plugin: Plugin): plugin is EnrichmentPlugin => plugin.type === 'enrichment' || plugin.type === undefined,\n );\n\n for (const plugin of enrichment) {\n /* istanbul ignore if */\n if (!plugin.execute) {\n // do nothing\n continue;\n }\n const e = await plugin.execute({ ...event });\n if (e === null) {\n resolve({ event, code: 0, message: '' });\n return;\n } else {\n event = e;\n }\n }\n\n const destination = this.plugins.filter<DestinationPlugin>(\n (plugin: Plugin): plugin is DestinationPlugin => plugin.type === 'destination',\n );\n\n const executeDestinations = destination.map((plugin) => {\n const eventClone = { ...event };\n return plugin.execute(eventClone).catch((e) => buildResult(eventClone, 0, String(e)));\n });\n\n void Promise.all(executeDestinations).then(([result]) => {\n const resolveResult =\n result || buildResult(event, 100, 'Event not tracked, no destination plugins on the instance');\n resolve(resolveResult);\n });\n\n return;\n }\n\n async flush() {\n const queue = this.queue;\n this.queue = [];\n\n await Promise.all(queue.map((item) => this.apply(item)));\n\n const destination = this.plugins.filter<DestinationPlugin>(\n (plugin: Plugin): plugin is DestinationPlugin => plugin.type === 'destination',\n );\n\n const executeDestinations = destination.map((plugin) => {\n return plugin.flush && plugin.flush();\n });\n\n await Promise.all(executeDestinations);\n }\n}\n"]}
1
+ {"version":3,"file":"timeline.js","sourceRoot":"","sources":["../../src/timeline.ts"],"names":[],"mappings":";;;;AAMA,yDAAqD;AACrD,qCAAoC;AAEpC;IAQE,kBAAoB,MAAkB;QAAlB,W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AAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,UAAC,IAAI,IAAK,OAAA,KAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAhB,CAAgB,CAAC,CAAC,EAAA;;wBAAxD,SAAwD,CAAC;wBAEnD,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CACrC,UAAC,MAAc,IAAkC,OAAA,MAAM,CAAC,IAAI,KAAK,aAAa,EAA7B,CAA6B,CAC/E,CAAC;wBAEI,mBAAmB,GAAG,WAAW,CAAC,GAAG,CAAC,UAAC,MAAM;4BACjD,OAAO,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;wBACxC,CAAC,CAAC,CAAC;wBAEH,qBAAM,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,EAAA;;wBAAtC,SAAsC,CAAC;;;;;KACxC;IACH,eAAC;AAAD,CAAC,AApJD,IAoJC;AApJY,4BAAQ","sourcesContent":["import { BeforePlugin, DestinationPlugin, EnrichmentPlugin, Plugin } from './types/plugin';\nimport { CoreClient } from './core-client';\nimport { IConfig } from './config';\nimport { EventCallback } from './types/event-callback';\nimport { Event } from './types/event/event';\nimport { Result } from './types/result';\nimport { buildResult } from './utils/result-builder';\nimport { UUID } from './utils/uuid';\n\nexport class Timeline {\n queue: [Event, EventCallback][] = [];\n // Flag to guarantee one schedule apply is running\n applying = false;\n // Flag indicates whether timeline is ready to process event\n // Events collected before timeline is ready will stay in the queue to be processed later\n plugins: Plugin[] = [];\n\n constructor(private client: CoreClient) {}\n\n async register(plugin: Plugin, config: IConfig) {\n if (this.plugins.some((existingPlugin) => existingPlugin.name === plugin.name)) {\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n config.loggerProvider.warn(`Plugin with name ${plugin.name} already exists, skipping registration`);\n return;\n }\n\n if (plugin.name === undefined) {\n plugin.name = UUID();\n config.loggerProvider.warn(`Plugin name is undefined. \n Generating a random UUID for plugin name: ${plugin.name}. \n Set a name for the plugin to prevent it from being added multiple times.`);\n }\n\n plugin.type = plugin.type ?? 'enrichment';\n await plugin.setup?.(config, this.client);\n this.plugins.push(plugin);\n }\n\n async deregister(pluginName: string, config: IConfig) {\n const index = this.plugins.findIndex((plugin) => plugin.name === pluginName);\n if (index === -1) {\n config.loggerProvider.warn(`Plugin with name ${pluginName} does not exist, skipping deregistration`);\n return;\n }\n const plugin = this.plugins[index];\n this.plugins.splice(index, 1);\n await plugin.teardown?.();\n }\n\n reset(client: CoreClient) {\n this.applying = false;\n const plugins = this.plugins;\n plugins.map((plugin) => plugin.teardown?.());\n this.plugins = [];\n this.client = client;\n }\n\n push(event: Event) {\n return new Promise<Result>((resolve) => {\n this.queue.push([event, resolve]);\n this.scheduleApply(0);\n });\n }\n\n scheduleApply(timeout: number) {\n if (this.applying) return;\n this.applying = true;\n setTimeout(() => {\n void this.apply(this.queue.shift()).then(() => {\n this.applying = false;\n if (this.queue.length > 0) {\n this.scheduleApply(0);\n }\n });\n }, timeout);\n }\n\n async apply(item: [Event, EventCallback] | undefined) {\n if (!item) {\n return;\n }\n\n let [event] = item;\n const [, resolve] = item;\n\n const before = this.plugins.filter<BeforePlugin>(\n (plugin: Plugin): plugin is BeforePlugin => plugin.type === 'before',\n );\n\n for (const plugin of before) {\n /* istanbul ignore if */\n if (!plugin.execute) {\n // do nothing\n continue;\n }\n const e = await plugin.execute({ ...event });\n if (e === null) {\n resolve({ event, code: 0, message: '' });\n return;\n } else {\n event = e;\n }\n }\n\n const enrichment = this.plugins.filter<EnrichmentPlugin>(\n (plugin: Plugin): plugin is EnrichmentPlugin => plugin.type === 'enrichment' || plugin.type === undefined,\n );\n\n for (const plugin of enrichment) {\n /* istanbul ignore if */\n if (!plugin.execute) {\n // do nothing\n continue;\n }\n const e = await plugin.execute({ ...event });\n if (e === null) {\n resolve({ event, code: 0, message: '' });\n return;\n } else {\n event = e;\n }\n }\n\n const destination = this.plugins.filter<DestinationPlugin>(\n (plugin: Plugin): plugin is DestinationPlugin => plugin.type === 'destination',\n );\n\n const executeDestinations = destination.map((plugin) => {\n const eventClone = { ...event };\n return plugin.execute(eventClone).catch((e) => buildResult(eventClone, 0, String(e)));\n });\n\n void Promise.all(executeDestinations).then(([result]) => {\n const resolveResult =\n result || buildResult(event, 100, 'Event not tracked, no destination plugins on the instance');\n resolve(resolveResult);\n });\n\n return;\n }\n\n async flush() {\n const queue = this.queue;\n this.queue = [];\n\n await Promise.all(queue.map((item) => this.apply(item)));\n\n const destination = this.plugins.filter<DestinationPlugin>(\n (plugin: Plugin): plugin is DestinationPlugin => plugin.type === 'destination',\n );\n\n const executeDestinations = destination.map((plugin) => {\n return plugin.flush && plugin.flush();\n });\n\n await Promise.all(executeDestinations);\n }\n}\n"]}
@@ -1,4 +1,7 @@
1
- import { Payload, Response, Status, Transport } from '@amplitude/analytics-types';
1
+ import { Transport } from '../types/transport';
2
+ import { Status } from '../types/status';
3
+ import { Payload } from '../types/payload';
4
+ import { Response } from '../types/response';
2
5
  export declare class BaseTransport implements Transport {
3
6
  send(_serverUrl: string, _payload: Payload): Promise<Response | null>;
4
7
  buildResponse(responseJSON: Record<string, any>): Response | null;
@@ -1 +1 @@
1
- {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/transports/base.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAElF,qBAAa,aAAc,YAAW,SAAS;IAC7C,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAIrE,aAAa,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,QAAQ,GAAG,IAAI;IAqEjE,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CA2BlC"}
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/transports/base.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,qBAAa,aAAc,YAAW,SAAS;IAC7C,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAIrE,aAAa,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,QAAQ,GAAG,IAAI;IAqEjE,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CA2BlC"}
@@ -1,10 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BaseTransport = void 0;
4
- /* eslint-disable @typescript-eslint/no-unsafe-argument */
5
- /* eslint-disable @typescript-eslint/no-unsafe-assignment */
6
- /* eslint-disable @typescript-eslint/no-unsafe-call */
7
- var analytics_types_1 = require("@amplitude/analytics-types");
4
+ var status_1 = require("../types/status");
8
5
  var BaseTransport = /** @class */ (function () {
9
6
  function BaseTransport() {
10
7
  }
@@ -19,7 +16,7 @@ var BaseTransport = /** @class */ (function () {
19
16
  var statusCode = responseJSON.code || 0;
20
17
  var status = this.buildStatus(statusCode);
21
18
  switch (status) {
22
- case analytics_types_1.Status.Success:
19
+ case status_1.Status.Success:
23
20
  return {
24
21
  status: status,
25
22
  statusCode: statusCode,
@@ -29,7 +26,7 @@ var BaseTransport = /** @class */ (function () {
29
26
  serverUploadTime: (_c = responseJSON.server_upload_time) !== null && _c !== void 0 ? _c : 0,
30
27
  },
31
28
  };
32
- case analytics_types_1.Status.Invalid:
29
+ case status_1.Status.Invalid:
33
30
  return {
34
31
  status: status,
35
32
  statusCode: statusCode,
@@ -47,7 +44,7 @@ var BaseTransport = /** @class */ (function () {
47
44
  throttledEvents: (_p = responseJSON.throttled_events) !== null && _p !== void 0 ? _p : [],
48
45
  },
49
46
  };
50
- case analytics_types_1.Status.PayloadTooLarge:
47
+ case status_1.Status.PayloadTooLarge:
51
48
  return {
52
49
  status: status,
53
50
  statusCode: statusCode,
@@ -55,7 +52,7 @@ var BaseTransport = /** @class */ (function () {
55
52
  error: (_q = responseJSON.error) !== null && _q !== void 0 ? _q : '',
56
53
  },
57
54
  };
58
- case analytics_types_1.Status.RateLimit:
55
+ case status_1.Status.RateLimit:
59
56
  return {
60
57
  status: status,
61
58
  statusCode: statusCode,
@@ -69,7 +66,7 @@ var BaseTransport = /** @class */ (function () {
69
66
  throttledEvents: (_x = responseJSON.throttled_events) !== null && _x !== void 0 ? _x : [],
70
67
  },
71
68
  };
72
- case analytics_types_1.Status.Timeout:
69
+ case status_1.Status.Timeout:
73
70
  default:
74
71
  return {
75
72
  status: status,
@@ -79,24 +76,24 @@ var BaseTransport = /** @class */ (function () {
79
76
  };
80
77
  BaseTransport.prototype.buildStatus = function (code) {
81
78
  if (code >= 200 && code < 300) {
82
- return analytics_types_1.Status.Success;
79
+ return status_1.Status.Success;
83
80
  }
84
81
  if (code === 429) {
85
- return analytics_types_1.Status.RateLimit;
82
+ return status_1.Status.RateLimit;
86
83
  }
87
84
  if (code === 413) {
88
- return analytics_types_1.Status.PayloadTooLarge;
85
+ return status_1.Status.PayloadTooLarge;
89
86
  }
90
87
  if (code === 408) {
91
- return analytics_types_1.Status.Timeout;
88
+ return status_1.Status.Timeout;
92
89
  }
93
90
  if (code >= 400 && code < 500) {
94
- return analytics_types_1.Status.Invalid;
91
+ return status_1.Status.Invalid;
95
92
  }
96
93
  if (code >= 500) {
97
- return analytics_types_1.Status.Failed;
94
+ return status_1.Status.Failed;
98
95
  }
99
- return analytics_types_1.Status.Unknown;
96
+ return status_1.Status.Unknown;
100
97
  };
101
98
  return BaseTransport;
102
99
  }());
@@ -1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;QACtB,IAAI,IAAI,IAAI,GAAG,IAAI,IAAI,GAAG,GAAG,EAAE;YAC7B,OAAO,wBAAM,CAAC,OAAO,CAAC;SACvB;QAED,IAAI,IAAI,KAAK,GAAG,EAAE;YAChB,OAAO,wBAAM,CAAC,SAAS,CAAC;SACzB;QAED,IAAI,IAAI,KAAK,GAAG,EAAE;YAChB,OAAO,wBAAM,CAAC,eAAe,CAAC;SAC/B;QAED,IAAI,IAAI,KAAK,GAAG,EAAE;YAChB,OAAO,wBAAM,CAAC,OAAO,CAAC;SACvB;QAED,IAAI,IAAI,IAAI,GAAG,IAAI,IAAI,GAAG,GAAG,EAAE;YAC7B,OAAO,wBAAM,CAAC,OAAO,CAAC;SACvB;QAED,IAAI,IAAI,IAAI,GAAG,EAAE;YACf,OAAO,wBAAM,CAAC,MAAM,CAAC;SACtB;QAED,OAAO,wBAAM,CAAC,OAAO,CAAC;IACxB,CAAC;IACH,oBAAC;AAAD,CAAC,AArGD,IAqGC;AArGY,sCAAa","sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-argument */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable @typescript-eslint/no-unsafe-call */\nimport { Payload, Response, Status, Transport } from '@amplitude/analytics-types';\n\nexport class BaseTransport implements Transport {\n send(_serverUrl: string, _payload: Payload): Promise<Response | null> {\n return Promise.resolve(null);\n }\n\n buildResponse(responseJSON: Record<string, any>): Response | null {\n if (typeof responseJSON !== 'object') {\n return null;\n }\n\n const statusCode = responseJSON.code || 0;\n const status = this.buildStatus(statusCode);\n\n switch (status) {\n case Status.Success:\n return {\n status,\n statusCode,\n body: {\n eventsIngested: responseJSON.events_ingested ?? 0,\n payloadSizeBytes: responseJSON.payload_size_bytes ?? 0,\n serverUploadTime: responseJSON.server_upload_time ?? 0,\n },\n };\n\n case Status.Invalid:\n return {\n status,\n statusCode,\n body: {\n error: responseJSON.error ?? '',\n missingField: responseJSON.missing_field ?? '',\n eventsWithInvalidFields: responseJSON.events_with_invalid_fields ?? {},\n eventsWithMissingFields: responseJSON.events_with_missing_fields ?? {},\n eventsWithInvalidIdLengths: responseJSON.events_with_invalid_id_lengths ?? {},\n epsThreshold: responseJSON.eps_threshold ?? 0,\n exceededDailyQuotaDevices: responseJSON.exceeded_daily_quota_devices ?? {},\n silencedDevices: responseJSON.silenced_devices ?? [],\n silencedEvents: responseJSON.silenced_events ?? [],\n throttledDevices: responseJSON.throttled_devices ?? {},\n throttledEvents: responseJSON.throttled_events ?? [],\n },\n };\n case Status.PayloadTooLarge:\n return {\n status,\n statusCode,\n body: {\n error: responseJSON.error ?? '',\n },\n };\n case Status.RateLimit:\n return {\n status,\n statusCode,\n body: {\n error: responseJSON.error ?? '',\n epsThreshold: responseJSON.eps_threshold ?? 0,\n throttledDevices: responseJSON.throttled_devices ?? {},\n throttledUsers: responseJSON.throttled_users ?? {},\n exceededDailyQuotaDevices: responseJSON.exceeded_daily_quota_devices ?? {},\n exceededDailyQuotaUsers: responseJSON.exceeded_daily_quota_users ?? {},\n throttledEvents: responseJSON.throttled_events ?? [],\n },\n };\n case Status.Timeout:\n default:\n return {\n status,\n statusCode,\n };\n }\n }\n\n buildStatus(code: number): Status {\n if (code >= 200 && code < 300) {\n return Status.Success;\n }\n\n if (code === 429) {\n return Status.RateLimit;\n }\n\n if (code === 413) {\n return Status.PayloadTooLarge;\n }\n\n if (code === 408) {\n return Status.Timeout;\n }\n\n if (code >= 400 && code < 500) {\n return Status.Invalid;\n }\n\n if (code >= 500) {\n return Status.Failed;\n }\n\n return Status.Unknown;\n }\n}\n"]}
1
+ {"version":3,"file":"base.js","sourceRoot":"","sources":["../../../src/transports/base.ts"],"names":[],"mappings":";;;AAIA,0CAAyC;AAIzC;IAAA;IAqGA,CAAC;IApGC,4BAAI,GAAJ,UAAK,UAAkB,EAAE,QAAiB;QACxC,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED,qCAAa,GAAb,UAAc,YAAiC;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AAC,OAAO,CAAC;SACvB;QAED,IAAI,IAAI,IAAI,GAAG,IAAI,IAAI,GAAG,GAAG,EAAE;YAC7B,OAAO,eAAM,CAAC,OAAO,CAAC;SACvB;QAED,IAAI,IAAI,IAAI,GAAG,EAAE;YACf,OAAO,eAAM,CAAC,MAAM,CAAC;SACtB;QAED,OAAO,eAAM,CAAC,OAAO,CAAC;IACxB,CAAC;IACH,oBAAC;AAAD,CAAC,AArGD,IAqGC;AArGY,sCAAa","sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-argument */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable @typescript-eslint/no-unsafe-call */\nimport { Transport } from '../types/transport';\nimport { Status } from '../types/status';\nimport { Payload } from '../types/payload';\nimport { Response } from '../types/response';\n\nexport class BaseTransport implements Transport {\n send(_serverUrl: string, _payload: Payload): Promise<Response | null> {\n return Promise.resolve(null);\n }\n\n buildResponse(responseJSON: Record<string, any>): Response | null {\n if (typeof responseJSON !== 'object') {\n return null;\n }\n\n const statusCode = responseJSON.code || 0;\n const status = this.buildStatus(statusCode);\n\n switch (status) {\n case Status.Success:\n return {\n status,\n statusCode,\n body: {\n eventsIngested: responseJSON.events_ingested ?? 0,\n payloadSizeBytes: responseJSON.payload_size_bytes ?? 0,\n serverUploadTime: responseJSON.server_upload_time ?? 0,\n },\n };\n\n case Status.Invalid:\n return {\n status,\n statusCode,\n body: {\n error: responseJSON.error ?? '',\n missingField: responseJSON.missing_field ?? '',\n eventsWithInvalidFields: responseJSON.events_with_invalid_fields ?? {},\n eventsWithMissingFields: responseJSON.events_with_missing_fields ?? {},\n eventsWithInvalidIdLengths: responseJSON.events_with_invalid_id_lengths ?? {},\n epsThreshold: responseJSON.eps_threshold ?? 0,\n exceededDailyQuotaDevices: responseJSON.exceeded_daily_quota_devices ?? {},\n silencedDevices: responseJSON.silenced_devices ?? [],\n silencedEvents: responseJSON.silenced_events ?? [],\n throttledDevices: responseJSON.throttled_devices ?? {},\n throttledEvents: responseJSON.throttled_events ?? [],\n },\n };\n case Status.PayloadTooLarge:\n return {\n status,\n statusCode,\n body: {\n error: responseJSON.error ?? '',\n },\n };\n case Status.RateLimit:\n return {\n status,\n statusCode,\n body: {\n error: responseJSON.error ?? '',\n epsThreshold: responseJSON.eps_threshold ?? 0,\n throttledDevices: responseJSON.throttled_devices ?? {},\n throttledUsers: responseJSON.throttled_users ?? {},\n exceededDailyQuotaDevices: responseJSON.exceeded_daily_quota_devices ?? {},\n exceededDailyQuotaUsers: responseJSON.exceeded_daily_quota_users ?? {},\n throttledEvents: responseJSON.throttled_events ?? [],\n },\n };\n case Status.Timeout:\n default:\n return {\n status,\n statusCode,\n };\n }\n }\n\n buildStatus(code: number): Status {\n if (code >= 200 && code < 300) {\n return Status.Success;\n }\n\n if (code === 429) {\n return Status.RateLimit;\n }\n\n if (code === 413) {\n return Status.PayloadTooLarge;\n }\n\n if (code === 408) {\n return Status.Timeout;\n }\n\n if (code >= 400 && code < 500) {\n return Status.Invalid;\n }\n\n if (code >= 500) {\n return Status.Failed;\n }\n\n return Status.Unknown;\n }\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import { BaseTransport } from './base';
2
+ import { Transport } from '../types/transport';
3
+ import { Payload } from '../types/payload';
4
+ import { Response } from '../types/response';
5
+ export declare class FetchTransport extends BaseTransport implements Transport {
6
+ send(serverUrl: string, payload: Payload): Promise<Response | null>;
7
+ }
8
+ //# sourceMappingURL=fetch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../src/transports/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,qBAAa,cAAe,SAAQ,aAAc,YAAW,SAAS;IAC9D,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;CAsB1E"}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FetchTransport = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var base_1 = require("./base");
6
+ var FetchTransport = /** @class */ (function (_super) {
7
+ tslib_1.__extends(FetchTransport, _super);
8
+ function FetchTransport() {
9
+ return _super !== null && _super.apply(this, arguments) || this;
10
+ }
11
+ FetchTransport.prototype.send = function (serverUrl, payload) {
12
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
13
+ var options, response, responseText;
14
+ return tslib_1.__generator(this, function (_a) {
15
+ switch (_a.label) {
16
+ case 0:
17
+ /* istanbul ignore if */
18
+ if (typeof fetch === 'undefined') {
19
+ throw new Error('FetchTransport is not supported');
20
+ }
21
+ options = {
22
+ headers: {
23
+ 'Content-Type': 'application/json',
24
+ Accept: '*/*',
25
+ },
26
+ body: JSON.stringify(payload),
27
+ method: 'POST',
28
+ };
29
+ return [4 /*yield*/, fetch(serverUrl, options)];
30
+ case 1:
31
+ response = _a.sent();
32
+ return [4 /*yield*/, response.text()];
33
+ case 2:
34
+ responseText = _a.sent();
35
+ try {
36
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
37
+ return [2 /*return*/, this.buildResponse(JSON.parse(responseText))];
38
+ }
39
+ catch (_b) {
40
+ return [2 /*return*/, this.buildResponse({ code: response.status })];
41
+ }
42
+ return [2 /*return*/];
43
+ }
44
+ });
45
+ });
46
+ };
47
+ return FetchTransport;
48
+ }(base_1.BaseTransport));
49
+ exports.FetchTransport = FetchTransport;
50
+ //# sourceMappingURL=fetch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../../src/transports/fetch.ts"],"names":[],"mappings":";;;;AAAA,+BAAuC;AAKvC;IAAoC,0CAAa;IAAjD;;IAuBA,CAAC;IAtBO,6BAAI,GAAV,UAAW,SAAiB,EAAE,OAAgB;;;;;;wBAC5C,wBAAwB;wBACxB,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE;4BAChC,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;yBACpD;wBACK,OAAO,GAAgB;4BAC3B,OAAO,EAAE;gCACP,cAAc,EAAE,kBAAkB;gCAClC,MAAM,EAAE,KAAK;6BACd;4BACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;4BAC7B,MAAM,EAAE,MAAM;yBACf,CAAC;wBACe,qBAAM,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,EAAA;;wBAA1C,QAAQ,GAAG,SAA+B;wBAC3B,qBAAM,QAAQ,CAAC,IAAI,EAAE,EAAA;;wBAApC,YAAY,GAAG,SAAqB;wBAC1C,IAAI;4BACF,iEAAiE;4BACjE,sBAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,EAAC;yBACrD;wBAAC,WAAM;4BACN,sBAAO,IAAI,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAC;yBACtD;;;;;KACF;IACH,qBAAC;AAAD,CAAC,AAvBD,CAAoC,oBAAa,GAuBhD;AAvBY,wCAAc","sourcesContent":["import { BaseTransport } from './base';\nimport { Transport } from '../types/transport';\nimport { Payload } from '../types/payload';\nimport { Response } from '../types/response';\n\nexport class FetchTransport extends BaseTransport implements Transport {\n async send(serverUrl: string, payload: Payload): Promise<Response | null> {\n /* istanbul ignore if */\n if (typeof fetch === 'undefined') {\n throw new Error('FetchTransport is not supported');\n }\n const options: RequestInit = {\n headers: {\n 'Content-Type': 'application/json',\n Accept: '*/*',\n },\n body: JSON.stringify(payload),\n method: 'POST',\n };\n const response = await fetch(serverUrl, options);\n const responseText = await response.text();\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n return this.buildResponse(JSON.parse(responseText));\n } catch {\n return this.buildResponse({ code: response.status });\n }\n }\n}\n"]}