@playpilot/tpi 8.41.0 → 8.42.0-beta.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/dist/editorial.mount.js +10 -10
- package/dist/link-injections.js +2 -2
- package/dist/mount.css +1 -1
- package/dist/mount.js +7 -7
- package/package.json +1 -1
- package/src/lib/enums/SplitTest.ts +5 -0
- package/src/lib/fakeData.ts +2 -2
- package/src/lib/injection.ts +3 -13
- package/src/lib/types/config.d.ts +0 -5
- package/src/lib/url.ts +0 -4
- package/src/routes/components/Ads/Display.svelte +52 -5
- package/src/routes/components/Debugger.svelte +2 -0
- package/src/routes/components/Modals/RailModal.svelte +12 -4
- package/src/routes/components/Modals/TitlesRailModal.svelte +3 -1
- package/src/routes/components/Playlinks/Playlinks.svelte +11 -3
- package/src/routes/components/Title.svelte +10 -2
- package/src/routes/elements/+page.svelte +20 -1
- package/src/tests/lib/injection.test.js +1520 -1548
- package/src/tests/lib/url.test.js +1 -24
- package/src/tests/routes/components/Ads/Display.test.js +11 -1
package/package.json
CHANGED
package/src/lib/fakeData.ts
CHANGED
|
@@ -172,10 +172,10 @@ export const campaign: Campaign = {
|
|
|
172
172
|
campaign_region: 'nl',
|
|
173
173
|
content: {
|
|
174
174
|
header: 'Content header',
|
|
175
|
-
header_logo:
|
|
175
|
+
header_logo: 'https://placehold.co/50?text=content.header_logo',
|
|
176
176
|
header_logo_uuid: null,
|
|
177
177
|
subheader: 'Content subheader',
|
|
178
|
-
image:
|
|
178
|
+
image: 'https://placehold.co/320x180/333/666?text=content.image',
|
|
179
179
|
image_uuid: null,
|
|
180
180
|
video: null,
|
|
181
181
|
format: null,
|
package/src/lib/injection.ts
CHANGED
|
@@ -10,7 +10,6 @@ import { clearInTextWidgets, insertInTextWidgets } from './inTextWidgets'
|
|
|
10
10
|
import { encodeHtmlEntities } from './html'
|
|
11
11
|
import type { ParticipantData } from './types/participant'
|
|
12
12
|
import { getConfigValue } from './api/config'
|
|
13
|
-
import { isParticipantsUrlExcludedViaConfig } from './url'
|
|
14
13
|
|
|
15
14
|
export const keyDataAttribute = 'data-playpilot-injection-key'
|
|
16
15
|
export const keySelector = `[${keyDataAttribute}]`
|
|
@@ -30,8 +29,6 @@ export function injectLinksInDocument(elements: HTMLElement[], injections: LinkI
|
|
|
30
29
|
// This is to filter out injections that can't be injected anyway.
|
|
31
30
|
const fullText = cleanPhrase(elements.map(element => element.innerText).join(' '))
|
|
32
31
|
|
|
33
|
-
const excludeParticipantsByUrl = isParticipantsUrlExcludedViaConfig(window.PlayPilotLinkInjections.config || {})
|
|
34
|
-
|
|
35
32
|
const validInjections = filterInvalidInTextInjections(mergedInjections)
|
|
36
33
|
const foundInjections = validInjections.filter(i => fullText.includes(cleanPhrase(i.sentence)))
|
|
37
34
|
const { injections: limitedInjections, failedMessages } = limitInjectionsByCount(foundInjections)
|
|
@@ -40,16 +37,9 @@ export function injectLinksInDocument(elements: HTMLElement[], injections: LinkI
|
|
|
40
37
|
for (const injection of sortInjections(limitedInjections)) {
|
|
41
38
|
injectionIndex++
|
|
42
39
|
|
|
43
|
-
if (!injection.manual && injection.type === 'participant') {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
continue
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (!doesParticipantMeetThreshold(mergedInjections, injection.participant_details!)) {
|
|
50
|
-
failedMessages[injection.key] = 'Participant does not meet popularity threshold.'
|
|
51
|
-
continue
|
|
52
|
-
}
|
|
40
|
+
if (!injection.manual && injection.type === 'participant' && !doesParticipantMeetThreshold(mergedInjections, injection.participant_details!)) {
|
|
41
|
+
failedMessages[injection.key] = 'Participant does not meet popularity threshold.'
|
|
42
|
+
continue
|
|
53
43
|
}
|
|
54
44
|
|
|
55
45
|
const elementIndex = elements.findIndex(element => cleanPhrase(element.innerText).includes(cleanPhrase(injection.sentence)))
|
|
@@ -7,11 +7,6 @@ export type ConfigResponse = {
|
|
|
7
7
|
*/
|
|
8
8
|
exclude_urls_pattern?: string
|
|
9
9
|
|
|
10
|
-
/**
|
|
11
|
-
* Similar to `exclude_urls_pattern` but limited to participant injections. Other injections will continue to function.
|
|
12
|
-
*/
|
|
13
|
-
exclude_participants_urls_pattern?: string
|
|
14
|
-
|
|
15
10
|
/**
|
|
16
11
|
* Used to inject custom styling for the links, modal, and popover. All styling is done via CSS variables. The passed
|
|
17
12
|
* string should not contain a selector.
|
package/src/lib/url.ts
CHANGED
|
@@ -27,7 +27,3 @@ export function paramsToString(params: Record<string, any>): string {
|
|
|
27
27
|
export function isUrlExcludedViaConfig(config: ConfigResponse): boolean {
|
|
28
28
|
return !!(config.exclude_urls_pattern && getFullUrlPath().match(new RegExp(config.exclude_urls_pattern)))
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
export function isParticipantsUrlExcludedViaConfig(config: ConfigResponse): boolean {
|
|
32
|
-
return !!(config.exclude_participants_urls_pattern && getFullUrlPath().match(new RegExp(config.exclude_participants_urls_pattern)))
|
|
33
|
-
}
|
|
@@ -6,18 +6,23 @@
|
|
|
6
6
|
import { onDestroy } from 'svelte'
|
|
7
7
|
import Tooltip from '../Tooltip.svelte'
|
|
8
8
|
import Disclaimer from './Disclaimer.svelte'
|
|
9
|
+
import { getSplitTestVariantName } from '$lib/splitTest'
|
|
10
|
+
import { SplitTest } from '$lib/enums/SplitTest'
|
|
9
11
|
|
|
10
12
|
interface Props {
|
|
11
13
|
campaign: Campaign
|
|
12
14
|
compact?: boolean
|
|
15
|
+
slim?: boolean
|
|
13
16
|
}
|
|
14
17
|
|
|
15
|
-
const { campaign, compact = false }: Props = $props()
|
|
18
|
+
const { campaign, compact = false, slim = false }: Props = $props()
|
|
16
19
|
|
|
17
20
|
const { disclaimer, content, cta, campaign_type } = $derived(campaign)
|
|
18
21
|
const { header, subheader, header_logo: logo, image, video } = $derived(content)
|
|
19
22
|
const { header: buttonLabel, url: href, subheader: info } = $derived(cta)
|
|
20
23
|
|
|
24
|
+
const tall = slim && getSplitTestVariantName(SplitTest.DisplayAdFormat) === 'Tall'
|
|
25
|
+
|
|
21
26
|
let contentHeight = $state(0)
|
|
22
27
|
let videoElement: HTMLVideoElement | null = $state(null)
|
|
23
28
|
|
|
@@ -34,8 +39,8 @@
|
|
|
34
39
|
})
|
|
35
40
|
</script>
|
|
36
41
|
|
|
37
|
-
<a {href} target="_blank" class="display" class:compact rel="sponsored" {onclick} use:middlemouse={{ onclick }}>
|
|
38
|
-
{#if info}
|
|
42
|
+
<a {href} target="_blank" class="display" class:compact class:slim class:tall rel="sponsored" {onclick} use:middlemouse={{ onclick }}>
|
|
43
|
+
{#if info && !slim}
|
|
39
44
|
<div class="info">
|
|
40
45
|
{#if compact}
|
|
41
46
|
<Tooltip>
|
|
@@ -62,7 +67,7 @@
|
|
|
62
67
|
<span class="name">{header}</span>
|
|
63
68
|
{/if}
|
|
64
69
|
|
|
65
|
-
{#if subheader}
|
|
70
|
+
{#if subheader && !slim}
|
|
66
71
|
<div class="subheader">{subheader}</div>
|
|
67
72
|
{/if}
|
|
68
73
|
</div>
|
|
@@ -90,6 +95,8 @@
|
|
|
90
95
|
</a>
|
|
91
96
|
|
|
92
97
|
<style lang="scss">
|
|
98
|
+
$background-color: rgb(110, 110, 110);
|
|
99
|
+
|
|
93
100
|
.display {
|
|
94
101
|
display: block;
|
|
95
102
|
position: relative;
|
|
@@ -102,6 +109,16 @@
|
|
|
102
109
|
font-family: theme(detail-font-family, font-family);
|
|
103
110
|
line-height: 1.2;
|
|
104
111
|
font-style: normal !important;
|
|
112
|
+
|
|
113
|
+
&.slim {
|
|
114
|
+
aspect-ratio: unset;
|
|
115
|
+
height: margin(5.5);
|
|
116
|
+
background: $background-color;
|
|
117
|
+
|
|
118
|
+
&.tall {
|
|
119
|
+
height: margin(8);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
105
122
|
}
|
|
106
123
|
|
|
107
124
|
.info {
|
|
@@ -131,7 +148,7 @@
|
|
|
131
148
|
bottom: 0;
|
|
132
149
|
left: 0;
|
|
133
150
|
padding: margin(0.5);
|
|
134
|
-
background: linear-gradient(to right,
|
|
151
|
+
background: linear-gradient(to right, $background-color, rgba(85, 85, 85, 0.3));
|
|
135
152
|
font-size: margin(0.875);
|
|
136
153
|
text-decoration: none;
|
|
137
154
|
|
|
@@ -142,10 +159,25 @@
|
|
|
142
159
|
padding: margin(0.75);
|
|
143
160
|
}
|
|
144
161
|
}
|
|
162
|
+
|
|
163
|
+
.slim & {
|
|
164
|
+
background: transparent;
|
|
165
|
+
padding-left: margin(10.5);
|
|
166
|
+
height: 100%;
|
|
167
|
+
font-size: theme(font-size-small);
|
|
168
|
+
}
|
|
145
169
|
}
|
|
146
170
|
|
|
147
171
|
.logo {
|
|
148
172
|
border-radius: theme(display-ad-border-radius, border-radius);
|
|
173
|
+
|
|
174
|
+
.slim & {
|
|
175
|
+
position: absolute;
|
|
176
|
+
width: margin(1.5);
|
|
177
|
+
height: margin(1.5);
|
|
178
|
+
bottom: margin(0.5);
|
|
179
|
+
left: margin(0.5);
|
|
180
|
+
}
|
|
149
181
|
}
|
|
150
182
|
|
|
151
183
|
.name {
|
|
@@ -176,11 +208,26 @@
|
|
|
176
208
|
display: block;
|
|
177
209
|
width: 100%;
|
|
178
210
|
height: auto;
|
|
211
|
+
|
|
212
|
+
.slim & {
|
|
213
|
+
width: auto;
|
|
214
|
+
height: 100%;
|
|
215
|
+
aspect-ratio: 16 / 9;
|
|
216
|
+
background: black;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
.tall & {
|
|
220
|
+
mask-image: linear-gradient(to right, white 50%, transparent);
|
|
221
|
+
}
|
|
179
222
|
}
|
|
180
223
|
|
|
181
224
|
.disclaimer {
|
|
182
225
|
position: absolute;
|
|
183
226
|
bottom: calc(var(--offset) + margin(0.25));
|
|
184
227
|
right: margin(0.25);
|
|
228
|
+
|
|
229
|
+
.slim & {
|
|
230
|
+
bottom: margin(0.25);
|
|
231
|
+
}
|
|
185
232
|
}
|
|
186
233
|
</style>
|
|
@@ -76,6 +76,8 @@
|
|
|
76
76
|
campaign_name: 'some_campaign',
|
|
77
77
|
// @ts-ignore
|
|
78
78
|
content: {
|
|
79
|
+
header_logo: 'https://placehold.co/50?text=content.header_logo',
|
|
80
|
+
image: 'https://placehold.co/320x180/333/666?text=content.image',
|
|
79
81
|
header: 'Content header',
|
|
80
82
|
subheader: 'Content subheader',
|
|
81
83
|
},
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
import IconArrow from '../Icons/IconArrow.svelte'
|
|
10
10
|
import ModalCloseOverlay from './ModalCloseOverlay.svelte'
|
|
11
11
|
import Display from '../Ads/Display.svelte'
|
|
12
|
+
import { SplitTest } from '$lib/enums/SplitTest'
|
|
13
|
+
import { getSplitTestVariantName, trackSplitTestView } from '$lib/splitTest'
|
|
12
14
|
|
|
13
15
|
interface Props {
|
|
14
16
|
items: Record<string, any>[]
|
|
@@ -27,6 +29,8 @@
|
|
|
27
29
|
let element: HTMLElement | null = $state(null)
|
|
28
30
|
let displayAd = $state(getFirstAdOfType('card'))
|
|
29
31
|
|
|
32
|
+
if (!!displayAd) trackSplitTestView(SplitTest.DisplayAdFormat)
|
|
33
|
+
|
|
30
34
|
onMount(() => {
|
|
31
35
|
setAvailableHeight()
|
|
32
36
|
|
|
@@ -52,17 +56,21 @@
|
|
|
52
56
|
return
|
|
53
57
|
}
|
|
54
58
|
|
|
55
|
-
|
|
56
|
-
|
|
59
|
+
availableHeight = 0
|
|
60
|
+
|
|
61
|
+
requestAnimationFrame(() => {
|
|
62
|
+
const modal = document.querySelector('.modal')!
|
|
63
|
+
availableHeight = window.innerHeight - (element!.getBoundingClientRect().top + modal.scrollTop + parseInt(window.getComputedStyle(modal).paddingBottom))
|
|
64
|
+
})
|
|
57
65
|
}
|
|
58
66
|
</script>
|
|
59
67
|
|
|
60
68
|
<svelte:window onresize={setAvailableHeight} onupdateads={() => displayAd = getFirstAdOfType('card')} />
|
|
61
69
|
|
|
62
70
|
{#snippet prepend()}
|
|
63
|
-
{#if displayAd}
|
|
71
|
+
{#if displayAd && getSplitTestVariantName(SplitTest.DisplayAdFormat) !== 'Inline'}
|
|
64
72
|
<div class="ad">
|
|
65
|
-
<Display campaign={displayAd} />
|
|
73
|
+
<Display campaign={displayAd} slim />
|
|
66
74
|
</div>
|
|
67
75
|
{/if}
|
|
68
76
|
{/snippet}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import { SplitTest } from '$lib/enums/SplitTest'
|
|
2
3
|
import { TrackingEvent } from '$lib/enums/TrackingEvent'
|
|
4
|
+
import { getSplitTestVariantName } from '$lib/splitTest'
|
|
3
5
|
import { track } from '$lib/tracking'
|
|
4
6
|
import type { TitleData } from '$lib/types/title'
|
|
5
7
|
import Title from '../Title.svelte'
|
|
@@ -16,6 +18,6 @@
|
|
|
16
18
|
|
|
17
19
|
<RailModal items={titles} {initialIndex} {onclose} onchange={(index) => track(TrackingEvent.ExploreTitleRailSetIndex, titles[index], { index })} {...restProps}>
|
|
18
20
|
{#snippet each(title, currentIndex)}
|
|
19
|
-
<Title {title} useVideoBackground={title.sid === titles[currentIndex]?.sid} />
|
|
21
|
+
<Title {title} useVideoBackground={title.sid === titles[currentIndex]?.sid} useDisplayAdSplitTest={getSplitTestVariantName(SplitTest.DisplayAdFormat) === 'Inline'} />
|
|
20
22
|
{/snippet}
|
|
21
23
|
</RailModal>
|
|
@@ -7,11 +7,14 @@
|
|
|
7
7
|
import type { TitleData } from '$lib/types/title'
|
|
8
8
|
import { heading } from '$lib/actions/heading'
|
|
9
9
|
import { campaignToPlaylink, getFirstAdOfType } from '$lib/api/ads'
|
|
10
|
-
import { getContext } from 'svelte'
|
|
10
|
+
import { getContext, type Snippet } from 'svelte'
|
|
11
11
|
import Playlink from './Playlink.svelte'
|
|
12
12
|
import Button from '../Button.svelte'
|
|
13
13
|
import PlaylinksDisclaimer from './PlaylinksDisclaimer.svelte'
|
|
14
14
|
import { getConfigValue } from '$lib/api/config'
|
|
15
|
+
import { getSplitTestVariantName } from '$lib/splitTest'
|
|
16
|
+
import { SplitTest } from '$lib/enums/SplitTest'
|
|
17
|
+
import Display from '../Ads/Display.svelte'
|
|
15
18
|
|
|
16
19
|
type Category = PlaylinkCategory | '' | 'Other'
|
|
17
20
|
type CategorizedPlaylinks = Partial<Record<Category, PlaylinkData[]>>
|
|
@@ -21,9 +24,10 @@
|
|
|
21
24
|
playlinks: PlaylinkData[]
|
|
22
25
|
title: TitleData
|
|
23
26
|
limit?: number
|
|
27
|
+
children?: Snippet
|
|
24
28
|
}
|
|
25
29
|
|
|
26
|
-
const { playlinks, title, limit = 3 }: Props = $props()
|
|
30
|
+
const { playlinks, title, limit = 3, children }: Props = $props()
|
|
27
31
|
|
|
28
32
|
const isModal = getContext('scope') === 'modal'
|
|
29
33
|
const type = getContext('type')
|
|
@@ -94,7 +98,11 @@
|
|
|
94
98
|
|
|
95
99
|
<!-- A fake highlighted playlink as part of the display ad, to be shown after the first playlink -->
|
|
96
100
|
{#if displayAd && (index === 0)}
|
|
97
|
-
|
|
101
|
+
{#if children}
|
|
102
|
+
{@render children()}
|
|
103
|
+
{:else}
|
|
104
|
+
<Playlink playlink={campaignToPlaylink(displayAd)} onclick={() => track(TrackingEvent.DisplayedAdPlaylickClick, title, { campaign_name: displayAd.campaign_name })} hideCategory disclaimer={displayAd.disclaimer || ''} />
|
|
105
|
+
{/if}
|
|
98
106
|
{/if}
|
|
99
107
|
{/each}
|
|
100
108
|
</div>
|
|
@@ -14,14 +14,18 @@
|
|
|
14
14
|
import { TrackingEvent } from '$lib/enums/TrackingEvent'
|
|
15
15
|
import TitleBackground from './TitleBackground.svelte'
|
|
16
16
|
import TitleInfo from './TitleInfo.svelte'
|
|
17
|
+
import Display from './Ads/Display.svelte'
|
|
18
|
+
import type { Campaign } from '$lib/types/campaign'
|
|
19
|
+
import { getFirstAdOfType } from '$lib/api/ads'
|
|
17
20
|
|
|
18
21
|
interface Props {
|
|
19
22
|
title: TitleData
|
|
20
23
|
small?: boolean
|
|
21
24
|
useVideoBackground?: boolean
|
|
25
|
+
useDisplayAdSplitTest?: boolean // NOTE: Temporary split test, remove me after the DisplayAdFormat split test is gone
|
|
22
26
|
}
|
|
23
27
|
|
|
24
|
-
const { title, small = false, useVideoBackground = true }: Props = $props()
|
|
28
|
+
const { title, small = false, useVideoBackground = true, useDisplayAdSplitTest = false }: Props = $props()
|
|
25
29
|
|
|
26
30
|
const noAffiliate = !!window.PlayPilotLinkInjections?.no_affiliate
|
|
27
31
|
|
|
@@ -58,7 +62,11 @@
|
|
|
58
62
|
{/if}
|
|
59
63
|
|
|
60
64
|
{#if !noAffiliate}
|
|
61
|
-
<Playlinks playlinks={title.providers} {title}
|
|
65
|
+
<Playlinks playlinks={title.providers} {title}>
|
|
66
|
+
{#if useDisplayAdSplitTest && getFirstAdOfType('card')}
|
|
67
|
+
<Display campaign={getFirstAdOfType('card')!} />
|
|
68
|
+
{/if}
|
|
69
|
+
</Playlinks>
|
|
62
70
|
{/if}
|
|
63
71
|
|
|
64
72
|
<ParticipantsRail {title} />
|
|
@@ -39,10 +39,21 @@
|
|
|
39
39
|
|
|
40
40
|
// Used to re-render some elements with a key
|
|
41
41
|
let renderKey = Math.random()
|
|
42
|
+
|
|
43
|
+
function insertMockAd(): void {
|
|
44
|
+
// @ts-ignore
|
|
45
|
+
window.PlayPilotLinkInjections.consents = {
|
|
46
|
+
ads: true
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
window.PlayPilotLinkInjections.ads = [campaign]
|
|
50
|
+
}
|
|
42
51
|
</script>
|
|
43
52
|
|
|
44
53
|
<h1>Elements</h1>
|
|
45
54
|
|
|
55
|
+
<button onclick={insertMockAd}>Insert mock ad</button>
|
|
56
|
+
|
|
46
57
|
<p>This page lays out various elements used in TPI. It does not currently include editor elements.</p>
|
|
47
58
|
|
|
48
59
|
<h2>Youtube Embed</h2>
|
|
@@ -173,7 +184,15 @@
|
|
|
173
184
|
<div class="group">
|
|
174
185
|
<div>
|
|
175
186
|
<h3>Ads/Display.svelte</h3>
|
|
176
|
-
<div class="item"
|
|
187
|
+
<div class="item">
|
|
188
|
+
<Display {campaign} />
|
|
189
|
+
|
|
190
|
+
Compact (Used in popover)
|
|
191
|
+
<Display {campaign} compact />
|
|
192
|
+
|
|
193
|
+
Slim (Used in rail modals)
|
|
194
|
+
<Display {campaign} slim />
|
|
195
|
+
</div>
|
|
177
196
|
</div>
|
|
178
197
|
|
|
179
198
|
<div>
|