@playpilot/tpi 8.23.0 → 8.23.2

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",
3
+ "version": "8.23.2",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
@@ -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',
@@ -1,4 +1,3 @@
1
- import { hasConsentedTo } from './consent'
2
1
  import { TrackingEvent } from './enums/TrackingEvent'
3
2
  import { track } from './tracking'
4
3
 
@@ -15,8 +14,6 @@ export const sessionStoragePrefix = 'playpilot_split_test_'
15
14
  * The identifier is saved on the window object so that it is consistent across this session.
16
15
  */
17
16
  export function getSplitTestIdentifier({ key }: SplitTest): number {
18
- if (!hasConsentedTo('tracking')) return 0
19
-
20
17
  const windowIdentifier = window.PlayPilotLinkInjections?.split_test_identifiers?.[key]
21
18
  if (windowIdentifier !== undefined) return windowIdentifier
22
19
 
@@ -25,7 +22,7 @@ export function getSplitTestIdentifier({ key }: SplitTest): number {
25
22
  let storedIdentifier = sessionStorage.getItem(sessionStoragePrefix + key)
26
23
 
27
24
  if (!storedIdentifier) {
28
- const randomIdentifier = Math.random().toString()
25
+ const randomIdentifier = (Math.floor(Math.random() * 100) / 100).toString()
29
26
  sessionStorage.setItem(sessionStoragePrefix + key, randomIdentifier)
30
27
  storedIdentifier = randomIdentifier
31
28
  }
@@ -53,8 +50,6 @@ export function getSplitTestVariantName(test: SplitTest): string {
53
50
  }
54
51
 
55
52
  export function isInSplitTestVariant(test: SplitTest, variant = 1): boolean {
56
- if (!hasConsentedTo('tracking')) return false
57
-
58
53
  return getSplitTestVariantIndex(test) === variant
59
54
  }
60
55
 
@@ -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={50} 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 -->
@@ -92,7 +100,7 @@
92
100
  </TinySlider>
93
101
  </div>
94
102
 
95
- <ModalCloseOverlay label={t('Explore All Movies And Shows')} />
103
+ <ModalCloseOverlay {onclose} label={t('Explore All Movies And Shows')} />
96
104
  {/snippet}
97
105
  </Modal>
98
106
  </div>
@@ -2,11 +2,6 @@ import { describe, it, expect, vi, afterEach } from 'vitest'
2
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
- import { hasConsentedTo } from '$lib/consent'
6
-
7
- vi.mock('$lib/consent', () => ({
8
- hasConsentedTo: vi.fn(() => true),
9
- }))
10
5
 
11
6
  vi.mock('$lib/tracking', () => ({
12
7
  track: vi.fn(),
@@ -23,8 +18,6 @@ describe('$lib/splitTest', () => {
23
18
  window.PlayPilotLinkInjections = {}
24
19
 
25
20
  vi.resetAllMocks()
26
-
27
- vi.mocked(hasConsentedTo).mockImplementation(() => true)
28
21
  })
29
22
 
30
23
  describe('getSplitTestIdentifier', () => {
@@ -60,12 +53,6 @@ describe('$lib/splitTest', () => {
60
53
  })
61
54
  })
62
55
 
63
- it('Should return 0 if user did not consent', () => {
64
- vi.mocked(hasConsentedTo).mockImplementation(() => false)
65
-
66
- expect(getSplitTestIdentifier(splitTest)).toBe(0)
67
- })
68
-
69
56
  it('Should store value in sessionStorage', () => {
70
57
  getSplitTestIdentifier(splitTest)
71
58
 
@@ -118,16 +105,6 @@ describe('$lib/splitTest', () => {
118
105
  expect(isInSplitTestVariant(multiple, 1)).toBe(false)
119
106
  expect(isInSplitTestVariant(multiple, 2)).toBe(true)
120
107
  })
121
-
122
- it('Should return false if user did not consent', () => {
123
- vi.mocked(hasConsentedTo).mockImplementation(() => false)
124
-
125
- // @ts-ignore
126
- window.PlayPilotLinkInjections.split_test_identifiers = {}
127
- window.PlayPilotLinkInjections.split_test_identifiers[splitTest.key] = 0.75
128
-
129
- expect(isInSplitTestVariant(splitTest)).toBe(false)
130
- })
131
108
  })
132
109
 
133
110
  describe('trackSplitTestView', () => {