@schibsted/pulse-sdk 8.0.0-rc.2 → 8.0.0-rc.21

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 (409) hide show
  1. package/dist/cjs/Tracker.js +582 -471
  2. package/dist/cjs/app-integration.js +3 -3
  3. package/dist/cjs/builders/actor.js +6 -6
  4. package/dist/cjs/builders/consents.js +8 -8
  5. package/dist/cjs/builders/device-browser.js +8 -8
  6. package/dist/cjs/builders/device-node.js +3 -3
  7. package/dist/cjs/builders/events-anonymous-node.js +3 -3
  8. package/dist/cjs/builders/events-node.js +7 -7
  9. package/dist/cjs/builders/experimentMetadata.js +2 -2
  10. package/dist/cjs/builders/experiments.js +1 -0
  11. package/dist/cjs/builders/objects/objects-anonymous-browser.js +2 -2
  12. package/dist/cjs/builders/objects/objects-anonymous-node.js +9 -9
  13. package/dist/cjs/builders/objects/objects-browser.js +2 -2
  14. package/dist/cjs/builders/objects/objects-node.js +10 -10
  15. package/dist/cjs/builders/objects/utils.js +3 -3
  16. package/dist/cjs/builders/origin-browser.js +2 -2
  17. package/dist/cjs/builders/origin-node.js +4 -4
  18. package/dist/cjs/builders/session-browser.js +6 -80
  19. package/dist/cjs/cis-sync/cis-browser.js +219 -0
  20. package/{node_modules/@schibsted/pulse-cis-sync/dist/cjs → dist/cjs/cis-sync}/cis.js +0 -1
  21. package/dist/cjs/cis-sync/eventEmitter.js +37 -0
  22. package/{node_modules/@schibsted/pulse-cis-sync/dist/cjs → dist/cjs/cis-sync}/index.js +0 -1
  23. package/{node_modules/@schibsted/pulse-cis-sync/dist/cjs → dist/cjs/cis-sync}/pulse-cookie.js +53 -63
  24. package/{node_modules/@schibsted/pulse-cis-sync/dist/cjs → dist/cjs/cis-sync}/storage/pulseStorage.js +28 -21
  25. package/dist/cjs/cis-sync/storage/storage.js +24 -0
  26. package/dist/cjs/createPulseTracker.js +4 -4
  27. package/dist/cjs/identity/actor.js +20 -8
  28. package/dist/cjs/identity/advertising.js +1 -1
  29. package/dist/cjs/identity/cis.js +7 -6
  30. package/dist/cjs/index.js +3 -3
  31. package/dist/cjs/leaveTracking/index.js +10 -10
  32. package/dist/cjs/leaveTrackingTpaas/constants.js +2 -7
  33. package/dist/cjs/leaveTrackingTpaas/index.js +70 -46
  34. package/dist/cjs/network-browser.js +3 -3
  35. package/dist/cjs/remoteConfig/index.js +5 -5
  36. package/dist/cjs/session/store.js +96 -0
  37. package/dist/cjs/tpaas-builders/builders/catalogVersion.js +9 -0
  38. package/{node_modules/@schibsted/tpaas-event-builder/dist/cjs → dist/cjs/tpaas-builders}/builders/device.js +50 -72
  39. package/{node_modules/@schibsted/tpaas-event-builder/dist/cjs → dist/cjs/tpaas-builders}/builders/navigationType.js +2 -3
  40. package/dist/cjs/tpaas-builders/builders/pageContent.js +7 -0
  41. package/{node_modules/@schibsted/tpaas-event-builder/dist/cjs → dist/cjs/tpaas-builders}/builders/pageInfo.js +2 -3
  42. package/dist/cjs/tpaas-builders/builders/pageSports.js +7 -0
  43. package/dist/cjs/tpaas-builders/builders/provider.js +19 -0
  44. package/dist/cjs/tpaas-builders/builders/referrer.js +17 -0
  45. package/dist/cjs/tpaas-builders/builders/session.js +5 -0
  46. package/{node_modules/@schibsted/tpaas-event-builder/dist/cjs → dist/cjs/tpaas-builders}/builders/trackerBuilder.js +2 -3
  47. package/{node_modules/@schibsted/tpaas-event-builder/dist/cjs → dist/cjs/tpaas-builders}/builders/user.js +1 -1
  48. package/{node_modules/@schibsted/tpaas-event-builder/dist/cjs → dist/cjs/tpaas-builders}/builders/utm.js +3 -9
  49. package/dist/cjs/tpaas-builders/builders.js +326 -0
  50. package/dist/cjs/tpaas-builders/guards.js +7 -0
  51. package/{node_modules/@schibsted/tpaas-event-builder/dist/cjs → dist/cjs/tpaas-builders}/index.js +3 -0
  52. package/dist/cjs/tpaas-context/adapters.js +85 -0
  53. package/dist/cjs/tpaas-context/browser.js +51 -0
  54. package/dist/cjs/tpaas-context/index.js +6 -0
  55. package/dist/cjs/tpaas-context/prepare.js +177 -0
  56. package/dist/cjs/tpaas-context/session.js +23 -0
  57. package/{node_modules/@schibsted/pulse-cis-sync/dist/cjs → dist/cjs/tpaas-context}/types.js +0 -1
  58. package/{node_modules/@schibsted/tpaas-schemas/dist/cjs → dist/cjs/tpaas-schemas}/constants.js +189 -158
  59. package/{node_modules/@schibsted/tpaas-schemas/dist/cjs → dist/cjs/tpaas-schemas}/index.js +1 -0
  60. package/dist/cjs/tpaas-schemas/types.js +2 -0
  61. package/dist/cjs/tracker-proxy/consts.js +29 -7
  62. package/dist/cjs/tracker-proxy/proxy-provider.js +2 -2
  63. package/{node_modules/@schibsted/pulse-utils/dist/cjs → dist/cjs/utils}/index.js +4 -1
  64. package/dist/cjs/utils/xDomainId.js +15 -0
  65. package/dist/cjs/version.js +1 -1
  66. package/dist/cjs/visibility-observer/index.js +9 -7
  67. package/dist/cjs/wrapper/types/event.js +5 -0
  68. package/dist/cjs/wrapper/utils/map-page-to-page-ref.js +13 -0
  69. package/dist/ejs/Tracker.js +558 -447
  70. package/dist/ejs/app-integration.js +1 -1
  71. package/dist/ejs/builders/actor.js +3 -3
  72. package/dist/ejs/builders/consents.js +4 -4
  73. package/dist/ejs/builders/device-browser.js +2 -2
  74. package/dist/ejs/builders/device-node.js +1 -1
  75. package/dist/ejs/builders/events-anonymous-node.js +1 -1
  76. package/dist/ejs/builders/events-node.js +4 -4
  77. package/dist/ejs/builders/experimentMetadata.js +1 -1
  78. package/dist/ejs/builders/experiments.js +1 -1
  79. package/dist/ejs/builders/objects/objects-anonymous-browser.js +1 -1
  80. package/dist/ejs/builders/objects/objects-anonymous-node.js +1 -1
  81. package/dist/ejs/builders/objects/objects-browser.js +1 -1
  82. package/dist/ejs/builders/objects/objects-node.js +1 -1
  83. package/dist/ejs/builders/objects/utils.js +1 -1
  84. package/dist/ejs/builders/origin-browser.js +1 -1
  85. package/dist/ejs/builders/origin-node.js +1 -1
  86. package/dist/ejs/builders/session-browser.js +5 -77
  87. package/{node_modules/@schibsted/pulse-cis-sync/dist/ejs → dist/ejs/cis-sync}/cis-browser.js +17 -4
  88. package/{node_modules/@schibsted/pulse-cis-sync/dist/ejs → dist/ejs/cis-sync}/cis.js +0 -1
  89. package/{node_modules/@schibsted/pulse-cis-sync/dist/ejs → dist/ejs/cis-sync}/eventEmitter.js +0 -1
  90. package/{node_modules/@schibsted/pulse-cis-sync/dist/ejs → dist/ejs/cis-sync}/index.js +0 -1
  91. package/{node_modules/@schibsted/pulse-cis-sync/dist/ejs → dist/ejs/cis-sync}/pulse-cookie.js +1 -2
  92. package/{node_modules/@schibsted/pulse-cis-sync/dist/ejs → dist/ejs/cis-sync}/storage/pulseStorage.js +12 -4
  93. package/{node_modules/@schibsted/pulse-cis-sync/dist/ejs → dist/ejs/cis-sync}/storage/storage.js +6 -2
  94. package/dist/ejs/createPulseTracker.js +1 -1
  95. package/dist/ejs/identity/actor.js +21 -9
  96. package/dist/ejs/identity/advertising.js +1 -1
  97. package/dist/ejs/identity/cis.js +4 -3
  98. package/dist/ejs/index.js +4 -3
  99. package/dist/ejs/leaveTracking/index.js +1 -1
  100. package/dist/ejs/leaveTrackingTpaas/constants.js +1 -5
  101. package/dist/ejs/leaveTrackingTpaas/index.js +65 -41
  102. package/dist/ejs/network-browser.js +1 -1
  103. package/dist/ejs/remoteConfig/index.js +1 -1
  104. package/dist/ejs/session/store.js +90 -0
  105. package/dist/ejs/tpaas-builders/builders/catalogVersion.js +6 -0
  106. package/{node_modules/@schibsted/tpaas-event-builder/dist/ejs → dist/ejs/tpaas-builders}/builders/device.js +50 -72
  107. package/{node_modules/@schibsted/tpaas-event-builder/dist/ejs → dist/ejs/tpaas-builders}/builders/navigationType.js +2 -3
  108. package/dist/ejs/tpaas-builders/builders/pageContent.js +3 -0
  109. package/{node_modules/@schibsted/tpaas-event-builder/dist/ejs → dist/ejs/tpaas-builders}/builders/pageInfo.js +2 -3
  110. package/dist/ejs/tpaas-builders/builders/pageSports.js +3 -0
  111. package/dist/ejs/tpaas-builders/builders/provider.js +16 -0
  112. package/dist/ejs/tpaas-builders/builders/referrer.js +13 -0
  113. package/dist/ejs/tpaas-builders/builders/session.js +1 -0
  114. package/dist/ejs/tpaas-builders/builders/trackerBuilder.js +10 -0
  115. package/{node_modules/@schibsted/tpaas-event-builder/dist/ejs → dist/ejs/tpaas-builders}/builders/user.js +1 -1
  116. package/{node_modules/@schibsted/tpaas-event-builder/dist/ejs → dist/ejs/tpaas-builders}/builders/utm.js +3 -9
  117. package/dist/ejs/tpaas-builders/builders.js +259 -0
  118. package/dist/ejs/tpaas-builders/guards.js +4 -0
  119. package/dist/ejs/tpaas-builders/index.js +2 -0
  120. package/dist/ejs/tpaas-context/adapters.js +80 -0
  121. package/dist/ejs/tpaas-context/browser.js +47 -0
  122. package/dist/ejs/tpaas-context/index.js +1 -0
  123. package/dist/ejs/tpaas-context/prepare.js +137 -0
  124. package/dist/ejs/tpaas-context/session.js +19 -0
  125. package/{node_modules/@schibsted/tpaas-schemas/dist/ejs → dist/ejs/tpaas-schemas}/constants.js +187 -156
  126. package/{node_modules/@schibsted/tpaas-schemas/dist/ejs → dist/ejs/tpaas-schemas}/index.js +1 -0
  127. package/dist/ejs/tpaas-schemas/types.js +1 -0
  128. package/dist/ejs/tracker-proxy/consts.js +29 -7
  129. package/dist/ejs/tracker-proxy/proxy-provider.js +1 -1
  130. package/{node_modules/@schibsted/pulse-utils/dist/ejs → dist/ejs/utils}/index.js +1 -0
  131. package/dist/ejs/utils/xDomainId.js +11 -0
  132. package/dist/ejs/version.js +1 -1
  133. package/dist/ejs/visibility-observer/index.js +9 -7
  134. package/dist/ejs/wrapper/types/event.js +4 -1
  135. package/dist/ejs/wrapper/utils/map-page-to-page-ref.js +10 -0
  136. package/dist/types/Tracker.d.ts +198 -93
  137. package/dist/types/builders/actor.d.ts +3 -2
  138. package/dist/types/builders/consents.d.ts +3 -3
  139. package/dist/types/builders/device-node.d.ts +2 -2
  140. package/dist/types/builders/events-anonymous-node.d.ts +4 -4
  141. package/dist/types/builders/events-node.d.ts +5 -5
  142. package/dist/types/builders/experiments.d.ts +1 -0
  143. package/dist/types/builders/index.d.ts +1 -1
  144. package/dist/types/builders/objects/objects-anonymous-node.d.ts +1 -1
  145. package/dist/types/builders/objects/objects-node.d.ts +1 -1
  146. package/dist/types/builders/origin-node.d.ts +1 -1
  147. package/dist/types/builders/session-browser.d.ts +1 -13
  148. package/{node_modules/@schibsted/pulse-cis-sync/dist/types → dist/types/cis-sync}/cis-browser.d.ts +1 -0
  149. package/{node_modules/@schibsted/pulse-cis-sync/dist/types → dist/types/cis-sync}/storage/pulseStorage.d.ts +12 -4
  150. package/{node_modules/@schibsted/pulse-cis-sync/dist/cjs → dist/types/cis-sync}/storage/storage.d.ts +2 -1
  151. package/dist/types/config.d.ts +1 -1
  152. package/dist/types/createPulseTracker.d.ts +1 -1
  153. package/dist/types/identity/actor.d.ts +3 -3
  154. package/dist/types/identity/advertising.d.ts +2 -2
  155. package/dist/types/identity/cis.d.ts +4 -4
  156. package/dist/types/index.d.ts +7 -8
  157. package/dist/types/leaveTrackingTpaas/constants.d.ts +1 -5
  158. package/dist/types/leaveTrackingTpaas/index.d.ts +6 -6
  159. package/dist/types/leaveTrackingTpaas/types.d.ts +2 -10
  160. package/dist/types/session/store.d.ts +34 -0
  161. package/dist/types/tpaas-builders/builders/anonymous.d.ts +3 -0
  162. package/dist/types/tpaas-builders/builders/baseEvent.d.ts +3 -0
  163. package/dist/types/tpaas-builders/builders/catalogVersion.d.ts +3 -0
  164. package/dist/types/tpaas-builders/builders/consents.d.ts +5 -0
  165. package/dist/types/tpaas-builders/builders/device.d.ts +5 -0
  166. package/dist/types/tpaas-builders/builders/experiments.d.ts +9 -0
  167. package/dist/types/tpaas-builders/builders/navigationType.d.ts +6 -0
  168. package/dist/types/tpaas-builders/builders/pageContent.d.ts +6 -0
  169. package/dist/types/tpaas-builders/builders/pageInfo.d.ts +7 -0
  170. package/dist/types/tpaas-builders/builders/pageSports.d.ts +6 -0
  171. package/dist/types/tpaas-builders/builders/pageviewId.d.ts +6 -0
  172. package/dist/types/tpaas-builders/builders/provider.d.ts +5 -0
  173. package/dist/types/tpaas-builders/builders/referrer.d.ts +6 -0
  174. package/dist/types/tpaas-builders/builders/session.d.ts +4 -0
  175. package/dist/types/tpaas-builders/builders/time.d.ts +4 -0
  176. package/dist/types/tpaas-builders/builders/trackerBuilder.d.ts +5 -0
  177. package/dist/types/tpaas-builders/builders/user.d.ts +5 -0
  178. package/dist/types/tpaas-builders/builders/utm.d.ts +7 -0
  179. package/dist/types/tpaas-builders/builders.d.ts +141 -0
  180. package/dist/types/tpaas-builders/guards.d.ts +2 -0
  181. package/dist/types/tpaas-builders/index.d.ts +2 -0
  182. package/dist/types/tpaas-context/adapters.d.ts +26 -0
  183. package/dist/types/tpaas-context/browser.d.ts +8 -0
  184. package/dist/types/tpaas-context/index.d.ts +2 -0
  185. package/dist/types/tpaas-context/prepare.d.ts +38 -0
  186. package/dist/types/tpaas-context/session.d.ts +10 -0
  187. package/dist/types/tpaas-context/types.d.ts +66 -0
  188. package/dist/types/tpaas-schemas/constants.d.ts +471 -0
  189. package/dist/types/tpaas-schemas/index.d.ts +5 -0
  190. package/dist/types/tpaas-schemas/types/ITpaasEvent.d.ts +130 -0
  191. package/dist/types/tpaas-schemas/types/schemas/IAnonymousImpressionUIElement.d.ts +58 -0
  192. package/dist/types/tpaas-schemas/types/schemas/ICompletedHealthAction.d.ts +139 -0
  193. package/dist/types/tpaas-schemas/types/schemas/IEngagementAd.d.ts +117 -0
  194. package/dist/types/tpaas-schemas/types/schemas/IEngagementAffiliate.d.ts +144 -0
  195. package/dist/types/tpaas-schemas/types/schemas/IEngagementAudio.d.ts +213 -0
  196. package/dist/types/tpaas-schemas/types/schemas/IEngagementForm.d.ts +111 -0
  197. package/dist/types/tpaas-schemas/types/schemas/IEngagementHealthUIElement.d.ts +133 -0
  198. package/dist/types/tpaas-schemas/types/schemas/IEngagementOffer.d.ts +107 -0
  199. package/dist/types/tpaas-schemas/types/schemas/IEngagementSchoolUIElement.d.ts +107 -0
  200. package/dist/types/tpaas-schemas/types/schemas/IEngagementSportsUIElement.d.ts +157 -0
  201. package/dist/types/tpaas-schemas/types/schemas/IEngagementTeaser.d.ts +114 -0
  202. package/dist/types/tpaas-schemas/types/schemas/IEngagementTvModule.d.ts +133 -0
  203. package/dist/types/tpaas-schemas/types/schemas/IEngagementTvSearch.d.ts +142 -0
  204. package/dist/types/tpaas-schemas/types/schemas/IEngagementUIElement.d.ts +105 -0
  205. package/dist/types/tpaas-schemas/types/schemas/IEngagementVideo.d.ts +238 -0
  206. package/dist/types/tpaas-schemas/types/schemas/IEngagementVideoAd.d.ts +147 -0
  207. package/dist/types/tpaas-schemas/types/schemas/IEngagementWidget.d.ts +91 -0
  208. package/dist/types/tpaas-schemas/types/schemas/IHeartbeatCommercialArticle.d.ts +96 -0
  209. package/dist/types/tpaas-schemas/types/schemas/IImpressionAd.d.ts +115 -0
  210. package/dist/types/tpaas-schemas/types/schemas/IImpressionAdSlot.d.ts +89 -0
  211. package/dist/types/tpaas-schemas/types/schemas/IImpressionAffiliate.d.ts +142 -0
  212. package/dist/types/tpaas-schemas/types/schemas/IImpressionForm.d.ts +113 -0
  213. package/dist/types/tpaas-schemas/types/schemas/IImpressionHealthUIElement.d.ts +138 -0
  214. package/dist/types/tpaas-schemas/types/schemas/IImpressionOffer.d.ts +109 -0
  215. package/dist/types/tpaas-schemas/types/schemas/IImpressionPlayer.d.ts +108 -0
  216. package/dist/types/tpaas-schemas/types/schemas/IImpressionSchoolUIElement.d.ts +109 -0
  217. package/dist/types/tpaas-schemas/types/schemas/IImpressionSportsUIElement.d.ts +159 -0
  218. package/dist/types/tpaas-schemas/types/schemas/IImpressionTeaser.d.ts +112 -0
  219. package/dist/types/tpaas-schemas/types/schemas/IImpressionUIElement.d.ts +107 -0
  220. package/dist/types/tpaas-schemas/types/schemas/IImpressionWidget.d.ts +89 -0
  221. package/dist/types/tpaas-schemas/types/schemas/ILeaveArticle.d.ts +133 -0
  222. package/dist/types/tpaas-schemas/types/schemas/ILeaveAudioPage.d.ts +88 -0
  223. package/dist/types/tpaas-schemas/types/schemas/ILeaveError.d.ts +95 -0
  224. package/dist/types/tpaas-schemas/types/schemas/ILeaveFrontpage.d.ts +83 -0
  225. package/dist/types/tpaas-schemas/types/schemas/ILeaveLandingpage.d.ts +90 -0
  226. package/dist/types/tpaas-schemas/types/schemas/ILeaveListing.d.ts +123 -0
  227. package/dist/types/tpaas-schemas/types/schemas/ILeaveLockedArticle.d.ts +139 -0
  228. package/dist/types/tpaas-schemas/types/schemas/ILeaveLockedAudioPage.d.ts +97 -0
  229. package/dist/types/tpaas-schemas/types/schemas/ILeaveLockedPage.d.ts +90 -0
  230. package/dist/types/tpaas-schemas/types/schemas/ILeaveLockedVideoPage.d.ts +97 -0
  231. package/dist/types/tpaas-schemas/types/schemas/ILeavePage.d.ts +82 -0
  232. package/dist/types/tpaas-schemas/types/schemas/ILeaveSchoolPage.d.ts +84 -0
  233. package/dist/types/tpaas-schemas/types/schemas/ILeaveSportsPage.d.ts +137 -0
  234. package/dist/types/tpaas-schemas/types/schemas/ILeaveVideoPage.d.ts +91 -0
  235. package/dist/types/tpaas-schemas/types/schemas/ILeaveWeather.d.ts +96 -0
  236. package/dist/types/tpaas-schemas/types/schemas/ILoadAd.d.ts +119 -0
  237. package/dist/types/tpaas-schemas/types/schemas/IViewArticle.d.ts +133 -0
  238. package/dist/types/tpaas-schemas/types/schemas/IViewAudioPage.d.ts +87 -0
  239. package/dist/types/tpaas-schemas/types/schemas/IViewError.d.ts +90 -0
  240. package/dist/types/tpaas-schemas/types/schemas/IViewFrontpage.d.ts +80 -0
  241. package/dist/types/tpaas-schemas/types/schemas/IViewHealthPage.d.ts +119 -0
  242. package/dist/types/tpaas-schemas/types/schemas/IViewLandingpage.d.ts +76 -0
  243. package/dist/types/tpaas-schemas/types/schemas/IViewListing.d.ts +118 -0
  244. package/dist/types/tpaas-schemas/types/schemas/IViewLockedArticle.d.ts +139 -0
  245. package/dist/types/tpaas-schemas/types/schemas/IViewLockedAudioPage.d.ts +95 -0
  246. package/dist/types/tpaas-schemas/types/schemas/IViewLockedPage.d.ts +94 -0
  247. package/dist/types/tpaas-schemas/types/schemas/IViewLockedVideoPage.d.ts +95 -0
  248. package/dist/types/tpaas-schemas/types/schemas/IViewPage.d.ts +86 -0
  249. package/dist/types/tpaas-schemas/types/schemas/IViewSchoolPage.d.ts +88 -0
  250. package/dist/types/tpaas-schemas/types/schemas/IViewSportsPage.d.ts +135 -0
  251. package/dist/types/tpaas-schemas/types/schemas/IViewTitle.d.ts +92 -0
  252. package/dist/types/tpaas-schemas/types/schemas/IViewVideoPage.d.ts +87 -0
  253. package/dist/types/tpaas-schemas/types/schemas/IViewWeather.d.ts +94 -0
  254. package/dist/types/tpaas-schemas/types/schemas/index.d.ts +63 -0
  255. package/dist/types/tpaas-schemas/types/templates/IBranded.d.ts +42 -0
  256. package/dist/types/tpaas-schemas/types/templates/IConsents.d.ts +34 -0
  257. package/dist/types/tpaas-schemas/types/templates/IContent.d.ts +56 -0
  258. package/dist/types/tpaas-schemas/types/templates/IDevice.d.ts +62 -0
  259. package/dist/types/tpaas-schemas/types/templates/IEngagement.d.ts +21 -0
  260. package/dist/types/tpaas-schemas/types/templates/IExperiments.d.ts +35 -0
  261. package/dist/types/tpaas-schemas/types/templates/IHealthFood.d.ts +55 -0
  262. package/dist/types/tpaas-schemas/types/templates/IHealthOrigin.d.ts +27 -0
  263. package/dist/types/tpaas-schemas/types/templates/IHealthPhysicalActivity.d.ts +36 -0
  264. package/dist/types/tpaas-schemas/types/templates/IHealthTraining.d.ts +74 -0
  265. package/dist/types/tpaas-schemas/types/templates/IHealthUserData.d.ts +25 -0
  266. package/dist/types/tpaas-schemas/types/templates/ILeave.d.ts +54 -0
  267. package/dist/types/tpaas-schemas/types/templates/ILeaveAudio.d.ts +37 -0
  268. package/dist/types/tpaas-schemas/types/templates/ILeaveStories.d.ts +34 -0
  269. package/dist/types/tpaas-schemas/types/templates/ILocation.d.ts +21 -0
  270. package/dist/types/tpaas-schemas/types/templates/IMetrics.d.ts +32 -0
  271. package/dist/types/tpaas-schemas/types/templates/IPageRef.d.ts +46 -0
  272. package/dist/types/tpaas-schemas/types/templates/IPlacement.d.ts +45 -0
  273. package/dist/types/tpaas-schemas/types/templates/IProvider.d.ts +73 -0
  274. package/dist/types/tpaas-schemas/types/templates/ISchool.d.ts +74 -0
  275. package/dist/types/tpaas-schemas/types/templates/ISession.d.ts +33 -0
  276. package/dist/types/tpaas-schemas/types/templates/ISports.d.ts +98 -0
  277. package/dist/types/tpaas-schemas/types/templates/ISportsUserFeatures.d.ts +28 -0
  278. package/dist/types/tpaas-schemas/types/templates/ITime.d.ts +32 -0
  279. package/dist/types/tpaas-schemas/types/templates/ITracker.d.ts +37 -0
  280. package/dist/types/tpaas-schemas/types/templates/IUser.d.ts +34 -0
  281. package/dist/types/tpaas-schemas/types/templates/IUtmTags.d.ts +38 -0
  282. package/dist/types/tpaas-schemas/types/templates/index.d.ts +27 -0
  283. package/dist/types/tpaas-schemas/types.d.ts +42 -0
  284. package/dist/types/tracker-proxy/consts.d.ts +2 -2
  285. package/dist/types/types.d.ts +21 -17
  286. package/{node_modules/@schibsted/pulse-utils/dist/types → dist/types/utils}/index.d.ts +1 -0
  287. package/dist/types/utils/xDomainId.d.ts +2 -0
  288. package/dist/types/version.d.ts +1 -1
  289. package/dist/types/visibility-observer/index.d.ts +6 -1
  290. package/dist/types/wrapper/engagement/ui-element/types.d.ts +1 -1
  291. package/dist/types/wrapper/types/base-event.d.ts +1 -1
  292. package/dist/types/wrapper/types/event.d.ts +4 -2
  293. package/dist/types/wrapper/types/utils.d.ts +1 -1
  294. package/dist/types/wrapper/utils/map-page-to-page-ref.d.ts +3 -0
  295. package/dist/types/wrapper/view/article/types.d.ts +1 -1
  296. package/dist/types/wrapper/view/frontpage/types.d.ts +1 -1
  297. package/dist/types/wrapper/view/listing/types.d.ts +1 -1
  298. package/dist/types/wrapper/view/loginposter/types.d.ts +1 -1
  299. package/dist/types/wrapper/view/page/types.d.ts +1 -1
  300. package/dist/types/wrapper/view/salesposter/types.d.ts +1 -1
  301. package/dist/types/wrapper/view/ui-element/types.d.ts +1 -1
  302. package/package.json +21 -20
  303. package/dist/cjs/Tracker.test-d.js +0 -76
  304. package/dist/ejs/Tracker.test-d.js +0 -71
  305. package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/cis-browser.d.ts +0 -26
  306. package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/cis-browser.js +0 -273
  307. package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/cis-browser.js.map +0 -1
  308. package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/cis.js.map +0 -1
  309. package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/eventEmitter.js +0 -39
  310. package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/eventEmitter.js.map +0 -1
  311. package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/index.js.map +0 -1
  312. package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/pulse-cookie.js.map +0 -1
  313. package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/storage/pulseStorage.d.ts +0 -36
  314. package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/storage/pulseStorage.js.map +0 -1
  315. package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/storage/storage.js +0 -21
  316. package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/storage/storage.js.map +0 -1
  317. package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/types.js.map +0 -1
  318. package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/cis-browser.d.ts +0 -26
  319. package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/cis-browser.js.map +0 -1
  320. package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/cis.d.ts +0 -10
  321. package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/cis.js.map +0 -1
  322. package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/eventEmitter.d.ts +0 -14
  323. package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/eventEmitter.js.map +0 -1
  324. package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/index.d.ts +0 -4
  325. package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/index.js.map +0 -1
  326. package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/pulse-cookie.d.ts +0 -55
  327. package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/pulse-cookie.js.map +0 -1
  328. package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/storage/pulseStorage.d.ts +0 -36
  329. package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/storage/pulseStorage.js.map +0 -1
  330. package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/storage/storage.d.ts +0 -6
  331. package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/storage/storage.js.map +0 -1
  332. package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/types.d.ts +0 -24
  333. package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/types.js +0 -2
  334. package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/types.js.map +0 -1
  335. package/node_modules/@schibsted/pulse-cis-sync/dist/types/cis.d.ts +0 -10
  336. package/node_modules/@schibsted/pulse-cis-sync/dist/types/eventEmitter.d.ts +0 -14
  337. package/node_modules/@schibsted/pulse-cis-sync/dist/types/index.d.ts +0 -4
  338. package/node_modules/@schibsted/pulse-cis-sync/dist/types/pulse-cookie.d.ts +0 -55
  339. package/node_modules/@schibsted/pulse-cis-sync/dist/types/storage/storage.d.ts +0 -6
  340. package/node_modules/@schibsted/pulse-cis-sync/dist/types/types.d.ts +0 -24
  341. package/node_modules/@schibsted/pulse-cis-sync/package.json +0 -44
  342. package/node_modules/@schibsted/pulse-utils/package.json +0 -36
  343. package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders/provider.js +0 -12
  344. package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders/referrer.js +0 -19
  345. package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders/session.js +0 -114
  346. package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders.js +0 -272
  347. package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders/provider.js +0 -9
  348. package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders/referrer.js +0 -15
  349. package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders/session.js +0 -108
  350. package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders/trackerBuilder.js +0 -11
  351. package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders.js +0 -215
  352. package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/index.js +0 -1
  353. package/node_modules/@schibsted/tpaas-event-builder/dist/index.d.ts +0 -5403
  354. package/node_modules/@schibsted/tpaas-event-builder/package.json +0 -40
  355. package/node_modules/@schibsted/tpaas-schemas/dist/index.d.ts +0 -6176
  356. package/node_modules/@schibsted/tpaas-schemas/package.json +0 -35
  357. /package/{node_modules/@schibsted/tpaas-event-builder/dist/cjs → dist/cjs/cis-sync}/types.js +0 -0
  358. /package/{node_modules/@schibsted/tpaas-event-builder/dist/cjs → dist/cjs/tpaas-builders}/builders/anonymous.js +0 -0
  359. /package/{node_modules/@schibsted/tpaas-event-builder/dist/cjs → dist/cjs/tpaas-builders}/builders/baseEvent.js +0 -0
  360. /package/{node_modules/@schibsted/tpaas-event-builder/dist/cjs → dist/cjs/tpaas-builders}/builders/consents.js +0 -0
  361. /package/{node_modules/@schibsted/tpaas-event-builder/dist/cjs → dist/cjs/tpaas-builders}/builders/experiments.js +0 -0
  362. /package/{node_modules/@schibsted/tpaas-event-builder/dist/cjs → dist/cjs/tpaas-builders}/builders/pageviewId.js +0 -0
  363. /package/{node_modules/@schibsted/tpaas-event-builder/dist/cjs → dist/cjs/tpaas-builders}/builders/time.js +0 -0
  364. /package/{node_modules/@schibsted/pulse-utils/dist/cjs → dist/cjs/utils}/cookie-config.js +0 -0
  365. /package/{node_modules/@schibsted/pulse-utils/dist/cjs → dist/cjs/utils}/cookie.js +0 -0
  366. /package/{node_modules/@schibsted/pulse-utils/dist/cjs → dist/cjs/utils}/events.js +0 -0
  367. /package/{node_modules/@schibsted/pulse-utils/dist/cjs → dist/cjs/utils}/get.js +0 -0
  368. /package/{node_modules/@schibsted/pulse-utils/dist/cjs → dist/cjs/utils}/getRootDomain.js +0 -0
  369. /package/{node_modules/@schibsted/pulse-utils/dist/cjs → dist/cjs/utils}/merge.js +0 -0
  370. /package/{node_modules/@schibsted/pulse-utils/dist/cjs → dist/cjs/utils}/objects.js +0 -0
  371. /package/{node_modules/@schibsted/pulse-utils/dist/cjs → dist/cjs/utils}/omit.js +0 -0
  372. /package/{node_modules/@schibsted/pulse-utils/dist/cjs → dist/cjs/utils}/randomString.js +0 -0
  373. /package/{node_modules/@schibsted/pulse-utils/dist/cjs → dist/cjs/utils}/throttle.js +0 -0
  374. /package/{node_modules/@schibsted/pulse-utils/dist/cjs → dist/cjs/utils}/webApi.js +0 -0
  375. /package/{node_modules/@schibsted/tpaas-event-builder/dist/ejs → dist/ejs/cis-sync}/types.js +0 -0
  376. /package/{node_modules/@schibsted/tpaas-event-builder/dist/ejs → dist/ejs/tpaas-builders}/builders/anonymous.js +0 -0
  377. /package/{node_modules/@schibsted/tpaas-event-builder/dist/ejs → dist/ejs/tpaas-builders}/builders/baseEvent.js +0 -0
  378. /package/{node_modules/@schibsted/tpaas-event-builder/dist/ejs → dist/ejs/tpaas-builders}/builders/consents.js +0 -0
  379. /package/{node_modules/@schibsted/tpaas-event-builder/dist/ejs → dist/ejs/tpaas-builders}/builders/experiments.js +0 -0
  380. /package/{node_modules/@schibsted/tpaas-event-builder/dist/ejs → dist/ejs/tpaas-builders}/builders/pageviewId.js +0 -0
  381. /package/{node_modules/@schibsted/tpaas-event-builder/dist/ejs → dist/ejs/tpaas-builders}/builders/time.js +0 -0
  382. /package/dist/{types/Tracker.test-d.d.ts → ejs/tpaas-context/types.js} +0 -0
  383. /package/{node_modules/@schibsted/pulse-utils/dist/ejs → dist/ejs/utils}/cookie-config.js +0 -0
  384. /package/{node_modules/@schibsted/pulse-utils/dist/ejs → dist/ejs/utils}/cookie.js +0 -0
  385. /package/{node_modules/@schibsted/pulse-utils/dist/ejs → dist/ejs/utils}/events.js +0 -0
  386. /package/{node_modules/@schibsted/pulse-utils/dist/ejs → dist/ejs/utils}/get.js +0 -0
  387. /package/{node_modules/@schibsted/pulse-utils/dist/ejs → dist/ejs/utils}/getRootDomain.js +0 -0
  388. /package/{node_modules/@schibsted/pulse-utils/dist/ejs → dist/ejs/utils}/merge.js +0 -0
  389. /package/{node_modules/@schibsted/pulse-utils/dist/ejs → dist/ejs/utils}/objects.js +0 -0
  390. /package/{node_modules/@schibsted/pulse-utils/dist/ejs → dist/ejs/utils}/omit.js +0 -0
  391. /package/{node_modules/@schibsted/pulse-utils/dist/ejs → dist/ejs/utils}/randomString.js +0 -0
  392. /package/{node_modules/@schibsted/pulse-utils/dist/ejs → dist/ejs/utils}/throttle.js +0 -0
  393. /package/{node_modules/@schibsted/pulse-utils/dist/ejs → dist/ejs/utils}/webApi.js +0 -0
  394. /package/{node_modules/@schibsted/pulse-cis-sync/dist/cjs → dist/types/cis-sync}/cis.d.ts +0 -0
  395. /package/{node_modules/@schibsted/pulse-cis-sync/dist/cjs → dist/types/cis-sync}/eventEmitter.d.ts +0 -0
  396. /package/{node_modules/@schibsted/pulse-cis-sync/dist/cjs → dist/types/cis-sync}/index.d.ts +0 -0
  397. /package/{node_modules/@schibsted/pulse-cis-sync/dist/cjs → dist/types/cis-sync}/pulse-cookie.d.ts +0 -0
  398. /package/{node_modules/@schibsted/pulse-cis-sync/dist/cjs → dist/types/cis-sync}/types.d.ts +0 -0
  399. /package/{node_modules/@schibsted/pulse-utils/dist/types → dist/types/utils}/cookie-config.d.ts +0 -0
  400. /package/{node_modules/@schibsted/pulse-utils/dist/types → dist/types/utils}/cookie.d.ts +0 -0
  401. /package/{node_modules/@schibsted/pulse-utils/dist/types → dist/types/utils}/events.d.ts +0 -0
  402. /package/{node_modules/@schibsted/pulse-utils/dist/types → dist/types/utils}/get.d.ts +0 -0
  403. /package/{node_modules/@schibsted/pulse-utils/dist/types → dist/types/utils}/getRootDomain.d.ts +0 -0
  404. /package/{node_modules/@schibsted/pulse-utils/dist/types → dist/types/utils}/merge.d.ts +0 -0
  405. /package/{node_modules/@schibsted/pulse-utils/dist/types → dist/types/utils}/objects.d.ts +0 -0
  406. /package/{node_modules/@schibsted/pulse-utils/dist/types → dist/types/utils}/omit.d.ts +0 -0
  407. /package/{node_modules/@schibsted/pulse-utils/dist/types → dist/types/utils}/randomString.d.ts +0 -0
  408. /package/{node_modules/@schibsted/pulse-utils/dist/types → dist/types/utils}/throttle.d.ts +0 -0
  409. /package/{node_modules/@schibsted/pulse-utils/dist/types → dist/types/utils}/webApi.d.ts +0 -0
