@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,71 @@
1
+ import { describe, it } from 'vitest';
2
+ import Tracker from './Tracker';
3
+ const ARTICLE_PAYLOAD = {
4
+ experiments: [
5
+ {
6
+ name: 'test-experiment',
7
+ variant: 'test-variant',
8
+ },
9
+ ],
10
+ object: {
11
+ category: 'abcd',
12
+ objectId: 'page-123',
13
+ objectSdrn: 'sdrn:the-standard:page:page-123',
14
+ tags: ['tag1', 'tag2'],
15
+ title: 'Test Page',
16
+ },
17
+ metrics: [
18
+ {
19
+ key: 'topKScore',
20
+ name: 'topKScore',
21
+ source: 'Curate',
22
+ value: 0,
23
+ },
24
+ ],
25
+ page: {
26
+ navigationType: 'Navigate',
27
+ referrer: {
28
+ pageId: 'referrer-page',
29
+ pageType: 'Article',
30
+ },
31
+ },
32
+ provider: {
33
+ component: 'test-component',
34
+ componentVersion: '1.0.0',
35
+ product: 'test-product',
36
+ stage: 'Dev',
37
+ version: '1.0.0',
38
+ },
39
+ };
40
+ const tracker = new Tracker('test-site', {});
41
+ describe('Type tests for Tracker', () => {
42
+ it('should compile without errors', () => {
43
+ tracker.trackViewPage(ARTICLE_PAYLOAD, { leaveTracking: false });
44
+ tracker.trackViewPage(ARTICLE_PAYLOAD, {
45
+ leaveTracking: {
46
+ objectElement: document.body,
47
+ },
48
+ });
49
+ tracker.trackViewPage(ARTICLE_PAYLOAD, {
50
+ leaveTracking: {
51
+ objectElement: document.body,
52
+ pageElement: document.documentElement,
53
+ objectResizable: true,
54
+ heightBuilder: () => ({
55
+ totalHeight: 0,
56
+ viewedHeight: 0,
57
+ }),
58
+ },
59
+ });
60
+ });
61
+ it('expects errors because invalid API calls', () => {
62
+ tracker.trackViewPage(ARTICLE_PAYLOAD, {
63
+ // @ts-expect-error we expect an error here because leaveTracking shouldn't be passed as true
64
+ leaveTracking: true,
65
+ });
66
+ // @ts-expect-error we expect an error here because we're missing the second parameter (options)
67
+ tracker.trackViewPage(ARTICLE_PAYLOAD);
68
+ // @ts-expect-error we expect an error here because we're mising leaveTracking options
69
+ tracker.trackViewPage(ARTICLE_PAYLOAD, {});
70
+ });
71
+ });
@@ -0,0 +1,33 @@
1
+ import { isBrowser } from '@schibsted/pulse-utils';
2
+ import logger from 'loglevel';
3
+ export function getDefaultNativeJwe(config) {
4
+ if (config.nativeJwe) {
5
+ logger.debug('Using nativeJwe from config');
6
+ return config.nativeJwe;
7
+ }
8
+ if (!isBrowser) {
9
+ return;
10
+ }
11
+ if (!window.__nativeJwe__ && !window.hermesJwe) {
12
+ logger.debug('No __nativeJwe__ or hermesJwe found in window');
13
+ return;
14
+ }
15
+ // Special support for Hybrid apps, using Pulse tracking and/or ad identifiers within a webview
16
+ return window.__nativeJwe__ || window.hermesJwe;
17
+ }
18
+ export function getDefaultAltHandler(config) {
19
+ if (config.altEventHandler) {
20
+ logger.debug('Using altEventHandler from config');
21
+ return config.altEventHandler;
22
+ }
23
+ if (!isBrowser) {
24
+ return;
25
+ }
26
+ if (!window.pulseEventHandler) {
27
+ logger.debug('No pulseEventHandler found in window');
28
+ return;
29
+ }
30
+ // If the pulse event handler is set, e.g. by a native app in
31
+ // a hybrid app setup, we pick that as the 'altEventHandler'
32
+ return window.pulseEventHandler;
33
+ }
@@ -0,0 +1,53 @@
1
+ import { isPlainObject, isString } from '@schibsted/pulse-utils';
2
+ /**
3
+ * generateActorSDRN
4
+ * Generates a well-formed sdrn for an actor, based on id, realm inputs
5
+ * @param id String
6
+ * @param realm String Realm is not required, so, without a fully formed "@id" in the actors input object, the "realm"
7
+ * part of the sdrn is flagged with "__REALM_NOT_SET__", for early noticing implementation/integration errors.
8
+ * @internal
9
+ */
10
+ export function generateActorSDRN(id, realm = '__REALM_NOT_SET__') {
11
+ const outputId = id || '__USER_ID_NOT_SET__';
12
+ return `sdrn:${realm}:user:${outputId}`;
13
+ }
14
+ /**
15
+ * Type guard to check if the input is an ActorInput
16
+ * @param input
17
+ * @internal
18
+ */
19
+ export function isActorInput(input) {
20
+ // biome-ignore lint/suspicious/noPrototypeBuiltins: Object.hasOwn is not available in ES2020
21
+ return isPlainObject(input) && Object.prototype.hasOwnProperty.call(input, 'actor');
22
+ }
23
+ function formatActorInput(input) {
24
+ if (isString(input)) {
25
+ return { id: input };
26
+ }
27
+ const { id, realm, ...rest } = input || {};
28
+ return { id, realm, ...rest };
29
+ }
30
+ /**
31
+ * Function to generate a builder for Actor objects.
32
+ */
33
+ export default function actor(input) {
34
+ const { actor: actorInput } = input || {};
35
+ if (!actorInput) {
36
+ return undefined;
37
+ }
38
+ const { id, realm, ...inputProps } = formatActorInput(actorInput);
39
+ // TODO: think in ways that a well-formed SDRN passed as @id in the input can render the "id" not necessary anymore.
40
+ if (!id) {
41
+ return undefined;
42
+ }
43
+ const actorSDRN = generateActorSDRN(id, realm);
44
+ const baseActor = {
45
+ '@id': actorSDRN,
46
+ 'spt:userId': actorSDRN,
47
+ };
48
+ return Object.assign(baseActor, inputProps);
49
+ }
50
+ /**
51
+ * @internal
52
+ */
53
+ export const defaultValue = () => undefined;
@@ -0,0 +1,125 @@
1
+ import logger from 'loglevel';
2
+ import { ConsentsCategory } from './consents';
3
+ /**
4
+ * Fallback if TCF fails to initialize
5
+ * These should always be "unknown" since we don't know the user's choice
6
+ * @returns
7
+ */
8
+ export function getFallbackConsents() {
9
+ return {
10
+ purposes: {
11
+ [ConsentsCategory.CMP_ADVERTISING]: {
12
+ optIn: false,
13
+ status: 'unknown',
14
+ },
15
+ [ConsentsCategory.CMP_ANALYTICS]: {
16
+ optIn: false,
17
+ status: 'unknown',
18
+ },
19
+ [ConsentsCategory.CMP_MARKETING]: {
20
+ optIn: false,
21
+ status: 'unknown',
22
+ },
23
+ [ConsentsCategory.CMP_PERSONALIZATION]: {
24
+ optIn: false,
25
+ status: 'unknown',
26
+ },
27
+ },
28
+ source: 'default',
29
+ };
30
+ }
31
+ /**
32
+ * Returns the consent manager (`_tcf_`), if available.
33
+ * It will await "cmp:loaded" event if the consent manager is not available yet and return it when it is.
34
+ * @returns The consent manager object.
35
+ * @example
36
+ * const manager = await consentManager();
37
+ */
38
+ export const consentManager = () => {
39
+ // For ConsentManager/window._tcf_ type, either duck type something yourself for now or wait for better types to be exposed from sourcepoint package.
40
+ const getManager = () => window._tcf_;
41
+ return new Promise((resolve, reject) => {
42
+ const manager = getManager();
43
+ if (manager) {
44
+ resolve(manager);
45
+ }
46
+ else {
47
+ let hasTimedOut = false;
48
+ const timeoutForManager = setTimeout(() => {
49
+ logger.error('Pulse - timed out waiting for consentManager');
50
+ hasTimedOut = true;
51
+ reject(new Error('Pulse - timed out waiting for consentManager'));
52
+ }, 5000);
53
+ document.addEventListener('cmp:loaded', () => {
54
+ if (hasTimedOut) {
55
+ logger.error('Pulse - consentManager triggered after timeout');
56
+ return;
57
+ }
58
+ clearTimeout(timeoutForManager);
59
+ resolve(getManager());
60
+ }, {
61
+ once: true,
62
+ });
63
+ }
64
+ });
65
+ };
66
+ /**
67
+ * Waits for user to reply to consents, then retrieves the cached or default consents for Pulse from the consent manager.
68
+ * Only needed if you want to wait for user to respond to consents rather than sending events with default consent
69
+ * WARNING: Do not use this without analytics consent being activated in TCF or it will never resolve for users without cached consents!
70
+ * @returns A promise with the cached or default consents for Pulse.
71
+ * @example
72
+ * const getConsentsWaitForAnalyticsPromise = getConsentsWaitForAnalytics();
73
+ */
74
+ export const getConsentsWaitForAnalytics = async (callback) => {
75
+ const consents = await getInitialConsentsFromTCF();
76
+ // no need to subscribe if we don't receive a callback to call
77
+ if (callback) {
78
+ await subscribeToConsentUpdates(callback);
79
+ }
80
+ return consents;
81
+ };
82
+ const subscribeToConsentUpdates = async (callback) => {
83
+ let manager;
84
+ try {
85
+ manager = await consentManager();
86
+ }
87
+ catch (error) {
88
+ logger.error('Unable to subscribe as tcf manager is not initialized', error);
89
+ // If we can't get the consent manager, we can't subscribe to updates
90
+ return;
91
+ }
92
+ manager.subscribeAny(() => {
93
+ const consents = manager.getCachedOrDefaultConsentsForPulse();
94
+ logger.debug('CMP:subscribeToConsentUpdates:subscribeAny - resolved after user replied to consent dialog', consents);
95
+ callback(consents);
96
+ });
97
+ };
98
+ const getInitialConsentsFromTCF = async () => {
99
+ let manager;
100
+ try {
101
+ manager = await consentManager();
102
+ }
103
+ catch (error) {
104
+ logger.error('Failed to get consent manager, using pulse default consents', error);
105
+ return getFallbackConsents();
106
+ }
107
+ // Check if analytics consent exists in cache.
108
+ const analyticsConsent = manager.getPermissionSync('CMP:analytics');
109
+ // null analyticsConsent means that the user has not yet replied to the consent dialog.
110
+ if (analyticsConsent === null) {
111
+ // Wait for the user to reply to the consent dialog.
112
+ return new Promise((resolve) => {
113
+ // Need to use subscribeAny since that is the only one resolving after all consents are properly set initially
114
+ const unsubscribe = manager.subscribeAny(() => {
115
+ logger.debug('CMP:getConsentsWaitForAnalytics - resolved after user replied to consent dialog');
116
+ resolve(manager.getCachedOrDefaultConsentsForPulse());
117
+ unsubscribe();
118
+ });
119
+ return;
120
+ });
121
+ }
122
+ // If we have consent in cache or do not need to wait, return the consents immediately.
123
+ logger.debug('CMP:getConsentsWaitForAnalytics - resolved immediately');
124
+ return manager.getCachedOrDefaultConsentsForPulse();
125
+ };
@@ -0,0 +1,138 @@
1
+ import { clearCookieAdvertisingIds } from '@schibsted/pulse-cis-sync';
2
+ import { isPromise } from '@schibsted/pulse-utils';
3
+ import warnOnce from '../warnOnce';
4
+ import { getFallbackConsents } from './consent-manager';
5
+ /**
6
+ * @enum ConsentCategory
7
+ */
8
+ export var ConsentsCategory;
9
+ (function (ConsentsCategory) {
10
+ ConsentsCategory["CMP_ANALYTICS"] = "CMP_ANALYTICS";
11
+ ConsentsCategory["CMP_MARKETING"] = "CMP_MARKETING";
12
+ ConsentsCategory["CMP_ADVERTISING"] = "CMP_ADVERTISING";
13
+ ConsentsCategory["CMP_PERSONALIZATION"] = "CMP_PERSONALIZATION";
14
+ })(ConsentsCategory || (ConsentsCategory = {}));
15
+ export const ConsentsSourceValues = ['default', 'cmp', 'cache'];
16
+ export const ConsentsPurposeCategoryStatusValues = ['accepted', 'rejected', 'unknown'];
17
+ const isLegacyConsentsPurpose = (consentsPurposeCategory) => {
18
+ return !consentsPurposeCategory?.status;
19
+ };
20
+ const isLegacyConsents = (consents) => {
21
+ return !!(consents &&
22
+ !isPromise(consents) &&
23
+ consents?.purposes &&
24
+ Object.values(consents.purposes).every((purpose) => isLegacyConsentsPurpose(purpose)));
25
+ };
26
+ const NO_CONSENT_IN_CONFIG = 'Invalid consents passed to the Pulse SDK. "requireAdvertisingOptIn" and no "consents" config param present.';
27
+ /**
28
+ *
29
+ * @param consents
30
+ * @param requireAdvertisingOptIn
31
+ * @returns The resolved consents and whether advertising is allowed
32
+ * @deprecated Advertising Identifiers methods will be removed in the next major version.
33
+ * @internal
34
+ */
35
+ export async function applyAdvertisingConsent(consents, requireAdvertisingOptIn) {
36
+ if (!consents && typeof requireAdvertisingOptIn !== 'undefined' && requireAdvertisingOptIn !== undefined) {
37
+ warnOnce('NO_CONSENT_IN_CONFIG', NO_CONSENT_IN_CONFIG);
38
+ }
39
+ const includeAdvertising = await resolveIncludeAdvertising(consents, requireAdvertisingOptIn);
40
+ if (!includeAdvertising) {
41
+ clearCookieAdvertisingIds();
42
+ }
43
+ return includeAdvertising;
44
+ }
45
+ /**
46
+ *
47
+ * @param consents
48
+ * @param requireAdvertisingOptIn
49
+ * @returns The resolved consents and whether advertising is allowed
50
+ * @deprecated Advertising Identifiers methods will be removed in the next major version.
51
+ * @internal
52
+ */
53
+ export function applyAdvertisingConsentSync(consents, requireAdvertisingOptIn) {
54
+ if (!consents && typeof requireAdvertisingOptIn !== 'undefined' && requireAdvertisingOptIn !== undefined) {
55
+ warnOnce('NO_CONSENT_IN_CONFIG', NO_CONSENT_IN_CONFIG);
56
+ }
57
+ const includeAdvertising = resolveIncludeAdvertisingSync(consents, requireAdvertisingOptIn);
58
+ if (!includeAdvertising) {
59
+ clearCookieAdvertisingIds();
60
+ }
61
+ return includeAdvertising;
62
+ }
63
+ /**
64
+ *
65
+ * @param consents
66
+ * @param requireAdvertisingOptIn
67
+ * @returns whether advertising is allowed
68
+ * @deprecated Advertising Identifiers methods will be removed in the next major version.
69
+ * @internal
70
+ */
71
+ export async function resolveIncludeAdvertising(consents, requireAdvertisingOptIn) {
72
+ const resolvedRequireAdvertisingOptIn = await requireAdvertisingOptIn;
73
+ if (!resolvedRequireAdvertisingOptIn) {
74
+ return true;
75
+ }
76
+ if (isPromise(consents)) {
77
+ const resolvedConsents = await consents;
78
+ return resolvedConsents?.purposes?.[ConsentsCategory.CMP_ADVERTISING]?.status === 'accepted';
79
+ }
80
+ if (isLegacyConsents(consents)) {
81
+ return Boolean(consents?.purposes?.[ConsentsCategory.CMP_ADVERTISING]?.optIn);
82
+ }
83
+ return consents?.purposes?.[ConsentsCategory.CMP_ADVERTISING]?.status === 'accepted';
84
+ }
85
+ /**
86
+ *
87
+ * @param consents
88
+ * @param requireAdvertisingOptIn
89
+ * @returns whether advertising is allowed
90
+ * @deprecated Advertising Identifiers methods will be removed in the next major version.
91
+ * @internal
92
+ */
93
+ export function resolveIncludeAdvertisingSync(consents, requireAdvertisingOptIn) {
94
+ if (!requireAdvertisingOptIn) {
95
+ return true;
96
+ }
97
+ if (isLegacyConsents(consents)) {
98
+ return Boolean(consents?.purposes?.[ConsentsCategory.CMP_ADVERTISING]?.optIn);
99
+ }
100
+ return consents?.purposes?.[ConsentsCategory.CMP_ADVERTISING]?.status === 'accepted';
101
+ }
102
+ /**
103
+ * Builds a consents object from input.
104
+ * @param input
105
+ */
106
+ export default function consents(input) {
107
+ const { consents: consentsInput } = input || {};
108
+ if (!consentsInput) {
109
+ return undefined;
110
+ }
111
+ const purposesInput = consentsInput?.purposes ?? {};
112
+ return {
113
+ purposes: purposes(purposesInput),
114
+ source: consentsInput?.source,
115
+ };
116
+ }
117
+ /**
118
+ * This can be removed when we no longer fill purposeInput.optIn: boolean based on status string.
119
+ * isConsentsPurposes can be used to return an unmodified consent object.
120
+ * @see https://schibsted.io.atlassian.net/browse/SDP-11907
121
+ * @internal
122
+ */
123
+ function purposes(purposesInput) {
124
+ const purposesOutput = getFallbackConsents().purposes;
125
+ for (const categoryInput in purposesInput) {
126
+ const consentCategory = categoryInput;
127
+ const purposeInput = purposesInput[consentCategory];
128
+ const isValidCategory = Boolean(purposesOutput[consentCategory]);
129
+ if (!purposeInput || !isValidCategory) {
130
+ continue;
131
+ }
132
+ if (!isLegacyConsentsPurpose(purposeInput)) {
133
+ purposeInput.optIn || (purposeInput.optIn = purposeInput.status === 'accepted');
134
+ }
135
+ purposesOutput[consentCategory] = purposeInput;
136
+ }
137
+ return purposesOutput;
138
+ }
@@ -0,0 +1,69 @@
1
+ import { parsePulseCookies } from '@schibsted/pulse-cis-sync';
2
+ import { deviceType, isBrowser, isString } from '@schibsted/pulse-utils';
3
+ import { device } from './device-node';
4
+ export * from './device-node';
5
+ function supportsLocalStorage() {
6
+ try {
7
+ const { localStorage } = window;
8
+ localStorage.setItem('pulse4test', 'check');
9
+ localStorage.removeItem('pulse4test');
10
+ return true;
11
+ }
12
+ catch (_e) {
13
+ return false;
14
+ }
15
+ }
16
+ function getViewportDimensions() {
17
+ if (!isBrowser) {
18
+ return '';
19
+ }
20
+ let viewportWidth;
21
+ let viewportHeight;
22
+ const { document } = window;
23
+ if (typeof window.innerWidth !== 'undefined') {
24
+ viewportWidth = window.innerWidth;
25
+ viewportHeight = window.innerHeight;
26
+ }
27
+ else if (typeof document.documentElement.clientWidth !== 'undefined' &&
28
+ document.documentElement.clientWidth !== 0) {
29
+ viewportWidth = document.documentElement.clientWidth;
30
+ viewportHeight = document.documentElement.clientHeight;
31
+ }
32
+ else {
33
+ viewportWidth = document.getElementsByTagName('body')[0].clientWidth;
34
+ viewportHeight = document.getElementsByTagName('body')[0].clientHeight;
35
+ }
36
+ return `${viewportWidth}x${viewportHeight}`;
37
+ }
38
+ export function getXEnvironmentId() {
39
+ if (!isBrowser) {
40
+ return undefined;
41
+ }
42
+ const urlParams = new URLSearchParams(window?.location?.search ?? '');
43
+ return urlParams.get('x_env_id') || undefined;
44
+ }
45
+ export const defaultValue = () => {
46
+ if (!isBrowser) {
47
+ return {};
48
+ }
49
+ const { navigator, screen } = window;
50
+ return {
51
+ acceptLanguage: navigator.userLanguage || navigator.language,
52
+ screenSize: `${screen.width}x${screen.height}`,
53
+ userAgent: navigator.userAgent,
54
+ deviceType: deviceType(window.navigator.userAgent),
55
+ viewportSize: getViewportDimensions(),
56
+ localStorageEnabled: supportsLocalStorage(),
57
+ xEnvironmentId: getXEnvironmentId(),
58
+ };
59
+ };
60
+ export default function (input) {
61
+ const { device: deviceInput } = input || {};
62
+ const { environmentId, jwe } = parsePulseCookies();
63
+ const data = {
64
+ id: environmentId,
65
+ jweIds: jwe,
66
+ ...(isString(deviceInput) ? { id: deviceInput } : deviceInput),
67
+ };
68
+ return device(defaultValue)({ device: data });
69
+ }
@@ -0,0 +1,57 @@
1
+ import { isString, pulseMerge } from '@schibsted/pulse-utils';
2
+ /**
3
+ * Generate a well-formed environment SDRN from an ID
4
+ * @param id
5
+ * @internal
6
+ */
7
+ export function generateEnvironmentSDRN(id) {
8
+ return `sdrn:schibsted:environment:${id}`;
9
+ }
10
+ function formatDeviceInput(input) {
11
+ if (isString(input)) {
12
+ return { id: input };
13
+ }
14
+ const { id, ...rest } = input || {};
15
+ return { id, ...rest };
16
+ }
17
+ /**
18
+ * Generate a device representation
19
+ *
20
+ * Several default values are used in a browser environment: acceptLanguage,
21
+ * screenSize, userAgent, deviceType, viewportSize, localStorageEnabled. See
22
+ * (device-browser.js)[device-browser.js] for implementation details.
23
+ *
24
+ * The browser implementation will also read the required values from the
25
+ * `_pulse2cookie` and if needed sync with CIS. Note that *this is not
26
+ * implemented for Node.js environments*. There are no default values in
27
+ * Node.js.
28
+ *
29
+ * @internal
30
+ */
31
+ export const device = (defaultValueHandler) => (input) => {
32
+ const { device: deviceInput } = input || {};
33
+ if (!deviceInput) {
34
+ return undefined;
35
+ }
36
+ const formattedInput = pulseMerge({}, defaultValueHandler(), formatDeviceInput(deviceInput));
37
+ const { id, additionalIds, ...props } = formattedInput;
38
+ if (!id) {
39
+ return undefined;
40
+ }
41
+ const baseDevice = {
42
+ '@type': 'Device',
43
+ environmentId: generateEnvironmentSDRN(id),
44
+ };
45
+ if (additionalIds) {
46
+ baseDevice.additionalEnvironmentIds = additionalIds.map(generateEnvironmentSDRN);
47
+ }
48
+ return Object.assign(baseDevice, props);
49
+ };
50
+ /**
51
+ * @internal
52
+ */
53
+ export const defaultValue = () => ({});
54
+ /**
55
+ * Builder for Device objects.
56
+ */
57
+ export default device(defaultValue);
@@ -0,0 +1,2 @@
1
+ export * from './device-node';
2
+ export { default } from './device-node';
@@ -0,0 +1 @@
1
+ export { anonymousEngagementEvent, anonymousTrackerEvent } from './events-anonymous-node';
@@ -0,0 +1,48 @@
1
+ import { omit, pulseMerge } from '@schibsted/pulse-utils';
2
+ import consentsBuilder from './consents';
3
+ import { DEFAULT_SCHEMA_LOCATION } from './events-node';
4
+ import experimentMetadataBuilder, { defaultValue as experimentMetadataDefaultValue } from './experimentMetadata';
5
+ import experimentsBuilder, { defaultValue as experimentsDefaultValue } from './experiments';
6
+ import objectBuilder, { defaultValue as objectDefaultValue } from './objects/objects-anonymous';
7
+ import originBuilder, { defaultValue as originDefaultValue } from './origin';
8
+ import providerBuilder, { defaultValue as providerDefaultValue } from './provider';
9
+ import trackerBuilder, { defaultValue as trackerDefaultValue } from './trackerBuilder';
10
+ /**
11
+ * Add default values to AnonymousTrackerEventInput.
12
+ */
13
+ function trackerAnonymousEventInput(eventInput) {
14
+ return pulseMerge({
15
+ experiments: experimentsDefaultValue(),
16
+ experimentMetadata: experimentMetadataDefaultValue(),
17
+ object: objectDefaultValue(),
18
+ origin: originDefaultValue(),
19
+ provider: providerDefaultValue(),
20
+ tracker: trackerDefaultValue(),
21
+ }, eventInput);
22
+ }
23
+ export function anonymousTrackerEvent({ eventInput, sdkConfig } = {}) {
24
+ const parentInput = trackerAnonymousEventInput(eventInput);
25
+ return Object.assign({}, omit(eventInput, ['type']), {
26
+ '@type': eventInput?.type || 'View',
27
+ schema: eventInput?.schema ||
28
+ `http://${sdkConfig?.schemaLocation || DEFAULT_SCHEMA_LOCATION}/events/tracker-event.json/351.json`,
29
+ consents: consentsBuilder(parentInput),
30
+ experiments: experimentsBuilder(parentInput),
31
+ experimentMetadata: experimentMetadataBuilder(parentInput),
32
+ object: objectBuilder(parentInput),
33
+ origin: originBuilder(parentInput),
34
+ provider: providerBuilder(parentInput),
35
+ target: parentInput.target && objectBuilder(Object.assign({}, parentInput, { object: parentInput.target })),
36
+ tracker: trackerBuilder(parentInput),
37
+ isAnonymous: true,
38
+ });
39
+ }
40
+ anonymousTrackerEvent.defaults = trackerAnonymousEventInput;
41
+ export function anonymousEngagementEvent({ eventInput, sdkConfig } = {}) {
42
+ return Object.assign(anonymousTrackerEvent({ eventInput, sdkConfig }), {
43
+ schema: eventInput?.schema ||
44
+ `http://${sdkConfig?.schemaLocation || DEFAULT_SCHEMA_LOCATION}/events/engagement-event.json/378.json`,
45
+ '@type': 'Engagement',
46
+ });
47
+ }
48
+ anonymousEngagementEvent.defaults = trackerAnonymousEventInput;
@@ -0,0 +1 @@
1
+ export * from './events-anonymous-node';
@@ -0,0 +1 @@
1
+ export { engagementEvent, identityEvent, routableEvent, trackerEvent } from './events-node';