@playpilot/tpi 8.34.4 → 8.34.5

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.4",
3
+ "version": "8.34.5",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
@@ -68,6 +68,7 @@ export const TrackingEvent = {
68
68
  RegionRequestFailed: 'ali_region_request_failed',
69
69
  YouTubeAvailabilityRequestFailed: 'ali_youtube_availability_request_failed',
70
70
  CardToExploreCta: 'ali_card_to_explore_cta',
71
+ TitleParticipantsView: 'ali_title_participants_view',
71
72
 
72
73
  // Explore
73
74
  // These deliberately do not use the `ali_` prefix. We might want to separate this from TPI at some point
@@ -52,9 +52,17 @@
52
52
 
53
53
  window.location.href = exploreModalUrl(participant.sid)
54
54
  }
55
+
56
+ async function getParticipants(): Promise<ParticipantData[]> {
57
+ const participants = await fetchParticipantsForTitle(title)
58
+
59
+ if (participants.length) track(TrackingEvent.TitleParticipantsView, title, { participants: participants.map(p => p.name).slice(0, 20) })
60
+
61
+ return participants
62
+ }
55
63
  </script>
56
64
 
57
- {#await fetchParticipantsForTitle(title)}
65
+ {#await getParticipants()}
58
66
  <Rail {heading}>
59
67
  {#each { length: 5 }}
60
68
  <div class="participant">
@@ -119,4 +119,14 @@ describe('ParticipantsRail.svelte', () => {
119
119
 
120
120
  expect(track).toHaveBeenCalledWith(TrackingEvent.ParticipantClick, null, { title_source: title.original_title, participant: participants[0].name })
121
121
  })
122
+
123
+ it('Should fire track event after participants are fetched', async () => {
124
+ vi.mocked(fetchParticipantsForTitle).mockResolvedValueOnce(participants)
125
+
126
+ render(ParticipantsRail, { title })
127
+
128
+ await waitFor(async () => {
129
+ expect(track).toHaveBeenCalledWith(TrackingEvent.TitleParticipantsView, title, { participants: participants.map(p => p.name) })
130
+ })
131
+ })
122
132
  })