@amplitude/analytics-core 2.5.5 → 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 (403) hide show
  1. package/lib/cjs/__mocks__/logger.js +1 -0
  2. package/lib/cjs/__mocks__/logger.js.map +1 -1
  3. package/lib/cjs/analytics-connector.d.ts +5 -0
  4. package/lib/cjs/analytics-connector.d.ts.map +1 -0
  5. package/lib/cjs/analytics-connector.js +20 -0
  6. package/lib/cjs/analytics-connector.js.map +1 -0
  7. package/lib/cjs/config.d.ts +107 -3
  8. package/lib/cjs/config.d.ts.map +1 -1
  9. package/lib/cjs/config.js +4 -3
  10. package/lib/cjs/config.js.map +1 -1
  11. package/lib/cjs/cookie-name.d.ts +3 -0
  12. package/lib/cjs/cookie-name.d.ts.map +1 -0
  13. package/lib/cjs/cookie-name.js +15 -0
  14. package/lib/cjs/cookie-name.js.map +1 -0
  15. package/lib/cjs/core-client.d.ts +154 -14
  16. package/lib/cjs/core-client.d.ts.map +1 -1
  17. package/lib/cjs/core-client.js +2 -1
  18. package/lib/cjs/core-client.js.map +1 -1
  19. package/lib/cjs/event-bridge/event-bridge-channel.d.ts +4 -3
  20. package/lib/cjs/event-bridge/event-bridge-channel.d.ts.map +1 -1
  21. package/lib/cjs/event-bridge/event-bridge-channel.js +1 -0
  22. package/lib/cjs/event-bridge/event-bridge-channel.js.map +1 -1
  23. package/lib/cjs/event-bridge/event-bridge-container.d.ts +1 -1
  24. package/lib/cjs/event-bridge/event-bridge-container.d.ts.map +1 -1
  25. package/lib/cjs/event-bridge/event-bridge-container.js +1 -0
  26. package/lib/cjs/event-bridge/event-bridge-container.js.map +1 -1
  27. package/lib/cjs/event-bridge/event-bridge.d.ts +9 -2
  28. package/lib/cjs/event-bridge/event-bridge.d.ts.map +1 -1
  29. package/lib/cjs/event-bridge/event-bridge.js +1 -0
  30. package/lib/cjs/event-bridge/event-bridge.js.map +1 -1
  31. package/lib/cjs/global-scope.d.ts +2 -0
  32. package/lib/cjs/global-scope.d.ts.map +1 -0
  33. package/lib/cjs/global-scope.js +28 -0
  34. package/lib/cjs/global-scope.js.map +1 -0
  35. package/lib/cjs/identify.d.ts +48 -1
  36. package/lib/cjs/identify.d.ts.map +1 -1
  37. package/lib/cjs/identify.js +33 -16
  38. package/lib/cjs/identify.js.map +1 -1
  39. package/lib/cjs/index.d.ts +37 -8
  40. package/lib/cjs/index.d.ts.map +1 -1
  41. package/lib/cjs/index.js +40 -6
  42. package/lib/cjs/index.js.map +1 -1
  43. package/lib/cjs/language.d.ts +2 -0
  44. package/lib/cjs/language.d.ts.map +1 -0
  45. package/lib/cjs/language.js +13 -0
  46. package/lib/cjs/language.js.map +1 -0
  47. package/lib/cjs/logger.d.ts +27 -1
  48. package/lib/cjs/logger.d.ts.map +1 -1
  49. package/lib/cjs/logger.js +9 -8
  50. package/lib/cjs/logger.js.map +1 -1
  51. package/lib/cjs/plugins/destination.d.ts +20 -7
  52. package/lib/cjs/plugins/destination.d.ts.map +1 -1
  53. package/lib/cjs/plugins/destination.js +70 -56
  54. package/lib/cjs/plugins/destination.js.map +1 -1
  55. package/lib/cjs/plugins/identity.d.ts +11 -0
  56. package/lib/cjs/plugins/identity.d.ts.map +1 -0
  57. package/lib/cjs/plugins/identity.js +37 -0
  58. package/lib/cjs/plugins/identity.js.map +1 -0
  59. package/lib/cjs/query-params.d.ts +3 -0
  60. package/lib/cjs/query-params.d.ts.map +1 -0
  61. package/lib/cjs/query-params.js +36 -0
  62. package/lib/cjs/query-params.js.map +1 -0
  63. package/lib/cjs/revenue.d.ts +45 -1
  64. package/lib/cjs/revenue.d.ts.map +1 -1
  65. package/lib/cjs/revenue.js +33 -7
  66. package/lib/cjs/revenue.js.map +1 -1
  67. package/lib/cjs/session.d.ts +2 -0
  68. package/lib/cjs/session.d.ts.map +1 -0
  69. package/lib/cjs/session.js +11 -0
  70. package/lib/cjs/session.js.map +1 -0
  71. package/lib/cjs/storage/cookie.d.ts +13 -0
  72. package/lib/cjs/storage/cookie.d.ts.map +1 -0
  73. package/lib/cjs/storage/cookie.js +172 -0
  74. package/lib/cjs/storage/cookie.js.map +1 -0
  75. package/lib/cjs/storage/helpers.d.ts +2 -0
  76. package/lib/cjs/storage/helpers.d.ts.map +1 -0
  77. package/lib/cjs/storage/helpers.js +11 -0
  78. package/lib/cjs/storage/helpers.js.map +1 -0
  79. package/lib/cjs/storage/memory.d.ts +1 -1
  80. package/lib/cjs/storage/memory.d.ts.map +1 -1
  81. package/lib/cjs/storage/memory.js +1 -0
  82. package/lib/cjs/storage/memory.js.map +1 -1
  83. package/lib/cjs/timeline.d.ts +8 -3
  84. package/lib/cjs/timeline.d.ts.map +1 -1
  85. package/lib/cjs/timeline.js +1 -0
  86. package/lib/cjs/timeline.js.map +1 -1
  87. package/lib/cjs/transports/base.d.ts +4 -1
  88. package/lib/cjs/transports/base.d.ts.map +1 -1
  89. package/lib/cjs/transports/base.js +14 -16
  90. package/lib/cjs/transports/base.js.map +1 -1
  91. package/lib/cjs/transports/fetch.d.ts +8 -0
  92. package/lib/cjs/transports/fetch.d.ts.map +1 -0
  93. package/lib/cjs/transports/fetch.js +50 -0
  94. package/lib/cjs/transports/fetch.js.map +1 -0
  95. package/lib/cjs/types/browser-client.d.ts +131 -0
  96. package/lib/cjs/types/browser-client.d.ts.map +1 -0
  97. package/lib/cjs/types/browser-client.js +3 -0
  98. package/lib/cjs/types/browser-client.js.map +1 -0
  99. package/lib/cjs/types/browser-config.d.ts +216 -0
  100. package/lib/cjs/types/browser-config.d.ts.map +1 -0
  101. package/lib/cjs/types/browser-config.js +3 -0
  102. package/lib/cjs/types/browser-config.js.map +1 -0
  103. package/lib/cjs/types/constants.d.ts.map +1 -0
  104. package/lib/cjs/{constants.js → types/constants.js} +1 -0
  105. package/lib/cjs/types/constants.js.map +1 -0
  106. package/lib/cjs/types/element-interactions.d.ts +73 -0
  107. package/lib/cjs/types/element-interactions.d.ts.map +1 -0
  108. package/lib/cjs/types/element-interactions.js +34 -0
  109. package/lib/cjs/types/element-interactions.js.map +1 -0
  110. package/lib/cjs/types/event/base-event.d.ts +64 -0
  111. package/lib/cjs/types/event/base-event.d.ts.map +1 -0
  112. package/lib/cjs/types/event/base-event.js +3 -0
  113. package/lib/cjs/types/event/base-event.js.map +1 -0
  114. package/lib/cjs/types/event/event.d.ts +68 -0
  115. package/lib/cjs/types/event/event.d.ts.map +1 -0
  116. package/lib/cjs/types/event/event.js +31 -0
  117. package/lib/cjs/types/event/event.js.map +1 -0
  118. package/lib/cjs/types/event/ingestion-metadata.d.ts +19 -0
  119. package/lib/cjs/types/event/ingestion-metadata.d.ts.map +1 -0
  120. package/lib/cjs/types/event/ingestion-metadata.js +3 -0
  121. package/lib/cjs/types/event/ingestion-metadata.js.map +1 -0
  122. package/lib/cjs/types/event/plan.d.ts +14 -0
  123. package/lib/cjs/types/event/plan.d.ts.map +1 -0
  124. package/lib/cjs/types/event/plan.js +3 -0
  125. package/lib/cjs/types/event/plan.js.map +1 -0
  126. package/lib/cjs/types/event-callback.d.ts +3 -0
  127. package/lib/cjs/types/event-callback.d.ts.map +1 -0
  128. package/lib/cjs/types/event-callback.js +3 -0
  129. package/lib/cjs/types/event-callback.js.map +1 -0
  130. package/lib/cjs/types/loglevel.d.ts +8 -0
  131. package/lib/cjs/types/loglevel.d.ts.map +1 -0
  132. package/lib/cjs/types/loglevel.js +12 -0
  133. package/lib/cjs/types/loglevel.js.map +1 -0
  134. package/lib/cjs/types/messages.d.ts.map +1 -0
  135. package/lib/cjs/{messages.js → types/messages.js} +1 -0
  136. package/lib/cjs/types/messages.js.map +1 -0
  137. package/lib/cjs/types/offline.d.ts +2 -0
  138. package/lib/cjs/types/offline.d.ts.map +1 -0
  139. package/lib/cjs/types/offline.js +5 -0
  140. package/lib/cjs/types/offline.js.map +1 -0
  141. package/lib/cjs/types/page-view-tracking.d.ts +9 -0
  142. package/lib/cjs/types/page-view-tracking.d.ts.map +1 -0
  143. package/lib/cjs/types/page-view-tracking.js +3 -0
  144. package/lib/cjs/types/page-view-tracking.js.map +1 -0
  145. package/lib/cjs/types/payload.d.ts +13 -0
  146. package/lib/cjs/types/payload.d.ts.map +1 -0
  147. package/lib/cjs/types/payload.js +3 -0
  148. package/lib/cjs/types/payload.js.map +1 -0
  149. package/lib/cjs/types/plugin.d.ts +30 -0
  150. package/lib/cjs/types/plugin.d.ts.map +1 -0
  151. package/lib/cjs/types/plugin.js +3 -0
  152. package/lib/cjs/types/plugin.js.map +1 -0
  153. package/lib/cjs/types/response.d.ts +81 -0
  154. package/lib/cjs/types/response.d.ts.map +1 -0
  155. package/lib/cjs/types/response.js +3 -0
  156. package/lib/cjs/types/response.js.map +1 -0
  157. package/lib/cjs/types/result.d.ts +7 -0
  158. package/lib/cjs/types/result.d.ts.map +1 -0
  159. package/lib/cjs/types/result.js +3 -0
  160. package/lib/cjs/types/result.js.map +1 -0
  161. package/lib/cjs/types/server-zone.d.ts +9 -0
  162. package/lib/cjs/types/server-zone.d.ts.map +1 -0
  163. package/lib/cjs/types/server-zone.js +12 -0
  164. package/lib/cjs/types/server-zone.js.map +1 -0
  165. package/lib/cjs/types/status.d.ts +22 -0
  166. package/lib/cjs/types/status.d.ts.map +1 -0
  167. package/lib/cjs/types/status.js +26 -0
  168. package/lib/cjs/types/status.js.map +1 -0
  169. package/lib/cjs/types/storage.d.ts +16 -0
  170. package/lib/cjs/types/storage.d.ts.map +1 -0
  171. package/lib/cjs/types/storage.js +3 -0
  172. package/lib/cjs/types/storage.js.map +1 -0
  173. package/lib/cjs/types/transport.d.ts +7 -0
  174. package/lib/cjs/types/transport.d.ts.map +1 -0
  175. package/lib/cjs/types/transport.js +3 -0
  176. package/lib/cjs/types/transport.js.map +1 -0
  177. package/lib/cjs/types/user-session.d.ts +11 -0
  178. package/lib/cjs/types/user-session.d.ts.map +1 -0
  179. package/lib/cjs/types/user-session.js +3 -0
  180. package/lib/cjs/types/user-session.js.map +1 -0
  181. package/lib/cjs/utils/chunk.js +1 -0
  182. package/lib/cjs/utils/chunk.js.map +1 -1
  183. package/lib/cjs/utils/debug.d.ts +1 -1
  184. package/lib/cjs/utils/debug.d.ts.map +1 -1
  185. package/lib/cjs/utils/debug.js +3 -6
  186. package/lib/cjs/utils/debug.js.map +1 -1
  187. package/lib/cjs/utils/event-builder.d.ts +5 -2
  188. package/lib/cjs/utils/event-builder.d.ts.map +1 -1
  189. package/lib/cjs/utils/event-builder.js +6 -5
  190. package/lib/cjs/utils/event-builder.js.map +1 -1
  191. package/lib/cjs/utils/result-builder.d.ts +2 -1
  192. package/lib/cjs/utils/result-builder.d.ts.map +1 -1
  193. package/lib/cjs/utils/result-builder.js +3 -2
  194. package/lib/cjs/utils/result-builder.js.map +1 -1
  195. package/lib/cjs/utils/return-wrapper.d.ts +3 -1
  196. package/lib/cjs/utils/return-wrapper.d.ts.map +1 -1
  197. package/lib/cjs/utils/return-wrapper.js +1 -0
  198. package/lib/cjs/utils/return-wrapper.js.map +1 -1
  199. package/lib/cjs/utils/uuid.js +1 -0
  200. package/lib/cjs/utils/uuid.js.map +1 -1
  201. package/lib/cjs/utils/valid-properties.js +1 -0
  202. package/lib/cjs/utils/valid-properties.js.map +1 -1
  203. package/lib/esm/analytics-connector.d.ts +5 -0
  204. package/lib/esm/analytics-connector.d.ts.map +1 -0
  205. package/lib/esm/analytics-connector.js +14 -0
  206. package/lib/esm/analytics-connector.js.map +1 -0
  207. package/lib/esm/config.d.ts +107 -3
  208. package/lib/esm/config.d.ts.map +1 -1
  209. package/lib/esm/config.js +2 -2
  210. package/lib/esm/config.js.map +1 -1
  211. package/lib/esm/cookie-name.d.ts +3 -0
  212. package/lib/esm/cookie-name.d.ts.map +1 -0
  213. package/lib/esm/cookie-name.js +10 -0
  214. package/lib/esm/cookie-name.js.map +1 -0
  215. package/lib/esm/core-client.d.ts +154 -14
  216. package/lib/esm/core-client.d.ts.map +1 -1
  217. package/lib/esm/core-client.js +1 -1
  218. package/lib/esm/core-client.js.map +1 -1
  219. package/lib/esm/event-bridge/event-bridge-channel.d.ts +4 -3
  220. package/lib/esm/event-bridge/event-bridge-channel.d.ts.map +1 -1
  221. package/lib/esm/event-bridge/event-bridge-channel.js.map +1 -1
  222. package/lib/esm/event-bridge/event-bridge-container.d.ts +1 -1
  223. package/lib/esm/event-bridge/event-bridge-container.d.ts.map +1 -1
  224. package/lib/esm/event-bridge/event-bridge-container.js.map +1 -1
  225. package/lib/esm/event-bridge/event-bridge.d.ts +9 -2
  226. package/lib/esm/event-bridge/event-bridge.d.ts.map +1 -1
  227. package/lib/esm/event-bridge/event-bridge.js.map +1 -1
  228. package/lib/esm/global-scope.d.ts +2 -0
  229. package/lib/esm/global-scope.d.ts.map +1 -0
  230. package/lib/esm/global-scope.js +24 -0
  231. package/lib/esm/global-scope.js.map +1 -0
  232. package/lib/esm/identify.d.ts +48 -1
  233. package/lib/esm/identify.d.ts.map +1 -1
  234. package/lib/esm/identify.js +18 -2
  235. package/lib/esm/identify.js.map +1 -1
  236. package/lib/esm/index.d.ts +37 -8
  237. package/lib/esm/index.d.ts.map +1 -1
  238. package/lib/esm/index.js +16 -2
  239. package/lib/esm/index.js.map +1 -1
  240. package/lib/esm/language.d.ts +2 -0
  241. package/lib/esm/language.d.ts.map +1 -0
  242. package/lib/esm/language.js +9 -0
  243. package/lib/esm/language.js.map +1 -0
  244. package/lib/esm/logger.d.ts +27 -1
  245. package/lib/esm/logger.d.ts.map +1 -1
  246. package/lib/esm/logger.js +1 -1
  247. package/lib/esm/logger.js.map +1 -1
  248. package/lib/esm/plugins/destination.d.ts +20 -7
  249. package/lib/esm/plugins/destination.d.ts.map +1 -1
  250. package/lib/esm/plugins/destination.js +64 -51
  251. package/lib/esm/plugins/destination.js.map +1 -1
  252. package/lib/esm/plugins/identity.d.ts +11 -0
  253. package/lib/esm/plugins/identity.d.ts.map +1 -0
  254. package/lib/esm/plugins/identity.js +34 -0
  255. package/lib/esm/plugins/identity.js.map +1 -0
  256. package/lib/esm/query-params.d.ts +3 -0
  257. package/lib/esm/query-params.d.ts.map +1 -0
  258. package/lib/esm/query-params.js +31 -0
  259. package/lib/esm/query-params.js.map +1 -0
  260. package/lib/esm/revenue.d.ts +45 -1
  261. package/lib/esm/revenue.d.ts.map +1 -1
  262. package/lib/esm/revenue.js +26 -1
  263. package/lib/esm/revenue.js.map +1 -1
  264. package/lib/esm/session.d.ts +2 -0
  265. package/lib/esm/session.d.ts.map +1 -0
  266. package/lib/esm/session.js +7 -0
  267. package/lib/esm/session.js.map +1 -0
  268. package/lib/esm/storage/cookie.d.ts +13 -0
  269. package/lib/esm/storage/cookie.d.ts.map +1 -0
  270. package/lib/esm/storage/cookie.js +169 -0
  271. package/lib/esm/storage/cookie.js.map +1 -0
  272. package/lib/esm/storage/helpers.d.ts +2 -0
  273. package/lib/esm/storage/helpers.d.ts.map +1 -0
  274. package/lib/esm/storage/helpers.js +7 -0
  275. package/lib/esm/storage/helpers.js.map +1 -0
  276. package/lib/esm/storage/memory.d.ts +1 -1
  277. package/lib/esm/storage/memory.d.ts.map +1 -1
  278. package/lib/esm/storage/memory.js.map +1 -1
  279. package/lib/esm/timeline.d.ts +8 -3
  280. package/lib/esm/timeline.d.ts.map +1 -1
  281. package/lib/esm/timeline.js.map +1 -1
  282. package/lib/esm/transports/base.d.ts +4 -1
  283. package/lib/esm/transports/base.d.ts.map +1 -1
  284. package/lib/esm/transports/base.js +1 -4
  285. package/lib/esm/transports/base.js.map +1 -1
  286. package/lib/esm/transports/fetch.d.ts +8 -0
  287. package/lib/esm/transports/fetch.d.ts.map +1 -0
  288. package/lib/esm/transports/fetch.js +47 -0
  289. package/lib/esm/transports/fetch.js.map +1 -0
  290. package/lib/esm/types/browser-client.d.ts +131 -0
  291. package/lib/esm/types/browser-client.d.ts.map +1 -0
  292. package/lib/esm/types/browser-client.js +2 -0
  293. package/lib/esm/types/browser-client.js.map +1 -0
  294. package/lib/esm/types/browser-config.d.ts +216 -0
  295. package/lib/esm/types/browser-config.d.ts.map +1 -0
  296. package/lib/esm/types/browser-config.js +2 -0
  297. package/lib/esm/types/browser-config.js.map +1 -0
  298. package/lib/esm/types/constants.d.ts.map +1 -0
  299. package/lib/esm/types/constants.js.map +1 -0
  300. package/lib/esm/types/element-interactions.d.ts +73 -0
  301. package/lib/esm/types/element-interactions.d.ts.map +1 -0
  302. package/lib/esm/types/element-interactions.js +31 -0
  303. package/lib/esm/types/element-interactions.js.map +1 -0
  304. package/lib/esm/types/event/base-event.d.ts +64 -0
  305. package/lib/esm/types/event/base-event.d.ts.map +1 -0
  306. package/lib/esm/types/event/base-event.js +2 -0
  307. package/lib/esm/types/event/base-event.js.map +1 -0
  308. package/lib/esm/types/event/event.d.ts +68 -0
  309. package/lib/esm/types/event/event.d.ts.map +1 -0
  310. package/lib/esm/types/event/event.js +28 -0
  311. package/lib/esm/types/event/event.js.map +1 -0
  312. package/lib/esm/types/event/ingestion-metadata.d.ts +19 -0
  313. package/lib/esm/types/event/ingestion-metadata.d.ts.map +1 -0
  314. package/lib/esm/types/event/ingestion-metadata.js +2 -0
  315. package/lib/esm/types/event/ingestion-metadata.js.map +1 -0
  316. package/lib/esm/types/event/plan.d.ts +14 -0
  317. package/lib/esm/types/event/plan.d.ts.map +1 -0
  318. package/lib/esm/types/event/plan.js +2 -0
  319. package/lib/esm/types/event/plan.js.map +1 -0
  320. package/lib/esm/types/event-callback.d.ts +3 -0
  321. package/lib/esm/types/event-callback.d.ts.map +1 -0
  322. package/lib/esm/types/event-callback.js +2 -0
  323. package/lib/esm/types/event-callback.js.map +1 -0
  324. package/lib/esm/types/loglevel.d.ts +8 -0
  325. package/lib/esm/types/loglevel.d.ts.map +1 -0
  326. package/lib/esm/types/loglevel.js +9 -0
  327. package/lib/esm/types/loglevel.js.map +1 -0
  328. package/lib/esm/types/messages.d.ts.map +1 -0
  329. package/lib/esm/types/messages.js.map +1 -0
  330. package/lib/esm/types/offline.d.ts +2 -0
  331. package/lib/esm/types/offline.d.ts.map +1 -0
  332. package/lib/esm/types/offline.js +2 -0
  333. package/lib/esm/types/offline.js.map +1 -0
  334. package/lib/esm/types/page-view-tracking.d.ts +9 -0
  335. package/lib/esm/types/page-view-tracking.d.ts.map +1 -0
  336. package/lib/esm/types/page-view-tracking.js +2 -0
  337. package/lib/esm/types/page-view-tracking.js.map +1 -0
  338. package/lib/esm/types/payload.d.ts +13 -0
  339. package/lib/esm/types/payload.d.ts.map +1 -0
  340. package/lib/esm/types/payload.js +2 -0
  341. package/lib/esm/types/payload.js.map +1 -0
  342. package/lib/esm/types/plugin.d.ts +30 -0
  343. package/lib/esm/types/plugin.d.ts.map +1 -0
  344. package/lib/esm/types/plugin.js +2 -0
  345. package/lib/esm/types/plugin.js.map +1 -0
  346. package/lib/esm/types/response.d.ts +81 -0
  347. package/lib/esm/types/response.d.ts.map +1 -0
  348. package/lib/esm/types/response.js +2 -0
  349. package/lib/esm/types/response.js.map +1 -0
  350. package/lib/esm/types/result.d.ts +7 -0
  351. package/lib/esm/types/result.d.ts.map +1 -0
  352. package/lib/esm/types/result.js +2 -0
  353. package/lib/esm/types/result.js.map +1 -0
  354. package/lib/esm/types/server-zone.d.ts +9 -0
  355. package/lib/esm/types/server-zone.d.ts.map +1 -0
  356. package/lib/esm/types/server-zone.js +9 -0
  357. package/lib/esm/types/server-zone.js.map +1 -0
  358. package/lib/esm/types/status.d.ts +22 -0
  359. package/lib/esm/types/status.d.ts.map +1 -0
  360. package/lib/esm/types/status.js +23 -0
  361. package/lib/esm/types/status.js.map +1 -0
  362. package/lib/esm/types/storage.d.ts +16 -0
  363. package/lib/esm/types/storage.d.ts.map +1 -0
  364. package/lib/esm/types/storage.js +2 -0
  365. package/lib/esm/types/storage.js.map +1 -0
  366. package/lib/esm/types/transport.d.ts +7 -0
  367. package/lib/esm/types/transport.d.ts.map +1 -0
  368. package/lib/esm/types/transport.js +2 -0
  369. package/lib/esm/types/transport.js.map +1 -0
  370. package/lib/esm/types/user-session.d.ts +11 -0
  371. package/lib/esm/types/user-session.d.ts.map +1 -0
  372. package/lib/esm/types/user-session.js +2 -0
  373. package/lib/esm/types/user-session.js.map +1 -0
  374. package/lib/esm/utils/debug.d.ts +1 -1
  375. package/lib/esm/utils/debug.d.ts.map +1 -1
  376. package/lib/esm/utils/debug.js +1 -5
  377. package/lib/esm/utils/debug.js.map +1 -1
  378. package/lib/esm/utils/event-builder.d.ts +5 -2
  379. package/lib/esm/utils/event-builder.d.ts.map +1 -1
  380. package/lib/esm/utils/event-builder.js +1 -1
  381. package/lib/esm/utils/event-builder.js.map +1 -1
  382. package/lib/esm/utils/result-builder.d.ts +2 -1
  383. package/lib/esm/utils/result-builder.d.ts.map +1 -1
  384. package/lib/esm/utils/result-builder.js +1 -1
  385. package/lib/esm/utils/result-builder.js.map +1 -1
  386. package/lib/esm/utils/return-wrapper.d.ts +3 -1
  387. package/lib/esm/utils/return-wrapper.d.ts.map +1 -1
  388. package/lib/esm/utils/return-wrapper.js.map +1 -1
  389. package/package.json +2 -3
  390. package/lib/cjs/constants.d.ts.map +0 -1
  391. package/lib/cjs/constants.js.map +0 -1
  392. package/lib/cjs/messages.d.ts.map +0 -1
  393. package/lib/cjs/messages.js.map +0 -1
  394. package/lib/esm/constants.d.ts.map +0 -1
  395. package/lib/esm/constants.js.map +0 -1
  396. package/lib/esm/messages.d.ts.map +0 -1
  397. package/lib/esm/messages.js.map +0 -1
  398. /package/lib/cjs/{constants.d.ts → types/constants.d.ts} +0 -0
  399. /package/lib/cjs/{messages.d.ts → types/messages.d.ts} +0 -0
  400. /package/lib/esm/{constants.d.ts → types/constants.d.ts} +0 -0
  401. /package/lib/esm/{constants.js → types/constants.js} +0 -0
  402. /package/lib/esm/{messages.d.ts → types/messages.d.ts} +0 -0
  403. /package/lib/esm/{messages.js → types/messages.js} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"event-bridge-container.js","sourceRoot":"","sources":["../../../src/event-bridge/event-bridge-container.ts"],"names":[],"mappings":";;AACA,+CAA6C;AAE7C;IAAA;IAQA,CAAC;IANQ,gCAAW,GAAlB,UAAmB,YAAoB;QACrC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE;YACjC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,GAAG,IAAI,0BAAW,EAAE,CAAC;SAClD;QACD,OAAO,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;IACtC,CAAC;IANM,8BAAS,GAAiC,EAAE,CAAC;IAOtD,2BAAC;CAAA,AARD,IAQC;AARY,oDAAoB","sourcesContent":["import { EventBridge as IEventBridge } from '@amplitude/analytics-types';\nimport { EventBridge } from './event-bridge';\n\nexport class EventBridgeContainer {\n static instances: Record<string, IEventBridge> = {};\n static getInstance(instanceName: string): IEventBridge {\n if (!this.instances[instanceName]) {\n this.instances[instanceName] = new EventBridge();\n }\n return this.instances[instanceName];\n }\n}\n"]}
