@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playpilot/tpi",
3
- "version": "8.26.1",
3
+ "version": "8.26.2",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
@@ -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 isPixelAllowed(): boolean {
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 { hasConsentedTo } from '$lib/consent'
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 (hasConsentedTo('pixels')) trackViaPixel(MetaEvent.SearchQuery, { query })
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 { isPixelAllowed } from '$lib/pixel'
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 isPixelAllowed() ? trackViewViaPixel(MetaEvent.GenreInterest, { genre: genreName, source: MetaSource.Card }) : null}>
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 { isPixelAllowed } from '$lib/pixel'
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 (isPixelAllowed() && type === 'title') trackViaPixel(MetaEvent.TitleInterest, { title: (data as TitleData).title, source: MetaSource.Card })
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 { isPixelAllowed } from '$lib/pixel'
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 (isPixelAllowed()) trackViaPixel(MetaEvent.TitleInterest, { title: title.title, source: MetaSource.Card })
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 { hasConsentedTo } from '$lib/consent'
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 (hasConsentedTo('pixels')) trackViaPixel(MetaEvent.ParticipantView, { participant: participant.name })
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 { isPixelAllowed } from '$lib/pixel'
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(isPixelAllowed() && !highlighted)
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 { isPixelAllowed } from '$lib/pixel'
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 (!isPixelAllowed()) return
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 { isPixelAllowed } from '$lib/pixel'
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('pixel.ts', () => {
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(isPixelAllowed()).toBe(false)
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(isPixelAllowed()).toBe(false)
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(isPixelAllowed()).toBe(false)
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(isPixelAllowed()).toBe(true)
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(isPixelAllowed()).toBe(false)
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
- isPixelAllowed()
70
+ isRetargetingAllowed()
71
71
 
72
72
  // @ts-ignore
73
73
  expect(window[RETARGETING_USER_ID_KEY]).toBe('abc')
@@ -15,8 +15,8 @@ vi.mock('$lib/tracking', () => ({
15
15
  track: vi.fn(),
16
16
  }))
17
17
 
18
- vi.mock('$lib/pixel', () => ({
19
- isPixelAllowed: vi.fn(),
18
+ vi.mock('$lib/retargeting', () => ({
19
+ isRetargetingAllowed: vi.fn(),
20
20
  }))
21
21
 
22
22
  vi.mock('$lib/api/participants', () => ({
@@ -15,8 +15,8 @@ vi.mock('$lib/tracking', () => ({
15
15
  track: vi.fn(),
16
16
  }))
17
17
 
18
- vi.mock('$lib/pixel', () => ({
19
- isPixelAllowed: vi.fn(),
18
+ vi.mock('$lib/retargeting', () => ({
19
+ isRetargetingAllowed: vi.fn(),
20
20
  }))
21
21
 
22
22
  vi.mock('$lib/api/participants', () => ({
@@ -8,8 +8,8 @@ vi.mock('$lib/tracking', () => ({
8
8
  track: vi.fn(),
9
9
  }))
10
10
 
11
- vi.mock('$lib/pixel', () => ({
12
- isPixelAllowed: vi.fn(),
11
+ vi.mock('$lib/retargeting', () => ({
12
+ isRetargetingAllowed: vi.fn(),
13
13
  }))
14
14
 
15
15
  vi.mock('$lib/consent', () => ({
@@ -11,8 +11,8 @@ vi.mock('$lib/tracking', () => ({
11
11
  track: vi.fn(),
12
12
  }))
13
13
 
14
- vi.mock('$lib/pixel', () => ({
15
- isPixelAllowed: vi.fn(),
14
+ vi.mock('$lib/retargeting', () => ({
15
+ isRetargetingAllowed: vi.fn(),
16
16
  }))
17
17
 
18
18
  vi.mock('svelte', async (importActual) => ({
@@ -11,8 +11,8 @@ vi.mock('$lib/tracking', () => ({
11
11
  track: vi.fn(),
12
12
  }))
13
13
 
14
- vi.mock('$lib/pixel', () => ({
15
- isPixelAllowed: vi.fn(),
14
+ vi.mock('$lib/retargeting', () => ({
15
+ isRetargetingAllowed: vi.fn(),
16
16
  }))
17
17
 
18
18
  vi.mock('$lib/api/participants', () => ({