@playpilot/tpi 8.15.1 → 8.16.0

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.15.1",
3
+ "version": "8.16.0",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
@@ -16,7 +16,7 @@
16
16
  "release": "node release.js"
17
17
  },
18
18
  "devDependencies": {
19
- "@playpilot/retargeting-tracking": "^0.1.0",
19
+ "@playpilot/retargeting-tracking": "^1.1.0",
20
20
  "@sveltejs/adapter-auto": "^7.0.1",
21
21
  "@sveltejs/kit": "^2.56.1",
22
22
  "@sveltejs/vite-plugin-svelte": "^4.0.0",
package/src/lib/modal.ts CHANGED
@@ -6,7 +6,6 @@ import type { ParticipantData } from './types/participant'
6
6
  import { mobileBreakpoint } from './constants'
7
7
  import TitleModal from '../routes/components/Modals/TitleModal.svelte'
8
8
  import ParticipantModal from '../routes/components/Modals/ParticipantModal.svelte'
9
- import ExploreModal from '../routes/components/Modals/ExploreModal.svelte'
10
9
  import { getPlayPilotWrapperElement, keyDataAttribute, keySelector } from './injection'
11
10
  import { playFallbackViewTransition } from './viewTransition'
12
11
  import { destroyLinkPopover } from './popover'
@@ -16,7 +15,7 @@ import TitlesRailModal from '../routes/components/Modals/TitlesRailModal.svelte'
16
15
  type Modal = {
17
16
  injection?: LinkInjection | null
18
17
  component?: object
19
- type: 'title' | 'participant' | 'explore' | 'titles-rail'
18
+ type: 'title' | 'participant' | 'titles-rail'
20
19
  data: TitleData | TitleData[] | ParticipantData | null
21
20
  scrollPosition?: number
22
21
  }
@@ -52,7 +51,6 @@ function getModalComponentByType(
52
51
  { type = 'title', target, data, props = {} }:
53
52
  { type: Modal['type'], target: Element, data: Modal['data'], props?: Record<string, any> }): ReturnType<typeof mount> {
54
53
  if (type === 'participant') return mount(ParticipantModal, { target, props: { participant: data as ParticipantData, ...props } })
55
- if (type === 'explore') return mount(ExploreModal, { target, props: { ...props } })
56
54
  if (type === 'titles-rail') return mount(TitlesRailModal, { target, props: { titles: data as TitleData[], ...props } })
57
55
  return mount(TitleModal, { target, props: { title: data as TitleData, ...props } })
58
56
  }
package/src/lib/pixel.ts CHANGED
@@ -1,6 +1,14 @@
1
+ import { RETARGETING_USER_ID_KEY } from '@playpilot/retargeting-tracking'
1
2
  import { hasConsentedTo } from './consent'
3
+ import { getUserId } from './user'
2
4
 
3
5
  export function isPixelAllowed(): boolean {
4
6
  if (!window.PlayPilotLinkInjections.config?.allow_retargeting_pixels) return false
5
- return hasConsentedTo('pixels')
7
+
8
+ if (!hasConsentedTo('pixels')) return false
9
+
10
+ // @ts-ignore
11
+ window[RETARGETING_USER_ID_KEY] = getUserId()
12
+
13
+ return true
6
14
  }
@@ -197,10 +197,6 @@
197
197
  {/key}
198
198
  </div>
199
199
 
200
- <div class="item">
201
- <button onclick={() => openModal({ type: 'explore' })}>Show explore modal</button>
202
- </div>
203
-
204
200
  <div class="item">
205
201
  <button onclick={insertExplore}>Insert explore component</button>
206
202
  <button onclick={insertExploreIntoNavigation}>Insert explore into navigation</button>
@@ -1,16 +1,25 @@
1
1
  import { hasConsentedTo } from '$lib/consent'
2
2
  import { isPixelAllowed } from '$lib/pixel'
3
+ import { getUserId } from '$lib/user'
4
+ import { RETARGETING_USER_ID_KEY } from '@playpilot/retargeting-tracking'
3
5
  import { beforeEach, describe, expect, it, vi } from 'vitest'
4
6
 
5
7
  vi.mock('$lib/consent', () => ({
6
8
  hasConsentedTo: vi.fn(() => true),
7
9
  }))
8
10
 
11
+ vi.mock('$lib/user', () => ({
12
+ getUserId: vi.fn(),
13
+ }))
14
+
9
15
  describe('pixel.ts', () => {
10
16
  beforeEach(() => {
11
17
  // @ts-ignore
12
18
  window.PlayPilotLinkInjections = {}
13
19
 
20
+ // @ts-ignore
21
+ delete window[RETARGETING_USER_ID_KEY]
22
+
14
23
  vi.mocked(hasConsentedTo).mockImplementation(() => true)
15
24
  })
16
25
 
@@ -43,11 +52,25 @@ describe('pixel.ts', () => {
43
52
  expect(isPixelAllowed()).toBe(true)
44
53
  })
45
54
 
46
- it('Should return true if config object is allow_retargeting_pixels is true but hasConsentedTo is false', () => {
55
+ it('Should return false if config object is allow_retargeting_pixels is true but hasConsentedTo is false', () => {
47
56
  vi.mocked(hasConsentedTo).mockImplementation(() => false)
48
57
  window.PlayPilotLinkInjections.config = { allow_retargeting_pixels: true }
49
58
 
50
59
  expect(isPixelAllowed()).toBe(false)
51
60
  })
61
+
62
+ it('Should set user id on window', () => {
63
+ vi.mocked(hasConsentedTo).mockImplementation(() => true)
64
+ vi.mocked(getUserId).mockImplementation(() => 'abc')
65
+ window.PlayPilotLinkInjections.config = { allow_retargeting_pixels: true }
66
+
67
+ // @ts-ignore
68
+ expect(window[RETARGETING_USER_ID_KEY]).not.toBeTruthy()
69
+
70
+ isPixelAllowed()
71
+
72
+ // @ts-ignore
73
+ expect(window[RETARGETING_USER_ID_KEY]).toBe('abc')
74
+ })
52
75
  })
53
76
  })
@@ -1,23 +0,0 @@
1
-
2
- <script lang="ts">
3
- import Modal from './Modal.svelte'
4
- import ExploreRouter from '../Explore/ExploreRouter.svelte'
5
-
6
- interface Props {
7
- initialScrollPosition?: number
8
- }
9
-
10
- const { initialScrollPosition = 0 }: Props = $props()
11
- </script>
12
-
13
- <Modal {initialScrollPosition} closeButtonStyle="flat" wide>
14
- <div class="content">
15
- <ExploreRouter />
16
- </div>
17
- </Modal>
18
-
19
- <style lang="scss">
20
- .content {
21
- padding-top: margin(2);
22
- }
23
- </style>