@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/dist/editorial.mount.js +6 -6
- package/dist/link-injections.js +2 -2
- package/dist/mount.js +4 -4
- package/package.json +1 -1
- package/src/lib/api/ads.ts +0 -5
- package/src/routes/+page.svelte +4 -1
- package/src/routes/components/Explore/Routes/ExploreModal.svelte +0 -4
- package/src/routes/components/Tracking/TrackingPixelsForTitleDataPerLink.svelte +1 -1
- package/src/tests/routes/+page.test.js +7 -5
- package/src/tests/routes/components/Explore/ExploreLayout.test.js +0 -9
package/package.json
CHANGED
package/src/lib/api/ads.ts
CHANGED
|
@@ -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 })
|
package/src/routes/+page.svelte
CHANGED
|
@@ -55,8 +55,11 @@
|
|
|
55
55
|
fireQueuedTrackingEvents()
|
|
56
56
|
track(TrackingEvent.ArticlePageView)
|
|
57
57
|
|
|
58
|
-
window.PlayPilotLinkInjections.
|
|
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,
|
|
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
|
|
483
|
-
|
|
484
|
-
|
|
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
|
-
|
|
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).
|
|
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'
|