@playpilot/tpi 6.8.0 → 6.9.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": "6.8.0",
3
+ "version": "6.9.1",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
@@ -4,9 +4,4 @@ export const SplitTest = {
4
4
  numberOfVariants: 2,
5
5
  variantNames: ['Separated', 'Inline'] as string[],
6
6
  },
7
- TitleDescriptionPlacement: {
8
- key: 'title_description_placement',
9
- numberOfVariants: 2,
10
- variantNames: ['Top', 'Bottom'] as string[],
11
- },
12
7
  } as const
@@ -49,6 +49,11 @@ export type ConfigResponse = {
49
49
  */
50
50
  allow_retargeting_pixels?: boolean
51
51
 
52
+ /**
53
+ * By default affiliate links (playlinks) will render as links even without consent, as a disclaimer is given. Set to true to require explicit consent, rendering as static text without consent.
54
+ */
55
+ require_affiliate_consent?: boolean
56
+
52
57
  /**
53
58
  * The following options are all relevant for in text disclaimers, which renders as a disclaimer text within the article,
54
59
  * rather than only inside of title cards.
@@ -35,7 +35,7 @@
35
35
  <!-- svelte-ignore a11y_no_static_element_interactions -->
36
36
  <svelte:element
37
37
  {onclick}
38
- this={hasConsentedTo('affiliate') ? 'a' : 'span'}
38
+ this={!window.PlayPilotLinkInjections?.config?.require_affiliate_consent || hasConsentedTo('affiliate') ? 'a' : 'span'}
39
39
  {@attach usePixel ? trackViewViaPixel(MetaEvent.ProviderInterest, { provider: playlink.slug }) : null}
40
40
  {@attach usePixel ? trackClickViaPixel(MetaEvent.ProviderClick, { provider: playlink.slug }) : null}
41
41
  href={url}
@@ -13,9 +13,7 @@
13
13
  import { heading } from '$lib/actions/heading'
14
14
  import { removeImageUrlPrefix } from '$lib/image'
15
15
  import { titleUrl } from '$lib/routes'
16
- import { isInSplitTestVariant, trackSplitTestView } from '$lib/splitTest'
17
- import { onMount, setContext } from 'svelte'
18
- import { SplitTest } from '$lib/enums/SplitTest'
16
+ import { setContext } from 'svelte'
19
17
  import { track } from '$lib/tracking'
20
18
  import { TrackingEvent } from '$lib/enums/TrackingEvent'
21
19
 
@@ -33,18 +31,8 @@
33
31
  let posterLoaded = $state(false)
34
32
  let backgroundLoaded = $state(false)
35
33
  let useBackgroundFallback = $state(false)
36
-
37
- onMount(() => {
38
- if (showDescription) trackSplitTestView(SplitTest.TitleDescriptionPlacement)
39
- })
40
34
  </script>
41
35
 
42
- {#snippet description()}
43
- {#if showDescription}
44
- <Description text={title.description!} blurb={title.blurb} onclick={() => track(TrackingEvent.ExpandTitleDescription, title)} />
45
- {/if}
46
- {/snippet}
47
-
48
36
  <div class="content" class:small>
49
37
  <div class="header">
50
38
  <div class="poster" class:loaded={posterLoaded}>
@@ -79,16 +67,12 @@
79
67
  </div>
80
68
 
81
69
  <div class="main">
82
- {#if isInSplitTestVariant(SplitTest.TitleDescriptionPlacement, 0)}
83
- {@render description()}
70
+ {#if showDescription}
71
+ <Description text={title.description!} blurb={title.blurb} onclick={() => track(TrackingEvent.ExpandTitleDescription, title)} />
84
72
  {/if}
85
73
 
86
74
  <Playlinks playlinks={title.providers} {title} />
87
75
 
88
- {#if isInSplitTestVariant(SplitTest.TitleDescriptionPlacement, 1)}
89
- {@render description()}
90
- {/if}
91
-
92
76
  <ParticipantsRail {title} />
93
77
  <SimilarRail {title} />
94
78
  </div>
@@ -9,8 +9,6 @@
9
9
  import TopScroll from './Ads/TopScroll.svelte'
10
10
  import Display from './Ads/Display.svelte'
11
11
  import ExploreCallToAction from './Explore/ExploreCallToAction.svelte'
12
- import { getSplitTestVariantName } from '$lib/splitTest'
13
- import { SplitTest } from '$lib/enums/SplitTest'
14
12
 
15
13
  interface Props {
16
14
  title: TitleData
@@ -30,7 +28,7 @@
30
28
  onMount(() => {
31
29
  const openTimestamp = Date.now()
32
30
 
33
- return () => track(TrackingEvent.TitleModalClose, title, { time_spent: Date.now() - openTimestamp, split_test: getSplitTestVariantName(SplitTest.TitleDescriptionPlacement) })
31
+ return () => track(TrackingEvent.TitleModalClose, title, { time_spent: Date.now() - openTimestamp })
34
32
  })
35
33
 
36
34
  function onscroll(): void {
@@ -8,8 +8,6 @@
8
8
  import Title from './Title.svelte'
9
9
  import TopScroll from './Ads/TopScroll.svelte'
10
10
  import Display from './Ads/Display.svelte'
11
- import { getSplitTestVariantName } from '$lib/splitTest'
12
- import { SplitTest } from '$lib/enums/SplitTest'
13
11
 
14
12
  interface Props {
15
13
  event: MouseEvent
@@ -29,7 +27,7 @@
29
27
  setOffset()
30
28
 
31
29
  const openTimestamp = Date.now()
32
- return () => track(TrackingEvent.TitlePopoverClose, title, { time_spent: Date.now() - openTimestamp, split_test: getSplitTestVariantName(SplitTest.TitleDescriptionPlacement) })
30
+ return () => track(TrackingEvent.TitlePopoverClose, title, { time_spent: Date.now() - openTimestamp })
33
31
  })
34
32
 
35
33
  /**
@@ -1,5 +1,5 @@
1
1
  import { fireEvent, render } from '@testing-library/svelte'
2
- import { describe, expect, it, vi } from 'vitest'
2
+ import { beforeEach, describe, expect, it, vi } from 'vitest'
3
3
 
4
4
  import Playlink from '../../../../routes/components/Playlinks/Playlink.svelte'
5
5
  import { hasConsentedTo } from '$lib/consent'
@@ -19,6 +19,11 @@ vi.mock('svelte', async (importActual) => ({
19
19
  }))
20
20
 
21
21
  describe('Playlink.svelte', () => {
22
+ beforeEach(() => {
23
+ // @ts-ignore
24
+ window.PlayPilotLinkInjections = { config: {} }
25
+ })
26
+
22
27
  const playlink = { name: 'Some playlink', logo_url: 'logo', url: 'https://playpilot.com/', extra_info: { category: 'SVOD' } }
23
28
 
24
29
  it('Should render category as words', () => {
@@ -109,7 +114,20 @@ describe('Playlink.svelte', () => {
109
114
  expect(getByRole('link')).toBeTruthy()
110
115
  })
111
116
 
112
- it('Should not render as link when user has not consented to affiliate', () => {
117
+ it('Should render as link when user has not consented to affiliate but require_affiliate_consent is false', () => {
118
+ window.PlayPilotLinkInjections.config.require_affiliate_consent = false
119
+
120
+ vi.mocked(hasConsentedTo).mockImplementation(() => false)
121
+
122
+ // @ts-ignore
123
+ const { queryByRole } = render(Playlink, { playlink })
124
+
125
+ expect(queryByRole('link')).toBeTruthy()
126
+ })
127
+
128
+ it('Should render as link when user has not consented to affiliate and require_affiliate_consent is true', () => {
129
+ window.PlayPilotLinkInjections.config.require_affiliate_consent = true
130
+
113
131
  vi.mocked(hasConsentedTo).mockImplementation(() => false)
114
132
 
115
133
  // @ts-ignore