1
+ {"version":3,"file":"event-bridge-container.js","sourceRoot":"","sources":["../../../src/event-bridge/event-bridge-container.ts"],"names":[],"mappings":";;;AAAA,+CAA2D;AAE3D;IAAA;IAQA,CAAC;IANQ,gCAAW,GAAlB,UAAmB,YAAoB;QACrC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE;YACjC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,GAAG,IAAI,0BAAW,EAAE,CAAC;SAClD;QACD,OAAO,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;IACtC,CAAC;IANM,8BAAS,GAAiC,EAAE,CAAC;IAOtD,2BAAC;CAAA,AARD,IAQC;AARY,oDAAoB","sourcesContent":["import { EventBridge, IEventBridge } from './event-bridge';\n\nexport class EventBridgeContainer {\n static instances: Record<string, IEventBridge> = {};\n static getInstance(instanceName: string): IEventBridge {\n if (!this.instances[instanceName]) {\n this.instances[instanceName] = new EventBridge();\n }\n return this.instances[instanceName];\n }\n}\n"]}
@@ -1,8 +1,15 @@
1
- import { Event, EventBridgeReceiver, EventBridge as IEventBridge } from '@amplitude/analytics-types';
1
+ import { Event } from '../types/event/event';
2
2
  import { EventBridgeChannel } from './event-bridge-channel';
