@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 @@
1
+ export declare function get(object: any, path: string, defaultValue: any): any;
@@ -0,0 +1,13 @@
1
+ export declare function makeGetRootDomainCached(): () => string;
2
+ export declare const resetGetRootDomain: () => void;
3
+ /**
4
+ * Function for getting the highest cookie domain where a cookie can be placed.
5
+ * This is done by trying to set and then read back a cookie at the tld, and
6
+ * then working downwards.
7
+ *
8
+ * This function is memoized as `window.location.hostname` is supposed to be
9
+ * immutable during the lifetime of the code.
10
+ *
11
+ * @returns {string} the top domain for setting cookies. Example: aftonbladet.se
12
+ */
13
+ export declare let getRootDomain: () => string;
@@ -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, type StorageType, webApi } from './webApi';
@@ -0,0 +1,4 @@
1
+ /**
2
+ * This function deep merges objects, concatenates array and handles promises as values.
3
+ */
4
+ export declare function pulseMerge(target: any, ...sources: any[]): any;
@@ -0,0 +1,6 @@
1
+ export declare function isObject(value?: unknown): value is Record<string, unknown>;
2
+ export declare function isPlainObject(value?: unknown): value is Record<string, unknown>;
3
+ export declare function isFunction(value: unknown): value is (...args: any[]) => any;
4
+ export declare function isString(s: unknown): s is string;
5
+ export declare function isPromise(s: unknown): s is Promise<unknown>;
6
+ export declare function isObjectEmpty(obj: object): boolean;
@@ -0,0 +1,3 @@
1
+ export declare function omit(target: unknown, props: string[]): {
2
+ [k: string]: any;
3
+ };
@@ -0,0 +1 @@
1
+ export declare function randomString(length?: number): string;
@@ -0,0 +1,3 @@
1
+ export declare function throttle<T extends (...args: unknown[]) => void>(func: T, wait?: number): {
2
+ cancel: () => void;
3
+ } & ((...args: Parameters<T>) => void);
@@ -0,0 +1,10 @@
1
+ export type StorageType = 'localStorage' | 'sessionStorage';
2
+ export declare const isBrowser: boolean;
3
+ type WebApi = {
4
+ crypto: Crypto;
5
+ localStorage?: Storage;
6
+ sessionStorage?: Storage;
7
+ };
8
+ export declare const initializeStorage: (storageType: StorageType) => Storage | undefined;
9
+ export declare const webApi: WebApi;
10
+ export {};
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@schibsted/pulse-utils",
3
+ "version": "1.0.2",
4
+ "description": "Common js utils",
5
+ "author": "Schibsted Data&Tech",
6
+ "license": "UNLICENSED",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://schibsted.ghe.com/data-platform/pulse-sdk-js.git",
10
+ "directory": "workspaces/sdk"
11
+ },
12
+ "main": "./dist/cjs/index.js",
13
+ "module": "./dist/ejs/index.js",
14
+ "types": "./dist/types/index.d.ts",
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "scripts": {
19
+ "build": "pnpm run build:cjs && pnpm run build:ejs && pnpm run build:types",
20
+ "build:clean": "rm -fr dist",
21
+ "build:ejs": "tsc --project tsconfig.ejs.json",
22
+ "build:types": "tsc --project tsconfig.types.json",
23
+ "build:cjs": "tsc",
24
+ "dev": "tsc --watch",
25
+ "test": "pnpm run test:lint && pnpm run test:unit",
26
+ "test:lint": "biome check",
27
+ "test:lint:fix": "biome check --write",
28
+ "test:unit": "vitest run"
29
+ },
30
+ "devDependencies": {
31
+ "@types/lodash": "4.17.24",
32
+ "@types/node": "24.10.13",
33
+ "lodash": "4.17.23",
34
+ "typescript": "5.9.3"
35
+ }
36
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.builder = builder;
4
+ function builder() {
5
+ return {
6
+ isAnonymous: true,
7
+ };
8
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.builder = builder;
4
+ const uuid_1 = require("uuid");
5
+ function builder() {
6
+ return {
7
+ eventId: (0, uuid_1.v4)(),
8
+ };
9
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.builder = builder;
4
+ function builder(consents) {
5
+ return { consents: consents || getDefaultConsents() };
6
+ }
7
+ function getDefaultConsents() {
8
+ return {
9
+ advertising: 'Unknown',
10
+ analytics: 'Unknown',
11
+ marketing: 'Unknown',
12
+ personalization: 'Unknown',
13
+ source: 'default',
14
+ };
15
+ }
@@ -0,0 +1,211 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.builder = void 0;
37
+ const pulse_utils_1 = require("@schibsted/pulse-utils");
38
+ const logger = __importStar(require("loglevel"));
39
+ const ua_parser_js_1 = require("ua-parser-js");
40
+ // Cache the UAParser result to avoid re-parsing on subsequent calls
41
+ let cachedUAParser;
42
+ function getUAParser() {
43
+ if (!cachedUAParser) {
44
+ cachedUAParser = (0, ua_parser_js_1.UAParser)();
45
+ }
46
+ return cachedUAParser;
47
+ }
48
+ const builder = (environmentId, jwe) => {
49
+ if (!pulse_utils_1.isBrowser) {
50
+ return {
51
+ device: {
52
+ // TODO: server side rendering (or nodejs). do we need to set all the following fields?
53
+ // should the SDK get request headers in that case?
54
+ clientType: 'Other',
55
+ browserVersion: '',
56
+ deviceType: 'Other',
57
+ environmentId: '',
58
+ operatingSystem: 'Other',
59
+ screenOrientation: 'Portrait',
60
+ viewportSize: 'XS',
61
+ },
62
+ };
63
+ }
64
+ const uaParser = getUAParser();
65
+ return {
66
+ device: {
67
+ clientType: getClientType(uaParser),
68
+ browserVersion: uaParser.browser.version || '',
69
+ deviceType: getDeviceType(uaParser),
70
+ environmentId,
71
+ jweIds: jwe,
72
+ mobileBrand: uaParser.device.vendor,
73
+ mobileModel: uaParser.device.model,
74
+ operatingSystem: getOperatingSystem(uaParser),
75
+ screenOrientation: getScreenOrientation(),
76
+ userAgent: window.navigator.userAgent,
77
+ viewportSize: getViewportSize(),
78
+ },
79
+ };
80
+ };
81
+ exports.builder = builder;
82
+ function getClientType(uaParser) {
83
+ const { browser } = uaParser;
84
+ const browserName = browser.name?.toLocaleLowerCase() || '';
85
+ if (browserName.includes('webview')) {
86
+ // works for Chrome and Edge webview
87
+ // unfortunately, Safari webview does not include "webview" in the user agent
88
+ // so we can't detect it reliably
89
+ return 'Webview';
90
+ }
91
+ if (browserName.includes('chrome')) {
92
+ return 'Chrome';
93
+ }
94
+ if (browserName.includes('safari')) {
95
+ return 'Safari';
96
+ }
97
+ if (browserName.includes('firefox')) {
98
+ return 'Firefox';
99
+ }
100
+ if (browserName.includes('edge')) {
101
+ return 'Edge';
102
+ }
103
+ if (browserName.includes('samsung')) {
104
+ return 'Samsung';
105
+ }
106
+ // there's one more value in IDevice.clientType, "NativeScreen", but that's for the native apps
107
+ logger.log(`Unknown client type: ${browserName}. Defaulting to 'other'.`);
108
+ return 'Other';
109
+ }
110
+ function getDeviceType(uaParser) {
111
+ const { device } = uaParser;
112
+ switch (device.type) {
113
+ case 'mobile':
114
+ return 'Mobile';
115
+ case 'tablet':
116
+ return 'Tablet';
117
+ case 'smarttv':
118
+ return 'SmartTv';
119
+ // this might look weird, but device.type is undefined for desktop/laptops
120
+ // ua-parser-js only returns what it can detect from UA, and desktop/laptop is not a specific type
121
+ // the absence of a device usually means that it's desktop/laptop
122
+ // see https://github.com/faisalman/ua-parser-js/issues/182
123
+ case undefined:
124
+ return 'Desktop';
125
+ // other device types available in ua-parser-js, but unused in TPaaS:
126
+ // case 'console':
127
+ // case 'wearable':
128
+ // case 'embedded':
129
+ default:
130
+ logger.log(`Unknown device type: ${device.type}. Defaulting to 'other'.`);
131
+ return 'Other';
132
+ }
133
+ }
134
+ // maybe grab information from navigation.userAgentData in the future
135
+ // at the moment, userAgentData is considered experimental and is not supported in firefox and safari
136
+ function getOperatingSystem(uaParser) {
137
+ const { os } = uaParser;
138
+ const osName = os.name?.toLocaleLowerCase() || '';
139
+ if (osName.includes('windows')) {
140
+ return 'Windows';
141
+ }
142
+ if (osName.includes('macos')) {
143
+ return 'Mac';
144
+ }
145
+ // some flavors of Linux might not be captured by this
146
+ // do we need a better detection, based on a list?
147
+ // for example (Gentoo - https://docs.uaparser.dev/info/os/name.html)
148
+ if (osName.includes('linux')) {
149
+ return 'Linux';
150
+ }
151
+ // the TPaaS `device` template is missing Android, iOS, iPadOS and maybe others?
152
+ logger.log(`Unknown operating system: ${osName}. Defaulting to 'other'.`);
153
+ // default value
154
+ return 'Other';
155
+ }
156
+ function getScreenOrientation() {
157
+ const orientationType = window.screen.orientation?.type;
158
+ const portraitOrientations = ['portrait-primary', 'portrait-secondary'];
159
+ const landscapeOrientations = ['landscape-primary', 'landscape-secondary'];
160
+ // the ifs might be a bit overkill, but it helps with separating the default value from the logic
161
+ if (portraitOrientations.includes(orientationType)) {
162
+ return 'Portrait';
163
+ }
164
+ if (landscapeOrientations.includes(orientationType)) {
165
+ return 'Landscape';
166
+ }
167
+ // default value
168
+ return 'Portrait';
169
+ }
170
+ function getSizeFromPixels(pixels) {
171
+ if (pixels < 360) {
172
+ return 'XS';
173
+ }
174
+ if (pixels < 480) {
175
+ return 'S';
176
+ }
177
+ if (pixels < 768) {
178
+ return 'M';
179
+ }
180
+ if (pixels < 1024) {
181
+ return 'L';
182
+ }
183
+ if (pixels >= 1024) {
184
+ return 'XL';
185
+ }
186
+ // default value
187
+ logger.error('Could not determine viewport size, defaulting to M');
188
+ return 'M';
189
+ }
190
+ function getViewportSize() {
191
+ let viewportWidth;
192
+ let viewportHeight;
193
+ const { document } = window;
194
+ if (typeof window.innerWidth !== 'undefined') {
195
+ viewportWidth = window.innerWidth;
196
+ viewportHeight = window.innerHeight;
197
+ }
198
+ else if (typeof document.documentElement.clientWidth !== 'undefined' &&
199
+ document.documentElement.clientWidth !== 0) {
200
+ viewportWidth = document.documentElement.clientWidth;
201
+ viewportHeight = document.documentElement.clientHeight;
202
+ }
203
+ else {
204
+ viewportWidth = document.getElementsByTagName('body')[0].clientWidth;
205
+ viewportHeight = document.getElementsByTagName('body')[0].clientHeight;
206
+ }
207
+ const shortestDimension = Math.min(viewportWidth, viewportHeight);
208
+ const size = getSizeFromPixels(shortestDimension);
209
+ logger.debug(`Viewport size: ${viewportWidth}x${viewportHeight}, mapped to ${size}`);
210
+ return size;
211
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.builder = void 0;
4
+ const builder = (baseExperiments = [], eventExperiments = []) => {
5
+ const experiments = [...baseExperiments, ...eventExperiments];
6
+ if (experiments.length === 0) {
7
+ return {};
8
+ }
9
+ return { experiments };
10
+ };
11
+ exports.builder = builder;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.builder = void 0;
4
+ const builder = (eventNavigationType) => {
5
+ if (eventNavigationType) {
6
+ return {
7
+ page: {
8
+ navigationType: eventNavigationType,
9
+ },
10
+ };
11
+ }
12
+ return {
13
+ page: {
14
+ navigationType: getNavigationType(),
15
+ },
16
+ };
17
+ };
18
+ exports.builder = builder;
19
+ // In practice they use the same values, but for future proofing we keep them separate and mapped
20
+ const modernNavigationMap = {
21
+ navigate: 'Navigate',
22
+ reload: 'Reload',
23
+ back_forward: 'BackForward',
24
+ prerender: 'Prerender',
25
+ };
26
+ const legacyNavigationMap = {
27
+ 0: 'Navigate',
28
+ 1: 'Reload',
29
+ 2: 'BackForward',
30
+ };
31
+ const getModernNavigationType = (entryType) => {
32
+ return modernNavigationMap[entryType];
33
+ };
34
+ const getLegacyNavigationType = (entryType) => {
35
+ return legacyNavigationMap[entryType] || 'Navigate';
36
+ };
37
+ // implementation is very similar to the one in sdk/src/navigation-type that was copied from the Media Wrapper
38
+ const getNavigationType = () => {
39
+ if (typeof window === 'undefined' || typeof window.performance === 'undefined') {
40
+ // ideally we shouldn't be in this case, but if we are, we assume a navigation happened
41
+ // we could also assume it's a 'prerender', but let's keep it simple for now
42
+ return 'Navigate';
43
+ }
44
+ const [navigationEntry] = window.performance.getEntriesByType('navigation');
45
+ if (navigationEntry) {
46
+ return getModernNavigationType(navigationEntry.type);
47
+ }
48
+ if (performance.navigation?.type !== undefined) {
49
+ return getLegacyNavigationType(performance.navigation.type);
50
+ }
51
+ return 'Navigate';
52
+ };
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.builder = void 0;
4
+ const pulse_utils_1 = require("@schibsted/pulse-utils");
5
+ const builder = (currentPage) => {
6
+ // if something happens and there was no View Page type of event sent before, we need a fallback
7
+ if (!currentPage) {
8
+ return {
9
+ page: {
10
+ info: {
11
+ pageId: 'unknown',
12
+ pageType: 'Page',
13
+ url: pulse_utils_1.isBrowser ? window.location.href : undefined,
14
+ },
15
+ },
16
+ };
17
+ }
18
+ return {
19
+ page: {
20
+ info: currentPage,
21
+ },
22
+ };
23
+ };
24
+ exports.builder = builder;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.builder = void 0;
4
+ const builder = (pageviewId) => {
5
+ return {
6
+ page: {
7
+ pageviewId,
8
+ },
9
+ };
10
+ };
11
+ exports.builder = builder;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.builder = builder;
4
+ const generateProviderSDRN = (providerId) => `sdrn:schibsted:client:${providerId}`;
5
+ function builder(providerId) {
6
+ return {
7
+ provider: {
8
+ providerId,
9
+ providerSdrn: generateProviderSDRN(providerId),
10
+ },
11
+ };
12
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.builder = void 0;
4
+ const pulse_utils_1 = require("@schibsted/pulse-utils");
5
+ const builder = () => {
6
+ if (pulse_utils_1.isBrowser && document.referrer) {
7
+ return {
8
+ page: {
9
+ referrer: {
10
+ url: document.referrer,
11
+ },
12
+ },
13
+ };
14
+ }
15
+ return {
16
+ page: {},
17
+ };
18
+ };
19
+ exports.builder = builder;
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readSession = exports.readAndParse = exports.builder = void 0;
4
+ const pulse_utils_1 = require("@schibsted/pulse-utils");
5
+ const uuid_1 = require("uuid");
6
+ const { USE_LOCALSTORAGE } = pulse_utils_1.cookieConfig;
7
+ const SESSION_STORAGE_KEY = '_pulsesession';
8
+ // 1. there are pros and cons to outputting { session: ISession } instead of just ISession
9
+ // this allows us to always have the session builde populate the same property (in this case '.session')
10
+ // if in the future we want the session builder to populate other properties, we should just output ISession and move the mapping logic in index.ts, as part of buildersByEventType
11
+ // 2. we don't need builder-level "isBrowser" checks. If an event is not supposed to be fired from the browser, then the builder shouldn't be assigned to it in buildersByEventType in index.ts
12
+ // however, we should keep minimal "isBrowser" checks before webApi calls because the code might run in SSR environments
13
+ const builder = (createdAt) => {
14
+ const oldSession = (0, exports.readSession)();
15
+ const newSession = updateSession(createdAt, oldSession);
16
+ writeSession(newSession);
17
+ const { sessionId, startTime, isFirstEvent } = newSession;
18
+ return {
19
+ session: {
20
+ isFirstEvent,
21
+ sessionId,
22
+ startTime,
23
+ xDomainId: getXDomainId(),
24
+ },
25
+ };
26
+ };
27
+ exports.builder = builder;
28
+ // TODO: do we need to save this in the session, as part of the localStorage?
29
+ // or should we just read it from the URL params every time?
30
+ const getXDomainId = () => {
31
+ if (!pulse_utils_1.isBrowser) {
32
+ return;
33
+ }
34
+ const urlParams = new URLSearchParams(window?.location?.search ?? '');
35
+ return urlParams.get('x_domain_id') || undefined;
36
+ };
37
+ // Return parsed json from cookie (or localStorage if enabled), or undefined.
38
+ // exported for testing purposes.
39
+ const readAndParse = (storageKey) => {
40
+ try {
41
+ const storedSession = (0, pulse_utils_1.readCookie)(storageKey);
42
+ if (storedSession) {
43
+ return JSON.parse(storedSession);
44
+ }
45
+ }
46
+ catch (_e) {
47
+ // If localStorage/cookie is not available, we treat it as if
48
+ // the value is undefined.
49
+ // If data is unparseable, we also ignore it.
50
+ return undefined;
51
+ }
52
+ return undefined;
53
+ };
54
+ exports.readAndParse = readAndParse;
55
+ // Read and parse session data from localStorage.
56
+ // Any invalid or unreadable data is ignored.
57
+ const readSession = () => {
58
+ const storedSession = (0, exports.readAndParse)(SESSION_STORAGE_KEY);
59
+ if (storedSession) {
60
+ const [sessionId, startTimeMs, lastEventTimeMs] = storedSession;
61
+ const startTime = new Date(startTimeMs);
62
+ const lastEventTime = new Date(lastEventTimeMs);
63
+ if (sessionId &&
64
+ startTime &&
65
+ lastEventTime &&
66
+ !Number.isNaN(startTime.getTime()) &&
67
+ !Number.isNaN(lastEventTime.getTime())) {
68
+ return { sessionId, startTime: startTime.toISOString(), lastEventTime, isFirstEvent: false };
69
+ }
70
+ }
71
+ return undefined;
72
+ };
73
+ exports.readSession = readSession;
74
+ // Write session data to localStorage
75
+ const writeSession = (session) => {
76
+ const { sessionId, startTime, lastEventTime } = session;
77
+ try {
78
+ const sessionToStore = [sessionId, new Date(startTime).getTime(), lastEventTime.getTime()];
79
+ const halfHourInDays = 1.0 / (24 * 2);
80
+ (0, pulse_utils_1.writeCookie)(SESSION_STORAGE_KEY, JSON.stringify(sessionToStore), (0, pulse_utils_1.getRootDomain)(), halfHourInDays);
81
+ // Delete old localStorage-based session if needed
82
+ if (!USE_LOCALSTORAGE) {
83
+ // removeItem will do nothing to a non-existing item.
84
+ // use webApi.localStorage instead of window.localStorage
85
+ pulse_utils_1.webApi.localStorage?.removeItem(SESSION_STORAGE_KEY);
86
+ }
87
+ }
88
+ catch (_e) {
89
+ // If we can't write the session, we just move on in life
90
+ }
91
+ };
92
+ const createSession = (eventCreationDate) => {
93
+ const now = eventCreationDate ?? new Date();
94
+ return {
95
+ sessionId: (0, uuid_1.v4)(),
96
+ startTime: now.toISOString(),
97
+ lastEventTime: now,
98
+ isFirstEvent: true,
99
+ };
100
+ };
101
+ const updateSession = (eventCreationDate, session) => {
102
+ const sessionMaxInterval = 30 * 60 * 1000; // 30 minutes in milliseconds
103
+ if (!session || session.lastEventTime.getTime() < eventCreationDate.getTime() - sessionMaxInterval) {
104
+ return createSession(eventCreationDate);
105
+ }
106
+ return {
107
+ ...session,
108
+ // to ensure backwards compatibility between the new sessionId format and old sessions
109
+ // we need to remove the SDRN prefix from old sessionIds
110
+ sessionId: session.sessionId.replace('sdrn:schibsted:session:', ''),
111
+ isFirstEvent: false,
112
+ lastEventTime: eventCreationDate,
113
+ };
114
+ };
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.builder = void 0;
4
+ const builder = (createdAt) => {
5
+ const isoString = createdAt.toISOString();
6
+ return {
7
+ time: {
8
+ createdAt: isoString,
9
+ // setting sentAt here, so we please the typescript gods, however, this value will be overwritten later
10
+ // sentAt will be set just before sending the event
11
+ sentAt: isoString, // this will be set just before sending the event
12
+ },
13
+ };
14
+ };
15
+ exports.builder = builder;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.builder = void 0;
4
+ const builder = (autoTrackerVersion, isHybrid, version) => {
5
+ return {
6
+ tracker: {
7
+ autoTrackerVersion,
8
+ isAutoTracker: !!autoTrackerVersion,
9
+ isHybrid,
10
+ trackerType: 'JS',
11
+ version,
12
+ },
13
+ };
14
+ };
15
+ exports.builder = builder;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.builder = void 0;
4
+ const builder = (user) => {
5
+ if (!user) {
6
+ console.warn('User is not set, inferring the user is anonymous (logged out).');
7
+ return {};
8
+ }
9
+ const { hasAnySubscription, region, id, realm } = user;
10
+ if (!id || !id.toString().trim()) {
11
+ // the user is anonymous (logged out)
12
+ return {};
13
+ }
14
+ return {
15
+ user: {
16
+ hasAnySubscription,
17
+ region,
18
+ userId: id,
19
+ userSdrn: generateUserSDRN(id, realm),
20
+ },
21
+ };
22
+ };
23
+ exports.builder = builder;
24
+ function generateUserSDRN(id, realm = '__REALM_NOT_SET__') {
25
+ return `sdrn:${realm}:user:${id}`;
26
+ }