@@ -0,0 +1,259 @@
1
+ import { merge } from 'ts-deepmerge';
2
+ import { AnonymousImpressionUIElement, CompletedHealthAction, EngagementAd, EngagementAffiliate, EngagementAudio, EngagementForm, EngagementHealthUIElement, EngagementOffer, EngagementSchoolUIElement, EngagementSportsUIElement, EngagementTeaser, EngagementTvModule, EngagementTvSearch, EngagementUIElement, EngagementVideo, EngagementVideoAd, EngagementWidget, HeartbeatCommercialArticle, ImpressionAd, ImpressionAdSlot, ImpressionAffiliate, ImpressionForm, ImpressionHealthUIElement, ImpressionOffer, ImpressionPlayer, ImpressionSchoolUIElement, ImpressionSportsUIElement, ImpressionTeaser, ImpressionUIElement, ImpressionWidget, LeaveArticle, LeaveAudioPage, LeaveError, LeaveFrontpage, LeaveLandingpage, LeaveListing, LeaveLockedArticle, LeaveLockedAudioPage, LeaveLockedPage, LeaveLockedVideoPage, LeavePage, LeaveSchoolPage, LeaveSportsPage, LeaveVideoPage, LeaveWeather, LoadAd, ViewArticle, ViewAudioPage, ViewError, ViewFrontpage, ViewHealthPage, ViewLandingpage, ViewListing, ViewLockedArticle, ViewLockedAudioPage, ViewLockedPage, ViewLockedVideoPage, ViewPage, ViewSchoolPage, ViewSportsPage, ViewTitle, ViewVideoPage, ViewWeather, } from '../tpaas-schemas';
3
+ import { builder as anonymousBuilder } from './builders/anonymous';
4
+ import { builder as baseEventBuilder } from './builders/baseEvent';
5
+ import { builder as catalogVersionBuilder } from './builders/catalogVersion';
6
+ import { builder as consentsBuilder } from './builders/consents';
7
+ import { builder as deviceBuilder } from './builders/device';
8
+ import { builder as experimentsBuilder } from './builders/experiments';
9
+ import { builder as navigationTypeBuilder } from './builders/navigationType';
10
+ import { builder as pageContentBuilder } from './builders/pageContent';
11
+ import { builder as pageInfoBuilder } from './builders/pageInfo';
12
+ import { builder as pageSportsBuilder } from './builders/pageSports';
13
+ import { builder as pageviewIdBuilder } from './builders/pageviewId';
14
+ import { builder as providerBuilder } from './builders/provider';
15
+ import { builder as referrerBuilder } from './builders/referrer';
16
+ import { builder as sessionBuilder } from './builders/session';
17
+ import { builder as timeBuilder } from './builders/time';
18
+ import { builder as trackerBuilder } from './builders/trackerBuilder';
19
+ import { builder as userBuilder } from './builders/user';
20
+ import { builder as utmBuilder } from './builders/utm';
21
+ export const getCommonBuildersOutput = (context) => {
22
+ const { createdAt, session, isHybrid, version, environmentId, jwe, user, consents, providerId, providerName, providerGroup, providerStage, providerProduct, providerVersion, component, componentVersion, pageviewId, currentPage, currentPageReferrer, routingStage, browser, } = context;
23
+ const { experiments } = context.input;
24
+ return merge(trackerBuilder({ isHybrid, version, routingStage }), timeBuilder(createdAt), sessionBuilder(session), deviceBuilder(environmentId, jwe, browser), userBuilder(user), baseEventBuilder(), consentsBuilder(consents), providerBuilder(providerId, providerStage, providerProduct, providerVersion, component, componentVersion, providerName, providerGroup), pageInfoBuilder(currentPage, browser.url), pageviewIdBuilder(pageviewId), utmBuilder(browser.search), referrerBuilder(currentPageReferrer), catalogVersionBuilder(), experimentsBuilder(context.experiments, experiments));
25
+ };
26
+ const getElementEventBuildersOutput = (context) => merge(getCommonBuildersOutput(context), pageContentBuilder(context.currentPageContent));
27
+ const getSportsElementEventBuildersOutput = (context) => merge(getElementEventBuildersOutput(context), pageSportsBuilder(context.currentPageSports));
28
+ // there's a bug in the ts-deepmerge library that doesn't properly resolve merging optionals with required properties
29
+ // due to this, we need to do 2 things:
30
+ // (1) manually omit navigationType from the input before merging.
31
+ // it has no effect on the final value since navigationType will always be set by the navigationTypeBuilder.
32
+ // (2) ensure page is always defined in the input, even when it's not passed to the SDK
33
+ // again, it has no effect on the final value because several builders are passing a page object
34
+ // But this makes TS happy in an elegant way, without type assertions at the merge level
35
+ const normalizePageInput = (input) => {
36
+ const { page, ...rest } = input;
37
+ if (!page) {
38
+ return {
39
+ ...rest,
40
+ page: {},
41
+ };
42
+ }
43
+ if (!('navigationType' in page)) {
44
+ return input;
45
+ }
46
+ const { navigationType: _, ...pageRest } = page;
47
+ return {
48
+ ...rest,
49
+ page: {
50
+ ...pageRest,
51
+ },
52
+ };
53
+ };
54
+ // #region AnonymousImpression Event Builders
55
+ export function buildAnonymousImpressionUIElementEvent(context) {
56
+ const { createdAt, isHybrid, version, pageviewId, providerId, providerName, providerGroup, providerStage, providerProduct, providerVersion, component, componentVersion, currentPageReferrer, routingStage, } = context;
57
+ return merge(AnonymousImpressionUIElement, baseEventBuilder(), trackerBuilder({ isHybrid, version, routingStage }), timeBuilder(createdAt), pageviewIdBuilder(pageviewId), utmBuilder(context.browser.search), anonymousBuilder(), providerBuilder(providerId, providerStage, providerProduct, providerVersion, component, componentVersion, providerName, providerGroup), referrerBuilder(currentPageReferrer), experimentsBuilder(context.experiments, context.input.experiments), catalogVersionBuilder(), normalizePageInput(context.input));
58
+ }
59
+ // #endregion
60
+ // #region View Event Builders
61
+ export function buildViewArticleEvent(context) {
62
+ return merge(ViewArticle, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
63
+ }
64
+ export function buildViewAudioPageEvent(context) {
65
+ return merge(ViewAudioPage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
66
+ }
67
+ export function buildViewErrorEvent(context) {
68
+ return merge(ViewError, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
69
+ }
70
+ export function buildViewFrontpageEvent(context) {
71
+ return merge(ViewFrontpage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
72
+ }
73
+ export function buildViewLandingpageEvent(context) {
74
+ return merge(ViewLandingpage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
75
+ }
76
+ export function buildViewListingEvent(context) {
77
+ return merge(ViewListing, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
78
+ }
79
+ export function buildViewLockedArticleEvent(context) {
80
+ return merge(ViewLockedArticle, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
81
+ }
82
+ export function buildViewLockedAudioPageEvent(context) {
83
+ return merge(ViewLockedAudioPage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
84
+ }
85
+ export function buildViewLockedPageEvent(context) {
86
+ return merge(ViewLockedPage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
87
+ }
88
+ export function buildViewLockedVideoPageEvent(context) {
89
+ return merge(ViewLockedVideoPage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
90
+ }
91
+ export function buildLeaveLockedVideoPageEvent(context) {
92
+ return merge(LeaveLockedVideoPage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
93
+ }
94
+ export function buildViewPageEvent(context) {
95
+ return merge(ViewPage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
96
+ }
97
+ export function buildViewSportsPageEvent(context) {
98
+ return merge(ViewSportsPage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
99
+ }
100
+ export function buildViewSchoolPageEvent(context) {
101
+ return merge(ViewSchoolPage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
102
+ }
103
+ export function buildViewTitleEvent(context) {
104
+ return merge(ViewTitle, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
105
+ }
106
+ export function buildViewVideoPageEvent(context) {
107
+ return merge(ViewVideoPage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
108
+ }
109
+ export function buildViewWeatherEvent(context) {
110
+ return merge(ViewWeather, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
111
+ }
112
+ // #endregion
113
+ // #region Leave Event Builders
114
+ export function buildLeaveArticleEvent(context) {
115
+ return merge(LeaveArticle, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
116
+ }
117
+ export function buildLeaveAudioPageEvent(context) {
118
+ return merge(LeaveAudioPage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
119
+ }
120
+ export function buildLeaveErrorEvent(context) {
121
+ return merge(LeaveError, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
122
+ }
123
+ export function buildLeaveFrontpageEvent(context) {
124
+ return merge(LeaveFrontpage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
125
+ }
126
+ export function buildLeaveLandingpageEvent(context) {
127
+ return merge(LeaveLandingpage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
128
+ }
129
+ export function buildLeaveListingEvent(context) {
130
+ return merge(LeaveListing, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
131
+ }
132
+ export function buildLeaveLockedArticleEvent(context) {
133
+ return merge(LeaveLockedArticle, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
134
+ }
135
+ export function buildLeaveLockedAudioPageEvent(context) {
136
+ return merge(LeaveLockedAudioPage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
137
+ }
138
+ export function buildLeaveLockedPageEvent(context) {
139
+ return merge(LeaveLockedPage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
140
+ }
141
+ export function buildLeavePageEvent(context) {
142
+ return merge(LeavePage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
143
+ }
144
+ export function buildLeaveSportsPageEvent(context) {
145
+ return merge(LeaveSportsPage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
146
+ }
147
+ export function buildLeaveSchoolPageEvent(context) {
148
+ return merge(LeaveSchoolPage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
149
+ }
150
+ export function buildLeaveVideoPageEvent(context) {
151
+ return merge(LeaveVideoPage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
152
+ }
153
+ export function buildLeaveWeatherEvent(context) {
154
+ return merge(LeaveWeather, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
155
+ }
156
+ // #endregion
157
+ // #region Engagement Event Builders
158
+ export function buildEngagementAdEvent(context) {
159
+ return merge(EngagementAd, getElementEventBuildersOutput(context), normalizePageInput(context.input));
160
+ }
161
+ export function buildEngagementAffiliateEvent(context) {
162
+ return merge(EngagementAffiliate, getElementEventBuildersOutput(context), normalizePageInput(context.input));
163
+ }
164
+ export function buildEngagementAudioEvent(context) {
165
+ return merge(EngagementAudio, getElementEventBuildersOutput(context), normalizePageInput(context.input));
166
+ }
167
+ export function buildEngagementFormEvent(context) {
168
+ return merge(EngagementForm, getElementEventBuildersOutput(context), normalizePageInput(context.input));
169
+ }
170
+ export function buildEngagementOfferEvent(context) {
171
+ return merge(EngagementOffer, getElementEventBuildersOutput(context), normalizePageInput(context.input));
172
+ }
173
+ export function buildEngagementSportsUIElementEvent(context) {
174
+ return merge(EngagementSportsUIElement, getSportsElementEventBuildersOutput(context), normalizePageInput(context.input));
175
+ }
176
+ export function buildEngagementSchoolUIElementEvent(context) {
177
+ return merge(EngagementSchoolUIElement, getElementEventBuildersOutput(context), normalizePageInput(context.input));
178
+ }
179
+ export function buildEngagementTeaserEvent(context) {
180
+ return merge(EngagementTeaser, getElementEventBuildersOutput(context), normalizePageInput(context.input));
181
+ }
182
+ export function buildEngagementTvModuleEvent(context) {
183
+ return merge(EngagementTvModule, getElementEventBuildersOutput(context), normalizePageInput(context.input));
184
+ }
185
+ export function buildEngagementTvSearchEvent(context) {
186
+ return merge(EngagementTvSearch, getElementEventBuildersOutput(context), normalizePageInput(context.input));
187
+ }
188
+ export function buildEngagementUIElementEvent(context) {
189
+ return merge(EngagementUIElement, getElementEventBuildersOutput(context), normalizePageInput(context.input));
190
+ }
191
+ export function buildEngagementVideoEvent(context) {
192
+ return merge(EngagementVideo, getElementEventBuildersOutput(context), normalizePageInput(context.input));
193
+ }
194
+ export function buildEngagementVideoAdEvent(context) {
195
+ return merge(EngagementVideoAd, getElementEventBuildersOutput(context), normalizePageInput(context.input));
196
+ }
197
+ export function buildEngagementWidgetEvent(context) {
198
+ return merge(EngagementWidget, getElementEventBuildersOutput(context), normalizePageInput(context.input));
199
+ }
200
+ // #endregion
201
+ // #region Heartbeat Event Builders
202
+ export function buildHeartbeatCommercialArticleEvent(context) {
203
+ return merge(HeartbeatCommercialArticle, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
204
+ }
205
+ // #endregion
206
+ // #region Health Event Builders
207
+ export function buildCompletedHealthActionEvent(context) {
208
+ return merge(CompletedHealthAction, getCommonBuildersOutput(context), normalizePageInput(context.input));
209
+ }
210
+ export function buildEngagementHealthUIElementEvent(context) {
211
+ return merge(EngagementHealthUIElement, getElementEventBuildersOutput(context), normalizePageInput(context.input));
212
+ }
213
+ export function buildViewHealthPageEvent(context) {
214
+ return merge(ViewHealthPage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
215
+ }
216
+ export function buildImpressionHealthUIElementEvent(context) {
217
+ return merge(ImpressionHealthUIElement, getCommonBuildersOutput(context), normalizePageInput(context.input));
218
+ }
219
+ // #endregion
220
+ // #region Impression Event Builders
221
+ export function buildImpressionAdEvent(context) {
222
+ return merge(ImpressionAd, getElementEventBuildersOutput(context), normalizePageInput(context.input));
223
+ }
224
+ export function buildImpressionAdSlotEvent(context) {
225
+ return merge(ImpressionAdSlot, getElementEventBuildersOutput(context), normalizePageInput(context.input));
226
+ }
227
+ export function buildImpressionAffiliateEvent(context) {
228
+ return merge(ImpressionAffiliate, getElementEventBuildersOutput(context), normalizePageInput(context.input));
229
+ }
230
+ export function buildImpressionFormEvent(context) {
231
+ return merge(ImpressionForm, getElementEventBuildersOutput(context), normalizePageInput(context.input));
232
+ }
233
+ export function buildImpressionOfferEvent(context) {
234
+ return merge(ImpressionOffer, getElementEventBuildersOutput(context), normalizePageInput(context.input));
235
+ }
236
+ export function buildImpressionPlayerEvent(context) {
237
+ return merge(ImpressionPlayer, getElementEventBuildersOutput(context), normalizePageInput(context.input));
238
+ }
239
+ export function buildImpressionSportsUIElementEvent(context) {
240
+ return merge(ImpressionSportsUIElement, getSportsElementEventBuildersOutput(context), normalizePageInput(context.input));
241
+ }
242
+ export function buildImpressionSchoolUIElementEvent(context) {
243
+ return merge(ImpressionSchoolUIElement, getElementEventBuildersOutput(context), normalizePageInput(context.input));
244
+ }
245
+ export function buildImpressionTeaserEvent(context) {
246
+ return merge(ImpressionTeaser, getElementEventBuildersOutput(context), normalizePageInput(context.input));
247
+ }
248
+ export function buildImpressionUIElementEvent(context) {
249
+ return merge(ImpressionUIElement, getElementEventBuildersOutput(context), normalizePageInput(context.input));
250
+ }
251
+ export function buildImpressionWidgetEvent(context) {
252
+ return merge(ImpressionWidget, getElementEventBuildersOutput(context), normalizePageInput(context.input));
253
+ }
254
+ // #endregion
255
+ // #region Ad Lifecycle Event Builders
256
+ export function buildLoadAdEvent(context) {
257
+ return merge(LoadAd, getCommonBuildersOutput(context), normalizePageInput(context.input));
258
+ }
259
+ // #endregion
@@ -0,0 +1,4 @@
1
+ import { PAGE_TYPE_VALUES } from '../tpaas-schemas';
2
+ export function isPageType(pageType) {
3
+ return PAGE_TYPE_VALUES.some((val) => val === pageType);
4
+ }
@@ -0,0 +1,2 @@
1
+ export * from './builders';
2
+ export { isPageType } from './guards';
@@ -0,0 +1,80 @@
1
+ import { generateExperimentSDRN } from '../builders/experiments';
2
+ import { isString } from '../utils';
3
+ /**
4
+ * Adapts the legacy actor input to the TPaaS user format.
5
+ *
6
+ * @privateRemarks
7
+ * This is a temporary solution to adapt the actor to the new format.
8
+ * It should be removed once we have new methods in place to get the actor.
9
+ *
10
+ * @private
11
+ */
12
+ export function adaptActorToNewFormat(actor) {
13
+ if (!actor) {
14
+ return;
15
+ }
16
+ return {
17
+ id: actor.id?.toString() || '',
18
+ realm: actor.realm || '',
19
+ hasAnySubscription: !!actor.hasAnySubscription,
20
+ region: isString(actor.region) ? actor.region : undefined,
21
+ };
22
+ }
23
+ function adaptStatusOrOptIn({ status, optIn }) {
24
+ // doing an unnecessary check for status here
25
+ // because otherwise the code after the switch will be marked as unreachable in the IDE
26
+ if (status) {
27
+ switch (status) {
28
+ case 'accepted':
29
+ return 'Accepted';
30
+ case 'rejected':
31
+ return 'Rejected';
32
+ case 'unknown':
33
+ return 'Unknown';
34
+ }
35
+ }
36
+ if (optIn === true) {
37
+ return 'Accepted';
38
+ }
39
+ if (optIn === false) {
40
+ return 'Rejected';
41
+ }
42
+ return 'Unknown';
43
+ }
44
+ /**
45
+ * Adapts the legacy consents to the TPaaS consents format.
46
+ *
47
+ * @private
48
+ */
49
+ export function adaptConsentsToNewFormat(consents) {
50
+ if (!consents) {
51
+ return;
52
+ }
53
+ const { purposes, source } = consents;
54
+ const { CMP_ADVERTISING, CMP_ANALYTICS, CMP_MARKETING, CMP_PERSONALIZATION } = purposes;
55
+ return {
56
+ advertising: adaptStatusOrOptIn(CMP_ADVERTISING),
57
+ analytics: adaptStatusOrOptIn(CMP_ANALYTICS),
58
+ marketing: adaptStatusOrOptIn(CMP_MARKETING),
59
+ personalization: adaptStatusOrOptIn(CMP_PERSONALIZATION),
60
+ source: source || 'unknown',
61
+ };
62
+ }
63
+ /**
64
+ * Adapts the base experiments stored in the tracker to the TPaaS experiments format.
65
+ *
66
+ * @private
67
+ */
68
+ export function adaptExperiments(baseExperiments = []) {
69
+ return baseExperiments.map((exp) => {
70
+ return {
71
+ name: exp.name || exp.id,
72
+ variant: exp.variant || '',
73
+ // nobody should be sending experiment id with an sdrn format, but in case they do
74
+ // we want to be able to handle it and not generate an invalid sdrn by adding another layer to it
75
+ experimentSdrn: exp.id.startsWith('sdrn:') ? exp.id : generateExperimentSDRN(exp.id, exp.platform),
76
+ platform: exp.platform || '',
77
+ testId: exp.custom?.testId,
78
+ };
79
+ });
80
+ }
@@ -0,0 +1,47 @@
1
+ import { isBrowser } from '../utils';
2
+ /**
3
+ * Reads the browser state that can change between events, such as the URL after an SPA navigation
4
+ * or the viewport after a resize. Call it synchronously, when the event is tracked.
5
+ *
6
+ * @private
7
+ */
8
+ export const captureBrowserContext = () => {
9
+ if (!isBrowser) {
10
+ return {
11
+ url: undefined,
12
+ search: '',
13
+ screenOrientationType: undefined,
14
+ viewportWidth: 0,
15
+ viewportHeight: 0,
16
+ userAgent: undefined,
17
+ };
18
+ }
19
+ const { viewportWidth, viewportHeight } = getViewportDimensions();
20
+ return {
21
+ url: window.location.href,
22
+ search: window.location.search ?? '',
23
+ screenOrientationType: window.screen.orientation?.type,
24
+ viewportWidth,
25
+ viewportHeight,
26
+ userAgent: window.navigator.userAgent,
27
+ };
28
+ };
29
+ function getViewportDimensions() {
30
+ let viewportWidth;
31
+ let viewportHeight;
32
+ const { document } = window;
33
+ if (typeof window.innerWidth !== 'undefined') {
34
+ viewportWidth = window.innerWidth;
35
+ viewportHeight = window.innerHeight;
36
+ }
37
+ else if (typeof document.documentElement.clientWidth !== 'undefined' &&
38
+ document.documentElement.clientWidth !== 0) {
39
+ viewportWidth = document.documentElement.clientWidth;
40
+ viewportHeight = document.documentElement.clientHeight;
41
+ }
42
+ else {
43
+ viewportWidth = document.getElementsByTagName('body')[0].clientWidth;
44
+ viewportHeight = document.getElementsByTagName('body')[0].clientHeight;
45
+ }
46
+ return { viewportWidth, viewportHeight };
47
+ }
@@ -0,0 +1 @@
1
+ export { prepareAnonymousTpaasEventContext, prepareTpaasEventContext } from './prepare';
@@ -0,0 +1,137 @@
1
+ import logger from 'loglevel';
2
+ import { parsePulseCookies } from '../cis-sync';
3
+ import * as identity from '../identity';
4
+ import { SDK_VERSION } from '../version';
5
+ import { mapPageToPageRef } from '../wrapper/utils/map-page-to-page-ref';
6
+ import { adaptActorToNewFormat, adaptConsentsToNewFormat, adaptExperiments } from './adapters';
7
+ import { captureBrowserContext } from './browser';
8
+ import { resolveSession } from './session';
9
+ // This looks overkill, but a mapping feels safer than doing string operations (capitalize) with javascript
10
+ const mapDeployStageToTpaasStage = (deployStage) => {
11
+ switch (deployStage) {
12
+ case 'dev':
13
+ return 'Dev';
14
+ case 'pre':
15
+ return 'Pre';
16
+ case 'pro':
17
+ return 'Pro';
18
+ }
19
+ };
20
+ /**
21
+ * The context fields derived from the tracker state, shared by all TPaaS events.
22
+ */
23
+ const getStateContext = (state) => ({
24
+ version: SDK_VERSION,
25
+ isHybrid: !!state.isHybrid,
26
+ pageviewId: state.pageViewId,
27
+ providerId: state.providerId,
28
+ providerName: state.provider?.name,
29
+ providerGroup: state.provider?.group,
30
+ providerStage: state.stage,
31
+ providerProduct: state.product,
32
+ providerVersion: state.version,
33
+ component: state.component,
34
+ componentVersion: state.componentVersion,
35
+ routingStage: mapDeployStageToTpaasStage(state.deployStageTpaas),
36
+ });
37
+ /**
38
+ * Deep copies the tracking input, so a caller that reuses and changes the same input object afterwards
39
+ * cannot change an event that is still being prepared. When the input cannot be copied, it is used as it is.
40
+ */
41
+ const copyInput = (input) => {
42
+ try {
43
+ return structuredClone(input);
44
+ }
45
+ catch (ex) {
46
+ // older browsers, or inputs with values that cannot be cloned (functions, Promises, framework proxies)
47
+ logger.debug('Could not copy the tracking input, using it as is', ex);
48
+ return input;
49
+ }
50
+ };
51
+ const getPageRef = async (pageInfo) => {
52
+ const { id, type, url } = await pageInfo;
53
+ return mapPageToPageRef(id, type, url);
54
+ };
55
+ /**
56
+ * Resolves the context of an anonymous TPaaS event.
57
+ * Callers specify the event schema because it cannot be inferred from `InputParams<I>`.
58
+ *
59
+ * @private
60
+ */
61
+ export async function prepareAnonymousTpaasEventContext(source, input) {
62
+ // Read everything before any asynchronous work, so the context reflects the moment the event
63
+ // was tracked and a later update or View event cannot change it.
64
+ const createdAt = new Date();
65
+ const eventInput = copyInput(input);
66
+ const browser = captureBrowserContext();
67
+ const stateContext = getStateContext(source.state);
68
+ const experiments = source.builders.experiments;
69
+ const { referrer } = source.currentPage;
70
+ try {
71
+ await source.applyRemoteConfig();
72
+ }
73
+ catch (ex) {
74
+ logger.trace('Failed to sync remote config', ex);
75
+ }
76
+ return {
77
+ input: eventInput,
78
+ createdAt,
79
+ browser,
80
+ ...stateContext,
81
+ experiments: adaptExperiments(experiments),
82
+ currentPageReferrer: await referrer,
83
+ };
84
+ }
85
+ /**
86
+ * Resolves the context of a TPaaS event.
87
+ * Callers specify the event schema because it cannot be inferred from `InputParams<I>`.
88
+ *
89
+ * @private
90
+ */
91
+ export async function prepareTpaasEventContext(source, input) {
92
+ // Read everything before any asynchronous work, so the context reflects the moment the event
93
+ // was tracked and a later update or View event cannot change it.
94
+ // The session is resolved here too, so sessions are updated in the order events are tracked.
95
+ const createdAt = new Date();
96
+ const eventInput = copyInput(input);
97
+ const session = resolveSession(createdAt);
98
+ const browser = captureBrowserContext();
99
+ const stateContext = getStateContext(source.state);
100
+ const builders = { ...source.builders };
101
+ const { info, content, sports, referrer } = source.currentPage;
102
+ // Session listeners run synchronously and may update the tracker or start another View.
103
+ // Notify them only after this event's context has been captured.
104
+ source.onSessionResolved();
105
+ try {
106
+ await source.syncRemoteResources(builders);
107
+ }
108
+ catch (ex) {
109
+ logger.trace('Failed to sync remote resources', ex);
110
+ // remote config and CIS failures are also ignored for the old track() method. doing the same here
111
+ }
112
+ // Consents are intentionally not read upfront. Read them after remote synchronization
113
+ // so a blocking tracking call can use newly resolved consents.
114
+ const [actor, consents, currentPage, currentPageReferrer] = await Promise.all([
115
+ identity.getActor(builders),
116
+ source.getConsents(),
117
+ getPageRef(info),
118
+ referrer,
119
+ ]);
120
+ const { environmentId, jwe } = parsePulseCookies();
121
+ return {
122
+ input: eventInput,
123
+ createdAt,
124
+ session,
125
+ browser,
126
+ ...stateContext,
127
+ user: adaptActorToNewFormat(actor),
128
+ consents: adaptConsentsToNewFormat(consents),
129
+ experiments: adaptExperiments(builders.experiments),
130
+ currentPage,
131
+ currentPageContent: content,
132
+ currentPageSports: sports,
133
+ currentPageReferrer,
134
+ environmentId,
135
+ jwe,
136
+ };
137
+ }
@@ -0,0 +1,19 @@
1
+ import { touchSession } from '../session/store';
2
+ import { getXDomainId } from '../utils';
3
+ /**
4
+ * Registers an event created at `createdAt` in the stored session and returns it in the TPaaS format.
5
+ *
6
+ * Call it synchronously, together with capturing `createdAt`, before any asynchronous work.
7
+ * Sessions are then updated in the order events are tracked, which is also their creation order.
8
+ *
9
+ * @private
10
+ */
11
+ export const resolveSession = (createdAt) => {
12
+ const { sessionId, startTime, isFirstEvent } = touchSession(createdAt);
13
+ return {
14
+ isFirstEvent,
15
+ sessionId,
16
+ startTime: startTime.toISOString(),
17
+ xDomainId: getXDomainId(),
18
+ };
19
+ };