@playpilot/tpi 8.21.0 → 8.21.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.21.
|
|
3
|
+
"version": "8.21.2",
|
|
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": "^1.2
|
|
19
|
+
"@playpilot/retargeting-tracking": "^1.3.2",
|
|
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/api/region.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SupportedRegion } from '$lib/enums/Region'
|
|
2
2
|
import { TrackingEvent } from '$lib/enums/TrackingEvent'
|
|
3
3
|
import { track } from '$lib/tracking'
|
|
4
|
+
import { RETARGETING_REGION_KEY } from '@playpilot/retargeting-tracking'
|
|
4
5
|
|
|
5
6
|
export async function getRegionBasedOnIp(timeout = 5000): Promise<string> {
|
|
6
7
|
const savedRegion = window.PlayPilotLinkInjections?.region
|
|
@@ -41,4 +42,7 @@ function setSavedRegion(region: string): void {
|
|
|
41
42
|
if (!window.PlayPilotLinkInjections) return
|
|
42
43
|
|
|
43
44
|
window.PlayPilotLinkInjections.region = region
|
|
45
|
+
|
|
46
|
+
// @ts-ignore
|
|
47
|
+
window[RETARGETING_REGION_KEY] = region
|
|
44
48
|
}
|
package/src/routes/+page.svelte
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
import { authorize, getAuthToken, isEditorialModeEnabled, removeAuthCookie, setEditorialParamInUrl } from '$lib/api/auth'
|
|
13
13
|
import { getPageTextAndElements } from '$lib/injectionElements'
|
|
14
14
|
import type { LinkInjectionResponse, LinkInjection, LinkInjectionTypes } from '$lib/types/injection'
|
|
15
|
+
import { getRegionBasedOnIp } from '$lib/api/region'
|
|
15
16
|
import Editor from './components/Editorial/Editor.svelte'
|
|
16
17
|
import EditorTrigger from './components/Editorial/EditorTrigger.svelte'
|
|
17
18
|
import Alert from './components/Editorial/Alert.svelte'
|
|
@@ -91,8 +92,10 @@
|
|
|
91
92
|
}
|
|
92
93
|
|
|
93
94
|
try {
|
|
94
|
-
response = await
|
|
95
|
-
|
|
95
|
+
[response] = (await Promise.allSettled([
|
|
96
|
+
await (window.PlayPilotLinkInjections.initial_link_injections_promise || pollLinkInjections({ maxTries: 1, runAiWhenRelevant: !isCrawler() })),
|
|
97
|
+
await getRegionBasedOnIp(),
|
|
98
|
+
])).map(promise => (promise.status === 'fulfilled' ? promise.value : null)) as [LinkInjectionResponse | null, string]
|
|
96
99
|
|
|
97
100
|
loading = false
|
|
98
101
|
|
|
@@ -85,6 +85,10 @@ vi.mock('$lib/consent', () => ({
|
|
|
85
85
|
hasConsentedTo: vi.fn(() => true),
|
|
86
86
|
}))
|
|
87
87
|
|
|
88
|
+
vi.mock('$lib/api/region', () => ({
|
|
89
|
+
getRegionBasedOnIp: vi.fn(),
|
|
90
|
+
}))
|
|
91
|
+
|
|
88
92
|
describe('$routes/+page.svelte', () => {
|
|
89
93
|
beforeEach(() => {
|
|
90
94
|
document.body.innerHTML = ''
|