@playpilot/tpi 6.6.2 → 6.6.4
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/link-injections.js +7 -7
- package/package.json +1 -1
- package/src/lib/tracking.ts +5 -0
- package/src/lib/types/config.d.ts +5 -0
- package/src/routes/components/Genres.svelte +2 -2
- package/src/routes/components/Playlinks/Playlink.svelte +2 -1
- package/src/tests/lib/tracking.test.js +38 -1
- package/src/tests/routes/components/Playlinks/Playlink.test.js +1 -0
- package/src/tests/routes/components/Playlinks/Playlinks.test.js +1 -0
- package/src/tests/routes/components/Title.test.js +1 -0
- package/src/tests/routes/components/TitleModal.test.js +1 -0
- package/src/tests/routes/components/TitlePopover.test.js +1 -0
package/package.json
CHANGED
package/src/lib/tracking.ts
CHANGED
|
@@ -98,3 +98,8 @@ export function fireQueuedTrackingEvents(): void {
|
|
|
98
98
|
|
|
99
99
|
window.PlayPilotLinkInjections.queued_tracking_events = []
|
|
100
100
|
}
|
|
101
|
+
|
|
102
|
+
export function isPixelAllowed(): boolean {
|
|
103
|
+
if (!window.PlayPilotLinkInjections.config?.allow_retargeting_pixels) return false
|
|
104
|
+
return hasConsentedTo('pixels')
|
|
105
|
+
}
|
|
@@ -44,6 +44,11 @@ export type ConfigResponse = {
|
|
|
44
44
|
*/
|
|
45
45
|
playlinks_disclaimer_text?: string
|
|
46
46
|
|
|
47
|
+
/**
|
|
48
|
+
* Whether or not we can insert retargeting pixels. Not all third parties allow this and it is disabled by default
|
|
49
|
+
*/
|
|
50
|
+
allow_retargeting_pixels?: boolean
|
|
51
|
+
|
|
47
52
|
/**
|
|
48
53
|
* The following options are all relevant for in text disclaimers, which renders as a disclaimer text within the article,
|
|
49
54
|
* rather than only inside of title cards.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { hasConsentedTo } from '$lib/consent'
|
|
3
2
|
import genreData from '$lib/data/genres.json'
|
|
4
3
|
import { MetaEvent } from '$lib/enums/TrackingEvent'
|
|
5
4
|
import { t } from '$lib/localization'
|
|
5
|
+
import { isPixelAllowed } from '$lib/tracking'
|
|
6
6
|
import { trackViewViaPixel } from '@playpilot/retargeting-tracking'
|
|
7
7
|
|
|
8
8
|
interface Props {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
{@const genreName = genreData.find(g => g.slug === genre)?.name}
|
|
20
20
|
|
|
21
21
|
{#if genreName}
|
|
22
|
-
<div class="genre" {@attach
|
|
22
|
+
<div class="genre" {@attach isPixelAllowed() ? trackViewViaPixel(MetaEvent.GenreInterest, { genre: genreName }) : null}>
|
|
23
23
|
{t(genreName)}
|
|
24
24
|
</div>
|
|
25
25
|
{/if}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import type { PlaylinkData } from '$lib/types/playlink'
|
|
8
8
|
import { trackClickViaPixel, trackViewViaPixel } from '@playpilot/retargeting-tracking'
|
|
9
9
|
import { MetaEvent } from '$lib/enums/TrackingEvent'
|
|
10
|
+
import { isPixelAllowed } from '$lib/tracking'
|
|
10
11
|
|
|
11
12
|
interface Props {
|
|
12
13
|
playlink: PlaylinkData
|
|
@@ -19,7 +20,7 @@
|
|
|
19
20
|
|
|
20
21
|
const { name, url, logo_url, highlighted, cta_text, action_text, pixels, extra_info: { category } } = $derived(playlink)
|
|
21
22
|
|
|
22
|
-
const usePixel = $derived(
|
|
23
|
+
const usePixel = $derived(isPixelAllowed() && !highlighted)
|
|
23
24
|
|
|
24
25
|
const categoryStrings = {
|
|
25
26
|
SVOD: t('Stream'),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
|
2
2
|
|
|
3
|
-
import { fireQueuedTrackingEvents, queueTrackingEvent, setTrackingSids, track } from '$lib/tracking'
|
|
3
|
+
import { fireQueuedTrackingEvents, isPixelAllowed, queueTrackingEvent, setTrackingSids, track } from '$lib/tracking'
|
|
4
4
|
import { title } from '$lib/fakeData'
|
|
5
5
|
import { getFullUrlPath } from '$lib/url'
|
|
6
6
|
import { fakeFetch } from '../helpers'
|
|
@@ -241,4 +241,41 @@ describe('$lib/tracking', () => {
|
|
|
241
241
|
expect(global.fetch).toHaveBeenCalledTimes(2)
|
|
242
242
|
})
|
|
243
243
|
})
|
|
244
|
+
|
|
245
|
+
describe('isPixelAllow', () => {
|
|
246
|
+
it('Should return false if no config object is set', () => {
|
|
247
|
+
vi.mocked(hasConsentedTo).mockImplementation(() => true)
|
|
248
|
+
window.PlayPilotLinkInjections.config = null
|
|
249
|
+
|
|
250
|
+
expect(isPixelAllowed()).toBe(false)
|
|
251
|
+
})
|
|
252
|
+
|
|
253
|
+
it('Should return false if config object is without allow_retargeting_pixels', () => {
|
|
254
|
+
vi.mocked(hasConsentedTo).mockImplementation(() => true)
|
|
255
|
+
window.PlayPilotLinkInjections.config = { something: true }
|
|
256
|
+
|
|
257
|
+
expect(isPixelAllowed()).toBe(false)
|
|
258
|
+
})
|
|
259
|
+
|
|
260
|
+
it('Should return false if config object is allow_retargeting_pixels is false', () => {
|
|
261
|
+
vi.mocked(hasConsentedTo).mockImplementation(() => true)
|
|
262
|
+
window.PlayPilotLinkInjections.config = { allow_retargeting_pixels: false }
|
|
263
|
+
|
|
264
|
+
expect(isPixelAllowed()).toBe(false)
|
|
265
|
+
})
|
|
266
|
+
|
|
267
|
+
it('Should return true if config object is allow_retargeting_pixels is true', () => {
|
|
268
|
+
vi.mocked(hasConsentedTo).mockImplementation(() => true)
|
|
269
|
+
window.PlayPilotLinkInjections.config = { allow_retargeting_pixels: true }
|
|
270
|
+
|
|
271
|
+
expect(isPixelAllowed()).toBe(true)
|
|
272
|
+
})
|
|
273
|
+
|
|
274
|
+
it('Should return true if config object is allow_retargeting_pixels is true but hasConsentedTo is false', () => {
|
|
275
|
+
vi.mocked(hasConsentedTo).mockImplementation(() => false)
|
|
276
|
+
window.PlayPilotLinkInjections.config = { allow_retargeting_pixels: true }
|
|
277
|
+
|
|
278
|
+
expect(isPixelAllowed()).toBe(false)
|
|
279
|
+
})
|
|
280
|
+
})
|
|
244
281
|
})
|