@playpilot/tpi 8.26.1 → 8.26.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/dist/editorial.mount.js +8 -8
- package/dist/link-injections.js +1 -1
- package/dist/mount.js +6 -6
- package/package.json +1 -1
- package/src/lib/{pixel.ts → retargeting.ts} +1 -1
- package/src/routes/components/Explore/Routes/ExploreResults.svelte +2 -2
- package/src/routes/components/Genres.svelte +2 -2
- package/src/routes/components/InjectionPopover.svelte +2 -2
- package/src/routes/components/Modals/TitleModal.svelte +2 -2
- package/src/routes/components/Participant.svelte +2 -2
- package/src/routes/components/Playlinks/Playlink.svelte +2 -2
- package/src/routes/components/Tracking/TrackingPixelsForTitleDataPerLink.svelte +2 -2
- package/src/tests/lib/{pixel.test.js → retargeting.test.js} +8 -8
- package/src/tests/routes/components/InjectionPopover.test.js +2 -2
- package/src/tests/routes/components/Modals/TitleModal.test.js +2 -2
- package/src/tests/routes/components/Playlinks/Playlink.test.js +2 -2
- package/src/tests/routes/components/Playlinks/Playlinks.test.js +2 -2
- package/src/tests/routes/components/Title.test.js +2 -2
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@ import { RETARGETING_USER_ID_KEY } from '@playpilot/retargeting-tracking'
|
|
|
2
2
|
import { hasConsentedTo } from './consent'
|
|
3
3
|
import { getUserId } from './user'
|
|
4
4
|
|
|
5
|
-
export function
|
|
5
|
+
export function isRetargetingAllowed(): boolean {
|
|
6
6
|
if (!window.PlayPilotLinkInjections.config?.allow_retargeting_pixels) return false
|
|
7
7
|
|
|
8
8
|
if (!hasConsentedTo('pixels')) return false
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import type { APIPaginatedResult } from '$lib/types/api'
|
|
8
8
|
import type { ExploreFilter } from '$lib/types/filter'
|
|
9
9
|
import type { TitleData } from '$lib/types/title'
|
|
10
|
-
import {
|
|
10
|
+
import { isRetargetingAllowed } from '$lib/retargeting'
|
|
11
11
|
import { t } from '$lib/localization'
|
|
12
12
|
import { trackViaPixel } from '@playpilot/retargeting-tracking'
|
|
13
13
|
import Button from '../../Button.svelte'
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
if (!query) return
|
|
102
102
|
|
|
103
103
|
track(TrackingEvent.ExploreSearch, null, { query })
|
|
104
|
-
if (
|
|
104
|
+
if (isRetargetingAllowed()) trackViaPixel(MetaEvent.SearchQuery, { query })
|
|
105
105
|
}, 100)
|
|
106
106
|
}
|
|
107
107
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import genreData from '$lib/data/genres.json'
|
|
3
3
|
import { MetaEvent, MetaSource } from '$lib/enums/TrackingEvent'
|
|
4
4
|
import { t } from '$lib/localization'
|
|
5
|
-
import {
|
|
5
|
+
import { isRetargetingAllowed } from '$lib/retargeting'
|
|
6
6
|
import { trackViewViaPixel } from '@playpilot/retargeting-tracking'
|
|
7
7
|
|
|
8
8
|
interface Props {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
{@const genreName = genreData.find(g => g.slug === genre)?.name}
|
|
21
21
|
|
|
22
22
|
{#if genreName}
|
|
23
|
-
<div class="genre" {@attach
|
|
23
|
+
<div class="genre" {@attach isRetargetingAllowed() ? trackViewViaPixel(MetaEvent.GenreInterest, { genre: genreName, source: MetaSource.Card }) : null}>
|
|
24
24
|
{t(genreName)}
|
|
25
25
|
</div>
|
|
26
26
|
{/if}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import type { ParticipantData } from '$lib/types/participant'
|
|
7
7
|
import type { LinkInjectionDataType } from '$lib/types/injection'
|
|
8
8
|
import { onMount, setContext } from 'svelte'
|
|
9
|
-
import {
|
|
9
|
+
import { isRetargetingAllowed } from '$lib/retargeting'
|
|
10
10
|
import { trackViaPixel } from '@playpilot/retargeting-tracking'
|
|
11
11
|
import Popover from './Popover.svelte'
|
|
12
12
|
import Title from './Title.svelte'
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
if (type === 'title') track(TrackingEvent.InjectionPopoverView, data as TitleData, { type })
|
|
33
33
|
if (type === 'participant') track(TrackingEvent.InjectionPopoverView, null, { type, participant: (data as ParticipantData).name })
|
|
34
34
|
|
|
35
|
-
if (
|
|
35
|
+
if (isRetargetingAllowed() && type === 'title') trackViaPixel(MetaEvent.TitleInterest, { title: (data as TitleData).title, source: MetaSource.Card })
|
|
36
36
|
|
|
37
37
|
onMount(() => {
|
|
38
38
|
setOffset()
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { getFirstAdOfType } from '$lib/api/ads'
|
|
6
6
|
import { exploreParentSelector } from '$lib/explore'
|
|
7
7
|
import { onMount, setContext } from 'svelte'
|
|
8
|
-
import {
|
|
8
|
+
import { isRetargetingAllowed } from '$lib/retargeting'
|
|
9
9
|
import { trackViaPixel } from '@playpilot/retargeting-tracking'
|
|
10
10
|
import Modal from './Modal.svelte'
|
|
11
11
|
import Title from '../Title.svelte'
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
|
|
32
32
|
track(TrackingEvent.TitleModalView, title)
|
|
33
33
|
|
|
34
|
-
if (
|
|
34
|
+
if (isRetargetingAllowed()) trackViaPixel(MetaEvent.TitleInterest, { title: title.title, source: MetaSource.Card })
|
|
35
35
|
|
|
36
36
|
onMount(() => {
|
|
37
37
|
const openTimestamp = Date.now()
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import type { TitleData } from '$lib/types/title'
|
|
8
8
|
import ListTitle from './ListTitle.svelte'
|
|
9
9
|
import { t } from '$lib/localization'
|
|
10
|
-
import {
|
|
10
|
+
import { isRetargetingAllowed } from '$lib/retargeting'
|
|
11
11
|
import { trackViaPixel } from '@playpilot/retargeting-tracking'
|
|
12
12
|
import { MetaEvent } from '$lib/enums/TrackingEvent'
|
|
13
13
|
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
|
|
30
30
|
onMount(loadMore)
|
|
31
31
|
|
|
32
|
-
if (
|
|
32
|
+
if (isRetargetingAllowed()) trackViaPixel(MetaEvent.ParticipantView, { participant: participant.name })
|
|
33
33
|
|
|
34
34
|
function formatDate(dateString: string): string {
|
|
35
35
|
const date = new Date(dateString)
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import type { PlaylinkData } from '$lib/types/playlink'
|
|
8
8
|
import { trackClickViaPixel, trackViewViaPixel } from '@playpilot/retargeting-tracking'
|
|
9
9
|
import { MetaEvent, MetaSource } from '$lib/enums/TrackingEvent'
|
|
10
|
-
import {
|
|
10
|
+
import { isRetargetingAllowed } from '$lib/retargeting'
|
|
11
11
|
|
|
12
12
|
interface Props {
|
|
13
13
|
playlink: PlaylinkData
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
const { name, url, logo_url, highlighted, cta_text, action_text, pixels, extra_info: { category } } = $derived(playlink)
|
|
22
22
|
|
|
23
|
-
const usePixel = $derived(
|
|
23
|
+
const usePixel = $derived(isRetargetingAllowed() && !highlighted)
|
|
24
24
|
|
|
25
25
|
const categoryStrings = {
|
|
26
26
|
AVOD: t('Stream'),
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import genreData from '$lib/data/genres.json'
|
|
3
3
|
import { MetaEvent, MetaSource } from '$lib/enums/TrackingEvent'
|
|
4
4
|
import { keyDataAttribute } from '$lib/injection'
|
|
5
|
-
import {
|
|
5
|
+
import { isRetargetingAllowed } from '$lib/retargeting'
|
|
6
6
|
import type { LinkInjection } from '$lib/types/injection'
|
|
7
7
|
import type { TitleData } from '$lib/types/title'
|
|
8
8
|
import { trackViaPixel } from '@playpilot/retargeting-tracking'
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
const { linkInjections }: Props = $props()
|
|
16
16
|
|
|
17
17
|
onMount(() => {
|
|
18
|
-
if (!
|
|
18
|
+
if (!isRetargetingAllowed()) return
|
|
19
19
|
|
|
20
20
|
const observer = new IntersectionObserver((entries) => {
|
|
21
21
|
entries.forEach(entry => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { hasConsentedTo } from '$lib/consent'
|
|
2
|
-
import {
|
|
2
|
+
import { isRetargetingAllowed } from '$lib/retargeting'
|
|
3
3
|
import { getUserId } from '$lib/user'
|
|
4
4
|
import { RETARGETING_USER_ID_KEY } from '@playpilot/retargeting-tracking'
|
|
5
5
|
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
@@ -12,7 +12,7 @@ vi.mock('$lib/user', () => ({
|
|
|
12
12
|
getUserId: vi.fn(),
|
|
13
13
|
}))
|
|
14
14
|
|
|
15
|
-
describe('
|
|
15
|
+
describe('retargeting.ts', () => {
|
|
16
16
|
beforeEach(() => {
|
|
17
17
|
// @ts-ignore
|
|
18
18
|
window.PlayPilotLinkInjections = {}
|
|
@@ -28,35 +28,35 @@ describe('pixel.ts', () => {
|
|
|
28
28
|
vi.mocked(hasConsentedTo).mockImplementation(() => true)
|
|
29
29
|
window.PlayPilotLinkInjections.config = null
|
|
30
30
|
|
|
31
|
-
expect(
|
|
31
|
+
expect(isRetargetingAllowed()).toBe(false)
|
|
32
32
|
})
|
|
33
33
|
|
|
34
34
|
it('Should return false if config object is without allow_retargeting_pixels', () => {
|
|
35
35
|
vi.mocked(hasConsentedTo).mockImplementation(() => true)
|
|
36
36
|
window.PlayPilotLinkInjections.config = { something: true }
|
|
37
37
|
|
|
38
|
-
expect(
|
|
38
|
+
expect(isRetargetingAllowed()).toBe(false)
|
|
39
39
|
})
|
|
40
40
|
|
|
41
41
|
it('Should return false if config object is allow_retargeting_pixels is false', () => {
|
|
42
42
|
vi.mocked(hasConsentedTo).mockImplementation(() => true)
|
|
43
43
|
window.PlayPilotLinkInjections.config = { allow_retargeting_pixels: false }
|
|
44
44
|
|
|
45
|
-
expect(
|
|
45
|
+
expect(isRetargetingAllowed()).toBe(false)
|
|
46
46
|
})
|
|
47
47
|
|
|
48
48
|
it('Should return true if config object is allow_retargeting_pixels is true', () => {
|
|
49
49
|
vi.mocked(hasConsentedTo).mockImplementation(() => true)
|
|
50
50
|
window.PlayPilotLinkInjections.config = { allow_retargeting_pixels: true }
|
|
51
51
|
|
|
52
|
-
expect(
|
|
52
|
+
expect(isRetargetingAllowed()).toBe(true)
|
|
53
53
|
})
|
|
54
54
|
|
|
55
55
|
it('Should return false if config object is allow_retargeting_pixels is true but hasConsentedTo is false', () => {
|
|
56
56
|
vi.mocked(hasConsentedTo).mockImplementation(() => false)
|
|
57
57
|
window.PlayPilotLinkInjections.config = { allow_retargeting_pixels: true }
|
|
58
58
|
|
|
59
|
-
expect(
|
|
59
|
+
expect(isRetargetingAllowed()).toBe(false)
|
|
60
60
|
})
|
|
61
61
|
|
|
62
62
|
it('Should set user id on window', () => {
|
|
@@ -67,7 +67,7 @@ describe('pixel.ts', () => {
|
|
|
67
67
|
// @ts-ignore
|
|
68
68
|
expect(window[RETARGETING_USER_ID_KEY]).not.toBeTruthy()
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
isRetargetingAllowed()
|
|
71
71
|
|
|
72
72
|
// @ts-ignore
|
|
73
73
|
expect(window[RETARGETING_USER_ID_KEY]).toBe('abc')
|
|
@@ -11,8 +11,8 @@ vi.mock('$lib/tracking', () => ({
|
|
|
11
11
|
track: vi.fn(),
|
|
12
12
|
}))
|
|
13
13
|
|
|
14
|
-
vi.mock('$lib/
|
|
15
|
-
|
|
14
|
+
vi.mock('$lib/retargeting', () => ({
|
|
15
|
+
isRetargetingAllowed: vi.fn(),
|
|
16
16
|
}))
|
|
17
17
|
|
|
18
18
|
vi.mock('svelte', async (importActual) => ({
|