@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
@@ -41,10 +41,6 @@ exports.subscribe = subscribe;
41
41
  exports.subscribeOnce = subscribeOnce;
42
42
  exports.subscribeWithState = subscribeWithState;
43
43
  exports.unsubscribe = unsubscribe;
44
- const pulse_cis_sync_1 = require("@schibsted/pulse-cis-sync");
45
- const pulse_utils_1 = require("@schibsted/pulse-utils");
46
- const tpaas_event_builder_1 = require("@schibsted/tpaas-event-builder");
47
- const tpaas_schemas_1 = require("@schibsted/tpaas-schemas");
48
44
  const loglevel_1 = __importDefault(require("loglevel"));
49
45
  const uuid_1 = require("uuid");
50
46
  const app_integration_1 = require("./app-integration");
@@ -53,7 +49,6 @@ const consent_manager_1 = require("./builders/consent-manager");
53
49
  const consents_1 = require("./builders/consents");
54
50
  const events_1 = require("./builders/events");
55
51
  const events_anonymous_node_1 = require("./builders/events-anonymous-node");
56
- const session_browser_1 = require("./builders/session-browser");
57
52
  const config_1 = require("./config");
58
53
  const config_browser_1 = require("./config-browser");
59
54
  const defer_1 = __importDefault(require("./defer"));
@@ -63,11 +58,18 @@ const leaveTracking_1 = require("./leaveTracking");
63
58
  const leaveTrackingTpaas_1 = require("./leaveTrackingTpaas");
64
59
  const network_1 = __importDefault(require("./network"));
65
60
  const config = __importStar(require("./remoteConfig"));
61
+ const store_1 = require("./session/store");
62
+ const tpaas_builders_1 = require("./tpaas-builders");
63
+ const tpaas_context_1 = require("./tpaas-context");
64
+ const tpaas_schemas_1 = require("./tpaas-schemas");
66
65
  const proxy_provider_1 = require("./tracker-proxy/proxy-provider");
66
+ const utils_1 = require("./utils");
67
67
  const version_1 = require("./version");
68
68
  const visibility_observer_1 = require("./visibility-observer");
69
69
  const warnOnce_1 = __importDefault(require("./warnOnce"));
70
70
  const event_builder_1 = require("./wrapper/engagement/ui-element/event-builder");
71
+ const types_1 = require("./wrapper/types");
72
+ const map_page_to_page_ref_1 = require("./wrapper/utils/map-page-to-page-ref");
71
73
  const page_from_page_view_1 = require("./wrapper/utils/page-from-page-view");
72
74
  const event_builder_2 = require("./wrapper/view/article/event-builder");
73
75
  const event_builder_3 = require("./wrapper/view/frontpage/event-builder");
@@ -103,6 +105,7 @@ const anonymousEvents = {
103
105
  trackerEvent: events_anonymous_node_1.anonymousTrackerEvent,
104
106
  engagementEvent: events_anonymous_node_1.anonymousEngagementEvent,
105
107
  };
108
+ const ANONYMOUS_EVENT_FORBIDDEN_FIELDS = ['session', 'actor', 'device', 'location', 'pageViewId'];
106
109
  /**
107
110
  * @typeParam T Type of event to track
108
111
  * @param name
@@ -157,6 +160,32 @@ function unsubscribe(eventName, callback) {
157
160
  * @class Tracker
158
161
  */
