@playpilot/tpi 8.29.6-beta.6 → 8.29.7

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.29.6-beta.6",
3
+ "version": "8.29.7",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
@@ -7,11 +7,8 @@ import type { PlaylinkData } from '../types/playlink'
7
7
  import { api } from './api'
8
8
 
9
9
  export async function fetchAds(): Promise<Campaign[]> {
10
- console.log(1)
11
10
  if (!hasConsentedTo('ads')) return []
12
- console.log(2)
13
11
  if (window.PlayPilotLinkInjections.no_affiliate) return []
14
- console.log(3)
15
12
 
16
13
  const apiToken = getApiToken()
17
14
 
@@ -20,8 +17,6 @@ export async function fetchAds(): Promise<Campaign[]> {
20
17
  try {
21
18
  const response = await api<Campaign[]>(`/ads/browse/?api-token=${apiToken}`)
22
19
 
23
- console.log({ response })
24
-
25
20
  return response
26
21
  } catch (error: any) {
27
22
  track(TrackingEvent.AdsFetchFailed, null, { status: error.status })
@@ -55,8 +55,11 @@
55
55
  fireQueuedTrackingEvents()
56
56
  track(TrackingEvent.ArticlePageView)
57
57
 
58
- window.PlayPilotLinkInjections.ads = await fetchAds()
58
+ const explorePath = window.PlayPilotLinkInjections.config?.explore_navigation_path
59
+
60
+ if ((!aiInjections.length && !manualInjections.length) && !(explorePath && document.location.href.includes(explorePath))) return
59
61
 
62
+ window.PlayPilotLinkInjections.ads = await fetchAds()
60
63
  window.dispatchEvent(new CustomEvent('updateads', { bubbles: true }))
61
64
  }
62
65
 
@@ -1,5 +1,4 @@
1
1
  <script lang="ts">
2
- import { fetchAds } from '$lib/api/ads'
3
2
  import { fetchParticipantBySid } from '$lib/api/participants'
4
3
  import { fetchSimilarTitles, fetchTitleBySid } from '$lib/api/titles'
5
4
  import { mobileBreakpoint } from '$lib/constants'
@@ -7,7 +6,6 @@
7
6
  import { t } from '$lib/localization'
8
7
  import { openModal, type ModalType } from '$lib/modal'
9
8
  import { getSplitTestVariantName, trackSplitTestView } from '$lib/splitTest'
10
- import type { Campaign } from '$lib/types/campaign'
11
9
  import type { TitleData } from '$lib/types/title'
12
10
  import Modal from '../../Modals/Modal.svelte'
13
11
 
@@ -42,8 +40,6 @@
42
40
  data = await fetchParticipantBySid(sid)
43
41
  }
44
42
 
45
- console.log('ads', window.PlayPilotLinkInjections.ads)
46
-
47
43
  openModal({
48
44
  type,
49
45
  data,
@@ -47,7 +47,7 @@
47
47
  trackViaPixel(MetaEvent.GenreInterest, { genre: genreData.find(g => g.slug === genre)?.name, source: MetaSource.Link })
48
48
  })
49
49
 
50
- participants?.slice(0, 5).forEach(participant => {
50
+ participants?.slice(0, 10).forEach(participant => {
51
51
  trackViaPixel(MetaEvent.ParticipantInterest, { participant: participant.name, source: MetaSource.Link })
52
52
  })
53
53
 
@@ -479,17 +479,19 @@ describe('$routes/+page.svelte', () => {
479
479
  expect(fetchAds).not.toHaveBeenCalled()
480
480
  })
481
481
 
482
- it('Should not fetch ads if no_affilite is true', async () => {
483
- // @ts-ignore
484
- vi.mocked(pollLinkInjections).mockResolvedValueOnce({ ai_injections: [{}], manual_injections: [{}] })
482
+ it('Should fetch ads if any no injections are given but page is explore', async () => {
483
+ window.PlayPilotLinkInjections.config = {
484
+ explore_navigation_path: 'localhost',
485
+ }
486
+
485
487
  // @ts-ignore
486
- window.PlayPilotLinkInjections = { no_affiliate: true }
488
+ vi.mocked(pollLinkInjections).mockResolvedValueOnce({ ai_injections: [], manual_injections: [] })
487
489
 
488
490
  render(page)
489
491
 
490
492
  await new Promise(res => setTimeout(res, 100)) // Await possible fetches
491
493
 
492
- expect(fetchAds).not.toHaveBeenCalled()
494
+ expect(fetchAds).toHaveBeenCalled()
493
495
  })
494
496
 
495
497
  describe('Config', () => {
@@ -57,15 +57,6 @@ describe('ExploreLayout.svelte', () => {
57
57
  expect(fetchAds).toHaveBeenCalled()
58
58
  })
59
59
 
60
- it('Should not call fetchAds on mount if ads are already present', () => {
61
- // @ts-ignore
62
- window.PlayPilotLinkInjections.ads = ['a']
63
-
64
- render(ExploreLayout, { children })
65
-
66
- expect(fetchAds).not.toHaveBeenCalled()
67
- })
68
-
69
60
  it('Should show message for unsupported regions', async () => {
70
61
  // @ts-ignore
71
62
  window.PlayPilotLinkInjections.region = 'not'