@playpilot/tpi 8.42.0-beta.1 → 8.42.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.
@@ -1,142 +1,158 @@
1
- import type { InsertPosition } from './position'
2
-
3
- export type ConfigResponse = {
4
- /**
5
- * Used to exclude URL matching a regex pattern. If a url matches, nothing is executed beyond fetching the config.
6
- * The url should never be indexed.
7
- */
8
- exclude_urls_pattern?: string
9
-
10
- /**
11
- * Used to inject custom styling for the links, modal, and popover. All styling is done via CSS variables. The passed
12
- * string should not contain a selector.
13
- * For example:
14
- * `--some-variable: some-value;`
15
- *
16
- * rather than:
17
- * `body { --some-variable: some-value; }`
18
- */
19
- custom_style?: string
20
-
21
- /**
22
- * The primary selector for the entire article from which text will be selected. Should contain as little content as
23
- * possible. Should match all pages. May contain multiple selectors like `.article, .listicle`.
24
- */
25
- html_selector?: string
26
-
27
- /**
28
- * Some pages contain elements that can't easily be excluded via the `html_selector`. These elements can instead be
29
- * excluded via this property. May contain multiple selectors like `.footer, .ad`.
30
- */
31
- exclude_elements_selector?: string
32
-
33
- /**
34
- * Disable all injections from showing on pages without editorial mode enabled
35
- */
36
- disable_public_injections?: boolean
37
-
38
- /**
39
- * Region to fall back on if other methods of getting the region fail. This should be equal to the region most relevant
40
- * to the partner. Should be lowercase.
41
- */
42
- fallback_region?: string
43
-
44
- /**
45
- * Disclaimer text that is shown above playlinks in title cards used to replace the default text
46
- */
47
- playlinks_disclaimer_text?: string
48
-
49
- /**
50
- * Some partners may want to display titles without affiliate links, which currently comes down to no playlinks.
51
- * This can also be set via the config on the script itself.
52
- */
53
- no_affiliate?: boolean
54
-
55
- /**
56
- * Whether or not we can insert retargeting pixels. Not all third parties allow this and it is disabled by default
57
- */
58
- allow_retargeting_pixels?: boolean
59
-
60
- /**
61
- * 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.
62
- */
63
- require_affiliate_consent?: boolean
64
-
65
- /**
66
- * Scroll reveal posters that show on mobile are enabled by default. Use this option to disable them.
67
- */
68
- disable_scroll_reveal_posters?: boolean
69
-
70
- /**
71
- * Playlinks are merged by default, when this option is enabled playlinks will instead be shown categorized.
72
- */
73
- categorize_playlinks?: boolean
74
-
75
- /**
76
- * By default no user identifiable data is tracked. This can be changed using this option. User ids are stored in localStorage and sent along with any tracking request.
77
- */
78
- allow_user_id_tracking?: boolean
79
-
80
- /**
81
- * The sid for the current domain, used for tracking
82
- */
83
- domain_sid?: string
84
-
85
- /**
86
- * The sid for the organization the domain belongs to, used for tracking. Can be empty.
87
- */
88
- organization_sid?: string
89
-
90
- /**
91
- * The following options are all relevant for in text disclaimers, which renders as a disclaimer text within the article,
92
- * rather than only inside of title cards.
93
- * Change the text content using `in_text_disclaimer_text`.
94
- * Change where the element is inserted using `in_text_disclaimer_selector`, by default it will insert before the first text element.
95
- * Change the insert position using `in_text_disclaimer_insert_position`, by default it will insert before the given selector.
96
- */
97
- in_text_disclaimer_enabled?: boolean
98
- in_text_disclaimer_text?: string
99
- in_text_disclaimer_selector?: string
100
- in_text_disclaimer_insert_position?: InsertPosition
101
-
102
- /**
103
- * Open TPI links in explore rather than in modals in the article
104
- */
105
- open_tpi_links_in_explore?: boolean
106
-
107
- /**
108
- * Participants with a popularity score lower than this threshold will not be injected
109
- */
110
- participant_injection_popularity_threshold?: number
111
-
112
- /**
113
- * Whether or not to base the threshold on the article participants average popularity score.
114
- * When enabled, this turns `participant_injection_popularity_threshold` into a percentage.
115
- */
116
- participant_injection_popularity_threshold_use_article_average?: boolean
117
-
118
- /**
119
- * Include a limit of how many times a single titles/participants may appear in one article.
120
- */
121
- unique_injection_count_limit?: number
122
-
123
- /**
124
- * No more than this count of participant links will show on the entire article.
125
- */
126
- total_participant_injection_count_limit?: number
127
-
128
- /**
129
- * These options are all relevant for the Explore component, which can be inserted as a widget on any page or as a modal.
130
- * `explore_navigation_selector` is used to select the navigation element that should be copied and inserted _after_.
131
- * `explore_navigation_label` will end up being the label of the navigation item, defaults to `Streaming Guide`.
132
- * `explore_navigation_path` is the path that the navigation item will lead to, this will be set up by the third party.
133
- * `explore_navigation_insert_position` is used to determine if the navigation item should be inserted before or after the given selector.
134
- * `explore_insert_cta_in_tpi` is used to insert a call to action in modals which opens the explore page as a modal.
135
- */
136
- explore_navigation_selector?: string
137
- explore_navigation_label?: string
138
- explore_navigation_path?: string
139
- explore_navigation_insert_position?: InsertPosition
140
- explore_insert_cta_in_tpi?: boolean
141
- explore_custom_style?: string
142
- }
1
+ import type { LinkInjection } from './injection'
2
+ import type { InsertPosition } from './position'
3
+
4
+ export type ConfigResponse = {
5
+ /**
6
+ * Used to exclude URL matching a regex pattern. If a url matches, nothing is executed beyond fetching the config.
7
+ * The url should never be indexed.
8
+ */
9
+ exclude_urls_pattern?: string
10
+
11
+ /**
12
+ * Similar to `exclude_urls_pattern` but limited to participant injections. Other injections will continue to function.
13
+ */
14
+ exclude_participants_urls_pattern?: string
15
+
16
+ /**
17
+ * Used to inject custom styling for the links, modal, and popover. All styling is done via CSS variables. The passed
18
+ * string should not contain a selector.
19
+ * For example:
20
+ * `--some-variable: some-value;`
21
+ *
22
+ * rather than:
23
+ * `body { --some-variable: some-value; }`
24
+ */
25
+ custom_style?: string
26
+
27
+ /**
28
+ * The primary selector for the entire article from which text will be selected. Should contain as little content as
29
+ * possible. Should match all pages. May contain multiple selectors like `.article, .listicle`.
30
+ */
31
+ html_selector?: string
32
+
33
+ /**
34
+ * Some pages contain elements that can't easily be excluded via the `html_selector`. These elements can instead be
35
+ * excluded via this property. May contain multiple selectors like `.footer, .ad`.
36
+ */
37
+ exclude_elements_selector?: string
38
+
39
+ /**
40
+ * Disable all injections from showing on pages without editorial mode enabled
41
+ */
42
+ disable_public_injections?: boolean
43
+
44
+ /**
45
+ * Region to fall back on if other methods of getting the region fail. This should be equal to the region most relevant
46
+ * to the partner. Should be lowercase.
47
+ */
48
+ fallback_region?: string
49
+
50
+ /**
51
+ * Disclaimer text that is shown above playlinks in title cards used to replace the default text
52
+ */
53
+ playlinks_disclaimer_text?: string
54
+
55
+ /**
56
+ * Some partners may want to display titles without affiliate links, which currently comes down to no playlinks.
57
+ * This can also be set via the config on the script itself.
58
+ */
59
+ no_affiliate?: boolean
60
+
61
+ /**
62
+ * Whether or not we can insert retargeting pixels. Not all third parties allow this and it is disabled by default
63
+ */
64
+ allow_retargeting_pixels?: boolean
65
+
66
+ /**
67
+ * 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.
68
+ */
69
+ require_affiliate_consent?: boolean
70
+
71
+ /**
72
+ * Scroll reveal posters that show on mobile are enabled by default. Use this option to disable them.
73
+ */
74
+ disable_scroll_reveal_posters?: boolean
75
+
76
+ /**
77
+ * Playlinks are merged by default, when this option is enabled playlinks will instead be shown categorized.
78
+ */
79
+ categorize_playlinks?: boolean
80
+
81
+ /**
82
+ * By default no user identifiable data is tracked. This can be changed using this option. User ids are stored in localStorage and sent along with any tracking request.
83
+ */
84
+ allow_user_id_tracking?: boolean
85
+
86
+ /**
87
+ * The sid for the current domain, used for tracking
88
+ */
89
+ domain_sid?: string
90
+
91
+ /**
92
+ * The sid for the organization the domain belongs to, used for tracking. Can be empty.
93
+ */
94
+ organization_sid?: string
95
+
96
+ /**
97
+ * The following options are all relevant for in text disclaimers, which renders as a disclaimer text within the article,
98
+ * rather than only inside of title cards.
99
+ * Change the text content using `in_text_disclaimer_text`.
100
+ * Change where the element is inserted using `in_text_disclaimer_selector`, by default it will insert before the first text element.
101
+ * Change the insert position using `in_text_disclaimer_insert_position`, by default it will insert before the given selector.
102
+ */
103
+ in_text_disclaimer_enabled?: boolean
104
+ in_text_disclaimer_text?: string
105
+ in_text_disclaimer_selector?: string
106
+ in_text_disclaimer_insert_position?: InsertPosition
107
+
108
+ /**
109
+ * Open TPI links in explore rather than in modals in the article
110
+ */
111
+ open_tpi_links_in_explore?: boolean
112
+
113
+ /**
114
+ * Participants with a popularity score lower than this threshold will not be injected
115
+ */
116
+ participant_injection_popularity_threshold?: number
117
+
118
+ /**
119
+ * Whether or not to base the threshold on the article participants average popularity score.
120
+ * When enabled, this turns `participant_injection_popularity_threshold` into a percentage.
121
+ */
122
+ participant_injection_popularity_threshold_use_article_average?: boolean
123
+
124
+ /**
125
+ * Include a limit of how many times a single titles/participants may appear in one article.
126
+ */
127
+ unique_injection_count_limit?: number
128
+
129
+ /**
130
+ * No more than this count of participant links will show on the entire article.
131
+ */
132
+ total_participant_injection_count_limit?: number
133
+
134
+ /**
135
+ * Exclude any injections that use one of the given anchors
136
+ */
137
+ exclude_injections_by_anchors?: LinkInjection['anchor'][]
138
+
139
+ /**
140
+ * Exclude any injections that use one of the given evidence
141
+ */
142
+ exclude_injections_by_evidence?: LinkInjection['evidence'][]
143
+
144
+ /**
145
+ * These options are all relevant for the Explore component, which can be inserted as a widget on any page or as a modal.
146
+ * `explore_navigation_selector` is used to select the navigation element that should be copied and inserted _after_.
147
+ * `explore_navigation_label` will end up being the label of the navigation item, defaults to `Streaming Guide`.
148
+ * `explore_navigation_path` is the path that the navigation item will lead to, this will be set up by the third party.
149
+ * `explore_navigation_insert_position` is used to determine if the navigation item should be inserted before or after the given selector.
150
+ * `explore_insert_cta_in_tpi` is used to insert a call to action in modals which opens the explore page as a modal.
151
+ */
152
+ explore_navigation_selector?: string
153
+ explore_navigation_label?: string
154
+ explore_navigation_path?: string
155
+ explore_navigation_insert_position?: InsertPosition
156
+ explore_insert_cta_in_tpi?: boolean
157
+ explore_custom_style?: string
158
+ }
@@ -1,59 +1,65 @@
1
- import type { ParticipantData } from './participant'
2
- import type { TitleData } from './title'
3
-
4
- export type LinkInjectionDataType = 'title' | 'participant'
5
-
6
- export type LinkInjection = {
7
- sid: string
8
- title: string
9
- sentence: string
10
- playpilot_url: string
11
- key: string
12
- title_details?: TitleData
13
- participant_details?: ParticipantData
14
- phrase_before?: string | null
15
- phrase_after?: string | null
16
- inactive?: boolean
17
- failed?: boolean
18
- failed_message?: string
19
- in_text?: boolean
20
- after_article?: boolean
21
- after_article_style?: 'modal_button' | 'playlinks' | null
22
- manual?: boolean
23
- removed?: boolean
24
- duplicate?: boolean
25
- matchingElement?: null | Element
26
- popularity?: number | null
27
- type: LinkInjectionDataType
28
- }
29
-
30
- export type LinkInjectionRanges = Record<string, { elementIndex: number, from: number, to: number }>
31
-
32
- export type LinkInjectionResponse = {
33
- injections_ready: boolean
34
- ai_enabled: boolean
35
- injections_enabled: boolean
36
- ai_running: boolean
37
- ai_injections: LinkInjection[] | null
38
- ai_progress_message: string
39
- ai_progress_percentage: number
40
- ai_last_run: string | null
41
- manual_injections: LinkInjection[] | null
42
- organization_sid?: string
43
- domain_sid?: string
44
- session_id?: string | null
45
- session_last_ping?: string | null
46
- content_modified_time?: string | null
47
- pixels?: string[]
48
- }
49
-
50
- export type LinkInjectionTypes = {
51
- aiInjections: LinkInjection[]
52
- manualInjections: LinkInjection[]
53
- }
54
-
55
- export type ArticleMetaData = {
56
- content_heading: string | null
57
- content_modified_time: string | null
58
- content_published_time: string | null
59
- }
1
+ import type { ParticipantData } from './participant'
2
+ import type { TitleData } from './title'
3
+
4
+ export type LinkInjectionDataType = 'title' | 'participant'
5
+
6
+ export type LinkInjection = {
7
+ sid: string
8
+ title: string
9
+ sentence: string
10
+ playpilot_url: string
11
+ key: string
12
+ title_details?: TitleData
13
+ participant_details?: ParticipantData
14
+ phrase_before?: string | null
15
+ phrase_after?: string | null
16
+ inactive?: boolean
17
+ failed?: boolean
18
+ failed_message?: string
19
+ in_text?: boolean
20
+ after_article?: boolean
21
+ after_article_style?: 'modal_button' | 'playlinks' | null
22
+ manual?: boolean
23
+ removed?: boolean
24
+ duplicate?: boolean
25
+ matchingElement?: null | Element
26
+ popularity?: number | null
27
+ anchor?: 'full' | 'attached' | 'bare' | null
28
+ evidence?: 'credited' | 'screen_work' | 'title_mention' | 'name_only' | null
29
+ type: LinkInjectionDataType
30
+ }
31
+
32
+ export type LinkInjectionRanges = Record<string, {
33
+ elementIndex: number
34
+ from: number
35
+ to: number
36
+ }>
37
+
38
+ export type LinkInjectionResponse = {
39
+ injections_ready: boolean
40
+ ai_enabled: boolean
41
+ injections_enabled: boolean
42
+ ai_running: boolean
43
+ ai_injections: LinkInjection[] | null
44
+ ai_progress_message: string
45
+ ai_progress_percentage: number
46
+ ai_last_run: string | null
47
+ manual_injections: LinkInjection[] | null
48
+ organization_sid?: string
49
+ domain_sid?: string
50
+ session_id?: string | null
51
+ session_last_ping?: string | null
52
+ content_modified_time?: string | null
53
+ pixels?: string[]
54
+ }
55
+
56
+ export type LinkInjectionTypes = {
57
+ aiInjections: LinkInjection[]
58
+ manualInjections: LinkInjection[]
59
+ }
60
+
61
+ export type ArticleMetaData = {
62
+ content_heading: string | null
63
+ content_modified_time: string | null
64
+ content_published_time: string | null
65
+ }
package/src/lib/url.ts CHANGED
@@ -27,3 +27,7 @@ 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,23 +6,18 @@
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'
11
9
 