159
162
  class Tracker {
163
+ /**
164
+ * What the TPaaS context module reads to resolve the context of an event.
165
+ * Built on every call, so it always reflects the current state.
166
+ */
167
+ get tpaasContextSource() {
168
+ return {
169
+ state: this.state,
170
+ builders: this.builders,
171
+ currentPage: this.currentPageContext,
172
+ applyRemoteConfig: () => this._applyRemoteConfigEndpoints(),
173
+ syncRemoteResources: (builders) => this.syncRemoteResources(undefined, builders),
174
+ getConsents: () => this.getConsents(),
175
+ onSessionResolved: () => this.resolveSessionIdPromise(),
176
+ };
177
+ }
178
+ async getCurrentLegacyPage() {
179
+ const { id, type, url } = await this.currentPageContext.info;
180
+ // make sure the pageType is valid for legacy events
181
+ const validatedType = (0, types_1.isLegacyPageType)(type) ? type : 'Page';
182
+ return {
183
+ // add the SDRN prefix if it's not there, legacy events expect the full SDRN format
184
+ id: id.startsWith('sdrn:') ? id : `sdrn:${this.state.providerId}:${validatedType.toLowerCase()}:${id}`,
185
+ type: validatedType,
186
+ url,
187
+ };
188
+ }
160
189
  /**
161
190
  * > [!WARNING]
162
191
  * >
@@ -175,12 +204,37 @@ class Tracker {
175
204
  // the tracking of the same element with both old and new events at the same time
176
205
  this.legacyVisibilityObservers = new Map();
177
206
  this.visibilityObservers = new Map();
178
- this.legacyCurrentPage = {
179
- id: 'undefined-id',
180
- type: 'Page',
181
- url: typeof window !== 'undefined' ? window.location.href : '',
207
+ /**
208
+ * Current page state shared by legacy and TPaaS tracking. See CurrentPageContext for
209
+ * which properties are shared and which are exclusively TPaaS metadata.
210
+ */
211
+ this.currentPageContext = {
212
+ info: {
213
+ id: 'unknown',
214
+ type: 'Page',
215
+ url: utils_1.isBrowser ? window.location.href : undefined,
216
+ },
217
+ referrer: {
218
+ url: utils_1.isBrowser ? document.referrer || undefined : undefined,
219
+ },
220
+ };
221
+ this.setCurrentTpaasPageData = ({ id, type, referrer, content, sports, }) => {
222
+ // TPaaS Views replace the context, intentionally resetting omitted content and sports.
223
+ this.currentPageContext = {
224
+ info: {
225
+ id: id || 'unknown',
226
+ type: type || 'Page',
227
+ url: utils_1.isBrowser ? window.location.href : undefined,
228
+ },
229
+ referrer: {
230
+ ...referrer,
231
+ url: referrer?.url ?? (utils_1.isBrowser ? document.referrer || undefined : undefined),
232
+ },
233
+ // destructure and copy content and sports to avoid mutations from outside
234
+ content: content && { ...content },
235
+ sports: sports && { ...sports },
236
+ };
182
237
  };
183
- this.currentPage = undefined;
184
238
  /**
185
239
  * Promise that resolves when a session ID becomes available
186
240
  * @private
@@ -192,32 +246,30 @@ class Tracker {
192
246
  */
193
247
  this.hasProxyListener = false;
194
248
  this.setPageDefaults = (pageViewEvent) => {
195
- this.legacyCurrentPage = (0, page_from_page_view_1.pageFromPageView)(pageViewEvent);
249
+ // Legacy Views update only the shared properties, preserving TPaaS-only content and sports.
250
+ this.currentPageContext.info = (0, page_from_page_view_1.pageFromPageView)(pageViewEvent);
251
+ this.currentPageContext.referrer = Promise.resolve(pageViewEvent.origin).then((originProperties) => (0, map_page_to_page_ref_1.mapPageToPageRef)(originProperties?.id, originProperties?.type, originProperties?.url));
196
252
  if (pageViewEvent.origin) {
197
253
  const pageDefaults = { origin: pageViewEvent.origin };
198
254
  this.update(pageDefaults, true);
199
255
  }
200
256
  };
201
- this.setCurrentPage = (id, type) => {
202
- this.currentPage = {
203
- pageId: id,
204
- pageType: type,
205
- url: pulse_utils_1.isBrowser ? window.location.href : undefined,
206
- };
207
- };
208
257
  loglevel_1.default.setLevel(config?.logLevel ?? loglevel_1.default.levels.ERROR);
209
258
  // runtime check for providerId inconsistency
210
259
  if (!providerId || !(typeof providerId === 'string')) {
211
260
  throw new Error('Required parameter `providerId` missing');
212
261
  }
262
+ if (config?.componentVersion !== undefined && config?.component === undefined) {
263
+ throw new Error('`componentVersion` cannot be provided without `component`');
264
+ }
213
265
  let includeAdvertising;
214
- if (pulse_utils_1.isBrowser && config?.autoCreateConsents) {
266
+ if (utils_1.isBrowser && config?.autoCreateConsents) {
215
267
  config.consents = (0, consent_manager_1.getConsentsWaitForAnalytics)((consents) => {
216
268
  loglevel_1.default.debug('Consents received from CMP', consents);
217
269
  return this.setConsentsInternal(consents);
218
270
  });
219
271
  }
220
- if ((0, pulse_utils_1.isPromise)(config?.consents)) {
272
+ if ((0, utils_1.isPromise)(config?.consents)) {
221
273
  includeAdvertising = (0, consents_1.applyAdvertisingConsent)(config?.consents, config?.requireAdvertisingOptIn);
222
274
  }
223
275
  else {
@@ -233,7 +285,7 @@ class Tracker {
233
285
  identity.clearCookieJweIfStale(config?.nativeJwe);
234
286
  const deployStage = config?.deployStage || 'pro';
235
287
  const deployStageTpaas = config?.deployStageTpaas || 'pre';
236
- this.state = (0, pulse_utils_1.pulseMerge)({}, config_1.baseConfig, {
288
+ this.state = (0, utils_1.pulseMerge)({}, config_1.baseConfig, {
237
289
  collectorBaseUrl: config_browser_1.collectorEndpoints[deployStage],
238
290
  deployStage,
239
291
  deployStageTpaas,
@@ -248,11 +300,15 @@ class Tracker {
248
300
  tpaasCollectorBaseUrl: config_browser_1.collectorEndpoints[deployStageTpaas],
249
301
  trackerId: (0, uuid_1.v4)(),
250
302
  vendors: config?.vendors?.length ? [] : ['xandr'],
303
+ useBeacon: true,
304
+ useBeaconWhenAvailable: true,
251
305
  }, config);
252
306
  // Move to default config?
253
- this.builders = (0, pulse_utils_1.pulseMerge)({}, builders, {
307
+ this.builders = (0, utils_1.pulseMerge)({}, builders, {
254
308
  provider: {
255
309
  id: providerId,
310
+ ...(config?.component !== undefined && { component: config.component }),
311
+ ...(config?.componentVersion !== undefined && { componentVersion: config.componentVersion }),
256
312
  },
257
313
  tracker: {
258
314
  version: version_1.SDK_VERSION,
@@ -268,7 +324,7 @@ class Tracker {
268
324
  this.retryTpaasEventQueue = [];
269
325
  if (this.state.environment === 'browser') {
270
326
  // @ts-expect-error
271
- if (pulse_utils_1.isBrowser && window.navigator?.sendBeacon) {
327
+ if (utils_1.isBrowser && window.navigator?.sendBeacon) {
272
328
  const originalUseBeacon = this.state.useBeacon;
273
329
  window.addEventListener('pagehide', () => {
274
330
  this.state.useBeacon = true;
@@ -282,7 +338,7 @@ class Tracker {
282
338
  }
283
339
  }
284
340
  // @ts-expect-error
285
- this.debouncedSend = (0, pulse_utils_1.throttle)(async () => {
341
+ this.debouncedSend = (0, utils_1.throttle)(async () => {
286
342
  try {
287
343
  return await this._sendImmediately();
288
344
  }
@@ -291,7 +347,7 @@ class Tracker {
291
347
  }
292
348
  }, this.state.eventDebounce);
293
349
  // @ts-expect-error
294
- this.debouncedSendAnonymous = (0, pulse_utils_1.throttle)(async () => {
350
+ this.debouncedSendAnonymous = (0, utils_1.throttle)(async () => {
295
351
  try {
296
352
  return await this._sendImmediatelyAnonymous();
297
353
  }
@@ -300,7 +356,7 @@ class Tracker {
300
356
  }
301
357
  }, this.state.eventDebounce);
302
358
  // @ts-expect-error
303
- this.debouncedSendTpaas = (0, pulse_utils_1.throttle)(async () => {
359
+ this.debouncedSendTpaas = (0, utils_1.throttle)(async () => {
304
360
  try {
305
361
  return await this._sendImmediatelyTpaas();
306
362
  }
@@ -369,6 +425,11 @@ class Tracker {
369
425
  return queuedEvent.then((result) => result);
370
426
  });
371
427
  };
428
+ /*
429
+ * Casting `input` as `Partial<Builders>` to formalise the intention of processing the event input in relation to the properties in
430
+ * the Builders type. It would justify changing the public api for `.track`, but as this deals with legacy code, we
431
+ * keep it internal, so dependencies from now on can count on objects being a Partial<Builder>
432
+ */
372
433
  return this.syncRemoteResources(input, currentBuilders).then(_track, _track);
373
434
  }
374
435
  /**
@@ -401,12 +462,12 @@ class Tracker {
401
462
  */
402
463
  async trackAnonymous(eventType, input, options) {
403
464
  // We must create the event as soon as possible, as it defines the creationDate.
404
- const newEvent = this.createAnonymousEvent(input);
465
+ const newEvent = (0, utils_1.omit)(this.createAnonymousEvent(input), ANONYMOUS_EVENT_FORBIDDEN_FIELDS);
405
466
  // Remote config values ----------------
406
467
  await this._applyRemoteConfigEndpoints();
407
468
  // Resolve all available properties ----------------
408
- const resolvedOutput = await Promise.all([this.resolveTrackInput(newEvent), this.resolveTrackGlobals()]);
409
- let eventOutput = resolvedOutput.reduce((acc, p) => (0, pulse_utils_1.pulseMerge)(acc, p), {});
469
+ const resolvedOutput = await Promise.all([this.resolveTrackInput(newEvent), this.resolveAnonymousTrackGlobals()]);
470
+ let eventOutput = resolvedOutput.reduce((acc, p) => (0, utils_1.pulseMerge)(acc, p), {});
410
471
  eventOutput = this.applyAnonymousEventTypeDefaults(eventOutput, eventType);
411
472
  // Leave Events ----------------
412
473
  // they require (most) properties of the previous PageView event, which was saved under a bookmark key when tracked
@@ -419,6 +480,7 @@ class Tracker {
419
480
  eventInput: eventOutput,
420
481
  sdkConfig: this.state,
421
482
  });
483
+ eventOutput = (0, utils_1.omit)(eventOutput, ANONYMOUS_EVENT_FORBIDDEN_FIELDS);
422
484
  if (options?.bookmarkKey) {
423
485
  this.bookmark.set(options.bookmarkKey, eventOutput);
424
486
  }
@@ -433,132 +495,6 @@ class Tracker {
433
495
  await this.sendAnonymous();
434
496
  return queuedEvent;
435
497
  }
436
- async adaptExperiments(baseExperiments = []) {
437
- return baseExperiments.map((exp) => {
438
- return {
439
- name: exp.name || exp.id,
440
- variant: exp.variant || '',
441
- };
442
- });
443
- }
444
- /**
445
- *
446
- * @private
447
- * @category TPaaS Tracking
448
- */
449
- async prepareAnonymousTpaasEvent() {
450
- try {
451
- await this._applyRemoteConfigEndpoints();
452
- }
453
- catch (ex) {
454
- loglevel_1.default.trace('Failed to sync remote config', ex);
455
- }
456
- return {
457
- autoTrackerVersion: this.builders.tracker?.autoTrackerVersion,
458
- version: version_1.SDK_VERSION,
459
- isHybrid: !!this.state.isHybrid,
460
- pageviewId: this.state.pageViewId,
461
- providerId: this.state.providerId,
462
- experiments: await this.adaptExperiments(this.builders.experiments),
463
- };
464
- }
465
- /**
466
- *
467
- * @private
468
- * @category TPaaS Tracking
469
- */
470
- async prepareTpaasEvent() {
471
- try {
472
- await this.syncRemoteResources(undefined, { ...this.builders });
473
- }
474
- catch (ex) {
475
- loglevel_1.default.trace('Failed to sync remote resources', ex);
476
- // remote config and CIS failures are also ignored for the old track() method. doing the same here
477
- }
478
- function adaptActorToNewFormat(actor) {
479
- // this is a temporary solution to adapt the actor to the new format
480
- // it should be removed once we have new methods in place to get the actor
481
- if (!actor) {
482
- return;
483
- }
484
- return {
485
- id: actor.id?.toString() || '',
486
- realm: actor.realm || '',
487
- hasAnySubscription: !!actor.hasAnySubscription,
488
- region: (0, pulse_utils_1.isString)(actor.region) ? actor.region : undefined,
489
- };
490
- }
491
- function adaptConsentsToNewFormat(consents) {
492
- if (!consents) {
493
- return;
494
- }
495
- const { purposes, source } = consents;
496
- const { CMP_ADVERTISING, CMP_ANALYTICS, CMP_MARKETING, CMP_PERSONALIZATION } = purposes;
497
- function adaptStatusOrOptIn({ status, optIn }) {
498
- // doing an unnecessary check for status here
499
- // because otherwise the code after the switch will be marked as unreachable in the IDE
500
- if (status) {
501
- switch (status) {
502
- case 'accepted':
503
- return 'Accepted';
504
- case 'rejected':
505
- return 'Rejected';
506
- case 'unknown':
507
- return 'Unknown';
508
- }
509
- }
510
- if (optIn === true) {
511
- return 'Accepted';
512
- }
513
- if (optIn === false) {
514
- return 'Rejected';
515
- }
516
- return 'Unknown';
517
- }
518
- return {
519
- advertising: adaptStatusOrOptIn(CMP_ADVERTISING),
520
- analytics: adaptStatusOrOptIn(CMP_ANALYTICS),
521
- marketing: adaptStatusOrOptIn(CMP_MARKETING),
522
- personalization: adaptStatusOrOptIn(CMP_PERSONALIZATION),
523
- source: source || 'unknown',
524
- };
525
- }
526
- const [actor, consents, experiments] = await Promise.all([
527
- this.getActor(),
528
- this.getConsents(),
529
- this.adaptExperiments(this.builders.experiments),
530
- ]);
531
- const { environmentId, jwe } = (0, pulse_cis_sync_1.parsePulseCookies)();
532
- return {
533
- autoTrackerVersion: this.builders.tracker?.autoTrackerVersion,
534
- version: version_1.SDK_VERSION,
535
- isHybrid: !!this.state.isHybrid,
536
- user: adaptActorToNewFormat(actor),
537
- consents: adaptConsentsToNewFormat(consents),
538
- providerId: this.state.providerId,
539
- pageviewId: this.state.pageViewId,
540
- currentPage: this.currentPage,
541
- experiments,
542
- environmentId,
543
- jwe,
544
- };
545
- }
546
- /**
547
- * Generate a generic TPaaS event with common builders output
548
- * The method should be used for experiments, not for real production work.
549
- * It doesn't have any real TPaaS schema associated with it.
550
- * The method doesn't queue or send the event, it just returns the merged object.
551
- * The method can be removed at any time in the future, so use it with caution.
552
- *
553
- * @param input - The input object to merge with the common builders output
554
- * @returns A promise that resolves to the merged object
555
- * @private
556
- * @category TPaaS Tracking
557
- */
558
- async generateGenericTpaasEvent(input) {
559
- const dependencies = await this.prepareTpaasEvent();
560
- return (0, pulse_utils_1.pulseMerge)({}, input, (0, tpaas_event_builder_1.getCommonBuildersOutput)(new Date(), dependencies));
561
- }
562
498
  /**
563
499
  * This method extends the list of base experiments that will be automatically included in every event sent by the tracker.
564
500
  *
@@ -580,6 +516,9 @@ class Tracker {
580
516
  * @category Tracking
581
517
  */
582
518
  addExperiments(experiments) {
519
+ if (experiments.some((experiment) => experiment.id.startsWith('sdrn:'))) {
520
+ loglevel_1.default.warn('Pulse - addExperiments received an experiment id starting with "sdrn:"; pass the raw experiment id instead. The SDK will generate the sdrn automatically.');
521
+ }
583
522
  this.update({ experiments }, true);
584
523
  }
585
524
  /**
@@ -614,7 +553,7 @@ class Tracker {
614
553
  const viewUIElementInputProperties = buildEventFromElement(element);
615
554
  this.trackLegacyViewUIElement(viewUIElementInputProperties);
616
555
  }));
617
- this.legacyVisibilityObservers.get(selector)?.observe(selector);
556
+ this.legacyVisibilityObservers.get(selector)?.observe(selector, {});
618
557
  }
619
558
  /**
620
559
  * The `addUIElementVisibilityTracking` function provides an interface for sending tracking events when specific UI elements become visible within the viewport.
@@ -646,7 +585,38 @@ class Tracker {
646
585
  const eventInput = buildEventFromElement(element);
647
586
  this.trackImpressionUIElement(eventInput);
648
587
  }));
649
- this.visibilityObservers.get(selector)?.observe(selector);
588
+ this.visibilityObservers.get(selector)?.observe(selector, {});
589
+ }
590
+ /**
591
+ * The `addElementVisibilityObserver` function provides an interface for executing arbitrary code when specific DOM Elements become visible within the viewport.
592
+ * It is built on the `VisibilityObserver` class, which efficiently detects visibility changes in DOM elements.
593
+ * When an element becomes at least 2/3 visible, a callback is triggered, with the Element that invoked the callback call as argument.
594
+ * It leverages the [Intersection Observer API](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API) for viewport tracking
595
+ * and the [Mutation Observer API](https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver) to monitor lazy-loaded elements.
596
+ *
597
+ * Example usage:
598
+ *
599
+ * ```ts
600
+ * tracker.addElementVisibilityObserver('[data-pulse-entity-id]', (element) => {
601
+ * const eventInput = parseElementIntoEventInput(element); // user-defined function
602
+ * tracker.trackImpressionTeaser(eventInput); // can be anything actually, not necessarily a Teaser tracking call
603
+ * });
604
+ * ```
605
+ * @param selector
606
+ * @param callback
607
+ * @param options {ObserverOptions}
608
+ * @param options.threshold - A number between 0 and 1 indicating how much of the element should be visible to trigger
609
+ * the callback. Default is 0.67 (2/3 of the element).
610
+ */
611
+ addElementVisibilityObserver(selector, callback, options = {}) {
612
+ if (this.visibilityObservers.has(selector)) {
613
+ console.warn(`Cannot add UI Element visibility tracking for selector "${selector}" as it is already being tracked.`);
614
+ return;
615
+ }
616
+ this.visibilityObservers.set(selector, new visibility_observer_1.VisibilityObserver((element) => {
617
+ callback(element);
618
+ }));
619
+ this.visibilityObservers.get(selector)?.observe(selector, options);
650
620
  }
651
621
  /**
652
622
  * The old trackViewArticle method from the Media Wrapper.
@@ -740,7 +710,7 @@ class Tracker {
740
710
  * @category Legacy Tracking
741
711
  */
742
712
  trackLegacyViewUIElement(inputProperties, trackOptions) {
743
- const viewUIElementEventData = (0, event_builder_8.buildLegacyViewUIElementEvent)(inputProperties, this.legacyCurrentPage);
713
+ const viewUIElementEventData = (0, event_builder_8.buildLegacyViewUIElementEvent)(inputProperties, this.getCurrentLegacyPage());
744
714
  return this.track('trackerEvent', viewUIElementEventData, trackOptions);
745
715
  }
746
716
  /**
@@ -751,7 +721,7 @@ class Tracker {
751
721
  * @category Legacy Tracking
752
722
  */
753
723
  trackLegacyClickUIElement(inputProperties, trackOptions) {
754
- const clickUIElementEventData = (0, event_builder_1.buildClickUIElementEvent)(inputProperties, this.legacyCurrentPage);
724
+ const clickUIElementEventData = (0, event_builder_1.buildClickUIElementEvent)(inputProperties, this.getCurrentLegacyPage());
755
725
  return this.track('trackerEvent', clickUIElementEventData, trackOptions);
756
726
  }
757
727
  /**
@@ -761,36 +731,39 @@ class Tracker {
761
731
  * @param input
762
732
  * @category TPaaS Tracking
763
733
  */
764
- async trackAnonymousViewUIElement(input) {
765
- const dependencies = await this.prepareAnonymousTpaasEvent();
766
- const event = (0, tpaas_event_builder_1.buildAnonymousViewUIElementEvent)(input, dependencies);
734
+ async trackAnonymousImpressionUIElement(input) {
735
+ const context = await (0, tpaas_context_1.prepareAnonymousTpaasEventContext)(this.tpaasContextSource, input);
736
+ const event = (0, tpaas_builders_1.buildAnonymousImpressionUIElementEvent)(context);
767
737
  return this.sendTpaasEvent(event);
768
738
  }
769
739
  async trackCompletedHealthAction(input) {
770
- const dependencies = await this.prepareTpaasEvent();
771
- const event = (0, tpaas_event_builder_1.buildCompletedHealthActionEvent)(input, dependencies);
740
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
741
+ const event = (0, tpaas_builders_1.buildCompletedHealthActionEvent)(context);
772
742
  return this.sendTpaasEvent(event);
773
743
  }
774
744
  async trackEngagementHealthUIElement(input) {
775
- const dependencies = await this.prepareTpaasEvent();
776
- const event = (0, tpaas_event_builder_1.buildEngagementHealthUIElementEvent)(input, dependencies);
745
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
746
+ const event = (0, tpaas_builders_1.buildEngagementHealthUIElementEvent)(context);
777
747
  return this.sendTpaasEvent(event);
778
748
  }
779
749
  async trackViewHealthPage(input, options) {
780
750
  this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
781
- this.setCurrentPage(input.object.objectId, 'Page'); // ViewHealthPage.object.objectType is HealthPage, which is not allowed as a pageType
782
- const dependencies = await this.prepareTpaasEvent();
783
- const event = (0, tpaas_event_builder_1.buildViewHealthPageEvent)(input, dependencies);
751
+ this.setCurrentTpaasPageData({
752
+ id: input.object.objectId,
753
+ type: tpaas_schemas_1.ViewHealthPage.object.objectType,
754
+ referrer: input.page?.referrer,
755
+ });
756
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
757
+ const event = (0, tpaas_builders_1.buildViewHealthPageEvent)(context);
784
758
  const result = this.sendTpaasEvent(event);
785
759
  if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
786
- const { objectElement, pageElement, heightBuilder, objectResizable } = options.leaveTracking;
787
- // HealthView Page is a bit special, in the sense that in doesn't have a dedicated Leave event.
788
- // Instead, we need to reuse the generic Leave Page event, but adapt the input accordingly.
789
- // This means omitting some fields from HealthView Page that are not part of Leave Page schema.
790
- const { experiments, metrics, object, ...restInput } = input;
791
- const { category, custom, intent, name, tags, ...restObject } = input.object;
792
- const leavePageCallback = (leave) => {
793
- this.trackLeavePage({
760
+ const leavePageCallback = async (leave) => {
761
+ // HealthView Page is a bit special, in the sense that in doesn't have a dedicated Leave event.
762
+ // Instead, we need to reuse the generic Leave Page event, but adapt the input accordingly.
763
+ // This means omitting some fields from HealthView Page that are not part of Leave Page schema.
764
+ const { experiments, metrics, object, origin, userHealthData, ...restInput } = context.input;
765
+ const { category, custom, name, tags, food, physicalActivity, training, ...restObject } = context.input.object;
766
+ await this.trackLeavePage({
794
767
  leave,
795
768
  ...restInput,
796
769
  object: {
@@ -800,10 +773,7 @@ class Tracker {
800
773
  });
801
774
  };
802
775
  (0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
803
- objectElement,
804
- pageElement,
805
- objectResizable,
806
- heightBuilder,
776
+ ...options.leaveTracking,
807
777
  schema: tpaas_schemas_1.LeavePage.object.objectType,
808
778
  trackMethod: leavePageCallback,
809
779
  });
@@ -811,8 +781,8 @@ class Tracker {
811
781
  return result;
812
782
  }
813
783
  async trackImpressionHealthUIElement(input) {
814
- const dependencies = await this.prepareTpaasEvent();
815
- const event = (0, tpaas_event_builder_1.buildImpressionHealthUIElementEvent)(input, dependencies);
784
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
785
+ const event = (0, tpaas_builders_1.buildImpressionHealthUIElementEvent)(context);
816
786
  return this.sendTpaasEvent(event);
817
787
  }
818
788
  /**
@@ -822,23 +792,23 @@ class Tracker {
822
792
  */
823
793
  async trackViewPage(input, options) {
824
794
  this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
825
- this.setCurrentPage(input.object.objectId, tpaas_schemas_1.ViewPage.object.objectType);
826
- const dependencies = await this.prepareTpaasEvent();
827
- const event = (0, tpaas_event_builder_1.buildViewPageEvent)(input, dependencies);
795
+ this.setCurrentTpaasPageData({
796
+ id: input.object.objectId,
797
+ type: tpaas_schemas_1.ViewPage.object.objectType,
798
+ referrer: input.page?.referrer,
799
+ });
800
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
801
+ const event = (0, tpaas_builders_1.buildViewPageEvent)(context);
828
802
  const result = this.sendTpaasEvent(event);
829
803
  if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
830
- const { objectElement, pageElement, heightBuilder, objectResizable } = options.leaveTracking;
831
- const leavePageCallback = (leave) => {
832
- this.trackLeavePage({
804
+ const leavePageCallback = async (leave) => {
805
+ await this.trackLeavePage({
833
806
  leave,
834
- ...input,
807
+ ...context.input,
835
808
  });
836
809
  };
837
810
  (0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
838
- objectElement,
839
- pageElement,
840
- objectResizable,
841
- heightBuilder,
811
+ ...options.leaveTracking,
842
812
  schema: tpaas_schemas_1.LeavePage.object.objectType,
843
813
  trackMethod: leavePageCallback,
844
814
  });
@@ -852,38 +822,79 @@ class Tracker {
852
822
  */
853
823
  async trackViewSportsPage(input, options) {
854
824
  this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
855
- this.setCurrentPage(input.object.objectId, 'Page'); // ViewSportsPage.object.objectType is SportsPage, which is not allowed as a pageType
856
- const dependencies = await this.prepareTpaasEvent();
857
- const event = (0, tpaas_event_builder_1.buildViewSportsPageEvent)(input, dependencies);
825
+ this.setCurrentTpaasPageData({
826
+ id: input.object.objectId,
827
+ type: tpaas_schemas_1.ViewSportsPage.object.objectType,
828
+ referrer: input.page?.referrer,
829
+ sports: {
830
+ sportName: input.object.sportName,
831
+ sportSubview: input.object.sportSubview,
832
+ sportView: input.object.sportView,
833
+ sports: input.object.sports,
834
+ },
835
+ });
836
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
837
+ const event = (0, tpaas_builders_1.buildViewSportsPageEvent)(context);
858
838
  const result = this.sendTpaasEvent(event);
859
839
  if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
860
- const { objectElement, pageElement, heightBuilder, objectResizable } = options.leaveTracking;
861
- const leaveSportsPageCallback = (leave) => {
862
- this.trackLeaveSportsPage({
840
+ const leaveSportsPageCallback = async (leave) => {
841
+ await this.trackLeaveSportsPage({
863
842
  leave,
864
- ...input,
843
+ ...context.input,
865
844
  });
866
845
  };
867
846
  (0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
868
- objectElement,
869
- pageElement,
870
- objectResizable,
871
- heightBuilder,
847
+ ...options.leaveTracking,
872
848
  schema: tpaas_schemas_1.LeaveSportsPage.object.objectType,
873
849
  trackMethod: leaveSportsPageCallback,
874
850
  });
875
851
  }
876
852
  return result;
877
853
  }
854
+ /**
855
+ * @param input
856
+ * @param options
857
+ * @category TPaaS Tracking
858
+ */
859
+ async trackViewSchoolPage(input, options) {
860
+ this.newPageView();
861
+ // TODO: SchoolPage is not currently part of the catalog's PageRef.pageType enum.
862
+ this.setCurrentTpaasPageData({
863
+ id: input.object.objectId,
864
+ type: 'Page',
865
+ referrer: input.page?.referrer,
866
+ });
867
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
868
+ const event = (0, tpaas_builders_1.buildViewSchoolPageEvent)(context);
869
+ const result = this.sendTpaasEvent(event);
870
+ if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
871
+ const leaveSchoolPageCallback = async (leave) => {
872
+ await this.trackLeaveSchoolPage({
873
+ leave,
874
+ ...context.input,
875
+ });
876
+ };
877
+ (0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
878
+ ...options.leaveTracking,
879
+ schema: tpaas_schemas_1.LeaveSchoolPage.object.objectType,
880
+ trackMethod: leaveSchoolPageCallback,
881
+ });
882
+ }
883
+ return result;
884
+ }
878
885
  /**
879
886
  * @param input
880
887
  * @category TPaaS Tracking
881
888
  */
882
889
  async trackViewTitle(input) {
883
890
  this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
884
- this.setCurrentPage(input.object.objectId, tpaas_schemas_1.ViewTitle.object.objectType);
885
- const dependencies = await this.prepareTpaasEvent();
886
- const event = (0, tpaas_event_builder_1.buildViewTitleEvent)(input, dependencies);
891
+ this.setCurrentTpaasPageData({
892
+ id: input.object.objectId,
893
+ type: tpaas_schemas_1.ViewTitle.object.objectType,
894
+ referrer: input.page?.referrer,
895
+ });
896
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
897
+ const event = (0, tpaas_builders_1.buildViewTitleEvent)(context);
887
898
  return this.sendTpaasEvent(event);
888
899
  // there's no Leave Title event
889
900
  }
@@ -892,17 +903,17 @@ class Tracker {
892
903
  * @category TPaaS Tracking
893
904
  */
894
905
  async trackImpressionWidget(input) {
895
- const dependencies = await this.prepareTpaasEvent();
896
- const event = (0, tpaas_event_builder_1.buildImpressionWidgetEvent)(input, dependencies);
906
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
907
+ const event = (0, tpaas_builders_1.buildImpressionWidgetEvent)(context);
897
908
  return this.sendTpaasEvent(event);
898
909
  }
899
910
  /**
900
911
  * @param input
901
912
  * @category TPaaS Tracking
902
913
  */
903
- async trackImpressionAdSlot(input) {
904
- const dependencies = await this.prepareTpaasEvent();
905
- const event = (0, tpaas_event_builder_1.buildImpressionAdSlotEvent)(input, dependencies);
914
+ async trackLoadAd(input) {
915
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
916
+ const event = (0, tpaas_builders_1.buildLoadAdEvent)(context);
906
917
  return this.sendTpaasEvent(event);
907
918
  }
908
919
  /**
@@ -912,41 +923,30 @@ class Tracker {
912
923
  */
913
924
  async trackViewArticle(input, options) {
914
925
  this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
915
- this.setCurrentPage(input.object.objectId, tpaas_schemas_1.ViewArticle.object.objectType);
916
- const dependencies = await this.prepareTpaasEvent();
917
- const event = (0, tpaas_event_builder_1.buildViewArticleEvent)(input, dependencies);
926
+ this.setCurrentTpaasPageData({
927
+ id: input.object.objectId,
928
+ type: tpaas_schemas_1.ViewArticle.object.objectType,
929
+ referrer: input.page?.referrer,
930
+ content: input.page?.content,
931
+ });
932
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
933
+ const event = (0, tpaas_builders_1.buildViewArticleEvent)(context);
918
934
  const result = this.sendTpaasEvent(event);
919
935
  if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
920
- const { objectElement, pageElement, heightBuilder, objectResizable } = options.leaveTracking;
921
- const leaveArticleCallback = (leave) => {
922
- this.trackLeaveArticle({
936
+ const leaveArticleCallback = async (leave) => {
937
+ await this.trackLeaveArticle({
923
938
  leave,
924
- ...input,
939
+ ...context.input,
925
940
  });
926
941
  };
927
942
  (0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
928
- objectElement,
929
- pageElement,
930
- heightBuilder,
931
- objectResizable,
943
+ ...options.leaveTracking,
932
944
  schema: tpaas_schemas_1.LeaveArticle.object.objectType,
933
945
  trackMethod: leaveArticleCallback,
934
946
  });
935
947
  }
936
948
  return result;
937
949
  }
938
- /**
939
- * @param input
940
- * @param options
941
- * @category TPaaS Tracking
942
- */
943
- async trackViewAudio(input) {
944
- // despite the View event type, this is not a page view event, but rather a media object view event
945
- // so we shouldn't reset the page view ID here or enable leave tracking
946
- const dependencies = await this.prepareTpaasEvent();
947
- const event = (0, tpaas_event_builder_1.buildViewAudioEvent)(input, dependencies);
948
- return this.sendTpaasEvent(event);
949
- }
950
950
  /**
951
951
  * Tracks a View AudioPage event and automatically fires a Leave AudioPage event when the user
952
952
  * navigates away.
@@ -989,34 +989,36 @@ class Tracker {
989
989
  */
990
990
  async trackViewAudioPage(input, options) {
991
991
  this.newPageView();
992
- this.setCurrentPage(input.object.objectId, 'Audio'); // ViewAudioPage.object.objectType is AudioPage, which is not allowed as a pageType
993
- const dependencies = await this.prepareTpaasEvent();
994
- const event = (0, tpaas_event_builder_1.buildViewAudioPageEvent)(input, dependencies);
992
+ this.setCurrentTpaasPageData({
993
+ id: input.object.objectId,
994
+ type: tpaas_schemas_1.ViewAudioPage.object.objectType,
995
+ referrer: input.page?.referrer,
996
+ content: input.page?.content,
997
+ });
998
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
999
+ const event = (0, tpaas_builders_1.buildViewAudioPageEvent)(context);
995
1000
  const result = this.sendTpaasEvent(event);
996
1001
  if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
997
- const { objectElement, pageElement, heightBuilder, objectResizable, leaveAudioBuilder } = options.leaveTracking;
998
- const leaveAudioPageCallback = (leave) => {
1002
+ const { leaveAudioBuilder, ...restLeaveTrackingOptions } = options.leaveTracking;
1003
+ const leaveAudioPageCallback = async (leave) => {
999
1004
  const leaveAudioInput = leaveAudioBuilder?.() ?? {
1000
1005
  audioCompleted: 0,
1001
1006
  audioStarted: 0,
1002
1007
  maxPlaylistPosition: 0,
1003
1008
  playlistPositionPercentage: 0,
1004
1009
  };
1005
- this.trackLeaveAudioPage({
1010
+ await this.trackLeaveAudioPage({
1006
1011
  leave,
1007
1012
  leaveAudio: {
1008
1013
  ...leaveAudioInput,
1009
1014
  activityDurationMs: leave.activityDurationMs,
1010
1015
  durationMs: leave.durationMs,
1011
1016
  },
1012
- ...input,
1017
+ ...context.input,
1013
1018
  });
1014
1019
  };
1015
1020
  (0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
1016
- objectElement,
1017
- pageElement,
1018
- heightBuilder,
1019
- objectResizable,
1021
+ ...restLeaveTrackingOptions,
1020
1022
  schema: tpaas_schemas_1.LeaveAudioPage.object.objectType,
1021
1023
  trackMethod: leaveAudioPageCallback,
1022
1024
  });
@@ -1030,36 +1032,63 @@ class Tracker {
1030
1032
  */
1031
1033
  async trackViewError(input, options) {
1032
1034
  this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
1033
- this.setCurrentPage(input.object.objectId, tpaas_schemas_1.ViewError.object.objectType);
1034
- const dependencies = await this.prepareTpaasEvent();
1035
- const event = (0, tpaas_event_builder_1.buildViewErrorEvent)(input, dependencies);
1035
+ this.setCurrentTpaasPageData({
1036
+ id: input.object.objectId,
1037
+ type: tpaas_schemas_1.ViewError.object.objectType,
1038
+ referrer: input.page?.referrer,
1039
+ });
1040
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1041
+ const event = (0, tpaas_builders_1.buildViewErrorEvent)(context);
1036
1042
  const result = this.sendTpaasEvent(event);
1037
1043
  if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
1038
- const { objectElement, pageElement, heightBuilder, objectResizable } = options.leaveTracking;
1039
- const leaveErrorCallback = (leave) => {
1040
- this.trackLeaveError({
1044
+ const leaveErrorCallback = async (leave) => {
1045
+ await this.trackLeaveError({
1041
1046
  leave,
1042
- ...input,
1047
+ ...context.input,
1043
1048
  });
1044
1049
  };
1045
1050
  (0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
1046
- objectElement,
1047
- pageElement,
1048
- heightBuilder,
1049
- objectResizable,
1051
+ ...options.leaveTracking,
1050
1052
  schema: tpaas_schemas_1.LeaveError.object.objectType,
1051
1053
  trackMethod: leaveErrorCallback,
1052
1054
  });
1053
1055
  }
1054
1056
  return result;
1055
1057
  }
1058
+ /**
1059
+ * @param input
1060
+ * @category TPaaS Tracking
1061
+ */
1062
+ async trackImpressionAd(input) {
1063
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1064
+ const event = (0, tpaas_builders_1.buildImpressionAdEvent)(context);
1065
+ return this.sendTpaasEvent(event);
1066
+ }
1067
+ /**
1068
+ * @param input
1069
+ * @category TPaaS Tracking
1070
+ */
1071
+ async trackImpressionAdSlot(input) {
1072
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1073
+ const event = (0, tpaas_builders_1.buildImpressionAdSlotEvent)(context);
1074
+ return this.sendTpaasEvent(event);
1075
+ }
1076
+ /**
1077
+ * @param input
1078
+ * @category TPaaS Tracking
1079
+ */
1080
+ async trackImpressionAffiliate(input) {
1081
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1082
+ const event = (0, tpaas_builders_1.buildImpressionAffiliateEvent)(context);
1083
+ return this.sendTpaasEvent(event);
1084
+ }
1056
1085
  /**
1057
1086
  * @param input
1058
1087
  * @category TPaaS Tracking
1059
1088
  */
1060
1089
  async trackImpressionForm(input) {
1061
- const dependencies = await this.prepareTpaasEvent();
1062
- const event = (0, tpaas_event_builder_1.buildImpressionFormEvent)(input, dependencies);
1090
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1091
+ const event = (0, tpaas_builders_1.buildImpressionFormEvent)(context);
1063
1092
  return this.sendTpaasEvent(event);
1064
1093
  }
1065
1094
  /**
@@ -1067,8 +1096,8 @@ class Tracker {
1067
1096
  * @category TPaaS Tracking
1068
1097
  */
1069
1098
  async trackImpressionOffer(input) {
1070
- const dependencies = await this.prepareTpaasEvent();
1071
- const event = (0, tpaas_event_builder_1.buildImpressionOfferEvent)(input, dependencies);
1099
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1100
+ const event = (0, tpaas_builders_1.buildImpressionOfferEvent)(context);
1072
1101
  return this.sendTpaasEvent(event);
1073
1102
  }
1074
1103
  /**
@@ -1076,8 +1105,26 @@ class Tracker {
1076
1105
  * @category TPaaS Tracking
1077
1106
  */
1078
1107
  async trackImpressionPlayer(input) {
1079
- const dependencies = await this.prepareTpaasEvent();
1080
- const event = (0, tpaas_event_builder_1.buildImpressionPlayerEvent)(input, dependencies);
1108
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1109
+ const event = (0, tpaas_builders_1.buildImpressionPlayerEvent)(context);
1110
+ return this.sendTpaasEvent(event);
1111
+ }
1112
+ /**
1113
+ * @param input
1114
+ * @category TPaaS Tracking
1115
+ */
1116
+ async trackImpressionSportsUIElement(input) {
1117
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1118
+ const event = (0, tpaas_builders_1.buildImpressionSportsUIElementEvent)(context);
1119
+ return this.sendTpaasEvent(event);
1120
+ }
1121
+ /**
1122
+ * @param input
1123
+ * @category TPaaS Tracking
1124
+ */
1125
+ async trackImpressionSchoolUIElement(input) {
1126
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1127
+ const event = (0, tpaas_builders_1.buildImpressionSchoolUIElementEvent)(context);
1081
1128
  return this.sendTpaasEvent(event);
1082
1129
  }
1083
1130
  /**
@@ -1085,8 +1132,8 @@ class Tracker {
1085
1132
  * @category TPaaS Tracking
1086
1133
  */
1087
1134
  async trackImpressionTeaser(input) {
1088
- const dependencies = await this.prepareTpaasEvent();
1089
- const event = (0, tpaas_event_builder_1.buildImpressionTeaserEvent)(input, dependencies);
1135
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1136
+ const event = (0, tpaas_builders_1.buildImpressionTeaserEvent)(context);
1090
1137
  return this.sendTpaasEvent(event);
1091
1138
  }
1092
1139
  /**
@@ -1094,8 +1141,8 @@ class Tracker {
1094
1141
  * @category TPaaS Tracking
1095
1142
  */
1096
1143
  async trackImpressionUIElement(input) {
1097
- const dependencies = await this.prepareTpaasEvent();
1098
- const event = (0, tpaas_event_builder_1.buildImpressionUIElementEvent)(input, dependencies);
1144
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1145
+ const event = (0, tpaas_builders_1.buildImpressionUIElementEvent)(context);
1099
1146
  return this.sendTpaasEvent(event);
1100
1147
  }
1101
1148
  /**
@@ -1105,23 +1152,23 @@ class Tracker {
1105
1152
  */
1106
1153
  async trackViewFrontpage(input, options) {
1107
1154
  this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
1108
- this.setCurrentPage(input.object.objectId, tpaas_schemas_1.ViewFrontpage.object.objectType);
1109
- const dependencies = await this.prepareTpaasEvent();
1110
- const event = (0, tpaas_event_builder_1.buildViewFrontpageEvent)(input, dependencies);
1155
+ this.setCurrentTpaasPageData({
1156
+ id: input.object.objectId,
1157
+ type: tpaas_schemas_1.ViewFrontpage.object.objectType,
1158
+ referrer: input.page?.referrer,
1159
+ });
1160
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1161
+ const event = (0, tpaas_builders_1.buildViewFrontpageEvent)(context);
1111
1162
  const result = this.sendTpaasEvent(event);
1112
1163
  if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
1113
- const { objectElement, pageElement, heightBuilder, objectResizable } = options.leaveTracking;
1114
- const leaveFrontpageCallback = (leave) => {
1115
- this.trackLeaveFrontpage({
1164
+ const leaveFrontpageCallback = async (leave) => {
1165
+ await this.trackLeaveFrontpage({
1116
1166
  leave,
1117
- ...input,
1167
+ ...context.input,
1118
1168
  });
1119
1169
  };
1120
1170
  (0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
1121
- objectElement,
1122
- pageElement,
1123
- objectResizable,
1124
- heightBuilder,
1171
+ ...options.leaveTracking,
1125
1172
  schema: tpaas_schemas_1.LeaveFrontpage.object.objectType,
1126
1173
  trackMethod: leaveFrontpageCallback,
1127
1174
  });
@@ -1135,23 +1182,23 @@ class Tracker {
1135
1182
  */
1136
1183
  async trackViewLandingpage(input, options) {
1137
1184
  this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
1138
- this.setCurrentPage(input.object.objectId, 'LandingPage' /* TODO: ViewLandingpage.object.type once the schema is fixed */);
1139
- const dependencies = await this.prepareTpaasEvent();
1140
- const event = (0, tpaas_event_builder_1.buildViewLandingpageEvent)(input, dependencies);
1185
+ this.setCurrentTpaasPageData({
1186
+ id: input.object.objectId,
1187
+ type: tpaas_schemas_1.ViewLandingpage.object.objectType,
1188
+ referrer: input.page?.referrer,
1189
+ });
1190
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1191
+ const event = (0, tpaas_builders_1.buildViewLandingpageEvent)(context);
1141
1192
  const result = this.sendTpaasEvent(event);
1142
1193
  if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
1143
- const { objectElement, pageElement, heightBuilder, objectResizable } = options.leaveTracking;
1144
- const leaveLandingpageCallback = (leave) => {
1145
- this.trackLeaveLandingpage({
1194
+ const leaveLandingpageCallback = async (leave) => {
1195
+ await this.trackLeaveLandingpage({
1146
1196
  leave,
1147
- ...input,
1197
+ ...context.input,
1148
1198
  });
1149
1199
  };
1150
1200
  (0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
1151
- objectElement,
1152
- pageElement,
1153
- heightBuilder,
1154
- objectResizable,
1201
+ ...options.leaveTracking,
1155
1202
  schema: tpaas_schemas_1.LeaveLandingpage.object.objectType,
1156
1203
  trackMethod: leaveLandingpageCallback,
1157
1204
  });
@@ -1165,23 +1212,23 @@ class Tracker {
1165
1212
  */
1166
1213
  async trackViewListing(input, options) {
1167
1214
  this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
1168
- this.setCurrentPage(input.object.objectId, tpaas_schemas_1.ViewListing.object.objectType);
1169
- const dependencies = await this.prepareTpaasEvent();
1170
- const event = (0, tpaas_event_builder_1.buildViewListingEvent)(input, dependencies);
1215
+ this.setCurrentTpaasPageData({
1216
+ id: input.object.objectId,
1217
+ type: tpaas_schemas_1.ViewListing.object.objectType,
1218
+ referrer: input.page?.referrer,
1219
+ });
1220
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1221
+ const event = (0, tpaas_builders_1.buildViewListingEvent)(context);
1171
1222
  const result = this.sendTpaasEvent(event);
1172
1223
  if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
1173
- const { objectElement, pageElement, heightBuilder, objectResizable } = options.leaveTracking;
1174
- const leaveListingCallback = (leave) => {
1175
- this.trackLeaveListing({
1224
+ const leaveListingCallback = async (leave) => {
1225
+ await this.trackLeaveListing({
1176
1226
  leave,
1177
- ...input,
1227
+ ...context.input,
1178
1228
  });
1179
1229
  };
1180
1230
  (0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
1181
- objectElement,
1182
- pageElement,
1183
- heightBuilder,
1184
- objectResizable,
1231
+ ...options.leaveTracking,
1185
1232
  schema: tpaas_schemas_1.LeaveListing.object.objectType,
1186
1233
  trackMethod: leaveListingCallback,
1187
1234
  });
@@ -1195,41 +1242,30 @@ class Tracker {
1195
1242
  */
1196
1243
  async trackViewLockedArticle(input, options) {
1197
1244
  this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
1198
- this.setCurrentPage(input.object.objectId, tpaas_schemas_1.ViewLockedArticle.object.objectType);
1199
- const dependencies = await this.prepareTpaasEvent();
1200
- const event = (0, tpaas_event_builder_1.buildViewLockedArticleEvent)(input, dependencies);
1245
+ this.setCurrentTpaasPageData({
1246
+ id: input.object.objectId,
1247
+ type: tpaas_schemas_1.ViewLockedArticle.object.objectType,
1248
+ referrer: input.page?.referrer,
1249
+ content: input.page?.content,
1250
+ });
1251
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1252
+ const event = (0, tpaas_builders_1.buildViewLockedArticleEvent)(context);
1201
1253
  const result = this.sendTpaasEvent(event);
1202
1254
  if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
1203
- const { objectElement, pageElement, heightBuilder, objectResizable } = options.leaveTracking;
1204
- const leaveLockedArticleCallback = (leave) => {
1205
- this.trackLeaveLockedArticle({
1255
+ const leaveLockedArticleCallback = async (leave) => {
1256
+ await this.trackLeaveLockedArticle({
1206
1257
  leave,
1207
- ...input,
1258
+ ...context.input,
1208
1259
  });
1209
1260
  };
1210
1261
  (0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
1211
- objectElement,
1212
- pageElement,
1213
- objectResizable,
1214
- heightBuilder,
1262
+ ...options.leaveTracking,
1215
1263
  schema: tpaas_schemas_1.LeaveLockedArticle.object.objectType,
1216
1264
  trackMethod: leaveLockedArticleCallback,
1217
1265
  });
1218
1266
  }
1219
1267
  return result;
1220
1268
  }
1221
- /**
1222
- * @param input
1223
- * @param options
1224
- * @category TPaaS Tracking
1225
- */
1226
- async trackViewLockedAudio(input) {
1227
- // despite the View event type, this is not a page view event, but rather a media object view event
1228
- // so we shouldn't reset the page view ID here or enable leave tracking
1229
- const dependencies = await this.prepareTpaasEvent();
1230
- const event = (0, tpaas_event_builder_1.buildViewLockedAudioEvent)(input, dependencies);
1231
- return this.sendTpaasEvent(event);
1232
- }
1233
1269
  /**
1234
1270
  * @param input
1235
1271
  * @param options
@@ -1237,23 +1273,24 @@ class Tracker {
1237
1273
  */
1238
1274
  async trackViewLockedAudioPage(input, options) {
1239
1275
  this.newPageView();
1240
- this.setCurrentPage(input.object.objectId, 'Audio'); // ViewLockedAudioPage.object.objectType is AudioPage, which is not allowed as a pageType
1241
- const dependencies = await this.prepareTpaasEvent();
1242
- const event = (0, tpaas_event_builder_1.buildViewLockedAudioPageEvent)(input, dependencies);
1276
+ this.setCurrentTpaasPageData({
1277
+ id: input.object.objectId,
1278
+ type: tpaas_schemas_1.ViewLockedAudioPage.object.objectType,
1279
+ referrer: input.page?.referrer,
1280
+ content: input.page?.content,
1281
+ });
1282
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1283
+ const event = (0, tpaas_builders_1.buildViewLockedAudioPageEvent)(context);
1243
1284
  const result = this.sendTpaasEvent(event);
1244
1285
  if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
1245
- const { objectElement, pageElement, heightBuilder, objectResizable } = options.leaveTracking;
1246
- const leaveLockedAudioPageCallback = (leave) => {
1247
- this.trackLeaveLockedAudioPage({
1286
+ const leaveLockedAudioPageCallback = async (leave) => {
1287
+ await this.trackLeaveLockedAudioPage({
1248
1288
  leave,
1249
- ...input,
1289
+ ...context.input,
1250
1290
  });
1251
1291
  };
1252
1292
  (0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
1253
- objectElement,
1254
- pageElement,
1255
- heightBuilder,
1256
- objectResizable,
1293
+ ...options.leaveTracking,
1257
1294
  schema: tpaas_schemas_1.LeaveLockedAudioPage.object.objectType,
1258
1295
  trackMethod: leaveLockedAudioPageCallback,
1259
1296
  });
@@ -1262,14 +1299,33 @@ class Tracker {
1262
1299
  }
1263
1300
  /**
1264
1301
  * @param input
1302
+ * @param options
1265
1303
  * @category TPaaS Tracking
1266
1304
  */
1267
- async trackViewLockedVideo(input) {
1268
- // despite the name, this is not a page-level event. trackViewLockedVideoPage is a page-level event
1269
- // as such, we don't support (yet) automatic leave event enabling
1270
- const dependencies = await this.prepareTpaasEvent();
1271
- const event = (0, tpaas_event_builder_1.buildViewLockedVideoEvent)(input, dependencies);
1272
- return this.sendTpaasEvent(event);
1305
+ async trackViewLockedPage(input, options) {
1306
+ this.newPageView();
1307
+ this.setCurrentTpaasPageData({
1308
+ id: input.object.objectId,
1309
+ type: tpaas_schemas_1.ViewLockedPage.object.objectType,
1310
+ referrer: input.page?.referrer,
1311
+ });
1312
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1313
+ const event = (0, tpaas_builders_1.buildViewLockedPageEvent)(context);
1314
+ const result = this.sendTpaasEvent(event);
1315
+ if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
1316
+ const leaveLockedPageCallback = async (leave) => {
1317
+ await this.trackLeaveLockedPage({
1318
+ leave,
1319
+ ...context.input,
1320
+ });
1321
+ };
1322
+ (0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
1323
+ ...options.leaveTracking,
1324
+ schema: tpaas_schemas_1.LeaveLockedPage.object.objectType,
1325
+ trackMethod: leaveLockedPageCallback,
1326
+ });
1327
+ }
1328
+ return result;
1273
1329
  }
1274
1330
  /**
1275
1331
  * @param input
@@ -1278,40 +1334,30 @@ class Tracker {
1278
1334
  */
1279
1335
  async trackViewLockedVideoPage(input, options) {
1280
1336
  this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
1281
- this.setCurrentPage(input.object.objectId, tpaas_schemas_1.ViewLockedVideo.object.objectType);
1282
- const dependencies = await this.prepareTpaasEvent();
1283
- const event = (0, tpaas_event_builder_1.buildViewLockedVideoPageEvent)(input, dependencies);
1337
+ this.setCurrentTpaasPageData({
1338
+ id: input.object.objectId,
1339
+ type: tpaas_schemas_1.ViewLockedVideoPage.object.objectType,
1340
+ referrer: input.page?.referrer,
1341
+ content: input.page?.content,
1342
+ });
1343
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1344
+ const event = (0, tpaas_builders_1.buildViewLockedVideoPageEvent)(context);
1284
1345
  const result = this.sendTpaasEvent(event);
1285
1346
  if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
1286
- const { objectElement, pageElement, heightBuilder, objectResizable } = options.leaveTracking;
1287
- const leaveLockedVideoPageCallback = (leave) => {
1288
- this.trackLeaveLockedVideoPage({
1347
+ const leaveLockedVideoPageCallback = async (leave) => {
1348
+ await this.trackLeaveLockedVideoPage({
1289
1349
  leave,
1290
- ...input,
1350
+ ...context.input,
1291
1351
  });
1292
1352
  };
1293
1353
  (0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
1294
- objectElement,
1295
- pageElement,
1296
- heightBuilder,
1297
- objectResizable,
1354
+ ...options.leaveTracking,
1298
1355
  schema: tpaas_schemas_1.LeaveLockedVideoPage.object.objectType,
1299
1356
  trackMethod: leaveLockedVideoPageCallback,
1300
1357
  });
1301
1358
  }
1302
1359
  return result;
1303
1360
  }
1304
- /**
1305
- * @param input
1306
- * @category TPaaS Tracking
1307
- */
1308
- async trackViewVideo(input) {
1309
- // despite the View event type, this is not a page view event, but rather a media object view event
1310
- // so we shouldn't reset the page view ID here or enable leave tracking
1311
- const dependencies = await this.prepareTpaasEvent();
1312
- const event = (0, tpaas_event_builder_1.buildViewVideoEvent)(input, dependencies);
1313
- return this.sendTpaasEvent(event);
1314
- }
1315
1361
  /**
1316
1362
  * Tracks a View VideoPage event and automatically fires a Leave VideoPage event when the user
1317
1363
  * navigates away.
@@ -1356,29 +1402,27 @@ class Tracker {
1356
1402
  */
1357
1403
  async trackViewVideoPage(input, options) {
1358
1404
  this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
1359
- this.setCurrentPage(input.object.objectId, 'Video'); // ViewVideoPage.object.type is VideoPage, which is not allowed as a pageType
1360
- const dependencies = await this.prepareTpaasEvent();
1361
- const event = (0, tpaas_event_builder_1.buildViewVideoPageEvent)(input, dependencies);
1405
+ this.setCurrentTpaasPageData({
1406
+ id: input.object.objectId,
1407
+ type: tpaas_schemas_1.ViewVideoPage.object.objectType,
1408
+ referrer: input.page?.referrer,
1409
+ content: input.page?.content,
1410
+ });
1411
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1412
+ const event = (0, tpaas_builders_1.buildViewVideoPageEvent)(context);
1362
1413
  const result = this.sendTpaasEvent(event);
1363
1414
  if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
1364
- const { objectElement, pageElement, heightBuilder, objectResizable, leaveStoriesBuilder } = options.leaveTracking;
1365
- const leaveVideoCallback = (leave) => {
1415
+ const { leaveStoriesBuilder, ...restLeaveTrackingOptions } = options.leaveTracking;
1416
+ const leaveVideoCallback = async (leave) => {
1366
1417
  const leaveStoriesInput = leaveStoriesBuilder?.();
1367
- this.trackLeaveVideoPage({
1418
+ await this.trackLeaveVideoPage({
1368
1419
  leave,
1369
- leaveStories: leaveStoriesInput && {
1370
- ...leaveStoriesInput,
1371
- activityDurationMs: leave.activityDurationMs,
1372
- durationMs: leave.durationMs,
1373
- },
1374
- ...input,
1420
+ leaveStories: leaveStoriesInput,
1421
+ ...context.input,
1375
1422
  });
1376
1423
  };
1377
1424
  (0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
1378
- objectElement,
1379
- pageElement,
1380
- heightBuilder,
1381
- objectResizable,
1425
+ ...restLeaveTrackingOptions,
1382
1426
  schema: tpaas_schemas_1.LeaveVideoPage.object.objectType,
1383
1427
  trackMethod: leaveVideoCallback,
1384
1428
  });
@@ -1392,23 +1436,23 @@ class Tracker {
1392
1436
  */
1393
1437
  async trackViewWeather(input, options) {
1394
1438
  this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
1395
- this.setCurrentPage(input.object.objectId, 'Page' /* TODO: ViewWeather.object.type once the schema is fixed */);
1396
- const dependencies = await this.prepareTpaasEvent();
1397
- const event = (0, tpaas_event_builder_1.buildViewWeatherEvent)(input, dependencies);
1439
+ this.setCurrentTpaasPageData({
1440
+ id: input.object.objectId,
1441
+ type: tpaas_schemas_1.ViewWeather.object.objectType,
1442
+ referrer: input.page?.referrer,
1443
+ });
1444
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1445
+ const event = (0, tpaas_builders_1.buildViewWeatherEvent)(context);
1398
1446
  const result = this.sendTpaasEvent(event);
1399
1447
  if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
1400
- const { objectElement, pageElement, heightBuilder, objectResizable } = options.leaveTracking;
1401
- const leaveWeatherCallback = (leave) => {
1402
- this.trackLeaveWeather({
1448
+ const leaveWeatherCallback = async (leave) => {
1449
+ await this.trackLeaveWeather({
1403
1450
  leave,
1404
- ...input,
1451
+ ...context.input,
1405
1452
  });
1406
1453
  };
1407
1454
  (0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
1408
- objectElement,
1409
- pageElement,
1410
- heightBuilder,
1411
- objectResizable,
1455
+ ...options.leaveTracking,
1412
1456
  schema: tpaas_schemas_1.LeaveWeather.object.objectType,
1413
1457
  trackMethod: leaveWeatherCallback,
1414
1458
  });
@@ -1420,8 +1464,8 @@ class Tracker {
1420
1464
  * @category TPaaS Tracking
1421
1465
  */
1422
1466
  async trackLeaveArticle(input) {
1423
- const dependencies = await this.prepareTpaasEvent();
1424
- const event = (0, tpaas_event_builder_1.buildLeaveArticleEvent)(input, dependencies);
1467
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1468
+ const event = (0, tpaas_builders_1.buildLeaveArticleEvent)(context);
1425
1469
  return this.sendTpaasEvent(event);
1426
1470
  }
1427
1471
  /**
@@ -1429,8 +1473,8 @@ class Tracker {
1429
1473
  * @category TPaaS Tracking
1430
1474
  */
1431
1475
  async trackLeaveAudioPage(input) {
1432
- const dependencies = await this.prepareTpaasEvent();
1433
- const event = (0, tpaas_event_builder_1.buildLeaveAudioPageEvent)(input, dependencies);
1476
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1477
+ const event = (0, tpaas_builders_1.buildLeaveAudioPageEvent)(context);
1434
1478
  return this.sendTpaasEvent(event);
1435
1479
  }
1436
1480
  /**
@@ -1438,8 +1482,8 @@ class Tracker {
1438
1482
  * @category TPaaS Tracking
1439
1483
  */
1440
1484
  async trackLeaveError(input) {
1441
- const dependencies = await this.prepareTpaasEvent();
1442
- const event = (0, tpaas_event_builder_1.buildLeaveErrorEvent)(input, dependencies);
1485
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1486
+ const event = (0, tpaas_builders_1.buildLeaveErrorEvent)(context);
1443
1487
  return this.sendTpaasEvent(event);
1444
1488
  }
1445
1489
  /**
@@ -1447,8 +1491,8 @@ class Tracker {
1447
1491
  * @category TPaaS Tracking
1448
1492
  */
1449
1493
  async trackLeaveFrontpage(input) {
1450
- const dependencies = await this.prepareTpaasEvent();
1451
- const event = (0, tpaas_event_builder_1.buildLeaveFrontpageEvent)(input, dependencies);
1494
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1495
+ const event = (0, tpaas_builders_1.buildLeaveFrontpageEvent)(context);
1452
1496
  return this.sendTpaasEvent(event);
1453
1497
  }
1454
1498
  /**
@@ -1456,8 +1500,8 @@ class Tracker {
1456
1500
  * @category TPaaS Tracking
1457
1501
  */
1458
1502
  async trackLeaveLandingpage(input) {
1459
- const dependencies = await this.prepareTpaasEvent();
1460
- const event = (0, tpaas_event_builder_1.buildLeaveLandingpageEvent)(input, dependencies);
1503
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1504
+ const event = (0, tpaas_builders_1.buildLeaveLandingpageEvent)(context);
1461
1505
  return this.sendTpaasEvent(event);
1462
1506
  }
1463
1507
  /**
@@ -1465,8 +1509,8 @@ class Tracker {
1465
1509
  * @category TPaaS Tracking
1466
1510
  */
1467
1511
  async trackLeaveListing(input) {
1468
- const dependencies = await this.prepareTpaasEvent();
1469
- const event = (0, tpaas_event_builder_1.buildLeaveListingEvent)(input, dependencies);
1512
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1513
+ const event = (0, tpaas_builders_1.buildLeaveListingEvent)(context);
1470
1514
  return this.sendTpaasEvent(event);
1471
1515
  }
1472
1516
  /**
@@ -1474,62 +1518,62 @@ class Tracker {
1474
1518
  * @category TPaaS Tracking
1475
1519
  */
1476
1520
  async trackLeaveLockedArticle(input) {
1477
- const dependencies = await this.prepareTpaasEvent();
1478
- const event = (0, tpaas_event_builder_1.buildLeaveLockedArticleEvent)(input, dependencies);
1521
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1522
+ const event = (0, tpaas_builders_1.buildLeaveLockedArticleEvent)(context);
1479
1523
  return this.sendTpaasEvent(event);
1480
1524
  }
1481
1525
  /**
1482
1526
  * @param input
1483
1527
  * @category TPaaS Tracking
1484
1528
  */
1485
- async trackLeaveLockedAudio(input) {
1486
- const dependencies = await this.prepareTpaasEvent();
1487
- const event = (0, tpaas_event_builder_1.buildLeaveLockedAudioEvent)(input, dependencies);
1529
+ async trackLeaveLockedAudioPage(input) {
1530
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1531
+ const event = (0, tpaas_builders_1.buildLeaveLockedAudioPageEvent)(context);
1488
1532
  return this.sendTpaasEvent(event);
1489
1533
  }
1490
1534
  /**
1491
1535
  * @param input
1492
1536
  * @category TPaaS Tracking
1493
1537
  */
1494
- async trackLeaveLockedAudioPage(input) {
1495
- const dependencies = await this.prepareTpaasEvent();
1496
- const event = (0, tpaas_event_builder_1.buildLeaveLockedAudioPageEvent)(input, dependencies);
1538
+ async trackLeaveLockedPage(input) {
1539
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1540
+ const event = (0, tpaas_builders_1.buildLeaveLockedPageEvent)(context);
1497
1541
  return this.sendTpaasEvent(event);
1498
1542
  }
1499
1543
  /**
1500
1544
  * @param input
1501
1545
  * @category TPaaS Tracking
1502
1546
  */
1503
- async trackLeaveLockedVideo(input) {
1504
- const dependencies = await this.prepareTpaasEvent();
1505
- const event = (0, tpaas_event_builder_1.buildLeaveLockedVideoEvent)(input, dependencies);
1547
+ async trackLeaveLockedVideoPage(input) {
1548
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1549
+ const event = (0, tpaas_builders_1.buildLeaveLockedVideoPageEvent)(context);
1506
1550
  return this.sendTpaasEvent(event);
1507
1551
  }
1508
1552
  /**
1509
1553
  * @param input
1510
1554
  * @category TPaaS Tracking
1511
1555
  */
1512
- async trackLeaveLockedVideoPage(input) {
1513
- const dependencies = await this.prepareTpaasEvent();
1514
- const event = (0, tpaas_event_builder_1.buildLeaveLockedVideoPageEvent)(input, dependencies);
1556
+ async trackLeavePage(input) {
1557
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1558
+ const event = (0, tpaas_builders_1.buildLeavePageEvent)(context);
1515
1559
  return this.sendTpaasEvent(event);
1516
1560
  }
1517
1561
  /**
1518
1562
  * @param input
1519
1563
  * @category TPaaS Tracking
1520
1564
  */
1521
- async trackLeavePage(input) {
1522
- const dependencies = await this.prepareTpaasEvent();
1523
- const event = (0, tpaas_event_builder_1.buildLeavePageEvent)(input, dependencies);
1565
+ async trackLeaveSportsPage(input) {
1566
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1567
+ const event = (0, tpaas_builders_1.buildLeaveSportsPageEvent)(context);
1524
1568
  return this.sendTpaasEvent(event);
1525
1569
  }
1526
1570
  /**
1527
1571
  * @param input
1528
1572
  * @category TPaaS Tracking
1529
1573
  */
1530
- async trackLeaveSportsPage(input) {
1531
- const dependencies = await this.prepareTpaasEvent();
1532
- const event = (0, tpaas_event_builder_1.buildLeaveSportsPageEvent)(input, dependencies);
1574
+ async trackLeaveSchoolPage(input) {
1575
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1576
+ const event = (0, tpaas_builders_1.buildLeaveSchoolPageEvent)(context);
1533
1577
  return this.sendTpaasEvent(event);
1534
1578
  }
1535
1579
  /**
@@ -1537,8 +1581,8 @@ class Tracker {
1537
1581
  * @category TPaaS Tracking
1538
1582
  */
1539
1583
  async trackLeaveVideoPage(input) {
1540
- const dependencies = await this.prepareTpaasEvent();
1541
- const event = (0, tpaas_event_builder_1.buildLeaveVideoPageEvent)(input, dependencies);
1584
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1585
+ const event = (0, tpaas_builders_1.buildLeaveVideoPageEvent)(context);
1542
1586
  return this.sendTpaasEvent(event);
1543
1587
  }
1544
1588
  /**
@@ -1546,8 +1590,26 @@ class Tracker {
1546
1590
  * @category TPaaS Tracking
1547
1591
  */
1548
1592
  async trackLeaveWeather(input) {
1549
- const dependencies = await this.prepareTpaasEvent();
1550
- const event = (0, tpaas_event_builder_1.buildLeaveWeatherEvent)(input, dependencies);
1593
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1594
+ const event = (0, tpaas_builders_1.buildLeaveWeatherEvent)(context);
1595
+ return this.sendTpaasEvent(event);
1596
+ }
1597
+ /**
1598
+ * @param input
1599
+ * @category TPaaS Tracking
1600
+ */
1601
+ async trackEngagementAd(input) {
1602
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1603
+ const event = (0, tpaas_builders_1.buildEngagementAdEvent)(context);
1604
+ return this.sendTpaasEvent(event);
1605
+ }
1606
+ /**
1607
+ * @param input
1608
+ * @category TPaaS Tracking
1609
+ */
1610
+ async trackEngagementAffiliate(input) {
1611
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1612
+ const event = (0, tpaas_builders_1.buildEngagementAffiliateEvent)(context);
1551
1613
  return this.sendTpaasEvent(event);
1552
1614
  }
1553
1615
  /**
@@ -1555,8 +1617,8 @@ class Tracker {
1555
1617
  * @category TPaaS Tracking
1556
1618
  */
1557
1619
  async trackEngagementAudio(input) {
1558
- const dependencies = await this.prepareTpaasEvent();
1559
- const event = (0, tpaas_event_builder_1.buildEngagementAudioEvent)(input, dependencies);
1620
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1621
+ const event = (0, tpaas_builders_1.buildEngagementAudioEvent)(context);
1560
1622
  return this.sendTpaasEvent(event);
1561
1623
  }
1562
1624
  /**
@@ -1564,8 +1626,8 @@ class Tracker {
1564
1626
  * @category TPaaS Tracking
1565
1627
  */
1566
1628
  async trackEngagementForm(input) {
1567
- const dependencies = await this.prepareTpaasEvent();
1568
- const event = (0, tpaas_event_builder_1.buildEngagementFormEvent)(input, dependencies);
1629
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1630
+ const event = (0, tpaas_builders_1.buildEngagementFormEvent)(context);
1569
1631
  return this.sendTpaasEvent(event);
1570
1632
  }
1571
1633
  /**
@@ -1573,8 +1635,26 @@ class Tracker {
1573
1635
  * @category TPaaS Tracking
1574
1636
  */
1575
1637
  async trackEngagementOffer(input) {
1576
- const dependencies = await this.prepareTpaasEvent();
1577
- const event = (0, tpaas_event_builder_1.buildEngagementOfferEvent)(input, dependencies);
1638
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1639
+ const event = (0, tpaas_builders_1.buildEngagementOfferEvent)(context);
1640
+ return this.sendTpaasEvent(event);
1641
+ }
1642
+ /**
1643
+ * @param input
1644
+ * @category TPaaS Tracking
1645
+ */
1646
+ async trackEngagementSportsUIElement(input) {
1647
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1648
+ const event = (0, tpaas_builders_1.buildEngagementSportsUIElementEvent)(context);
1649
+ return this.sendTpaasEvent(event);
1650
+ }
1651
+ /**
1652
+ * @param input
1653
+ * @category TPaaS Tracking
1654
+ */
1655
+ async trackEngagementSchoolUIElement(input) {
1656
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1657
+ const event = (0, tpaas_builders_1.buildEngagementSchoolUIElementEvent)(context);
1578
1658
  return this.sendTpaasEvent(event);
1579
1659
  }
1580
1660
  /**
@@ -1582,8 +1662,26 @@ class Tracker {
1582
1662
  * @category TPaaS Tracking
1583
1663
  */
1584
1664
  async trackEngagementTeaser(input) {
1585
- const dependencies = await this.prepareTpaasEvent();
1586
- const event = (0, tpaas_event_builder_1.buildEngagementTeaserEvent)(input, dependencies);
1665
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1666
+ const event = (0, tpaas_builders_1.buildEngagementTeaserEvent)(context);
1667
+ return this.sendTpaasEvent(event);
1668
+ }
1669
+ /**
1670
+ * @param input
1671
+ * @category TPaaS Tracking
1672
+ */
1673
+ async trackEngagementTvModule(input) {
1674
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1675
+ const event = (0, tpaas_builders_1.buildEngagementTvModuleEvent)(context);
1676
+ return this.sendTpaasEvent(event);
1677
+ }
1678
+ /**
1679
+ * @param input
1680
+ * @category TPaaS Tracking
1681
+ */
1682
+ async trackEngagementTvSearch(input) {
1683
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1684
+ const event = (0, tpaas_builders_1.buildEngagementTvSearchEvent)(context);
1587
1685
  return this.sendTpaasEvent(event);
1588
1686
  }
1589
1687
  /**
@@ -1591,8 +1689,8 @@ class Tracker {
1591
1689
  * @category TPaaS Tracking
1592
1690
  */
1593
1691
  async trackEngagementUIElement(input) {
1594
- const dependencies = await this.prepareTpaasEvent();
1595
- const event = (0, tpaas_event_builder_1.buildEngagementUIElementEvent)(input, dependencies);
1692
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1693
+ const event = (0, tpaas_builders_1.buildEngagementUIElementEvent)(context);
1596
1694
  return this.sendTpaasEvent(event);
1597
1695
  }
1598
1696
  /**
@@ -1600,8 +1698,8 @@ class Tracker {
1600
1698
  * @category TPaaS Tracking
1601
1699
  */
1602
1700
  async trackEngagementVideo(input) {
1603
- const dependencies = await this.prepareTpaasEvent();
1604
- const event = (0, tpaas_event_builder_1.buildEngagementVideoEvent)(input, dependencies);
1701
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1702
+ const event = (0, tpaas_builders_1.buildEngagementVideoEvent)(context);
1605
1703
  return this.sendTpaasEvent(event);
1606
1704
  }
1607
1705
  /**
@@ -1609,8 +1707,8 @@ class Tracker {
1609
1707
  * @category TPaaS Tracking
1610
1708
  */
1611
1709
  async trackEngagementVideoAd(input) {
1612
- const dependencies = await this.prepareTpaasEvent();
1613
- const event = (0, tpaas_event_builder_1.buildEngagementVideoAdEvent)(input, dependencies);
1710
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1711
+ const event = (0, tpaas_builders_1.buildEngagementVideoAdEvent)(context);
1614
1712
  return this.sendTpaasEvent(event);
1615
1713
  }
1616
1714
  /**
@@ -1618,8 +1716,17 @@ class Tracker {
1618
1716
  * @category TPaaS Tracking
1619
1717
  */
1620
1718
  async trackEngagementWidget(input) {
1621
- const dependencies = await this.prepareTpaasEvent();
1622
- const event = (0, tpaas_event_builder_1.buildEngagementWidgetEvent)(input, dependencies);
1719
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1720
+ const event = (0, tpaas_builders_1.buildEngagementWidgetEvent)(context);
1721
+ return this.sendTpaasEvent(event);
1722
+ }
1723
+ /**
1724
+ * @param input
1725
+ * @category TPaaS Tracking
1726
+ */
1727
+ async trackHeartbeatCommercialArticle(input) {
1728
+ const context = await (0, tpaas_context_1.prepareTpaasEventContext)(this.tpaasContextSource, input);
1729
+ const event = (0, tpaas_builders_1.buildHeartbeatCommercialArticleEvent)(context);
1623
1730
  return this.sendTpaasEvent(event);
1624
1731
  }
1625
1732
  /**
@@ -1628,12 +1735,9 @@ class Tracker {
1628
1735
  * @category TPaaS Tracking
1629
1736
  */
1630
1737
  async sendTpaasEvent(event) {
1631
- // Resolve any pending session ID promises
1632
- // (session was created when the event was built)
1633
- this.resolveSessionIdPromise();
1634
1738
  // The Hybrid use case implements a "bridged" event method, injected into the window scope,
1635
1739
  // which is used to send events through the native app.
1636
- if ((0, pulse_utils_1.isFunction)(this.state.altEventHandler)) {
1740
+ if ((0, utils_1.isFunction)(this.state.altEventHandler)) {
1637
1741
  this.state.altEventHandler(JSON.stringify(event));
1638
1742
  return event;
1639
1743
  }
@@ -1716,7 +1820,7 @@ class Tracker {
1716
1820
  eventInput: evaluatedInput,
1717
1821
  sdkConfig: this.state,
1718
1822
  });
1719
- return (0, pulse_utils_1.evaluateAndFlatten)(data);
1823
+ return (0, utils_1.evaluateAndFlatten)(data);
1720
1824
  });
1721
1825
  }
1722
1826
  /**
@@ -1728,8 +1832,8 @@ class Tracker {
1728
1832
  * @category Legacy Tracking
1729
1833
  */
1730
1834
  async evaluateEventInputs(eventType, eventInput, builders = this.builders, options) {
1731
- const buildersOutput = await Promise.all([(0, pulse_utils_1.evaluateAndFlatten)(builders), (0, pulse_utils_1.evaluateAndFlatten)(eventInput)]);
1732
- let eventOutput = buildersOutput.reduce((acc, p) => (0, pulse_utils_1.pulseMerge)(acc, p), {});
1835
+ const buildersOutput = await Promise.all([(0, utils_1.evaluateAndFlatten)(builders), (0, utils_1.evaluateAndFlatten)(eventInput)]);
1836
+ let eventOutput = buildersOutput.reduce((acc, p) => (0, utils_1.pulseMerge)(acc, p), {});
1733
1837
  eventOutput = this.applyEventTypeDefaults(eventOutput, eventType);
1734
1838
  eventOutput = this.applyBookmarkedEvent(eventOutput, options?.applyBookmarkKey);
1735
1839
  eventOutput = await this.applyConsents(eventOutput);
@@ -1797,7 +1901,7 @@ class Tracker {
1797
1901
  */
1798
1902
  update(builder, mergeBuilder = false) {
1799
1903
  if (mergeBuilder) {
1800
- this.builders = (0, pulse_utils_1.pulseMerge)({}, this.builders, builder);
1904
+ this.builders = (0, utils_1.pulseMerge)({}, this.builders, builder);
1801
1905
  }
1802
1906
  else {
1803
1907
  this.builders = Object.assign({}, this.builders, builder);
@@ -1894,7 +1998,7 @@ class Tracker {
1894
1998
  * If no session exists yet, returns a promise that resolves with the session ID
1895
1999
  * when it gets created (typically when the first non-anonymous tracking event is sent).
1896
2000
  *
1897
- * Note: Anonymous events (such as those sent via {@link trackAnonymous} or {@link trackAnonymousViewUIElement})
2001
+ * Note: Anonymous events (such as those sent via {@link trackAnonymous} or {@link trackAnonymousImpressionUIElement})
1898
2002
  * do not create sessions and will not resolve pending session ID promises. The promise will only resolve when a
1899
2003
  * non-anonymous tracking event is sent.
1900
2004
  *
@@ -1904,9 +2008,9 @@ class Tracker {
1904
2008
  * @returns The session ID, or a promise that resolves to the session ID
1905
2009
  */
1906
2010
  getSessionId() {
1907
- const session = (0, session_browser_1.readSession)();
1908
- if (session?.id) {
1909
- return Promise.resolve(session.id);
2011
+ const session = (0, store_1.readSession)();
2012
+ if (session) {
2013
+ return Promise.resolve((0, store_1.generateSessionSDRN)(session.sessionId));
1910
2014
  }
1911
2015
  // No session exists yet, create or return existing promise
1912
2016
  if (!this.sessionIdPromise) {
@@ -2265,8 +2369,8 @@ class Tracker {
2265
2369
  * with the added guarantee that a second Leave event will not be triggered if one already has been sent.
2266
2370
  * @category TPaaS Leave Tracking
2267
2371
  */
2268
- trackTpaasActiveLeave() {
2269
- (0, leaveTrackingTpaas_1.trackTpaasActiveLeave)();
2372
+ async trackTpaasActiveLeave() {
2373
+ await (0, leaveTrackingTpaas_1.trackTpaasActiveLeave)();
2270
2374
  }
2271
2375
  /**
2272
2376
  * Check if leave tracking is enabled (if an event will be sent when the user leaves the page)
@@ -2290,13 +2394,14 @@ class Tracker {
2290
2394
  * @private
2291
2395
  */
2292
2396
  async resolveTrackInput(input) {
2293
- return (0, pulse_utils_1.evaluateAndFlatten)(input);
2397
+ return (0, utils_1.evaluateAndFlatten)(input);
2294
2398
  }
2295
2399
  /**
2296
2400
  * @private
2297
2401
  */
2298
- async resolveTrackGlobals() {
2299
- return (0, pulse_utils_1.evaluateAndFlatten)({ ...this.builders });
2402
+ async resolveAnonymousTrackGlobals() {
2403
+ // Omit before evaluation so forbidden promise/function builders cannot delay or fail anonymous tracking.
2404
+ return (0, utils_1.evaluateAndFlatten)((0, utils_1.omit)(this.builders, ANONYMOUS_EVENT_FORBIDDEN_FIELDS));
2300
2405
  }
2301
2406
  /**
2302
2407
  * Send all anonymous events that are in the internal anonymous event queue.
@@ -2360,12 +2465,18 @@ class Tracker {
2360
2465
  async prepareQueuesAndSend(eventQueue, retryEventQueue) {
2361
2466
  const promisesToBeSent = eventQueue.splice(0);
2362
2467
  const eventsToBeSent = promisesToBeSent.map((p) => p.inputValue);
2363
- const eventsToRetry = retryEventQueue;
2468
+ const eventsToRetry = retryEventQueue.splice(0);
2364
2469
  eventQueue.length = 0;
2365
2470
  retryEventQueue.length = 0;
2366
2471
  const evaluatedEvents = await Promise.all(eventsToBeSent);
2367
2472
  const url = this._getCollectorPath();
2368
2473
  const data = [...evaluatedEvents, ...eventsToRetry];
2474
+ // in some cases, _sendImmediately executes an asynchronous operation (cisSync) after checking for empty array
2475
+ // due to that, it's still possible for this function to be called with an empty array, so we need to check for that again before sending
2476
+ // in order to avoid making an empty request to collector
2477
+ if (data.length === 0) {
2478
+ return [];
2479
+ }
2369
2480
  // biome-ignore lint/suspicious/noExplicitAny: -
2370
2481
  async function onFailedSend(response) {
2371
2482
  // We retry an event once, but discard already retried events
@@ -2402,7 +2513,7 @@ class Tracker {
2402
2513
  const session = (0, builders_1.session)({}, creationDate);
2403
2514
  // Resolve any pending session ID promises
2404
2515
  this.resolveSessionIdPromise();
2405
- return (0, pulse_utils_1.pulseMerge)({}, eventInput, {
2516
+ return (0, utils_1.pulseMerge)({}, eventInput, {
2406
2517
  '@id': (0, uuid_1.v4)(),
2407
2518
  creationDate: creationDate.toISOString(),
2408
2519
  session,
@@ -2413,10 +2524,10 @@ class Tracker {
2413
2524
  * @private
2414
2525
  */
2415
2526
  resolveSessionIdPromise() {
2416
- const session = (0, session_browser_1.readSession)();
2417
- if (session?.id) {
2527
+ const session = (0, store_1.readSession)();
2528
+ if (session) {
2418
2529
  eventBus.emit('tracker:session:new', {
2419
- sessionId: session.id,
2530
+ sessionId: (0, store_1.generateSessionSDRN)(session.sessionId),
2420
2531
  });
2421
2532
  }
2422
2533
  }
@@ -2431,7 +2542,7 @@ class Tracker {
2431
2542
  */
2432
2543
  createAnonymousEvent(eventInput) {
2433
2544
  const creationDate = new Date();
2434
- return (0, pulse_utils_1.pulseMerge)({}, eventInput, {
2545
+ return (0, utils_1.pulseMerge)({}, eventInput, {
2435
2546
  '@id': (0, uuid_1.v4)(),
2436
2547
  creationDate: creationDate.toISOString(),
2437
2548
  });
@@ -2444,7 +2555,7 @@ class Tracker {
2444
2555
  */
2445
2556
  applyEventTypeDefaults(eventInput, eventType) {
2446
2557
  const eventDefaults = getEventBuilder(eventType).defaults;
2447
- return (0, pulse_utils_1.pulseMerge)({}, eventDefaults(), eventInput);
2558
+ return (0, utils_1.pulseMerge)({}, eventDefaults(), eventInput);
2448
2559
  }
2449
2560
  /**
2450
2561
  * @param eventInput
@@ -2453,7 +2564,7 @@ class Tracker {
2453
2564
  */
2454
2565
  applyAnonymousEventTypeDefaults(eventInput, eventType) {
2455
2566
  const eventDefaults = getAnonymousEventBuilder(eventType).defaults;
2456
- return (0, pulse_utils_1.pulseMerge)({}, eventDefaults(), eventInput);
2567
+ return (0, utils_1.pulseMerge)({}, eventDefaults(), eventInput);
2457
2568
  }
2458
2569
  /**
2459
2570
  * applyBookmarkedEvent
@@ -2468,7 +2579,7 @@ class Tracker {
2468
2579
  const eventOutput = Object.assign({}, eventInput);
2469
2580
  const bookmarkedPageViewEvent = this.bookmark.get(bookmarkKey) ?? {};
2470
2581
  const { '@id': _id, '@type': _type, creationDate: _creationDate, ...coreEvent } = bookmarkedPageViewEvent;
2471
- return (0, pulse_utils_1.pulseMerge)({}, eventOutput, coreEvent);
2582
+ return (0, utils_1.pulseMerge)({}, eventOutput, coreEvent);
2472
2583
  }
2473
2584
  /**
2474
2585
  * applyConsents
@@ -2476,7 +2587,7 @@ class Tracker {
2476
2587
  * @private
2477
2588
  */
2478
2589
  async applyConsents(eventInput) {
2479
- return (0, pulse_utils_1.pulseMerge)({}, eventInput, await this.evaluateConsents());
2590
+ return (0, utils_1.pulseMerge)({}, eventInput, await this.evaluateConsents());
2480
2591
  }
2481
2592
  /**
2482
2593
  * applyConsentsAnonymous
@@ -2484,7 +2595,7 @@ class Tracker {
2484
2595
  * @private
2485
2596
  */
2486
2597
  applyConsentsAnonymous(eventInput) {
2487
- return (0, pulse_utils_1.pulseMerge)({}, eventInput, this.evaluateConsentsAnonymous());
2598
+ return (0, utils_1.pulseMerge)({}, eventInput, this.evaluateConsentsAnonymous());
2488
2599
  }
2489
2600
  /**
2490
2601
  * Enriches the event with consent data saved in state.
@@ -2506,7 +2617,7 @@ class Tracker {
2506
2617
  * @category Consents
2507
2618
  */
2508
2619
  evaluateConsentsAnonymous() {
2509
- const consents = (0, pulse_utils_1.isPromise)(this.state.consents) ? (0, consent_manager_1.getFallbackConsents)() : this.state.consents;
2620
+ const consents = (0, utils_1.isPromise)(this.state.consents) ? (0, consent_manager_1.getFallbackConsents)() : this.state.consents;
2510
2621
  return {
2511
2622
  ...(consents && { consents }),
2512
2623
  };