@playpilot/tpi 8.23.0-beta.7 → 8.23.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/events.md CHANGED
@@ -126,6 +126,7 @@ Event | Action | Info | Payload
126
126
  `venus_title_rail_modal_view` | _Fires any time a title is clicked in a rail, opening the rail modal_ | | `rail` (heading key of the rail)
127
127
  `venus_title_rail_expand_click` | _Fires any time a title is expanded in a rail directly via a click_ | Does not fire when a title opens automatically on load or navigate | `Title`, `rail` (heading key of the rail)
128
128
  `venus_title_rail_set_index` | _Fires when navigating in the titles rail modal, either via arrows, swipe, or clicking titles_ | | `Title`, `index` (index of the new position of the slider)
129
+ `venus_title_reel_set_index` | _Fires when navigating in the titles reel modal, swipe, or clicking titles_ | | `Title`, `index` (index of the new position of the slider)
129
130
  `venus_navigate` | _Fires when navigating on the explore page_ | Does not fire on initial load | `route` (the key of the given route)
130
131
  `venus_any_click` | _Fires on any click anywhere_ | | `selector` (parent > child selector of the clicked element), `text` (direct text content of the clicked element, limited to 30 characters)
131
132
  `venus_scroll_distance` | _Fires on increments of scroll distance_ | 25%, 50%, 75%, 100% | `scroll_percentage` (percentage of the explore element the user has seen)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playpilot/tpi",
3
- "version": "8.23.0-beta.7",
3
+ "version": "8.23.1",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
@@ -4,4 +4,9 @@ export const SplitTest = {
4
4
  numberOfVariants: 2,
5
5
  variantNames: ['Separated', 'Inline'] as string[],
6
6
  },
7
+ Reels: {
8
+ key: 'reels',
9
+ numberOfVariants: 2,
10
+ variantNames: ['Default', 'Reel'] as string[],
11
+ },
7
12
  } as const
