@playpilot/tpi 8.34.0 → 8.34.1

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playpilot/tpi",
3
- "version": "8.34.0",
3
+ "version": "8.34.1",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
@@ -49,6 +49,7 @@ export const TrackingEvent = {
49
49
  DisplayAdView: 'ali_display_ad_view',
50
50
  DisplayAdClick: 'ali_display_ad_click',
51
51
  DisplayedAdPlaylickClick: 'ali_display_ad_playlink_click',
52
+ DisplayedAdVideoPercentage: 'ali_display_ad_video_percentage',
52
53
  AdsFetchFailed: 'ali_ads_fetch_failed',
53
54
 
54
55
  // Split tests
@@ -3,6 +3,7 @@
3
3
  import { TrackingEvent } from '$lib/enums/TrackingEvent'
4
4
  import { track } from '$lib/tracking'
5
5
  import type { Campaign } from '$lib/types/campaign'
6
+ import { onDestroy } from 'svelte'
6
7
  import Tooltip from '../Tooltip.svelte'
7
8
  import Disclaimer from './Disclaimer.svelte'
8
9
 
@@ -18,12 +19,19 @@
18
19
  const { header: buttonLabel, url: href, subheader: info } = $derived(cta)
19
20
 
20
21
  let contentHeight = $state(0)
22
+ let videoElement: HTMLVideoElement | null = $state(null)
21
23
 
22
24
  track(TrackingEvent.DisplayAdView, null, { campaign_name: campaign.campaign_name })
23
25
 
24
26
  function onclick(): void {
25
27
  track(TrackingEvent.DisplayAdClick, null, { campaign_name: campaign.campaign_name })
26
28
  }
29
+
30
+ onDestroy(() => {
31
+ if (!videoElement) return
32
+
33
+ track(TrackingEvent.DisplayedAdVideoPercentage, null, { percentage: 100 / videoElement.duration * videoElement.currentTime })
34
+ })
27
35
  </script>
28
36
 
29
37
  <a {href} target="_blank" class="display" class:compact rel="sponsored" {onclick} use:middlemouse={{ onclick }}>
@@ -68,7 +76,7 @@
68
76
  {#if campaign_type === 'image' && image}
69
77
  <img class="background" src={image} alt="" />
70
78
  {:else if campaign_type === 'video' && video}
71
- <video class="background" autoplay muted playsinline loop>
79
+ <video class="background" autoplay muted playsinline loop bind:this={videoElement}>
72
80
  <source src={video} type="video/mp4">
73
81
  <track kind="captions" />
74
82
  </video>