12
10
  interface Props {
13
11
  campaign: Campaign
14
12
  compact?: boolean
15
- slim?: boolean
16
13
  }
17
14
 
18
- const { campaign, compact = false, slim = false }: Props = $props()
15
+ const { campaign, compact = false }: Props = $props()
19
16
 
20
17
  const { disclaimer, content, cta, campaign_type } = $derived(campaign)
21
18
  const { header, subheader, header_logo: logo, image, video } = $derived(content)
22
19
  const { header: buttonLabel, url: href, subheader: info } = $derived(cta)
23
20
 
24
- const tall = slim && getSplitTestVariantName(SplitTest.DisplayAdFormat) === 'Tall'
25
-
26
21
  let contentHeight = $state(0)
27
22
  let videoElement: HTMLVideoElement | null = $state(null)
28
23
 
@@ -39,8 +34,8 @@
39
34
  })
40
35
  </script>
41
36
 
42
- <a {href} target="_blank" class="display" class:compact class:slim class:tall rel="sponsored" {onclick} use:middlemouse={{ onclick }}>
43
- {#if info && !slim}
37
+ <a {href} target="_blank" class="display" class:compact rel="sponsored" {onclick} use:middlemouse={{ onclick }}>
38
+ {#if info}
44
39
  <div class="info">
45
40
  {#if compact}
46
41
  <Tooltip>
@@ -67,7 +62,7 @@
67
62
  <span class="name">{header}</span>
68
63
  {/if}
69
64
 
70
- {#if subheader && !slim}
65
+ {#if subheader}
71
66
  <div class="subheader">{subheader}</div>
72
67
  {/if}
73
68
  </div>
@@ -95,8 +90,6 @@
95
90
  </a>
96
91
 
97
92
  <style lang="scss">
98
- $background-color: rgb(110, 110, 110);
99
-
100
93
  .display {
101
94
  display: block;
102
95
  position: relative;
@@ -109,16 +102,6 @@
109
102
  font-family: theme(detail-font-family, font-family);
110
103
  line-height: 1.2;
111
104
  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
- }
122
105
  }
123
106
 
124
107
  .info {
@@ -148,7 +131,7 @@
148
131
  bottom: 0;
149
132
  left: 0;
150
133
  padding: margin(0.5);
151
- background: linear-gradient(to right, $background-color, rgba(85, 85, 85, 0.3));
134
+ background: linear-gradient(to right, rgba(110, 110, 110, 1), rgba(85, 85, 85, 0.3));
152
135
  font-size: margin(0.875);
153
136
  text-decoration: none;
154
137
 
@@ -159,25 +142,10 @@
159
142
  padding: margin(0.75);
160
143
  }
161
144
  }
162
-
163
- .slim & {
164
- background: transparent;
165
- padding-left: margin(10.5);
166
- height: 100%;
167
- font-size: theme(font-size-small);
168
- }
169
145
  }
170
146
 
171
147
  .logo {
172
148
  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
- }
181
149
  }
182
150
 
183
151
  .name {
@@ -208,26 +176,11 @@
208
176
  display: block;
209
177
  width: 100%;
210
178
  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
- }
222
179
  }