@@ -79,6 +79,7 @@ export const TrackingEvent = {
79
79
  ExploreTitleRailModalView: 'venus_title_rail_modal_view',
80
80
  ExploreTitleRailExpandClick: 'venus_title_rail_expand_click',
81
81
  ExploreTitleRailSetIndex: 'venus_title_rail_set_index',
82
+ ExploreTitleReelSetIndex: 'venus_title_reel_set_index',
82
83
  ExploreNavigate: 'venus_navigate',
83
84
  ExploreAnyClick: 'venus_any_click',
84
85
  ExploreScrollDistance: 'venus_scroll_distance',
@@ -8,6 +8,8 @@ type SplitTest = {
8
8
  variantNames?: string[]
9
9
  }
10
10
 
11
+ export const sessionStoragePrefix = 'playpilot_split_test_'
12
+
11
13
  /**
12
14
  * Each split test uses a different split test identifier so a user can be part of one, multiple, or none, tests.
13
15
  * The identifier is saved on the window object so that it is consistent across this session.
@@ -20,10 +22,19 @@ export function getSplitTestIdentifier({ key }: SplitTest): number {
20
22
 
21
23
  if (!window.PlayPilotLinkInjections?.split_test_identifiers) window.PlayPilotLinkInjections.split_test_identifiers = {}
22
24
 
23
- const randomIdentifier = Math.random()
24
- window.PlayPilotLinkInjections.split_test_identifiers[key] = randomIdentifier
25
+ let storedIdentifier = sessionStorage.getItem(sessionStoragePrefix + key)
26
+
27
+ if (!storedIdentifier) {
28
+ const randomIdentifier = Math.random().toString()
29
+ sessionStorage.setItem(sessionStoragePrefix + key, randomIdentifier)
30
+ storedIdentifier = randomIdentifier
31
+ }
32
+
33
+ const parsed = parseFloat(storedIdentifier!)
34
+
35
+ window.PlayPilotLinkInjections.split_test_identifiers[key] = parsed
25
36
 
26
- return randomIdentifier
37
+ return parsed
27
38
  }
28
39
 
29
40
  export function getSplitTestVariantIndex(test: SplitTest): number {
@@ -1,7 +1,9 @@
1
1
  <script lang="ts">
2
2
  import { fetchSimilarTitles, fetchTitleBySid } from '$lib/api/titles'
3
3
  import { mobileBreakpoint } from '$lib/constants'
4
+ import { SplitTest } from '$lib/enums/SplitTest'
4
5
  import { openModal } from '$lib/modal'
6
+ import { getSplitTestVariantName, trackSplitTestView } from '$lib/splitTest'
5
7
  import type { TitleData } from '$lib/types/title'
6
8
 
7
9
  interface Props {
@@ -15,10 +17,15 @@
15
17
  async function openModalViaRoute(): Promise<void> {
16
18
  const currentUrl = new URL(document.location.toString())
17
19
  const sid = currentUrl.searchParams.get('sid')
18
- const type = window.innerWidth > mobileBreakpoint ? 'titles-rail' : 'titles-reel'
19
20
 
20
21
  if (!sid) return
21
22
 
23
+ const isMobile = window.innerWidth < mobileBreakpoint
24
+ const isInReelSplitTest = isMobile && getSplitTestVariantName(SplitTest.Reels) === 'Reel'
25
+ const type = isMobile && isInReelSplitTest ? 'titles-reel' : 'titles-rail'
26
+
27
+ if (isMobile) trackSplitTestView(SplitTest.Reels)
28
+
22
29
  try {
23
30
  const [title, railTitles] = (await Promise.allSettled([
24
31
  fetchTitleBySid(sid),
@@ -3,6 +3,8 @@
3
3
  import { onMount } from 'svelte'
4
4
  import { heading } from '$lib/actions/heading'
5
5
  import { t } from '$lib/localization'
6
+ import { track } from '$lib/tracking'
7
+ import { TrackingEvent } from '$lib/enums/TrackingEvent'
6
8
  import TinySlider from 'svelte-tiny-slider'
7
9
  import Modal from './Modal.svelte'
8
10
  import TitleBackground from '../TitleBackground.svelte'
@@ -15,9 +17,10 @@
15
17
 
16
18
  interface Props {
17
19
  titles: TitleData[],
20
+ onclose?: () => void
18
21
  }
19
22
 
20
- const { titles }: Props = $props()
23
+ const { titles, onclose = () => null }: Props = $props()
21
24
 
22
25
  let interval: ReturnType<typeof setInterval> | null = null
23
26
 
@@ -29,6 +32,11 @@
29
32
  }
30
33
  })
31
34
 
35
+ function onchange(index: number): void {
36
+ pauseAndPlay(index)
37
+ track(TrackingEvent.ExploreTitleReelSetIndex, titles[index], { index })
38
+ }
39
+
32
40
  function pauseAndPlay(index: number): void {
33
41
  ;[titles[index - 1], titles[index + 1]].forEach(title => {
34
42
  window.dispatchEvent(new CustomEvent('pauseembed', { detail: title?.embeddable_url } ))
@@ -49,7 +57,7 @@
49
57
  <Modal>
50
58
  {#snippet dialog()}
51
59
  <div class="slider">
52
- <TinySlider vertical threshold={100} moveThreshold={10} onchange={pauseAndPlay}>
60
+ <TinySlider vertical threshold={50} moveThreshold={10} {onchange}>
53
61
  {#snippet children({ currentIndex, setIndex })}
54
62
  {#each titles as title, index}
55
63
  <!-- svelte-ignore a11y_click_events_have_key_events -->
@@ -64,7 +72,9 @@
64
72
  </div>
65
73
 
66
74
  <div class="details">
67
- <Description text={title.description!} blurb={title.blurb} limit={80} />
75
+ {#if title.description}
76
+ <Description text={title.description} blurb={title.blurb} limit={80} />
77
+ {/if}
68
78
 
69
79
  <div class="playlinks-heading" use:heading={3}>{t('Where To Stream Online')}</div>
70
80
 
@@ -90,14 +100,14 @@
90
100
  </TinySlider>
91
101
  </div>
92
102
 
93
- <ModalCloseOverlay label={t('Explore All Movies And Shows')} />
103
+ <ModalCloseOverlay {onclose} label={t('Explore All Movies And Shows')} />
94
104
  {/snippet}
95
105
  </Modal>
96
106
  </div>
97
107
 
98
108
  <style lang="scss">
99
109
  $modal-height: calc(100vh - margin(4.5));
100
- $item-height: calc($modal-height - margin(7));
110
+ $item-height: calc($modal-height - margin(5));
101
111
 
102
112
  .reel {
103
113
  --playpilot-detail-background-height: #{$item-height};
@@ -153,13 +163,14 @@
153
163
  }
154
164
 
155
165
  .header {
156
- position: relative;
157
166
  z-index: 2;
158
- padding: theme(reel-item-padding, margin(2));
167
+ position: relative;
168
+ padding: theme(reel-item-padding, margin(1) margin(2) margin(2));
159
169
  font-size: theme(reel-header-font-size, font-size-small);
160
170
  }
161
171
 
162
172
  .heading {
173
+ padding-right: margin(1.5);
163
174
  margin-bottom: margin(0.5);
164
175
  color: theme(detail-title-text-color, text-color);
165
176
  font-family: theme(detail-title-font-family, inherit);
@@ -173,8 +184,20 @@
173
184
  z-index: 1;
174
185
  position: relative;
175
186
  padding: theme(reel-item-padding, margin(2));
176
- background: linear-gradient(to bottom, transparent, theme(detail-background, light) 4rem);
177
187
  font-size: theme(detail-font-size, font-size-base);
188
+
189
+ &::before {
190
+ z-index: -1;
191
+ content: "";
192
+ display: block;
193
+ position: absolute;
194
+ top: 0;
195
+ right: 0;
196
+ bottom: 0;
197
+ left: 0;
198
+ background: linear-gradient(to bottom, transparent, theme(detail-background, light) 4rem);
199
+ opacity: 0.85;
200
+ }
178
201
  }
179
202
 
180
203
  .playlinks-heading {
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect, vi, afterEach } from 'vitest'
2
- import { getSplitTestIdentifier, getSplitTestVariantIndex, getSplitTestVariantName, isInSplitTestVariant, trackSplitTestAction, trackSplitTestView } from '$lib/splitTest'
2
+ import { getSplitTestIdentifier, getSplitTestVariantIndex, getSplitTestVariantName, isInSplitTestVariant, sessionStoragePrefix, trackSplitTestAction, trackSplitTestView } from '$lib/splitTest'
3
3
  import { track } from '$lib/tracking'
4
4
  import { TrackingEvent } from '$lib/enums/TrackingEvent'
5
5
  import { hasConsentedTo } from '$lib/consent'
@@ -28,7 +28,6 @@ describe('$lib/splitTest', () => {
28
28
  })
29
29
 
30
30
  describe('getSplitTestIdentifier', () => {
31
-
32
31
  it('Should set window object with given key if window object was not set to begin with', () => {
33
32
  // @ts-ignore
34
33
  window.PlayPilotLinkInjections = {}
@@ -66,6 +65,18 @@ describe('$lib/splitTest', () => {
66
65
 
67
66
  expect(getSplitTestIdentifier(splitTest)).toBe(0)
68
67
  })
68
+
69
+ it('Should store value in sessionStorage', () => {
70
+ getSplitTestIdentifier(splitTest)
71
+
72
+ expect(sessionStorage.getItem(sessionStoragePrefix + splitTest.key)).toBeTruthy()
73
+ })
74
+
75
+ it('Should use value stored in sessionStorage', () => {
76
+ sessionStorage.setItem(sessionStoragePrefix + splitTest.key, '0.2')
77
+
78
+ expect(getSplitTestIdentifier(splitTest)).toBe(0.2)
79
+ })
69
80
  })
70
81
 
71
82
  describe('isInSplitTestVariant', () => {