3
+ export interface IEventBridge {
4
+ sendEvent(channel: string, event: Event): void;
5
+ setReceiver(channel: string, receiver: IEventBridgeReceiver): void;
6
+ }
7
+ export interface IEventBridgeReceiver {
8
+ receive(channel: string, event: Event): void;
9
+ }
3
10
  export declare class EventBridge implements IEventBridge {
4
11
  eventBridgeChannels: Record<string, EventBridgeChannel | undefined>;
5
12
  sendEvent(channel: string, event: Event): void;
6
- setReceiver(channel: string, receiver: EventBridgeReceiver): void;
13
+ setReceiver(channel: string, receiver: IEventBridgeReceiver): void;
7
14
  }
8
15
  //# sourceMappingURL=event-bridge.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"event-bridge.d.ts","sourceRoot":"","sources":["../../../src/event-bridge/event-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,mBAAmB,EAAE,WAAW,IAAI,YAAY,EAAE,MAAM,4BAA4B,CAAC;AACrG,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,qBAAa,WAAY,YAAW,YAAY;IAC9C,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,GAAG,SAAS,CAAC,CAAM;IAEzE,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK;IAOvC,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,mBAAmB;CAM3D"}
1
+ {"version":3,"file":"event-bridge.d.ts","sourceRoot":"","sources":["../../../src/event-bridge/event-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,MAAM,WAAW,YAAY;IAC3B,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAC/C,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,oBAAoB,GAAG,IAAI,CAAC;CACpE;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CAC9C;AAED,qBAAa,WAAY,YAAW,YAAY;IAC9C,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,GAAG,SAAS,CAAC,CAAM;IAEzE,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK;IAOvC,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,oBAAoB;CAM5D"}
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  Object.defineProperty(exports, "__esModule", { value: true });
2
3
  exports.EventBridge = void 0;
3
4
  var event_bridge_channel_1 = require("./event-bridge-channel");
@@ -1 +1 @@
1
- {"version":3,"file":"event-bridge.js","sourceRoot":"","sources":["../../../src/event-bridge/event-bridge.ts"],"names":[],"mappings":";;AACA,+DAA4D;AAE5D;IAAA;QACE,wBAAmB,GAAmD,EAAE,CAAC;IAe3E,CAAC;IAbC,+BAAS,GAAT,UAAU,OAAe,EAAE,KAAY;QACrC,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,EAAE;YACtC,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,GAAG,IAAI,yCAAkB,CAAC,OAAO,CAAC,CAAC;SACrE;QACA,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAwB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC7E,CAAC;IAED,iCAAW,GAAX,UAAY,OAAe,EAAE,QAA6B;QACxD,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,EAAE;YACtC,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,GAAG,IAAI,yCAAkB,CAAC,OAAO,CAAC,CAAC;SACrE;QACA,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAwB,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IAClF,CAAC;IACH,kBAAC;AAAD,CAAC,AAhBD,IAgBC;AAhBY,kCAAW","sourcesContent":["import { Event, EventBridgeReceiver, EventBridge as IEventBridge } from '@amplitude/analytics-types';\nimport { EventBridgeChannel } from './event-bridge-channel';\n\nexport class EventBridge implements IEventBridge {\n eventBridgeChannels: Record<string, EventBridgeChannel | undefined> = {};\n\n sendEvent(channel: string, event: Event) {\n if (!this.eventBridgeChannels[channel]) {\n this.eventBridgeChannels[channel] = new EventBridgeChannel(channel);\n }\n (this.eventBridgeChannels[channel] as EventBridgeChannel).sendEvent(event);\n }\n\n setReceiver(channel: string, receiver: EventBridgeReceiver) {\n if (!this.eventBridgeChannels[channel]) {\n this.eventBridgeChannels[channel] = new EventBridgeChannel(channel);\n }\n (this.eventBridgeChannels[channel] as EventBridgeChannel).setReceiver(receiver);\n }\n}\n"]}
1
+ {"version":3,"file":"event-bridge.js","sourceRoot":"","sources":["../../../src/event-bridge/event-bridge.ts"],"names":[],"mappings":";;;AACA,+DAA4D;AAW5D;IAAA;QACE,wBAAmB,GAAmD,EAAE,CAAC;IAe3E,CAAC;IAbC,+BAAS,GAAT,UAAU,OAAe,EAAE,KAAY;QACrC,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,EAAE;YACtC,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,GAAG,IAAI,yCAAkB,CAAC,OAAO,CAAC,CAAC;SACrE;QACA,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAwB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC7E,CAAC;IAED,iCAAW,GAAX,UAAY,OAAe,EAAE,QAA8B;QACzD,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,EAAE;YACtC,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,GAAG,IAAI,yCAAkB,CAAC,OAAO,CAAC,CAAC;SACrE;QACA,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAwB,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IAClF,CAAC;IACH,kBAAC;AAAD,CAAC,AAhBD,IAgBC;AAhBY,kCAAW","sourcesContent":["import { Event } from '../types/event/event';\nimport { EventBridgeChannel } from './event-bridge-channel';\n\nexport interface IEventBridge {\n sendEvent(channel: string, event: Event): void;\n setReceiver(channel: string, receiver: IEventBridgeReceiver): void;\n}\n\nexport interface IEventBridgeReceiver {\n receive(channel: string, event: Event): void;\n}\n\nexport class EventBridge implements IEventBridge {\n eventBridgeChannels: Record<string, EventBridgeChannel | undefined> = {};\n\n sendEvent(channel: string, event: Event) {\n if (!this.eventBridgeChannels[channel]) {\n this.eventBridgeChannels[channel] = new EventBridgeChannel(channel);\n }\n (this.eventBridgeChannels[channel] as EventBridgeChannel).sendEvent(event);\n }\n\n setReceiver(channel: string, receiver: IEventBridgeReceiver) {\n if (!this.eventBridgeChannels[channel]) {\n this.eventBridgeChannels[channel] = new EventBridgeChannel(channel);\n }\n (this.eventBridgeChannels[channel] as EventBridgeChannel).setReceiver(receiver);\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export declare const getGlobalScope: () => typeof globalThis | undefined;
2
+ //# sourceMappingURL=global-scope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global-scope.d.ts","sourceRoot":"","sources":["../../src/global-scope.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,cAAc,QAAO,iBAAiB,GAAG,SAoBrD,CAAC"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ /* eslint-disable no-restricted-globals */
3
+ /* Only file allowed to access to globalThis, window, self */
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.getGlobalScope = void 0;
6
+ var getGlobalScope = function () {
7
+ // This should only be used for integrations with Amplitude that are not running in a browser environment
8
+ // We need to specify the name of the global variable as a string to prevent it from being minified
9
+ var ampIntegrationContextName = 'ampIntegrationContext';
10
+ if (typeof globalThis !== 'undefined' && typeof globalThis[ampIntegrationContextName] !== 'undefined') {
11
+ return globalThis[ampIntegrationContextName];
12
+ }
13
+ if (typeof globalThis !== 'undefined') {
14
+ return globalThis;
15
+ }
16
+ if (typeof window !== 'undefined') {
17
+ return window;
18
+ }
19
+ if (typeof self !== 'undefined') {
20
+ return self;
21
+ }
22
+ if (typeof global !== 'undefined') {
23
+ return global;
24
+ }
25
+ return undefined;
26
+ };
27
+ exports.getGlobalScope = getGlobalScope;
28
+ //# sourceMappingURL=global-scope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global-scope.js","sourceRoot":"","sources":["../../src/global-scope.ts"],"names":[],"mappings":";AAAA,0CAA0C;AAC1C,6DAA6D;;;AAEtD,IAAM,cAAc,GAAG;IAC5B,yGAAyG;IACzG,qGAAqG;IACrG,IAAM,yBAAyB,GAAG,uBAAkD,CAAC;IACrF,IAAI,OAAO,UAAU,KAAK,WAAW,IAAI,OAAO,UAAU,CAAC,yBAAyB,CAAC,KAAK,WAAW,EAAE;QACrG,OAAO,UAAU,CAAC,yBAAyB,CAAsB,CAAC;KACnE;IACD,IAAI,OAAO,UAAU,KAAK,WAAW,EAAE;QACrC,OAAO,UAAU,CAAC;KACnB;IACD,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QACjC,OAAO,MAAM,CAAC;KACf;IACD,IAAI,OAAO,IAAI,KAAK,WAAW,EAAE;QAC/B,OAAO,IAAI,CAAC;KACb;IACD,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QACjC,OAAO,MAAM,CAAC;KACf;IACD,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AApBW,QAAA,cAAc,kBAoBzB","sourcesContent":["/* eslint-disable no-restricted-globals */\n/* Only file allowed to access to globalThis, window, self */\n\nexport const getGlobalScope = (): typeof globalThis | undefined => {\n // This should only be used for integrations with Amplitude that are not running in a browser environment\n // We need to specify the name of the global variable as a string to prevent it from being minified\n const ampIntegrationContextName = 'ampIntegrationContext' as keyof typeof globalThis;\n if (typeof globalThis !== 'undefined' && typeof globalThis[ampIntegrationContextName] !== 'undefined') {\n return globalThis[ampIntegrationContextName] as typeof globalThis;\n }\n if (typeof globalThis !== 'undefined') {\n return globalThis;\n }\n if (typeof window !== 'undefined') {\n return window;\n }\n if (typeof self !== 'undefined') {\n return self;\n }\n if (typeof global !== 'undefined') {\n return global;\n }\n return undefined;\n};\n"]}
@@ -1,4 +1,16 @@
1
- import { IdentifyUserProperties, ValidPropertyType, Identify as IIdentify } from '@amplitude/analytics-types';
1
+ export interface IIdentify {
2
+ getUserProperties(): IdentifyUserProperties;
3
+ set(property: string, value: ValidPropertyType): IIdentify;
4
+ setOnce(property: string, value: ValidPropertyType): IIdentify;
5
+ append(property: string, value: ValidPropertyType): IIdentify;
6
+ prepend(property: string, value: ValidPropertyType): IIdentify;
7
+ postInsert(property: string, value: ValidPropertyType): IIdentify;
8
+ preInsert(property: string, value: ValidPropertyType): IIdentify;
9
+ remove(property: string, value: ValidPropertyType): IIdentify;
10
+ add(property: string, value: number): IIdentify;
11
+ unset(property: string): IIdentify;
12
+ clearAll(): IIdentify;
13
+ }
2
14
  export declare class Identify implements IIdentify {
3
15
  protected readonly _propertySet: Set<string>;
4
16
  protected _properties: IdentifyUserProperties;
@@ -16,4 +28,39 @@ export declare class Identify implements IIdentify {
16
28
  private _safeSet;
17
29
  private _validate;
18
30
  }
31
+ export type ValidPropertyType = number | string | boolean | Array<string | number> | {
32
+ [key: string]: ValidPropertyType;
33
+ } | Array<{
34
+ [key: string]: ValidPropertyType;
35
+ }>;
36
+ interface BaseOperationConfig {
37
+ [key: string]: ValidPropertyType;
38
+ }
39
+ export interface IdentifyUserProperties {
40
+ [IdentifyOperation.ADD]?: {
41
+ [key: string]: number;
42
+ };
43
+ [IdentifyOperation.UNSET]?: BaseOperationConfig;
44
+ [IdentifyOperation.CLEAR_ALL]?: any;
45
+ [IdentifyOperation.SET]?: BaseOperationConfig;
46
+ [IdentifyOperation.SET_ONCE]?: BaseOperationConfig;
47
+ [IdentifyOperation.APPEND]?: BaseOperationConfig;
48
+ [IdentifyOperation.PREPEND]?: BaseOperationConfig;
49
+ [IdentifyOperation.POSTINSERT]?: BaseOperationConfig;
50
+ [IdentifyOperation.PREINSERT]?: BaseOperationConfig;
51
+ [IdentifyOperation.REMOVE]?: BaseOperationConfig;
52
+ }
53
+ export declare enum IdentifyOperation {
54
+ SET = "$set",
55
+ SET_ONCE = "$setOnce",
56
+ ADD = "$add",
57
+ APPEND = "$append",
58
+ PREPEND = "$prepend",
59
+ REMOVE = "$remove",
60
+ PREINSERT = "$preInsert",
61
+ POSTINSERT = "$postInsert",
62
+ UNSET = "$unset",
63
+ CLEAR_ALL = "$clearAll"
64
+ }
65
+ export {};
19
66
  //# sourceMappingURL=identify.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"identify.d.ts","sourceRoot":"","sources":["../../src/identify.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,sBAAsB,EACtB,iBAAiB,EACjB,QAAQ,IAAI,SAAS,EACtB,MAAM,4BAA4B,CAAC;AAIpC,qBAAa,QAAS,YAAW,SAAS;IACxC,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,CAAqB;IACjE,SAAS,CAAC,WAAW,EAAE,sBAAsB,CAAM;IAE5C,iBAAiB,IAAI,sBAAsB;IAI3C,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,GAAG,QAAQ;IAKzD,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,GAAG,QAAQ;IAK7D,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,GAAG,QAAQ;IAK5D,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,GAAG,QAAQ;IAK7D,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE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CAAE,CAAC,CAAC;AAEhD,UAAU,mBAAmB;IAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB,CAAC;CAClC;AAED,MAAM,WAAW,sBAAsB;IAErC,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAGpD,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,EAAE,mBAAmB,CAAC;IAEhD,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC;IAGpC,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,EAAE,mBAAmB,CAAC;IAC9C,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,EAAE,mBAAmB,CAAC;IACnD,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,EAAE,mBAAmB,CAAC;IACjD,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,EAAE,mBAAmB,CAAC;IAClD,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC,EAAE,mBAAmB,CAAC;IACrD,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC,EAAE,mBAAmB,CAAC;IACpD,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,EAAE,mBAAmB,CAAC;CAClD;AAED,oBAAY,iBAAiB;IAE3B,GAAG,SAAS;IACZ,QAAQ,aAAa;IAGrB,GAAG,SAAS;IACZ,MAAM,YAAY;IAClB,OAAO,aAAa;IACpB,MAAM,YAAY;IAGlB,SAAS,eAAe;IACxB,UAAU,gBAAgB;IAG1B,KAAK,WAAW;IAChB,SAAS,cAAc;CACxB"}
@@ -1,8 +1,8 @@
1
+ "use strict";
1
2
  Object.defineProperty(exports, "__esModule", { value: true });
2
- exports.Identify = void 0;
3
+ exports.IdentifyOperation = exports.Identify = void 0;
3
4
  var tslib_1 = require("tslib");
4
- var analytics_types_1 = require("@amplitude/analytics-types");
5
- var constants_1 = require("./constants");
5
+ var constants_1 = require("./types/constants");
6
6
  var valid_properties_1 = require("./utils/valid-properties");
7
7
  var Identify = /** @class */ (function () {
8
8
  function Identify() {
@@ -13,45 +13,45 @@ var Identify = /** @class */ (function () {
13
13
  return tslib_1.__assign({}, this._properties);
14
14
  };
15
15
  Identify.prototype.set = function (property, value) {
16
- this._safeSet(analytics_types_1.IdentifyOperation.SET, property, value);
16
+ this._safeSet(IdentifyOperation.SET, property, value);
17
17
  return this;
18
18
  };
19
19
  Identify.prototype.setOnce = function (property, value) {
20
- this._safeSet(analytics_types_1.IdentifyOperation.SET_ONCE, property, value);
20
+ this._safeSet(IdentifyOperation.SET_ONCE, property, value);
21
21
  return this;
22
22
  };
23
23
  Identify.prototype.append = function (property, value) {
24
- this._safeSet(analytics_types_1.IdentifyOperation.APPEND, property, value);
24
+ this._safeSet(IdentifyOperation.APPEND, property, value);
25
25
  return this;
26
26
  };
27
27
  Identify.prototype.prepend = function (property, value) {
28
- this._safeSet(analytics_types_1.IdentifyOperation.PREPEND, property, value);
28
+ this._safeSet(IdentifyOperation.PREPEND, property, value);
29
29
  return this;
30
30
  };
31
31
  Identify.prototype.postInsert = function (property, value) {
32
- this._safeSet(analytics_types_1.IdentifyOperation.POSTINSERT, property, value);
32
+ this._safeSet(IdentifyOperation.POSTINSERT, property, value);
33
33
  return this;
34
34
  };
35
35
  Identify.prototype.preInsert = function (property, value) {
36
- this._safeSet(analytics_types_1.IdentifyOperation.PREINSERT, property, value);
36
+ this._safeSet(IdentifyOperation.PREINSERT, property, value);
37
37
  return this;
38
38
  };
39
39
  Identify.prototype.remove = function (property, value) {
40
- this._safeSet(analytics_types_1.IdentifyOperation.REMOVE, property, value);
40
+ this._safeSet(IdentifyOperation.REMOVE, property, value);
41
41
  return this;
42
42
  };
43
43
  Identify.prototype.add = function (property, value) {
44
- this._safeSet(analytics_types_1.IdentifyOperation.ADD, property, value);
44
+ this._safeSet(IdentifyOperation.ADD, property, value);
45
45
  return this;
46
46
  };
47
47
  Identify.prototype.unset = function (property) {
48
- this._safeSet(analytics_types_1.IdentifyOperation.UNSET, property, constants_1.UNSET_VALUE);
48
+ this._safeSet(IdentifyOperation.UNSET, property, constants_1.UNSET_VALUE);
49
49
  return this;
50
50
  };
51
51
  Identify.prototype.clearAll = function () {
52
52
  // When clear all happens, all properties are unset. Reset the entire object.
53
53
  this._properties = {};
54
- this._properties[analytics_types_1.IdentifyOperation.CLEAR_ALL] = constants_1.UNSET_VALUE;
54
+ this._properties[IdentifyOperation.CLEAR_ALL] = constants_1.UNSET_VALUE;
55
55
  return this;
56
56
  };
57
57
  // Returns whether or not this set actually worked.
@@ -72,7 +72,7 @@ var Identify = /** @class */ (function () {
72
72
  return false;
73
73
  };
74
74
  Identify.prototype._validate = function (operation, property, value) {
75
- if (this._properties[analytics_types_1.IdentifyOperation.CLEAR_ALL] !== undefined) {
75
+ if (this._properties[IdentifyOperation.CLEAR_ALL] !== undefined) {
76
76
  // clear all already set. Skipping operation;
77
77
  return false;
78
78
  }
@@ -80,10 +80,10 @@ var Identify = /** @class */ (function () {
80
80
  // Property already used. Skipping operation
81
81
  return false;
82
82
  }
83
- if (operation === analytics_types_1.IdentifyOperation.ADD) {
83
+ if (operation === IdentifyOperation.ADD) {
84
84
  return typeof value === 'number';
85
85
  }
86
- if (operation !== analytics_types_1.IdentifyOperation.UNSET && operation !== analytics_types_1.IdentifyOperation.REMOVE) {
86
+ if (operation !== IdentifyOperation.UNSET && operation !== IdentifyOperation.REMOVE) {
87
87
  return (0, valid_properties_1.isValidProperties)(property, value);
88
88
  }
89
89
  return true;
@@ -91,4 +91,21 @@ var Identify = /** @class */ (function () {
91
91
  return Identify;
92
92
  }());
93
93
  exports.Identify = Identify;
94
+ var IdentifyOperation;
95
+ (function (IdentifyOperation) {
96
+ // Base Operations to set values
97
+ IdentifyOperation["SET"] = "$set";
98
+ IdentifyOperation["SET_ONCE"] = "$setOnce";
99
+ // Operations around modifying existing values
100
+ IdentifyOperation["ADD"] = "$add";
101
+ IdentifyOperation["APPEND"] = "$append";
102
+ IdentifyOperation["PREPEND"] = "$prepend";
103
+ IdentifyOperation["REMOVE"] = "$remove";
104
+ // Operations around appending values *if* they aren't present
105
+ IdentifyOperation["PREINSERT"] = "$preInsert";
106
+ IdentifyOperation["POSTINSERT"] = "$postInsert";
107
+ // Operations around removing properties/values
108
+ IdentifyOperation["UNSET"] = "$unset";
109
+ IdentifyOperation["CLEAR_ALL"] = "$clearAll";
110
+ })(IdentifyOperation = exports.IdentifyOperation || (exports.IdentifyOperation = {}));
94
111
  //# sourceMappingURL=identify.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"identify.js","sourceRoot":"","sources":["../../src/identify.ts"],"names":[],"mappings":";;;AAAA,8DAKoC;AACpC,yCAA0C;AAC1C,6DAA6D;AAE7D;IAAA;QACqB,iBAAY,GAAgB,IAAI,GAAG,EAAU,CAAC;QACvD,gBAAW,GAA2B,EAAE,CAAC;IAmGrD,CAAC;IAjGQ,oCAAiB,GAAxB;QACE,4BAAY,IAAI,CAAC,WAAW,EAAG;IACjC,CAAC;IAEM,sBAAG,GAAV,UAAW,QAAgB,EAAE,KAAwB;QACnD,IAAI,CAAC,QAAQ,CAAC,mCAAiB,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;QACtD,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,0BAAO,GAAd,UAAe,QAAgB,EAAE,KAAwB;QACvD,IAAI,CAAC,QAAQ,CAAC,mCAAiB,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;QAC3D,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,yBAAM,GAAb,UAAc,QAAgB,EAAE,KAAwB;QACtD,IAAI,CAAC,QAAQ,CAAC,mCAAiB,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;QACzD,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,0BAAO,GAAd,UAAe,QAAgB,EAAE,KAAwB;Q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types';\nimport { UNSET_VALUE } from './constants';\nimport { isValidProperties } from './utils/valid-properties';\n\nexport class Identify implements IIdentify {\n protected readonly _propertySet: Set<string> = new Set<string>();\n protected _properties: IdentifyUserProperties = {};\n\n public getUserProperties(): IdentifyUserProperties {\n return { ...this._properties };\n }\n\n public set(property: string, value: ValidPropertyType): Identify {\n this._safeSet(IdentifyOperation.SET, property, value);\n return this;\n }\n\n public setOnce(property: string, value: ValidPropertyType): Identify {\n this._safeSet(IdentifyOperation.SET_ONCE, property, value);\n return this;\n }\n\n public append(property: string, value: ValidPropertyType): Identify {\n this._safeSet(IdentifyOperation.APPEND, property, value);\n return this;\n }\n\n public prepend(property: string, value: ValidPropertyType): Identify {\n this._safeSet(IdentifyOperation.PREPEND, property, value);\n return this;\n }\n\n public postInsert(property: string, value: ValidPropertyType): Identify {\n this._safeSet(IdentifyOperation.POSTINSERT, property, value);\n return this;\n }\n\n public preInsert(property: string, value: ValidPropertyType): Identify {\n this._safeSet(IdentifyOperation.PREINSERT, property, value);\n return this;\n }\n\n public remove(property: string, value: ValidPropertyType): Identify {\n this._safeSet(IdentifyOperation.REMOVE, property, value);\n return this;\n }\n\n public add(property: string, value: number): Identify {\n this._safeSet(IdentifyOperation.ADD, property, value);\n return this;\n }\n\n public unset(property: string): Identify {\n this._safeSet(IdentifyOperation.UNSET, property, UNSET_VALUE);\n return this;\n }\n\n public clearAll(): Identify {\n // When clear all happens, all properties are unset. Reset the entire object.\n this._properties = {};\n this._properties[IdentifyOperation.CLEAR_ALL] = UNSET_VALUE;\n\n return this;\n }\n\n // Returns whether or not this set actually worked.\n private _safeSet(operation: IdentifyOperation, property: string, value: ValidPropertyType): boolean {\n if (this._validate(operation, property, value)) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n let userPropertyMap: any = this._properties[operation];\n if (userPropertyMap === undefined) {\n userPropertyMap = {};\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n this._properties[operation] = userPropertyMap;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n userPropertyMap[property] = value;\n this._propertySet.add(property);\n return true;\n }\n\n return false;\n }\n\n private _validate(operation: IdentifyOperation, property: string, value: ValidPropertyType): boolean {\n if (this._properties[IdentifyOperation.CLEAR_ALL] !== undefined) {\n // clear all already set. Skipping operation;\n return false;\n }\n\n if (this._propertySet.has(property)) {\n // Property already used. Skipping operation\n return false;\n }\n\n if (operation === IdentifyOperation.ADD) {\n return typeof value === 'number';\n }\n\n if (operation !== IdentifyOperation.UNSET && operation !== IdentifyOperation.REMOVE) {\n return isValidProperties(property, value);\n }\n return true;\n }\n}\n"]}
1
+ {"version":3,"file":"identify.js","sourceRoot":"","sources":["../../src/identify.ts"],"names":[],"mappings":";;;;AAAA,+CAAgD;AAChD,6DAA6D;AAgB7D;IAAA;QACqB,iBAAY,GAAgB,IAAI,GAAG,EAAU,CAAC;QACvD,gBAAW,GAA2B,EAAE,CAAC;IAmGrD,CAAC;IAjGQ,oCAAiB,GAAxB;QACE,4BAAY,IAAI,CAAC,WAAW,EAAG;IACjC,CAAC;IAEM,sBAAG,GAAV,UAAW,QAAgB,EAAE,KAAwB;QACnD,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;QACtD,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,0BAAO,GAAd,UAAe,QAAgB,EAAE,KAAwB;QACvD,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;QAC3D,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,yBAAM,GAAb,UAAc,QAAgB,EAAE,KAAwB;QACtD,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;QACzD,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,0BAAO,GAAd,UAAe,QAAgB,EAAE,KAAwB;QACvD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qB,CAAA;IAErB,8CAA8C;IAC9C,iCAAY,CAAA;IACZ,uCAAkB,CAAA;IAClB,yCAAoB,CAAA;IACpB,uCAAkB,CAAA;IAElB,8DAA8D;IAC9D,6CAAwB,CAAA;IACxB,+CAA0B,CAAA;IAE1B,+CAA+C;IAC/C,qCAAgB,CAAA;IAChB,4CAAuB,CAAA;AACzB,CAAC,EAlBW,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAkB5B","sourcesContent":["import { UNSET_VALUE } from './types/constants';\nimport { isValidProperties } from './utils/valid-properties';\n\nexport interface IIdentify {\n getUserProperties(): IdentifyUserProperties;\n set(property: string, value: ValidPropertyType): IIdentify;\n setOnce(property: string, value: ValidPropertyType): IIdentify;\n append(property: string, value: ValidPropertyType): IIdentify;\n prepend(property: string, value: ValidPropertyType): IIdentify;\n postInsert(property: string, value: ValidPropertyType): IIdentify;\n preInsert(property: string, value: ValidPropertyType): IIdentify;\n remove(property: string, value: ValidPropertyType): IIdentify;\n add(property: string, value: number): IIdentify;\n unset(property: string): IIdentify;\n clearAll(): IIdentify;\n}\n\nexport class Identify implements IIdentify {\n protected readonly _propertySet: Set<string> = new Set<string>();\n protected _properties: IdentifyUserProperties = {};\n\n public getUserProperties(): IdentifyUserProperties {\n return { ...this._properties };\n }\n\n public set(property: string, value: ValidPropertyType): Identify {\n this._safeSet(IdentifyOperation.SET, property, value);\n return this;\n }\n\n public setOnce(property: string, value: ValidPropertyType): Identify {\n this._safeSet(IdentifyOperation.SET_ONCE, property, value);\n return this;\n }\n\n public append(property: string, value: ValidPropertyType): Identify {\n this._safeSet(IdentifyOperation.APPEND, property, value);\n return this;\n }\n\n public prepend(property: string, value: ValidPropertyType): Identify {\n this._safeSet(IdentifyOperation.PREPEND, property, value);\n return this;\n }\n\n public postInsert(property: string, value: ValidPropertyType): Identify {\n this._safeSet(IdentifyOperation.POSTINSERT, property, value);\n return this;\n }\n\n public preInsert(property: string, value: ValidPropertyType): Identify {\n this._safeSet(IdentifyOperation.PREINSERT, property, value);\n return this;\n }\n\n public remove(property: string, value: ValidPropertyType): Identify {\n this._safeSet(IdentifyOperation.REMOVE, property, value);\n return this;\n }\n\n public add(property: string, value: number): Identify {\n this._safeSet(IdentifyOperation.ADD, property, value);\n return this;\n }\n\n public unset(property: string): Identify {\n this._safeSet(IdentifyOperation.UNSET, property, UNSET_VALUE);\n return this;\n }\n\n public clearAll(): Identify {\n // When clear all happens, all properties are unset. Reset the entire object.\n this._properties = {};\n this._properties[IdentifyOperation.CLEAR_ALL] = UNSET_VALUE;\n\n return this;\n }\n\n // Returns whether or not this set actually worked.\n private _safeSet(operation: IdentifyOperation, property: string, value: ValidPropertyType): boolean {\n if (this._validate(operation, property, value)) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n let userPropertyMap: any = this._properties[operation];\n if (userPropertyMap === undefined) {\n userPropertyMap = {};\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n this._properties[operation] = userPropertyMap;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n userPropertyMap[property] = value;\n this._propertySet.add(property);\n return true;\n }\n\n return false;\n }\n\n private _validate(operation: IdentifyOperation, property: string, value: ValidPropertyType): boolean {\n if (this._properties[IdentifyOperation.CLEAR_ALL] !== undefined) {\n // clear all already set. Skipping operation;\n return false;\n }\n\n if (this._propertySet.has(property)) {\n // Property already used. Skipping operation\n return false;\n }\n\n if (operation === IdentifyOperation.ADD) {\n return typeof value === 'number';\n }\n\n if (operation !== IdentifyOperation.UNSET && operation !== IdentifyOperation.REMOVE) {\n return isValidProperties(property, value);\n }\n return true;\n }\n}\n\nexport type ValidPropertyType =\n | number\n | string\n | boolean\n | Array<string | number>\n | { [key: string]: ValidPropertyType }\n | Array<{ [key: string]: ValidPropertyType }>;\n\ninterface BaseOperationConfig {\n [key: string]: ValidPropertyType;\n}\n\nexport interface IdentifyUserProperties {\n // Add operations can only take numbers\n [IdentifyOperation.ADD]?: { [key: string]: number };\n\n // This reads the keys of the passed object, but the values are not used\n [IdentifyOperation.UNSET]?: BaseOperationConfig;\n // This option does not read the key as it unsets all user properties\n [IdentifyOperation.CLEAR_ALL]?: any;\n\n // These operations can take numbers, strings, or arrays of both.\n [IdentifyOperation.SET]?: BaseOperationConfig;\n [IdentifyOperation.SET_ONCE]?: BaseOperationConfig;\n [IdentifyOperation.APPEND]?: BaseOperationConfig;\n [IdentifyOperation.PREPEND]?: BaseOperationConfig;\n [IdentifyOperation.POSTINSERT]?: BaseOperationConfig;\n [IdentifyOperation.PREINSERT]?: BaseOperationConfig;\n [IdentifyOperation.REMOVE]?: BaseOperationConfig;\n}\n\nexport enum IdentifyOperation {\n // Base Operations to set values\n SET = '$set',\n SET_ONCE = '$setOnce',\n\n // Operations around modifying existing values\n ADD = '$add',\n APPEND = '$append',\n PREPEND = '$prepend',\n REMOVE = '$remove',\n\n // Operations around appending values *if* they aren't present\n PREINSERT = '$preInsert',\n POSTINSERT = '$postInsert',\n\n // Operations around removing properties/values\n UNSET = '$unset',\n CLEAR_ALL = '$clearAll',\n}\n"]}
@@ -1,14 +1,43 @@
1
- export { AmplitudeCore } from './core-client';
2
- export { Identify } from './identify';
3
- export { Revenue } from './revenue';
1
+ export { AmplitudeCore, CoreClient } from './core-client';
2
+ export { Identify, IIdentify } from './identify';
3
+ export { Revenue, IRevenue } from './revenue';
4
4
  export { Destination } from './plugins/destination';
5
- export { Config, RequestMetadata } from './config';
6
- export { Logger } from './logger';
7
- export { AMPLITUDE_PREFIX, STORAGE_PREFIX } from './constants';
8
- export { returnWrapper } from './utils/return-wrapper';
5
+ export { IdentityEventSender } from './plugins/identity';
6
+ export { IConfig, Config, RequestMetadata } from './config';
7
+ export { Logger, ILogger } from './logger';
8
+ export { getGlobalScope } from './global-scope';
9
+ export { getAnalyticsConnector, setConnectorDeviceId, setConnectorUserId } from './analytics-connector';
10
+ export { isNewSession } from './session';
11
+ export { getCookieName, getOldCookieName } from './cookie-name';
12
+ export { getLanguage } from './language';
13
+ export { getQueryParams } from './query-params';
14
+ export { returnWrapper, AmplitudeReturn } from './utils/return-wrapper';
9
15
  export { debugWrapper, getClientLogConfig, getClientStates } from './utils/debug';
10
16
  export { UUID } from './utils/uuid';
17
+ export { createIdentifyEvent } from './utils/event-builder';
11
18
  export { MemoryStorage } from './storage/memory';
19
+ export { CookieStorage } from './storage/cookie';
20
+ export { getStorageKey } from './storage/helpers';
12
21
  export { BaseTransport } from './transports/base';
13
- export { createIdentifyEvent } from './utils/event-builder';
22
+ export { FetchTransport } from './transports/fetch';
23
+ export { LogLevel } from './types/loglevel';
24
+ export { AMPLITUDE_PREFIX, STORAGE_PREFIX } from './types/constants';
25
+ export { Storage, IdentityStorageType } from './types/storage';
26
+ export { Event } from './types/event/event';
27
+ export { EventOptions } from './types/event/base-event';
28
+ export { IngestionMetadata } from './types/event/ingestion-metadata';
29
+ export { ServerZoneType } from './types/server-zone';
30
+ export { OfflineDisabled } from './types/offline';
31
+ export { Plan } from './types/event/plan';
32
+ export { TransportType, Transport } from './types/transport';
33
+ export { Payload } from './types/payload';
34
+ export { Response } from './types/response';
35
+ export { UserSession } from './types/user-session';
36
+ export { Plugin, BeforePlugin, DestinationPlugin, EnrichmentPlugin, PluginType } from './types/plugin';
37
+ export { Result } from './types/result';
38
+ export { ElementInteractionsOptions, Messenger, ActionType, DEFAULT_CSS_SELECTOR_ALLOWLIST, DEFAULT_DATA_ATTRIBUTE_PREFIX, DEFAULT_ACTION_CLICK_ALLOWLIST, } from './types/element-interactions';
39
+ export { PageTrackingOptions, PageTrackingTrackOn, PageTrackingHistoryChanges } from './types/page-view-tracking';
40
+ export { Status } from './types/status';
41
+ export { BrowserConfig, BrowserOptions, DefaultTrackingOptions, TrackingOptions, AutocaptureOptions, CookieOptions, AttributionOptions, } from './types/browser-config';
42
+ export { BrowserClient } from './types/browser-client';
14
43
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.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AAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACvG,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EACL,0BAA0B,EAC1B,SAAS,EACT,UAAU,EACV,8BAA8B,EAC9B,6BAA6B,EAC7B,8BAA8B,GAC/B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AAClH,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EACL,aAAa,EACb,cAAc,EACd,sBAAsB,EACtB,eAAe,EACf,kBAAkB,EAClB,aAAa,EACb,kBAAkB,GACnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC"}
package/lib/cjs/index.js CHANGED
@@ -1,5 +1,6 @@
1
+ "use strict";
1
2
  Object.defineProperty(exports, "__esModule", { value: true });
2
- exports.createIdentifyEvent = exports.BaseTransport = exports.MemoryStorage = exports.UUID = exports.getClientStates = exports.getClientLogConfig = exports.debugWrapper = exports.returnWrapper = exports.STORAGE_PREFIX = exports.AMPLITUDE_PREFIX = exports.Logger = exports.RequestMetadata = exports.Config = exports.Destination = exports.Revenue = exports.Identify = exports.AmplitudeCore = void 0;
3
+ exports.Status = exports.DEFAULT_ACTION_CLICK_ALLOWLIST = exports.DEFAULT_DATA_ATTRIBUTE_PREFIX = exports.DEFAULT_CSS_SELECTOR_ALLOWLIST = exports.OfflineDisabled = exports.STORAGE_PREFIX = exports.AMPLITUDE_PREFIX = exports.LogLevel = exports.FetchTransport = exports.BaseTransport = exports.getStorageKey = exports.CookieStorage = exports.MemoryStorage = exports.createIdentifyEvent = exports.UUID = exports.getClientStates = exports.getClientLogConfig = exports.debugWrapper = exports.returnWrapper = exports.getQueryParams = exports.getLanguage = exports.getOldCookieName = exports.getCookieName = exports.isNewSession = exports.setConnectorUserId = exports.setConnectorDeviceId = exports.getAnalyticsConnector = exports.getGlobalScope = exports.Logger = exports.RequestMetadata = exports.Config = exports.IdentityEventSender = exports.Destination = exports.Revenue = exports.Identify = exports.AmplitudeCore = void 0;
3
4
  var core_client_1 = require("./core-client");
4
5
  Object.defineProperty(exports, "AmplitudeCore", { enumerable: true, get: function () { return core_client_1.AmplitudeCore; } });
5
6
  var identify_1 = require("./identify");
@@ -8,14 +9,28 @@ var revenue_1 = require("./revenue");
8
9
  Object.defineProperty(exports, "Revenue", { enumerable: true, get: function () { return revenue_1.Revenue; } });
9
10
  var destination_1 = require("./plugins/destination");
10
11
  Object.defineProperty(exports, "Destination", { enumerable: true, get: function () { return destination_1.Destination; } });
12
+ var identity_1 = require("./plugins/identity");
13
+ Object.defineProperty(exports, "IdentityEventSender", { enumerable: true, get: function () { return identity_1.IdentityEventSender; } });
11
14
  var config_1 = require("./config");
12
15
  Object.defineProperty(exports, "Config", { enumerable: true, get: function () { return config_1.Config; } });
13
16
  Object.defineProperty(exports, "RequestMetadata", { enumerable: true, get: function () { return config_1.RequestMetadata; } });
14
17
  var logger_1 = require("./logger");
15
18
  Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return logger_1.Logger; } });
16
- var constants_1 = require("./constants");
17
- Object.defineProperty(exports, "AMPLITUDE_PREFIX", { enumerable: true, get: function () { return constants_1.AMPLITUDE_PREFIX; } });
18
- Object.defineProperty(exports, "STORAGE_PREFIX", { enumerable: true, get: function () { return constants_1.STORAGE_PREFIX; } });
19
+ var global_scope_1 = require("./global-scope");
20
+ Object.defineProperty(exports, "getGlobalScope", { enumerable: true, get: function () { return global_scope_1.getGlobalScope; } });
21
+ var analytics_connector_1 = require("./analytics-connector");
22
+ Object.defineProperty(exports, "getAnalyticsConnector", { enumerable: true, get: function () { return analytics_connector_1.getAnalyticsConnector; } });
23
+ Object.defineProperty(exports, "setConnectorDeviceId", { enumerable: true, get: function () { return analytics_connector_1.setConnectorDeviceId; } });
24
+ Object.defineProperty(exports, "setConnectorUserId", { enumerable: true, get: function () { return analytics_connector_1.setConnectorUserId; } });
25
+ var session_1 = require("./session");
26
+ Object.defineProperty(exports, "isNewSession", { enumerable: true, get: function () { return session_1.isNewSession; } });
27
+ var cookie_name_1 = require("./cookie-name");
28
+ Object.defineProperty(exports, "getCookieName", { enumerable: true, get: function () { return cookie_name_1.getCookieName; } });
29
+ Object.defineProperty(exports, "getOldCookieName", { enumerable: true, get: function () { return cookie_name_1.getOldCookieName; } });
30
+ var language_1 = require("./language");
31
+ Object.defineProperty(exports, "getLanguage", { enumerable: true, get: function () { return language_1.getLanguage; } });
32
+ var query_params_1 = require("./query-params");
33
+ Object.defineProperty(exports, "getQueryParams", { enumerable: true, get: function () { return query_params_1.getQueryParams; } });
19
34
  var return_wrapper_1 = require("./utils/return-wrapper");
20
35
  Object.defineProperty(exports, "returnWrapper", { enumerable: true, get: function () { return return_wrapper_1.returnWrapper; } });
21
36
  var debug_1 = require("./utils/debug");
@@ -24,10 +39,29 @@ Object.defineProperty(exports, "getClientLogConfig", { enumerable: true, get: fu
24
39
  Object.defineProperty(exports, "getClientStates", { enumerable: true, get: function () { return debug_1.getClientStates; } });
25
40
  var uuid_1 = require("./utils/uuid");
26
41
  Object.defineProperty(exports, "UUID", { enumerable: true, get: function () { return uuid_1.UUID; } });
42
+ var event_builder_1 = require("./utils/event-builder");
43
+ Object.defineProperty(exports, "createIdentifyEvent", { enumerable: true, get: function () { return event_builder_1.createIdentifyEvent; } });
27
44
  var memory_1 = require("./storage/memory");
28
45
  Object.defineProperty(exports, "MemoryStorage", { enumerable: true, get: function () { return memory_1.MemoryStorage; } });
46
+ var cookie_1 = require("./storage/cookie");
47
+ Object.defineProperty(exports, "CookieStorage", { enumerable: true, get: function () { return cookie_1.CookieStorage; } });
48
+ var helpers_1 = require("./storage/helpers");
49
+ Object.defineProperty(exports, "getStorageKey", { enumerable: true, get: function () { return helpers_1.getStorageKey; } });
29
50
  var base_1 = require("./transports/base");
30
51
  Object.defineProperty(exports, "BaseTransport", { enumerable: true, get: function () { return base_1.BaseTransport; } });
31
- var event_builder_1 = require("./utils/event-builder");
32
- Object.defineProperty(exports, "createIdentifyEvent", { enumerable: true, get: function () { return event_builder_1.createIdentifyEvent; } });
52
+ var fetch_1 = require("./transports/fetch");
53
+ Object.defineProperty(exports, "FetchTransport", { enumerable: true, get: function () { return fetch_1.FetchTransport; } });
54
+ var loglevel_1 = require("./types/loglevel");
55
+ Object.defineProperty(exports, "LogLevel", { enumerable: true, get: function () { return loglevel_1.LogLevel; } });
56
+ var constants_1 = require("./types/constants");
57
+ Object.defineProperty(exports, "AMPLITUDE_PREFIX", { enumerable: true, get: function () { return constants_1.AMPLITUDE_PREFIX; } });
58
+ Object.defineProperty(exports, "STORAGE_PREFIX", { enumerable: true, get: function () { return constants_1.STORAGE_PREFIX; } });
59
+ var offline_1 = require("./types/offline");
60
+ Object.defineProperty(exports, "OfflineDisabled", { enumerable: true, get: function () { return offline_1.OfflineDisabled; } });
61
+ var element_interactions_1 = require("./types/element-interactions");
62
+ Object.defineProperty(exports, "DEFAULT_CSS_SELECTOR_ALLOWLIST", { enumerable: true, get: function () { return element_interactions_1.DEFAULT_CSS_SELECTOR_ALLOWLIST; } });
63
+ Object.defineProperty(exports, "DEFAULT_DATA_ATTRIBUTE_PREFIX", { enumerable: true, get: function () { return element_interactions_1.DEFAULT_DATA_ATTRIBUTE_PREFIX; } });
64
+ Object.defineProperty(exports, "DEFAULT_ACTION_CLICK_ALLOWLIST", { enumerable: true, get: function () { return element_interactions_1.DEFAULT_ACTION_CLICK_ALLOWLIST; } });
65
+ var status_1 = require("./types/status");
66
+ Object.defineProperty(exports, "Status", { enumerable: true, get: function () { return status_1.Status; } });
33
67
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;AAAA,6CAA8C;AAArC,4GAAA,aAAa,OAAA;AACtB,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,qDAAoD;AAA3C,0GAAA,WAAW,OAAA;AACpB,mCAAmD;AAA1C,gGAAA,MAAM,OAAA;AAAE,yGAAA,eAAe,OAAA;AAChC,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AACf,yCAA+D;AAAtD,6GAAA,gBAAgB,OAAA;AAAE,2GAAA,cAAc,OAAA;AACzC,yDAAuD;AAA9C,+GAAA,aAAa,OAAA;AACtB,uCAAkF;AAAzE,qGAAA,YAAY,OAAA;AAAE,2GAAA,kBAAkB,OAAA;AAAE,wGAAA,eAAe,OAAA;AAC1D,qCAAoC;AAA3B,4FAAA,IAAI,OAAA;AACb,2CAAiD;AAAxC,uGAAA,aAAa,OAAA;AACtB,0CAAkD;AAAzC,qGAAA,aAAa,OAAA;AACtB,uDAA4D;AAAnD,oHAAA,mBAAmB,OAAA","sourcesContent":["export { AmplitudeCore } from './core-client';\nexport { Identify } from './identify';\nexport { Revenue } from './revenue';\nexport { Destination } from './plugins/destination';\nexport { Config, RequestMetadata } from './config';\nexport { Logger } from './logger';\nexport { AMPLITUDE_PREFIX, STORAGE_PREFIX } from './constants';\nexport { returnWrapper } from './utils/return-wrapper';\nexport { debugWrapper, getClientLogConfig, getClientStates } from './utils/debug';\nexport { UUID } from './utils/uuid';\nexport { MemoryStorage } from './storage/memory';\nexport { BaseTransport } from './transports/base';\nexport { createIdentifyEvent } from './utils/event-builder';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,6CAA0D;AAAjD,4GAAA,aAAa,OAAA;AACtB,uCAAiD;AAAxC,oGAAA,QAAQ,OAAA;AACjB,qCAA8C;AAArC,kGAAA,OAAO,OAAA;AAChB,qDAAoD;AAA3C,0GAAA,WAAW,OAAA;AACpB,+CAAyD;AAAhD,+GAAA,mBAAmB,OAAA;AAC5B,mCAA4D;AAA1C,gGAAA,MAAM,OAAA;AAAE,yGAAA,eAAe,OAAA;AACzC,mCAA2C;AAAlC,gGAAA,MAAM,OAAA;AACf,+CAAgD;AAAvC,8GAAA,cAAc,OAAA;AACvB,6DAAwG;AAA/F,4HAAA,qBAAqB,OAAA;AAAE,2HAAA,oBAAoB,OAAA;AAAE,yHAAA,kBAAkB,OAAA;AACxE,qCAAyC;AAAhC,uGAAA,YAAY,OAAA;AACrB,6CAAgE;AAAvD,4GAAA,aAAa,OAAA;AAAE,+GAAA,gBAAgB,OAAA;AACxC,uCAAyC;AAAhC,uGAAA,WAAW,OAAA;AACpB,+CAAgD;AAAvC,8GAAA,cAAc,OAAA;AAEvB,yDAAwE;AAA/D,+GAAA,aAAa,OAAA;AACtB,uCAAkF;AAAzE,qGAAA,YAAY,OAAA;AAAE,2GAAA,kBAAkB,OAAA;AAAE,wGAAA,eAAe,OAAA;AAC1D,qCAAoC;AAA3B,4FAAA,IAAI,OAAA;AACb,uDAA4D;AAAnD,oHAAA,mBAAmB,OAAA;AAE5B,2CAAiD;AAAxC,uGAAA,aAAa,OAAA;AACtB,2CAAiD;AAAxC,uGAAA,aAAa,OAAA;AACtB,6CAAkD;AAAzC,wGAAA,aAAa,OAAA;AAEtB,0CAAkD;AAAzC,qGAAA,aAAa,OAAA;AACtB,4CAAoD;AAA3C,uGAAA,cAAc,OAAA;AAEvB,6CAA4C;AAAnC,oGAAA,QAAQ,OAAA;AACjB,+CAAqE;AAA5D,6GAAA,gBAAgB,OAAA;AAAE,2GAAA,cAAc,OAAA;AAMzC,2CAAkD;AAAzC,0GAAA,eAAe,OAAA;AAQxB,qEAOsC;AAHpC,sIAAA,8BAA8B,OAAA;AAC9B,qIAAA,6BAA6B,OAAA;AAC7B,sIAAA,8BAA8B,OAAA;AAGhC,yCAAwC;AAA/B,gGAAA,MAAM,OAAA","sourcesContent":["export { AmplitudeCore, CoreClient } from './core-client';\nexport { Identify, IIdentify } from './identify';\nexport { Revenue, IRevenue } from './revenue';\nexport { Destination } from './plugins/destination';\nexport { IdentityEventSender } from './plugins/identity';\nexport { IConfig, Config, RequestMetadata } from './config';\nexport { Logger, ILogger } from './logger';\nexport { getGlobalScope } from './global-scope';\nexport { getAnalyticsConnector, setConnectorDeviceId, setConnectorUserId } from './analytics-connector';\nexport { isNewSession } from './session';\nexport { getCookieName, getOldCookieName } from './cookie-name';\nexport { getLanguage } from './language';\nexport { getQueryParams } from './query-params';\n\nexport { returnWrapper, AmplitudeReturn } from './utils/return-wrapper';\nexport { debugWrapper, getClientLogConfig, getClientStates } from './utils/debug';\nexport { UUID } from './utils/uuid';\nexport { createIdentifyEvent } from './utils/event-builder';\n\nexport { MemoryStorage } from './storage/memory';\nexport { CookieStorage } from './storage/cookie';\nexport { getStorageKey } from './storage/helpers';\n\nexport { BaseTransport } from './transports/base';\nexport { FetchTransport } from './transports/fetch';\n\nexport { LogLevel } from './types/loglevel';\nexport { AMPLITUDE_PREFIX, STORAGE_PREFIX } from './types/constants';\nexport { Storage, IdentityStorageType } from './types/storage';\nexport { Event } from './types/event/event';\nexport { EventOptions } from './types/event/base-event';\nexport { IngestionMetadata } from './types/event/ingestion-metadata';\nexport { ServerZoneType } from './types/server-zone';\nexport { OfflineDisabled } from './types/offline';\nexport { Plan } from './types/event/plan';\nexport { TransportType, Transport } from './types/transport';\nexport { Payload } from './types/payload';\nexport { Response } from './types/response';\nexport { UserSession } from './types/user-session';\nexport { Plugin, BeforePlugin, DestinationPlugin, EnrichmentPlugin, PluginType } from './types/plugin';\nexport { Result } from './types/result';\nexport {\n ElementInteractionsOptions,\n Messenger,\n ActionType,\n DEFAULT_CSS_SELECTOR_ALLOWLIST,\n DEFAULT_DATA_ATTRIBUTE_PREFIX,\n DEFAULT_ACTION_CLICK_ALLOWLIST,\n} from './types/element-interactions';\nexport { PageTrackingOptions, PageTrackingTrackOn, PageTrackingHistoryChanges } from './types/page-view-tracking';\nexport { Status } from './types/status';\nexport {\n BrowserConfig,\n BrowserOptions,\n DefaultTrackingOptions,\n TrackingOptions,\n AutocaptureOptions,\n CookieOptions,\n AttributionOptions,\n} from './types/browser-config';\nexport { BrowserClient } from './types/browser-client';\n"]}
@@ -0,0 +1,2 @@
1
+ export declare const getLanguage: () => string;
2
+ //# sourceMappingURL=language.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"language.d.ts","sourceRoot":"","sources":["../../src/language.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,QAAO,MAM9B,CAAC"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getLanguage = void 0;
4
+ var getLanguage = function () {
5
+ var _a, _b, _c, _d;
6
+ if (typeof navigator === 'undefined')
7
+ return '';
8
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
9
+ var userLanguage = navigator.userLanguage;
10
+ return (_d = (_c = (_b = (_a = navigator.languages) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : navigator.language) !== null && _c !== void 0 ? _c : userLanguage) !== null && _d !== void 0 ? _d : '';
11
+ };
12
+ exports.getLanguage = getLanguage;
13
+ //# sourceMappingURL=language.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"language.js","sourceRoot":"","sources":["../../src/language.ts"],"names":[],"mappings":";;;AAAO,IAAM,WAAW,GAAG;;IACzB,IAAI,OAAO,SAAS,KAAK,WAAW;QAAE,OAAO,EAAE,CAAC;IAChD,sEAAsE;IACtE,IAAM,YAAY,GAAI,SAAiB,CAAC,YAAkC,CAAC;IAE3E,OAAO,MAAA,MAAA,MAAA,MAAA,SAAS,CAAC,SAAS,0CAAG,CAAC,CAAC,mCAAI,SAAS,CAAC,QAAQ,mCAAI,YAAY,mCAAI,EAAE,CAAC;AAC9E,CAAC,CAAC;AANW,QAAA,WAAW,eAMtB","sourcesContent":["export const getLanguage = (): string => {\n if (typeof navigator === 'undefined') return '';\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const userLanguage = (navigator as any).userLanguage as string | undefined;\n\n return navigator.languages?.[0] ?? navigator.language ?? userLanguage ?? '';\n};\n"]}
@@ -1,4 +1,29 @@
1
- import { LogLevel, Logger as ILogger } from '@amplitude/analytics-types';
1
+ import { LogLevel } from './types/loglevel';
2
+ export interface ILogger {
3
+ disable(): void;
4
+ enable(logLevel: LogLevel): void;
5
+ log(...args: any[]): void;
6
+ warn(...args: any[]): void;
7
+ error(...args: any[]): void;
8
+ debug(...args: any[]): void;
9
+ }
10
+ export interface LogConfig {
11
+ logger: ILogger;
12
+ logLevel: LogLevel;
13
+ }
14
+ type TimeKey = 'start' | 'end';
15
+ export interface DebugContext {
16
+ type: string;
17
+ name: string;
18
+ args: string[] | string;
19
+ stacktrace?: string[] | string;
20
+ time?: {
21
+ [key in TimeKey]?: string;
22
+ };
23
+ states?: {
24
+ [key: string]: any;
25
+ };
26
+ }
2
27
  export declare class Logger implements ILogger {
3
28
  logLevel: LogLevel;
4
29
  constructor();
@@ -9,4 +34,5 @@ export declare class Logger implements ILogger {
9
34
  error(...args: any[]): void;
10
35
  debug(...args: any[]): void;
11
36
  }
37
+ export {};
12
38
  //# sourceMappingURL=logger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAIzE,qBA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CAAC,EAAE;SAAG,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,MAAM;KAAE,CAAC;IACrC,MAAM,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;CACjC;AAED,qBAAa,MAAO,YAAW,OAAO;IACpC,QAAQ,EAAE,QAAQ,CAAC;;IAMnB,OAAO,IAAI,IAAI;IAIf,MAAM,CAAC,QAAQ,GAAE,QAAwB,GAAG,IAAI;IAIhD,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAOzB,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAO1B,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAO3B,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;CAO5B"}
package/lib/cjs/logger.js CHANGED
@@ -1,16 +1,17 @@
1
+ "use strict";
1
2
  Object.defineProperty(exports, "__esModule", { value: true });
2
3
  exports.Logger = void 0;
3
- var analytics_types_1 = require("@amplitude/analytics-types");
4
+ var loglevel_1 = require("./types/loglevel");
4
5
  var PREFIX = 'Amplitude Logger ';
5
6
  var Logger = /** @class */ (function () {
6
7
  function Logger() {
7
- this.logLevel = analytics_types_1.LogLevel.None;
8
+ this.logLevel = loglevel_1.LogLevel.None;
8
9
  }
9
10
  Logger.prototype.disable = function () {
10
- this.logLevel = analytics_types_1.LogLevel.None;
11
+ this.logLevel = loglevel_1.LogLevel.None;
11
12
  };
12
13
  Logger.prototype.enable = function (logLevel) {
13
- if (logLevel === void 0) { logLevel = analytics_types_1.LogLevel.Warn; }
14
+ if (logLevel === void 0) { logLevel = loglevel_1.LogLevel.Warn; }
14
15
  this.logLevel = logLevel;
15
16
  };
16
17
  Logger.prototype.log = function () {
@@ -18,7 +19,7 @@ var Logger = /** @class */ (function () {
18
19
  for (var _i = 0; _i < arguments.length; _i++) {
19
20
  args[_i] = arguments[_i];
20
21
  }
21
- if (this.logLevel < analytics_types_1.LogLevel.Verbose) {
22
+ if (this.logLevel < loglevel_1.LogLevel.Verbose) {
22
23
  return;
23
24
  }
24
25
  console.log("".concat(PREFIX, "[Log]: ").concat(args.join(' ')));
@@ -28,7 +29,7 @@ var Logger = /** @class */ (function () {
28
29
  for (var _i = 0; _i < arguments.length; _i++) {
29
30
  args[_i] = arguments[_i];
30
31
  }
31
- if (this.logLevel < analytics_types_1.LogLevel.Warn) {
32
+ if (this.logLevel < loglevel_1.LogLevel.Warn) {
32
33
  return;
33
34
  }
34
35
  console.warn("".concat(PREFIX, "[Warn]: ").concat(args.join(' ')));
@@ -38,7 +39,7 @@ var Logger = /** @class */ (function () {
38
39
  for (var _i = 0; _i < arguments.length; _i++) {
39
40
  args[_i] = arguments[_i];
40
41
  }
41
- if (this.logLevel < analytics_types_1.LogLevel.Error) {
42
+ if (this.logLevel < loglevel_1.LogLevel.Error) {
42
43
  return;
43
44
  }
44
45
  console.error("".concat(PREFIX, "[Error]: ").concat(args.join(' ')));
@@ -48,7 +49,7 @@ var Logger = /** @class */ (function () {
48
49
  for (var _i = 0; _i < arguments.length; _i++) {
49
50
  args[_i] = arguments[_i];
50
51
  }
51
- if (this.logLevel < analytics_types_1.LogLevel.Debug) {
52
+ if (this.logLevel < loglevel_1.LogLevel.Debug) {
52
53
  return;
53
54
  }
54
55
  // console.debug output is hidden by default in chrome