223
180
 
224
181
  .disclaimer {
225
182
  position: absolute;
226
183
  bottom: calc(var(--offset) + margin(0.25));
227
184
  right: margin(0.25);
228
-
229
- .slim & {
230
- bottom: margin(0.25);
231
- }
232
185
  }
233
186
  </style>
@@ -76,8 +76,6 @@
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',
81
79
  header: 'Content header',
82
80
  subheader: 'Content subheader',
83
81
  },
@@ -9,8 +9,6 @@
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'
14
12
 
15
13
  interface Props {
16
14
  items: Record<string, any>[]
@@ -29,8 +27,6 @@
29
27
  let element: HTMLElement | null = $state(null)
30
28
  let displayAd = $state(getFirstAdOfType('card'))
31
29
 
32
- if (!!displayAd) trackSplitTestView(SplitTest.DisplayAdFormat)
33
-
34
30
  onMount(() => {
35
31
  setAvailableHeight()
36
32
 
@@ -56,21 +52,17 @@
56
52
  return
57
53
  }
58
54
 
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
- })
55
+ const modal = document.querySelector('.modal')!
56
+ availableHeight = window.innerHeight - (element!.getBoundingClientRect().top + modal.scrollTop + parseInt(window.getComputedStyle(modal).paddingBottom))
65
57
  }
