@schibsted/pulse-sdk 8.0.0-alpha.16 → 8.0.0-alpha.18

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 (398) hide show
  1. package/dist/cjs/EventBus/EventBus.js +146 -0
  2. package/dist/cjs/Tracker.js +2499 -0
  3. package/dist/cjs/Tracker.test-d.js +76 -0
  4. package/dist/cjs/app-integration.js +40 -0
  5. package/dist/cjs/builders/actor.js +60 -0
  6. package/dist/cjs/builders/consent-manager.js +134 -0
  7. package/dist/cjs/builders/consents.js +149 -0
  8. package/dist/cjs/builders/device-browser.js +89 -0
  9. package/dist/cjs/builders/device-node.js +63 -0
  10. package/dist/cjs/builders/device.js +23 -0
  11. package/dist/cjs/builders/events-anonymous-browser.js +6 -0
  12. package/dist/cjs/builders/events-anonymous-node.js +88 -0
  13. package/dist/cjs/builders/events-anonymous.js +17 -0
  14. package/dist/cjs/builders/events-browser.js +8 -0
  15. package/dist/cjs/builders/events-node.js +127 -0
  16. package/dist/cjs/builders/events.js +17 -0
  17. package/dist/cjs/builders/experimentMetadata.js +25 -0
  18. package/dist/cjs/builders/experiments.js +32 -0
  19. package/dist/cjs/builders/index.js +52 -0
  20. package/dist/cjs/builders/location.js +38 -0
  21. package/dist/cjs/builders/objects/objects-anonymous-browser.js +36 -0
  22. package/dist/cjs/builders/objects/objects-anonymous-node.js +95 -0
  23. package/dist/cjs/builders/objects/objects-anonymous.js +23 -0
  24. package/dist/cjs/builders/objects/objects-browser.js +36 -0
  25. package/dist/cjs/builders/objects/objects-node.js +126 -0
  26. package/dist/cjs/builders/objects/objects.js +23 -0
  27. package/dist/cjs/builders/objects/utils.js +23 -0
  28. package/dist/cjs/builders/origin-browser.js +28 -0
  29. package/dist/cjs/builders/origin-node.js +29 -0
  30. package/dist/cjs/builders/origin.js +23 -0
  31. package/dist/cjs/builders/provider.js +24 -0
  32. package/dist/cjs/builders/session-browser.js +97 -0
  33. package/dist/cjs/builders/session-node.js +9 -0
  34. package/dist/cjs/builders/session.js +23 -0
  35. package/dist/cjs/builders/tracker-browser.js +34 -0
  36. package/dist/cjs/builders/tracker-node.js +22 -0
  37. package/dist/cjs/builders/trackerBuilder.js +23 -0
  38. package/dist/cjs/config-browser.js +26 -0
  39. package/dist/cjs/config.js +9 -0
  40. package/dist/cjs/createPulseTracker.js +50 -0
  41. package/dist/cjs/defer.js +20 -0
  42. package/dist/cjs/getPulseTracker.js +74 -0
  43. package/dist/cjs/identity/actor.js +60 -0
  44. package/dist/cjs/identity/advertising.js +62 -0
  45. package/dist/cjs/identity/cis.js +66 -0
  46. package/dist/cjs/identity/device.js +20 -0
  47. package/dist/cjs/identity/index.js +20 -0
  48. package/dist/cjs/index.js +57 -0
  49. package/dist/cjs/leaveTracking/constants.js +26 -0
  50. package/dist/cjs/leaveTracking/index.js +368 -0
  51. package/dist/cjs/leaveTracking/types.js +19 -0
  52. package/dist/cjs/leaveTrackingTpaas/constants.js +18 -0
  53. package/dist/cjs/leaveTrackingTpaas/index.js +341 -0
  54. package/dist/cjs/leaveTrackingTpaas/types.js +19 -0
  55. package/dist/cjs/network-browser.js +35 -0
  56. package/dist/cjs/network.js +15 -0
  57. package/dist/cjs/remoteConfig/index.js +124 -0
  58. package/dist/cjs/tracker-proxy/consts.js +72 -0
  59. package/dist/cjs/tracker-proxy/proxy-provider.js +68 -0
  60. package/dist/cjs/types.js +2 -0
  61. package/dist/cjs/version.json +1 -0
  62. package/dist/cjs/visibility-observer/index.js +101 -0
  63. package/dist/cjs/warnOnce.js +11 -0
  64. package/dist/cjs/wrapper/engagement/ui-element/event-builder.js +21 -0
  65. package/dist/cjs/wrapper/engagement/ui-element/types.js +2 -0
  66. package/dist/cjs/wrapper/types/base-event.js +2 -0
  67. package/dist/cjs/wrapper/types/engagement-event.js +2 -0
  68. package/dist/cjs/wrapper/types/event.js +2 -0
  69. package/dist/cjs/wrapper/types/index.js +19 -0
  70. package/dist/cjs/wrapper/types/utils.js +2 -0
  71. package/dist/cjs/wrapper/utils/get-navigation-type.js +32 -0
  72. package/dist/cjs/wrapper/utils/page-from-page-view.js +9 -0
  73. package/dist/cjs/wrapper/view/article/event-builder.js +19 -0
  74. package/dist/cjs/wrapper/view/article/types.js +2 -0
  75. package/dist/cjs/wrapper/view/frontpage/event-builder.js +16 -0
  76. package/dist/cjs/wrapper/view/frontpage/types.js +2 -0
  77. package/dist/cjs/wrapper/view/listing/event-builder.js +14 -0
  78. package/dist/cjs/wrapper/view/listing/types.js +2 -0
  79. package/dist/cjs/wrapper/view/loginposter/event-builder.js +11 -0
  80. package/dist/cjs/wrapper/view/loginposter/types.js +2 -0
  81. package/dist/cjs/wrapper/view/page/event-builder.js +18 -0
  82. package/dist/cjs/wrapper/view/page/types.js +2 -0
  83. package/dist/cjs/wrapper/view/salesposter/event-builder.js +18 -0
  84. package/dist/cjs/wrapper/view/salesposter/types.js +2 -0
  85. package/dist/cjs/wrapper/view/ui-element/event-builder.js +15 -0
  86. package/dist/cjs/wrapper/view/ui-element/types.js +2 -0
  87. package/dist/ejs/EventBus/EventBus.js +140 -0
  88. package/dist/ejs/Tracker.js +2455 -0
  89. package/dist/ejs/Tracker.test-d.js +71 -0
  90. package/dist/ejs/app-integration.js +33 -0
  91. package/dist/ejs/builders/actor.js +53 -0
  92. package/dist/ejs/builders/consent-manager.js +125 -0
  93. package/dist/ejs/builders/consents.js +138 -0
  94. package/dist/ejs/builders/device-browser.js +69 -0
  95. package/dist/ejs/builders/device-node.js +57 -0
  96. package/dist/ejs/builders/device.js +2 -0
  97. package/dist/ejs/builders/events-anonymous-browser.js +1 -0
  98. package/dist/ejs/builders/events-anonymous-node.js +48 -0
  99. package/dist/ejs/builders/events-anonymous.js +1 -0
  100. package/dist/ejs/builders/events-browser.js +1 -0
  101. package/dist/ejs/builders/events-node.js +84 -0
  102. package/dist/ejs/builders/events.js +1 -0
  103. package/dist/ejs/builders/experimentMetadata.js +21 -0
  104. package/dist/ejs/builders/experiments.js +27 -0
  105. package/dist/ejs/builders/index.js +12 -0
  106. package/dist/ejs/builders/location.js +34 -0
  107. package/dist/ejs/builders/objects/objects-anonymous-browser.js +14 -0
  108. package/dist/ejs/builders/objects/objects-anonymous-node.js +90 -0
  109. package/dist/ejs/builders/objects/objects-anonymous.js +2 -0
  110. package/dist/ejs/builders/objects/objects-browser.js +14 -0
  111. package/dist/ejs/builders/objects/objects-node.js +121 -0
  112. package/dist/ejs/builders/objects/objects.js +2 -0
  113. package/dist/ejs/builders/objects/utils.js +20 -0
  114. package/dist/ejs/builders/origin-browser.js +6 -0
  115. package/dist/ejs/builders/origin-node.js +24 -0
  116. package/dist/ejs/builders/origin.js +2 -0
  117. package/dist/ejs/builders/provider.js +18 -0
  118. package/dist/ejs/builders/session-browser.js +90 -0
  119. package/dist/ejs/builders/session-node.js +4 -0
  120. package/dist/ejs/builders/session.js +2 -0
  121. package/dist/ejs/builders/tracker-browser.js +13 -0
  122. package/dist/ejs/builders/tracker-node.js +14 -0
  123. package/dist/ejs/builders/trackerBuilder.js +2 -0
  124. package/dist/ejs/config-browser.js +23 -0
  125. package/dist/ejs/config.js +6 -0
  126. package/dist/ejs/createPulseTracker.js +44 -0
  127. package/dist/ejs/defer.js +17 -0
  128. package/dist/ejs/getPulseTracker.js +71 -0
  129. package/dist/ejs/identity/actor.js +51 -0
  130. package/dist/ejs/identity/advertising.js +57 -0
  131. package/dist/ejs/identity/cis.js +58 -0
  132. package/dist/ejs/identity/device.js +17 -0
  133. package/dist/ejs/identity/index.js +4 -0
  134. package/dist/ejs/index.js +9 -0
  135. package/dist/ejs/leaveTracking/constants.js +19 -0
  136. package/dist/ejs/leaveTracking/index.js +319 -0
  137. package/dist/ejs/leaveTracking/types.js +16 -0
  138. package/dist/ejs/leaveTrackingTpaas/constants.js +13 -0
  139. package/dist/ejs/leaveTrackingTpaas/index.js +291 -0
  140. package/dist/ejs/leaveTrackingTpaas/types.js +16 -0
  141. package/dist/ejs/network-browser.js +32 -0
  142. package/dist/ejs/network.js +12 -0
  143. package/dist/ejs/remoteConfig/index.js +111 -0
  144. package/dist/ejs/tracker-proxy/consts.js +68 -0
  145. package/dist/ejs/tracker-proxy/proxy-provider.js +62 -0
  146. package/dist/ejs/types.js +1 -0
  147. package/dist/ejs/version.json +1 -0
  148. package/dist/ejs/visibility-observer/index.js +97 -0
  149. package/dist/ejs/warnOnce.js +9 -0
  150. package/dist/ejs/wrapper/engagement/ui-element/event-builder.js +17 -0
  151. package/dist/ejs/wrapper/engagement/ui-element/types.js +1 -0
  152. package/dist/ejs/wrapper/types/base-event.js +1 -0
  153. package/dist/ejs/wrapper/types/engagement-event.js +1 -0
  154. package/dist/ejs/wrapper/types/event.js +1 -0
  155. package/dist/ejs/wrapper/types/index.js +3 -0
  156. package/dist/ejs/wrapper/types/utils.js +1 -0
  157. package/dist/ejs/wrapper/utils/get-navigation-type.js +29 -0
  158. package/dist/ejs/wrapper/utils/page-from-page-view.js +6 -0
  159. package/dist/ejs/wrapper/view/article/event-builder.js +15 -0
  160. package/dist/ejs/wrapper/view/article/types.js +1 -0
  161. package/dist/ejs/wrapper/view/frontpage/event-builder.js +12 -0
  162. package/dist/ejs/wrapper/view/frontpage/types.js +1 -0
  163. package/dist/ejs/wrapper/view/listing/event-builder.js +10 -0
  164. package/dist/ejs/wrapper/view/listing/types.js +1 -0
  165. package/dist/ejs/wrapper/view/loginposter/event-builder.js +7 -0
  166. package/dist/ejs/wrapper/view/loginposter/types.js +1 -0
  167. package/dist/ejs/wrapper/view/page/event-builder.js +14 -0
  168. package/dist/ejs/wrapper/view/page/types.js +1 -0
  169. package/dist/ejs/wrapper/view/salesposter/event-builder.js +14 -0
  170. package/dist/ejs/wrapper/view/salesposter/types.js +1 -0
  171. package/dist/ejs/wrapper/view/ui-element/event-builder.js +11 -0
  172. package/dist/ejs/wrapper/view/ui-element/types.js +1 -0
  173. package/dist/types/EventBus/EventBus.d.ts +106 -0
  174. package/dist/types/Tracker.d.ts +1418 -0
  175. package/dist/types/Tracker.test-d.d.ts +1 -0
  176. package/dist/types/app-integration.d.ts +10 -0
  177. package/dist/types/builders/actor.d.ts +39 -0
  178. package/dist/types/builders/consent-manager.d.ts +49 -0
  179. package/dist/types/builders/consents.d.ts +107 -0
  180. package/dist/types/builders/device-browser.d.ts +6 -0
  181. package/dist/types/builders/device-node.d.ts +65 -0
  182. package/dist/types/builders/device.d.ts +2 -0
  183. package/dist/types/builders/events-anonymous-browser.d.ts +1 -0
  184. package/dist/types/builders/events-anonymous-node.d.ts +82 -0
  185. package/dist/types/builders/events-anonymous.d.ts +1 -0
  186. package/dist/types/builders/events-browser.d.ts +1 -0
  187. package/dist/types/builders/events-node.d.ts +130 -0
  188. package/dist/types/builders/events.d.ts +1 -0
  189. package/dist/types/builders/experimentMetadata.d.ts +25 -0
  190. package/dist/types/builders/experiments.d.ts +24 -0
  191. package/dist/types/builders/index.d.ts +23 -0
  192. package/dist/types/builders/location.d.ts +34 -0
  193. package/dist/types/builders/objects/objects-anonymous-browser.d.ts +11 -0
  194. package/dist/types/builders/objects/objects-anonymous-node.d.ts +52 -0
  195. package/dist/types/builders/objects/objects-anonymous.d.ts +2 -0
  196. package/dist/types/builders/objects/objects-browser.d.ts +11 -0
  197. package/dist/types/builders/objects/objects-node.d.ts +60 -0
  198. package/dist/types/builders/objects/objects.d.ts +2 -0
  199. package/dist/types/builders/objects/utils.d.ts +1 -0
  200. package/dist/types/builders/origin-browser.d.ts +5 -0
  201. package/dist/types/builders/origin-node.d.ts +18 -0
  202. package/dist/types/builders/origin.d.ts +2 -0
  203. package/dist/types/builders/provider.d.ts +14 -0
  204. package/dist/types/builders/session-browser.d.ts +20 -0
  205. package/dist/types/builders/session-node.d.ts +3 -0
  206. package/dist/types/builders/session.d.ts +2 -0
  207. package/dist/types/builders/tracker-browser.d.ts +2 -0
  208. package/dist/types/builders/tracker-node.d.ts +14 -0
  209. package/dist/types/builders/trackerBuilder.d.ts +2 -0
  210. package/dist/types/config-browser.d.ts +23 -0
  211. package/dist/types/config.d.ts +6 -0
  212. package/dist/types/createPulseTracker.d.ts +21 -0
  213. package/dist/types/defer.d.ts +28 -0
  214. package/dist/types/getPulseTracker.d.ts +59 -0
  215. package/dist/types/identity/actor.d.ts +28 -0
  216. package/dist/types/identity/advertising.d.ts +30 -0
  217. package/dist/types/identity/cis.d.ts +21 -0
  218. package/dist/types/identity/device.d.ts +12 -0
  219. package/dist/types/identity/index.d.ts +4 -0
  220. package/dist/types/index.d.ts +31 -0
  221. package/dist/types/leaveTracking/constants.d.ts +26 -0
  222. package/dist/types/leaveTracking/index.d.ts +23 -0
  223. package/dist/types/leaveTracking/types.d.ts +78 -0
  224. package/dist/types/leaveTrackingTpaas/constants.d.ts +13 -0
  225. package/dist/types/leaveTrackingTpaas/index.d.ts +28 -0
  226. package/dist/types/leaveTrackingTpaas/types.d.ts +45 -0
  227. package/dist/types/network-browser.d.ts +5 -0
  228. package/dist/types/network.d.ts +4 -0
  229. package/dist/types/remoteConfig/index.d.ts +32 -0
  230. package/dist/types/tracker-proxy/consts.d.ts +45 -0
  231. package/dist/types/tracker-proxy/proxy-provider.d.ts +2 -0
  232. package/dist/types/types.d.ts +93 -0
  233. package/dist/types/visibility-observer/index.d.ts +38 -0
  234. package/dist/types/warnOnce.d.ts +2 -0
  235. package/dist/types/wrapper/engagement/ui-element/event-builder.d.ts +3 -0
  236. package/dist/types/wrapper/engagement/ui-element/types.d.ts +29 -0
  237. package/dist/types/wrapper/types/base-event.d.ts +74 -0
  238. package/dist/types/wrapper/types/engagement-event.d.ts +5 -0
  239. package/dist/types/wrapper/types/event.d.ts +41 -0
  240. package/dist/types/wrapper/types/index.d.ts +3 -0
  241. package/dist/types/wrapper/types/utils.d.ts +5 -0
  242. package/dist/types/wrapper/utils/get-navigation-type.d.ts +3 -0
  243. package/dist/types/wrapper/utils/page-from-page-view.d.ts +3 -0
  244. package/dist/types/wrapper/view/article/event-builder.d.ts +2 -0
  245. package/dist/types/wrapper/view/article/types.d.ts +27 -0
  246. package/dist/types/wrapper/view/frontpage/event-builder.d.ts +2 -0
  247. package/dist/types/wrapper/view/frontpage/types.d.ts +18 -0
  248. package/dist/types/wrapper/view/listing/event-builder.d.ts +2 -0
  249. package/dist/types/wrapper/view/listing/types.d.ts +27 -0
  250. package/dist/types/wrapper/view/loginposter/event-builder.d.ts +2 -0
  251. package/dist/types/wrapper/view/loginposter/types.d.ts +14 -0
  252. package/dist/types/wrapper/view/page/event-builder.d.ts +2 -0
  253. package/dist/types/wrapper/view/page/types.d.ts +16 -0
  254. package/dist/types/wrapper/view/salesposter/event-builder.d.ts +2 -0
  255. package/dist/types/wrapper/view/salesposter/types.d.ts +15 -0
  256. package/dist/types/wrapper/view/ui-element/event-builder.d.ts +3 -0
  257. package/dist/types/wrapper/view/ui-element/types.d.ts +28 -0
  258. package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/cis-browser.d.ts +26 -0
  259. package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/cis-browser.js +273 -0
  260. package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/cis-browser.js.map +1 -0
  261. package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/cis.d.ts +10 -0
  262. package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/cis.js +7 -0
  263. package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/cis.js.map +1 -0
  264. package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/eventEmitter.d.ts +14 -0
  265. package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/eventEmitter.js +39 -0
  266. package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/eventEmitter.js.map +1 -0
  267. package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/index.d.ts +4 -0
  268. package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/index.js +12 -0
  269. package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/index.js.map +1 -0
  270. package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/pulse-cookie.d.ts +55 -0
  271. package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/pulse-cookie.js +276 -0
  272. package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/pulse-cookie.js.map +1 -0
  273. package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/storage/pulseStorage.d.ts +36 -0
  274. package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/storage/pulseStorage.js +87 -0
  275. package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/storage/pulseStorage.js.map +1 -0
  276. package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/storage/storage.d.ts +6 -0
  277. package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/storage/storage.js +21 -0
  278. package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/storage/storage.js.map +1 -0
  279. package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/types.d.ts +24 -0
  280. package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/types.js +3 -0
  281. package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/types.js.map +1 -0
  282. package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/cis-browser.d.ts +26 -0
  283. package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/cis-browser.js +203 -0
  284. package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/cis-browser.js.map +1 -0
  285. package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/cis.d.ts +10 -0
  286. package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/cis.js +4 -0
  287. package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/cis.js.map +1 -0
  288. package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/eventEmitter.d.ts +14 -0
  289. package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/eventEmitter.js +35 -0
  290. package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/eventEmitter.js.map +1 -0
  291. package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/index.d.ts +4 -0
  292. package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/index.js +3 -0
  293. package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/index.js.map +1 -0
  294. package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/pulse-cookie.d.ts +55 -0
  295. package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/pulse-cookie.js +254 -0
  296. package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/pulse-cookie.js.map +1 -0
  297. package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/storage/pulseStorage.d.ts +36 -0
  298. package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/storage/pulseStorage.js +50 -0
  299. package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/storage/pulseStorage.js.map +1 -0
  300. package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/storage/storage.d.ts +6 -0
  301. package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/storage/storage.js +17 -0
  302. package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/storage/storage.js.map +1 -0
  303. package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/types.d.ts +24 -0
  304. package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/types.js +2 -0
  305. package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/types.js.map +1 -0
  306. package/node_modules/@schibsted/pulse-cis-sync/dist/types/cis-browser.d.ts +26 -0
  307. package/node_modules/@schibsted/pulse-cis-sync/dist/types/cis.d.ts +10 -0
  308. package/node_modules/@schibsted/pulse-cis-sync/dist/types/eventEmitter.d.ts +14 -0
  309. package/node_modules/@schibsted/pulse-cis-sync/dist/types/index.d.ts +4 -0
  310. package/node_modules/@schibsted/pulse-cis-sync/dist/types/pulse-cookie.d.ts +55 -0
  311. package/node_modules/@schibsted/pulse-cis-sync/dist/types/storage/pulseStorage.d.ts +36 -0
  312. package/node_modules/@schibsted/pulse-cis-sync/dist/types/storage/storage.d.ts +6 -0
  313. package/node_modules/@schibsted/pulse-cis-sync/dist/types/types.d.ts +24 -0
  314. package/node_modules/@schibsted/pulse-cis-sync/package.json +44 -0
  315. package/node_modules/@schibsted/pulse-utils/dist/cjs/cookie-config.js +10 -0
  316. package/node_modules/@schibsted/pulse-utils/dist/cjs/cookie.js +86 -0
  317. package/node_modules/@schibsted/pulse-utils/dist/cjs/events.js +109 -0
  318. package/node_modules/@schibsted/pulse-utils/dist/cjs/get.js +18 -0
  319. package/node_modules/@schibsted/pulse-utils/dist/cjs/getRootDomain.js +54 -0
  320. package/node_modules/@schibsted/pulse-utils/dist/cjs/index.js +38 -0
  321. package/node_modules/@schibsted/pulse-utils/dist/cjs/merge.js +38 -0
  322. package/node_modules/@schibsted/pulse-utils/dist/cjs/objects.js +34 -0
  323. package/node_modules/@schibsted/pulse-utils/dist/cjs/omit.js +9 -0
  324. package/node_modules/@schibsted/pulse-utils/dist/cjs/randomString.js +18 -0
  325. package/node_modules/@schibsted/pulse-utils/dist/cjs/throttle.js +34 -0
  326. package/node_modules/@schibsted/pulse-utils/dist/cjs/webApi.js +21 -0
  327. package/node_modules/@schibsted/pulse-utils/dist/ejs/cookie-config.js +7 -0
  328. package/node_modules/@schibsted/pulse-utils/dist/ejs/cookie.js +81 -0
  329. package/node_modules/@schibsted/pulse-utils/dist/ejs/events.js +103 -0
  330. package/node_modules/@schibsted/pulse-utils/dist/ejs/get.js +15 -0
  331. package/node_modules/@schibsted/pulse-utils/dist/ejs/getRootDomain.js +49 -0
  332. package/node_modules/@schibsted/pulse-utils/dist/ejs/index.js +11 -0
  333. package/node_modules/@schibsted/pulse-utils/dist/ejs/merge.js +35 -0
  334. package/node_modules/@schibsted/pulse-utils/dist/ejs/objects.js +26 -0
  335. package/node_modules/@schibsted/pulse-utils/dist/ejs/omit.js +6 -0
  336. package/node_modules/@schibsted/pulse-utils/dist/ejs/randomString.js +15 -0
  337. package/node_modules/@schibsted/pulse-utils/dist/ejs/throttle.js +31 -0
  338. package/node_modules/@schibsted/pulse-utils/dist/ejs/webApi.js +17 -0
  339. package/node_modules/@schibsted/pulse-utils/dist/types/cookie-config.d.ts +7 -0
  340. package/node_modules/@schibsted/pulse-utils/dist/types/cookie.d.ts +23 -0
  341. package/node_modules/@schibsted/pulse-utils/dist/types/events.d.ts +17 -0
  342. package/node_modules/@schibsted/pulse-utils/dist/types/get.d.ts +1 -0
  343. package/node_modules/@schibsted/pulse-utils/dist/types/getRootDomain.d.ts +13 -0
  344. package/node_modules/@schibsted/pulse-utils/dist/types/index.d.ts +11 -0
  345. package/node_modules/@schibsted/pulse-utils/dist/types/merge.d.ts +4 -0
  346. package/node_modules/@schibsted/pulse-utils/dist/types/objects.d.ts +6 -0
  347. package/node_modules/@schibsted/pulse-utils/dist/types/omit.d.ts +3 -0
  348. package/node_modules/@schibsted/pulse-utils/dist/types/randomString.d.ts +1 -0
  349. package/node_modules/@schibsted/pulse-utils/dist/types/throttle.d.ts +3 -0
  350. package/node_modules/@schibsted/pulse-utils/dist/types/webApi.d.ts +10 -0
  351. package/node_modules/@schibsted/pulse-utils/package.json +36 -0
  352. package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders/anonymous.js +8 -0
  353. package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders/baseEvent.js +9 -0
  354. package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders/consents.js +15 -0
  355. package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders/device.js +211 -0
  356. package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders/experiments.js +11 -0
  357. package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders/navigationType.js +52 -0
  358. package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders/pageInfo.js +24 -0
  359. package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders/pageviewId.js +11 -0
  360. package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders/provider.js +12 -0
  361. package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders/referrer.js +19 -0
  362. package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders/session.js +114 -0
  363. package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders/time.js +15 -0
  364. package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders/trackerBuilder.js +15 -0
  365. package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders/user.js +26 -0
  366. package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders/utm.js +35 -0
  367. package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders.js +264 -0
  368. package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/index.js +17 -0
  369. package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/types.js +2 -0
  370. package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders/anonymous.js +5 -0
  371. package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders/baseEvent.js +6 -0
  372. package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders/consents.js +12 -0
  373. package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders/device.js +174 -0
  374. package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders/experiments.js +7 -0
  375. package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders/navigationType.js +48 -0
  376. package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders/pageInfo.js +20 -0
  377. package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders/pageviewId.js +7 -0
  378. package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders/provider.js +9 -0
  379. package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders/referrer.js +15 -0
  380. package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders/session.js +108 -0
  381. package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders/time.js +11 -0
  382. package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders/trackerBuilder.js +11 -0
  383. package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders/user.js +22 -0
  384. package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders/utm.js +31 -0
  385. package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders.js +209 -0
  386. package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/index.js +1 -0
  387. package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/types.js +1 -0
  388. package/node_modules/@schibsted/tpaas-event-builder/dist/index.d.ts +5171 -0
  389. package/node_modules/@schibsted/tpaas-event-builder/package.json +40 -0
  390. package/node_modules/@schibsted/tpaas-schemas/dist/cjs/constants.js +62 -1
  391. package/node_modules/@schibsted/tpaas-schemas/dist/ejs/constants.js +61 -0
  392. package/node_modules/@schibsted/tpaas-schemas/dist/index.d.ts +128 -0
  393. package/package.json +58 -13
  394. package/CHANGELOG.md +0 -1035
  395. package/dist/index.d.ts +0 -13
  396. package/dist/index.d.ts.map +0 -1
  397. package/dist/index.js +0 -47
  398. package/dist/index.js.map +0 -1
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.webApi = exports.isBrowser = exports.initializeStorage = exports.throttle = exports.randomString = exports.omit = exports.isString = exports.isPromise = exports.isPlainObject = exports.isObjectEmpty = exports.isObject = exports.isFunction = exports.pulseMerge = exports.resetGetRootDomain = exports.getRootDomain = exports.get = exports.evaluateEventInput = exports.evaluateAndFlatten = exports.deviceType = exports.dateTime = exports.cookieConfig = exports.writeCookie = exports.readCookie = exports.deleteCookie = void 0;
4
+ var cookie_1 = require("./cookie");
5
+ Object.defineProperty(exports, "deleteCookie", { enumerable: true, get: function () { return cookie_1.deleteCookie; } });
6
+ Object.defineProperty(exports, "readCookie", { enumerable: true, get: function () { return cookie_1.readCookie; } });
7
+ Object.defineProperty(exports, "writeCookie", { enumerable: true, get: function () { return cookie_1.writeCookie; } });
8
+ var cookie_config_1 = require("./cookie-config");
9
+ Object.defineProperty(exports, "cookieConfig", { enumerable: true, get: function () { return cookie_config_1.cookieConfig; } });
10
+ var events_1 = require("./events");
11
+ Object.defineProperty(exports, "dateTime", { enumerable: true, get: function () { return events_1.dateTime; } });
12
+ Object.defineProperty(exports, "deviceType", { enumerable: true, get: function () { return events_1.deviceType; } });
13
+ Object.defineProperty(exports, "evaluateAndFlatten", { enumerable: true, get: function () { return events_1.evaluateAndFlatten; } });
14
+ Object.defineProperty(exports, "evaluateEventInput", { enumerable: true, get: function () { return events_1.evaluateEventInput; } });
15
+ var get_1 = require("./get");
16
+ Object.defineProperty(exports, "get", { enumerable: true, get: function () { return get_1.get; } });
17
+ var getRootDomain_1 = require("./getRootDomain");
18
+ Object.defineProperty(exports, "getRootDomain", { enumerable: true, get: function () { return getRootDomain_1.getRootDomain; } });
19
+ Object.defineProperty(exports, "resetGetRootDomain", { enumerable: true, get: function () { return getRootDomain_1.resetGetRootDomain; } });
20
+ var merge_1 = require("./merge");
21
+ Object.defineProperty(exports, "pulseMerge", { enumerable: true, get: function () { return merge_1.pulseMerge; } });
22
+ var objects_1 = require("./objects");
23
+ Object.defineProperty(exports, "isFunction", { enumerable: true, get: function () { return objects_1.isFunction; } });
24
+ Object.defineProperty(exports, "isObject", { enumerable: true, get: function () { return objects_1.isObject; } });
25
+ Object.defineProperty(exports, "isObjectEmpty", { enumerable: true, get: function () { return objects_1.isObjectEmpty; } });
26
+ Object.defineProperty(exports, "isPlainObject", { enumerable: true, get: function () { return objects_1.isPlainObject; } });
27
+ Object.defineProperty(exports, "isPromise", { enumerable: true, get: function () { return objects_1.isPromise; } });
28
+ Object.defineProperty(exports, "isString", { enumerable: true, get: function () { return objects_1.isString; } });
29
+ var omit_1 = require("./omit");
30
+ Object.defineProperty(exports, "omit", { enumerable: true, get: function () { return omit_1.omit; } });
31
+ var randomString_1 = require("./randomString");
32
+ Object.defineProperty(exports, "randomString", { enumerable: true, get: function () { return randomString_1.randomString; } });
33
+ var throttle_1 = require("./throttle");
34
+ Object.defineProperty(exports, "throttle", { enumerable: true, get: function () { return throttle_1.throttle; } });
35
+ var webApi_1 = require("./webApi");
36
+ Object.defineProperty(exports, "initializeStorage", { enumerable: true, get: function () { return webApi_1.initializeStorage; } });
37
+ Object.defineProperty(exports, "isBrowser", { enumerable: true, get: function () { return webApi_1.isBrowser; } });
38
+ Object.defineProperty(exports, "webApi", { enumerable: true, get: function () { return webApi_1.webApi; } });
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pulseMerge = pulseMerge;
4
+ const objects_1 = require("./objects");
5
+ /**
6
+ * This function deep merges objects, concatenates array and handles promises as values.
7
+ */
8
+ // biome-ignore lint/suspicious/noExplicitAny: -
9
+ function pulseMerge(target, ...sources) {
10
+ return sources.reduce((acc, source) => mergeValue(acc, source), target);
11
+ function innerMerge(target, source) {
12
+ for (const [key, value] of Object.entries(source)) {
13
+ target[key] = mergeValue(target[key], value);
14
+ }
15
+ }
16
+ function mergeValue(targetValue, value) {
17
+ if ((0, objects_1.isPromise)(targetValue) || (0, objects_1.isPromise)(value)) {
18
+ return Promise.all([targetValue, value]).then(([targetValue, value]) => {
19
+ const copiedTarget = (0, objects_1.isPlainObject)(targetValue) ? { ...targetValue } : targetValue;
20
+ return mergeValue(copiedTarget, value);
21
+ });
22
+ }
23
+ if (Array.isArray(value)) {
24
+ if (!Array.isArray(targetValue)) {
25
+ return value.filter((v) => v !== undefined);
26
+ }
27
+ return [...targetValue, ...value].filter((v) => v !== undefined);
28
+ }
29
+ if (typeof value === 'object') {
30
+ if (targetValue && value && typeof targetValue === 'object') {
31
+ innerMerge(targetValue, value);
32
+ return targetValue;
33
+ }
34
+ return value ? { ...value } : value;
35
+ }
36
+ return value ?? targetValue ?? undefined;
37
+ }
38
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isObject = isObject;
4
+ exports.isPlainObject = isPlainObject;
5
+ exports.isFunction = isFunction;
6
+ exports.isString = isString;
7
+ exports.isPromise = isPromise;
8
+ exports.isObjectEmpty = isObjectEmpty;
9
+ function isObject(value) {
10
+ const type = typeof value;
11
+ return value != null && (type === 'object' || type === 'function');
12
+ }
13
+ function isPlainObject(value) {
14
+ return isObject(value) && !Array.isArray(value);
15
+ }
16
+ // biome-ignore lint/suspicious/noExplicitAny: generic function
17
+ function isFunction(value) {
18
+ return typeof value === 'function';
19
+ }
20
+ function isString(s) {
21
+ return Object.prototype.toString.call(s) === '[object String]';
22
+ }
23
+ function isPromise(s) {
24
+ return s instanceof Promise;
25
+ }
26
+ function isObjectEmpty(obj) {
27
+ for (const prop in obj) {
28
+ // biome-ignore lint/suspicious/noPrototypeBuiltins: Object.hasOwn is not available in ES2020
29
+ if (Object.prototype.hasOwnProperty.call(obj, prop)) {
30
+ return false;
31
+ }
32
+ }
33
+ return true;
34
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.omit = omit;
4
+ function omit(target, props) {
5
+ if (!target) {
6
+ return {};
7
+ }
8
+ return Object.fromEntries(Object.entries(target).filter(([key]) => !props.includes(key)));
9
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.randomString = randomString;
4
+ const webApi_1 = require("./webApi");
5
+ function randomString(length = 16) {
6
+ const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
7
+ const charactersLength = characters.length;
8
+ let output = '';
9
+ if (length < 0) {
10
+ return output;
11
+ }
12
+ const randomValues = new Uint32Array(length);
13
+ webApi_1.webApi.crypto?.getRandomValues(randomValues);
14
+ randomValues.forEach((value) => {
15
+ output += characters.charAt(value % charactersLength);
16
+ });
17
+ return output;
18
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.throttle = throttle;
4
+ function throttle(func, wait = 0) {
5
+ let timeout;
6
+ let lastCallTime = 0;
7
+ const f = function (...args) {
8
+ const now = Date.now();
9
+ const remaining = wait - (now - lastCallTime);
10
+ if (remaining <= 0 || remaining > wait) {
11
+ if (timeout) {
12
+ clearTimeout(timeout);
13
+ timeout = null;
14
+ }
15
+ lastCallTime = now;
16
+ // @ts-expect-error
17
+ func.apply(this, args);
18
+ }
19
+ else if (!timeout) {
20
+ timeout = setTimeout(() => {
21
+ lastCallTime = Date.now();
22
+ timeout = null;
23
+ // @ts-expect-error
24
+ func.apply(this, args);
25
+ }, remaining);
26
+ }
27
+ };
28
+ f.cancel = () => {
29
+ if (timeout) {
30
+ clearTimeout(timeout);
31
+ }
32
+ };
33
+ return f;
34
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.webApi = exports.initializeStorage = exports.isBrowser = void 0;
4
+ exports.isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
5
+ const initializeStorage = (storageType) => {
6
+ if (!exports.isBrowser)
7
+ return;
8
+ try {
9
+ const storage = window[storageType];
10
+ return storage && typeof storage.getItem === 'function' ? storage : undefined;
11
+ }
12
+ catch {
13
+ return;
14
+ }
15
+ };
16
+ exports.initializeStorage = initializeStorage;
17
+ exports.webApi = {
18
+ crypto: exports.isBrowser ? crypto : globalThis.crypto,
19
+ localStorage: (0, exports.initializeStorage)('localStorage'),
20
+ sessionStorage: (0, exports.initializeStorage)('sessionStorage'),
21
+ };
@@ -0,0 +1,7 @@
1
+ export const cookieConfig = {
2
+ PULSE_COOKIE_KEY: '_pulse2data',
3
+ TEST_COOKIE_KEY: '_pulse2test',
4
+ ENV_COOKIE_KEY: '_pulse2env',
5
+ USE_SECURE_COOKIES: true,
6
+ USE_LOCALSTORAGE: false,
7
+ };
@@ -0,0 +1,81 @@
1
+ import { cookieConfig } from './cookie-config';
2
+ import { isBrowser } from './webApi';
3
+ const { USE_SECURE_COOKIES, USE_LOCALSTORAGE } = cookieConfig;
4
+ /**
5
+ * @private
6
+ */
7
+ function getExpiryDate(expiresInDays = 1) {
8
+ const expireTimestamp = Date.now() + expiresInDays * 1000 * 60 * 60 * 24;
9
+ return new Date(expireTimestamp);
10
+ }
11
+ /**
12
+ * Read a cookie from localStorage or document.cookie.
13
+ */
14
+ export function readCookie(key, useLocalStorage = USE_LOCALSTORAGE) {
15
+ if (!isBrowser) {
16
+ return '';
17
+ }
18
+ if (useLocalStorage) {
19
+ const fromLocalStorage = localStorage.getItem(key) || '';
20
+ if (fromLocalStorage) {
21
+ return fromLocalStorage;
22
+ }
23
+ }
24
+ return decodeURIComponent(document.cookie.replace(new RegExp(`(?:(?:^|.*;)\\s*${encodeURIComponent(key).replace(/[-.+*]/g, '\\$&')}\\s*\\=\\s*([^;]*).*$)|^.*$`), '$1'));
25
+ }
26
+ /**
27
+ * Write a cookie to document.cookie and/or localStorage
28
+ *
29
+ * @param key The key for the cookie
30
+ * @param value The value for the cookie
31
+ * @param domain The domain for the cookie. You might want to use `getRootDomain()`
32
+ * for this to set the cookie at the "best" domain.
33
+ * @param expiresInDays The number of days until the cookie should expire. Defaults to 1.
34
+ * @param useLocalStorage Whether to use localStorage *in addition* to setting a cookie.
35
+ * Note that localStorage has the specific origin of the current window.location, so
36
+ * if you set `domain` to something more general, then other subdomains will not be able
37
+ * to read back from the same localStorage, but will be able to read back the cookie only.
38
+ * @param useSecureCookies Whether to write that have SameSite=None and Secure set. You usually want this.
39
+ */
40
+ export function writeCookie(key, value, domain, expiresInDays = 1, useLocalStorage = USE_LOCALSTORAGE, useSecureCookies = USE_SECURE_COOKIES) {
41
+ if (isBrowser) {
42
+ const expires = getExpiryDate(expiresInDays).toUTCString();
43
+ let cookieString;
44
+ cookieString = `${key}=${encodeURIComponent(value)}`;
45
+ cookieString += ';path=/';
46
+ if (domain) {
47
+ cookieString += `;domain=${domain}`;
48
+ }
49
+ if (expiresInDays) {
50
+ cookieString += `;expires=${expires}`;
51
+ }
52
+ if (useSecureCookies &&
53
+ window.location.protocol === 'https:' &&
54
+ // 20200303
55
+ // This only detects safari on desktop
56
+ // (already fixed)
57
+ // https://bugs.webkit.org/show_bug.cgi?id=198181
58
+ // TODO: Remove this when market share with this
59
+ // bug is low.. maybe 2020-08-ish.
60
+ // biome-ignore lint/suspicious/noExplicitAny: -
61
+ window.safari === undefined) {
62
+ cookieString += ';SameSite=None;Secure';
63
+ }
64
+ // biome-ignore lint/suspicious/noDocumentCookie: -
65
+ document.cookie = cookieString;
66
+ if (useLocalStorage) {
67
+ if (value === '') {
68
+ localStorage.removeItem(key);
69
+ }
70
+ else {
71
+ localStorage.setItem(key, value);
72
+ }
73
+ }
74
+ }
75
+ }
76
+ /**
77
+ * Delete a cookie
78
+ */
79
+ export function deleteCookie(key, domain) {
80
+ writeCookie(key, '', domain, -1);
81
+ }
@@ -0,0 +1,103 @@
1
+ import { pulseMerge } from './merge';
2
+ import { isFunction, isObject, isPromise } from './objects';
3
+ /**
4
+ * @recursive
5
+ * @param eventInput
6
+ */
7
+ export async function evaluateEventInput(eventInput) {
8
+ if (isPromise(eventInput)) {
9
+ return evaluateEventInput(await eventInput);
10
+ }
11
+ if (Array.isArray(eventInput)) {
12
+ return Promise.all(eventInput.map(evaluateEventInput));
13
+ }
14
+ if (isFunction(eventInput)) {
15
+ return evaluateEventInput(eventInput());
16
+ }
17
+ if (isObject(eventInput)) {
18
+ const eventKeys = Object.getOwnPropertyNames(eventInput);
19
+ const evaluatedEventKeys = eventKeys.reduce((acc, key) => {
20
+ const eventInputProperty = eventInput[key];
21
+ if (isObject(eventInputProperty) || isFunction(eventInputProperty) || isPromise(eventInputProperty)) {
22
+ return acc.concat(evaluateEventInput(eventInputProperty));
23
+ }
24
+ return acc.concat([eventInputProperty]);
25
+ }, []);
26
+ const resolvedEventKeys = await Promise.all(evaluatedEventKeys);
27
+ return resolvedEventKeys.reduce((evaluatedEventInput, resolvedEventKey, index) => pulseMerge(evaluatedEventInput, { [eventKeys[index]]: resolvedEventKey }), {});
28
+ }
29
+ return eventInput;
30
+ }
31
+ export async function evaluateAndFlatten(builder) {
32
+ const builders = Array.isArray(builder) ? builder : [builder];
33
+ const results = await Promise.all(builders.map(evaluateEventInput));
34
+ return pulseMerge({}, ...results.filter(isObject));
35
+ }
36
+ /**
37
+ * Function for getting device type taken from the old SDK. It performs as well
38
+ * as one could expect from the size. It could be replaced with 'ua-parser-js'
39
+ * at the cost of 11kb minimized.
40
+ *
41
+ * @param {string} userAgent
42
+ *
43
+ * @returns {string} the device type the user is using
44
+ */
45
+ export function deviceType(userAgent) {
46
+ const knownDevices = {
47
+ mobile: [
48
+ /iPhone;/,
49
+ /iPod;/,
50
+ /iPod touch;/,
51
+ /^HTC/,
52
+ /Fennec/,
53
+ /IEMobile/,
54
+ /BB10;/,
55
+ /BlackBerry/,
56
+ /SymbianOS.*AppleWebKit/,
57
+ /^Mozilla.*Mobile.*Firefox/,
58
+ /^Mozilla.*Chrome.*Mobile/,
59
+ /Opera Mobi/,
60
+ /Android.*Mobile/,
61
+ /Android.*Mini/,
62
+ /Symbian/,
63
+ /^SonyEricsson/,
64
+ /^Nokia/,
65
+ /^SAMSUNG/,
66
+ /^LG/,
67
+ ],
68
+ tablet: [/iPad/, /Android/],
69
+ };
70
+ /**
71
+ * Hermes' apps (Shared app-platform for media) return "Hermes"&"_app_" as part of the user-agent
72
+ * Example UA: `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6)
73
+ * AppleWebKit/605.1.15 (KHTML, like Gecko) iOS AP Hermes/64.0.0 _app_`
74
+ * @returns {boolean} Returns true if the user is inside the app.
75
+ */
76
+ function isHermesApp() {
77
+ return userAgent.search(/Hermes.*_app_/) !== -1;
78
+ }
79
+ function isDeviceIn(devicesList) {
80
+ for (let i = 0; i < devicesList.length; i += 1) {
81
+ if (devicesList[i].test(userAgent)) {
82
+ return true;
83
+ }
84
+ }
85
+ return false;
86
+ }
87
+ if (userAgent) {
88
+ if (isDeviceIn(knownDevices.mobile)) {
89
+ return 'mobile';
90
+ }
91
+ if (isDeviceIn(knownDevices.tablet)) {
92
+ return 'tablet';
93
+ }
94
+ if (isHermesApp()) {
95
+ // If not a detected device but inside app it's most likely a tablet masking itself as desktop
96
+ return 'tablet';
97
+ }
98
+ }
99
+ return 'desktop';
100
+ }
101
+ export function dateTime() {
102
+ return new Date().toISOString();
103
+ }
@@ -0,0 +1,15 @@
1
+ import { isString } from './objects';
2
+ // biome-ignore lint/suspicious/noExplicitAny: -
3
+ export function get(object, path, defaultValue) {
4
+ if (!path || !isString(path)) {
5
+ return defaultValue;
6
+ }
7
+ const parts = path.split('.');
8
+ for (const part of parts) {
9
+ if (!object)
10
+ return defaultValue;
11
+ // biome-ignore lint/style/noParameterAssign: -
12
+ object = object[part];
13
+ }
14
+ return object ?? defaultValue;
15
+ }
@@ -0,0 +1,49 @@
1
+ import { deleteCookie, readCookie, writeCookie } from './cookie';
2
+ import { cookieConfig } from './cookie-config';
3
+ import { randomString } from './randomString';
4
+ import { isBrowser } from './webApi';
5
+ const { TEST_COOKIE_KEY } = cookieConfig;
6
+ // Exported for testing
7
+ export function makeGetRootDomainCached() {
8
+ let cache;
9
+ return () => {
10
+ if (!isBrowser) {
11
+ return '';
12
+ }
13
+ if (cache) {
14
+ return cache;
15
+ }
16
+ const parts = `${window.location.hostname}`.split('.');
17
+ const testValue = randomString();
18
+ let domain = window.location.hostname;
19
+ let test = '';
20
+ for (let i = 0; i < parts.length; i += 1) {
21
+ try {
22
+ domain = parts.slice(-(i + 1)).join('.');
23
+ writeCookie(TEST_COOKIE_KEY, testValue, domain, 1);
24
+ test = readCookie(TEST_COOKIE_KEY);
25
+ deleteCookie(TEST_COOKIE_KEY, domain);
26
+ if (test === testValue) {
27
+ break;
28
+ }
29
+ }
30
+ catch (_e) { }
31
+ }
32
+ cache = domain;
33
+ return domain;
34
+ };
35
+ }
36
+ export const resetGetRootDomain = () => {
37
+ getRootDomain = makeGetRootDomainCached();
38
+ };
39
+ /**
40
+ * Function for getting the highest cookie domain where a cookie can be placed.
41
+ * This is done by trying to set and then read back a cookie at the tld, and
42
+ * then working downwards.
43
+ *
44
+ * This function is memoized as `window.location.hostname` is supposed to be
45
+ * immutable during the lifetime of the code.
46
+ *
47
+ * @returns {string} the top domain for setting cookies. Example: aftonbladet.se
48
+ */
49
+ export let getRootDomain = makeGetRootDomainCached();
@@ -0,0 +1,11 @@
1
+ export { deleteCookie, readCookie, writeCookie } from './cookie';
2
+ export { cookieConfig } from './cookie-config';
3
+ export { dateTime, deviceType, evaluateAndFlatten, evaluateEventInput } from './events';
4
+ export { get } from './get';
5
+ export { getRootDomain, resetGetRootDomain } from './getRootDomain';
6
+ export { pulseMerge } from './merge';
7
+ export { isFunction, isObject, isObjectEmpty, isPlainObject, isPromise, isString } from './objects';
8
+ export { omit } from './omit';
9
+ export { randomString } from './randomString';
10
+ export { throttle } from './throttle';
11
+ export { initializeStorage, isBrowser, webApi } from './webApi';
@@ -0,0 +1,35 @@
1
+ import { isPlainObject, isPromise } from './objects';
2
+ /**
3
+ * This function deep merges objects, concatenates array and handles promises as values.
4
+ */
5
+ // biome-ignore lint/suspicious/noExplicitAny: -
6
+ export function pulseMerge(target, ...sources) {
7
+ return sources.reduce((acc, source) => mergeValue(acc, source), target);
8
+ function innerMerge(target, source) {
9
+ for (const [key, value] of Object.entries(source)) {
10
+ target[key] = mergeValue(target[key], value);
11
+ }
12
+ }
13
+ function mergeValue(targetValue, value) {
14
+ if (isPromise(targetValue) || isPromise(value)) {
15
+ return Promise.all([targetValue, value]).then(([targetValue, value]) => {
16
+ const copiedTarget = isPlainObject(targetValue) ? { ...targetValue } : targetValue;
17
+ return mergeValue(copiedTarget, value);
18
+ });
19
+ }
20
+ if (Array.isArray(value)) {
21
+ if (!Array.isArray(targetValue)) {
22
+ return value.filter((v) => v !== undefined);
23
+ }
24
+ return [...targetValue, ...value].filter((v) => v !== undefined);
25
+ }
26
+ if (typeof value === 'object') {
27
+ if (targetValue && value && typeof targetValue === 'object') {
28
+ innerMerge(targetValue, value);
29
+ return targetValue;
30
+ }
31
+ return value ? { ...value } : value;
32
+ }
33
+ return value ?? targetValue ?? undefined;
34
+ }
35
+ }
@@ -0,0 +1,26 @@
1
+ export function isObject(value) {
2
+ const type = typeof value;
3
+ return value != null && (type === 'object' || type === 'function');
4
+ }
5
+ export function isPlainObject(value) {
6
+ return isObject(value) && !Array.isArray(value);
7
+ }
8
+ // biome-ignore lint/suspicious/noExplicitAny: generic function
9
+ export function isFunction(value) {
10
+ return typeof value === 'function';
11
+ }
12
+ export function isString(s) {
13
+ return Object.prototype.toString.call(s) === '[object String]';
14
+ }
15
+ export function isPromise(s) {
16
+ return s instanceof Promise;
17
+ }
18
+ export function isObjectEmpty(obj) {
19
+ for (const prop in obj) {
20
+ // biome-ignore lint/suspicious/noPrototypeBuiltins: Object.hasOwn is not available in ES2020
21
+ if (Object.prototype.hasOwnProperty.call(obj, prop)) {
22
+ return false;
23
+ }
24
+ }
25
+ return true;
26
+ }
@@ -0,0 +1,6 @@
1
+ export function omit(target, props) {
2
+ if (!target) {
3
+ return {};
4
+ }
5
+ return Object.fromEntries(Object.entries(target).filter(([key]) => !props.includes(key)));
6
+ }
@@ -0,0 +1,15 @@
1
+ import { webApi } from './webApi';
2
+ export function randomString(length = 16) {
3
+ const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
4
+ const charactersLength = characters.length;
5
+ let output = '';
6
+ if (length < 0) {
7
+ return output;
8
+ }
9
+ const randomValues = new Uint32Array(length);
10
+ webApi.crypto?.getRandomValues(randomValues);
11
+ randomValues.forEach((value) => {
12
+ output += characters.charAt(value % charactersLength);
13
+ });
14
+ return output;
15
+ }
@@ -0,0 +1,31 @@
1
+ export function throttle(func, wait = 0) {
2
+ let timeout;
3
+ let lastCallTime = 0;
4
+ const f = function (...args) {
5
+ const now = Date.now();
6
+ const remaining = wait - (now - lastCallTime);
7
+ if (remaining <= 0 || remaining > wait) {
8
+ if (timeout) {
9
+ clearTimeout(timeout);
10
+ timeout = null;
11
+ }
12
+ lastCallTime = now;
13
+ // @ts-expect-error
14
+ func.apply(this, args);
15
+ }
16
+ else if (!timeout) {
17
+ timeout = setTimeout(() => {
18
+ lastCallTime = Date.now();
19
+ timeout = null;
20
+ // @ts-expect-error
21
+ func.apply(this, args);
22
+ }, remaining);
23
+ }
24
+ };
25
+ f.cancel = () => {
26
+ if (timeout) {
27
+ clearTimeout(timeout);
28
+ }
29
+ };
30
+ return f;
31
+ }
@@ -0,0 +1,17 @@
1
+ export const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
2
+ export const initializeStorage = (storageType) => {
3
+ if (!isBrowser)
4
+ return;
5
+ try {
6
+ const storage = window[storageType];
7
+ return storage && typeof storage.getItem === 'function' ? storage : undefined;
8
+ }
9
+ catch {
10
+ return;
11
+ }
12
+ };
13
+ export const webApi = {
14
+ crypto: isBrowser ? crypto : globalThis.crypto,
15
+ localStorage: initializeStorage('localStorage'),
16
+ sessionStorage: initializeStorage('sessionStorage'),
17
+ };
@@ -0,0 +1,7 @@
1
+ export declare const cookieConfig: {
2
+ PULSE_COOKIE_KEY: string;
3
+ TEST_COOKIE_KEY: string;
4
+ ENV_COOKIE_KEY: string;
5
+ USE_SECURE_COOKIES: boolean;
6
+ USE_LOCALSTORAGE: boolean;
7
+ };
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Read a cookie from localStorage or document.cookie.
3
+ */
4
+ export declare function readCookie(key: string, useLocalStorage?: boolean): string;
5
+ /**
6
+ * Write a cookie to document.cookie and/or localStorage
7
+ *
8
+ * @param key The key for the cookie
9
+ * @param value The value for the cookie
10
+ * @param domain The domain for the cookie. You might want to use `getRootDomain()`
11
+ * for this to set the cookie at the "best" domain.
12
+ * @param expiresInDays The number of days until the cookie should expire. Defaults to 1.
13
+ * @param useLocalStorage Whether to use localStorage *in addition* to setting a cookie.
14
+ * Note that localStorage has the specific origin of the current window.location, so
15
+ * if you set `domain` to something more general, then other subdomains will not be able
16
+ * to read back from the same localStorage, but will be able to read back the cookie only.
17
+ * @param useSecureCookies Whether to write that have SameSite=None and Secure set. You usually want this.
18
+ */
19
+ export declare function writeCookie(key: string, value: string, domain?: string, expiresInDays?: number, useLocalStorage?: boolean, useSecureCookies?: boolean): void;
20
+ /**
21
+ * Delete a cookie
22
+ */
23
+ export declare function deleteCookie(key: string, domain?: string): void;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @recursive
3
+ * @param eventInput
4
+ */
5
+ export declare function evaluateEventInput(eventInput: unknown): Promise<unknown>;
6
+ export declare function evaluateAndFlatten(builder: unknown): Promise<any>;
7
+ /**
8
+ * Function for getting device type taken from the old SDK. It performs as well
9
+ * as one could expect from the size. It could be replaced with 'ua-parser-js'
10
+ * at the cost of 11kb minimized.
11
+ *
12
+ * @param {string} userAgent
13
+ *
14
+ * @returns {string} the device type the user is using
15
+ */
16
+ export declare function deviceType(userAgent: string): string;
17
+ export declare function dateTime(): string;