66
58
  </script>
67
59
 
68
60
  <svelte:window onresize={setAvailableHeight} onupdateads={() => displayAd = getFirstAdOfType('card')} />
69
61
 
70
62
  {#snippet prepend()}
71
- {#if displayAd && getSplitTestVariantName(SplitTest.DisplayAdFormat) !== 'Inline'}
63
+ {#if displayAd}
72
64
  <div class="ad">
73
- <Display campaign={displayAd} slim />
65
+ <Display campaign={displayAd} />
74
66
  </div>
75
67
  {/if}
76
68
  {/snippet}
@@ -1,7 +1,5 @@
1
1
  <script lang="ts">
2
- import { SplitTest } from '$lib/enums/SplitTest'
3
2
  import { TrackingEvent } from '$lib/enums/TrackingEvent'
4
- import { getSplitTestVariantName } from '$lib/splitTest'
5
3
  import { track } from '$lib/tracking'
6
4
  import type { TitleData } from '$lib/types/title'
7
5
  import Title from '../Title.svelte'
@@ -18,6 +16,6 @@
18
16
 
19
17
  <RailModal items={titles} {initialIndex} {onclose} onchange={(index) => track(TrackingEvent.ExploreTitleRailSetIndex, titles[index], { index })} {...restProps}>
20
18
  {#snippet each(title, currentIndex)}
21
- <Title {title} useVideoBackground={title.sid === titles[currentIndex]?.sid} useDisplayAdSplitTest={getSplitTestVariantName(SplitTest.DisplayAdFormat) === 'Inline'} />
19
+ <Title {title} useVideoBackground={title.sid === titles[currentIndex]?.sid} />
22
20
  {/snippet}
23
21
  </RailModal>