@playpilot/tpi 6.4.3 → 6.4.4
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
|
@@ -29,7 +29,6 @@ export async function fetchLinkInjections(
|
|
|
29
29
|
// We use separate requests when running the AI or setting the editor session vs when only getting the results.
|
|
30
30
|
// For regular requests we use a GET endpoint, but when saving data we POST to the same url.
|
|
31
31
|
if (Object.entries(params).length) {
|
|
32
|
-
// Additional params are added when re-running AI. These are necessary for the API
|
|
33
32
|
if (params.run_ai) {
|
|
34
33
|
params.hash = hash
|
|
35
34
|
params.page_text = pageText
|
package/src/lib/genre.ts
ADDED
package/src/lib/tracking.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { hasConsentedTo } from './consent'
|
|
2
2
|
import { mobileBreakpoint } from './constants'
|
|
3
3
|
import { isCrawler } from './crawler'
|
|
4
|
+
import { genreSlugsToNames } from './genre'
|
|
4
5
|
import type { TitleData } from './types/title'
|
|
5
6
|
import { getFullUrlPath } from './url'
|
|
6
7
|
|
|
@@ -29,6 +30,7 @@ export async function track(event: string, title: TitleData | null = null, paylo
|
|
|
29
30
|
title: title.title,
|
|
30
31
|
title_sid: title.sid,
|
|
31
32
|
title_type: title.type,
|
|
33
|
+
genres: genreSlugsToNames(title.genres),
|
|
32
34
|
providers: [...new Set(title.providers?.map(p => p.name) || [])],
|
|
33
35
|
...payload,
|
|
34
36
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
|
|
3
|
+
import { genreSlugsToNames } from '$lib/genre'
|
|
4
|
+
|
|
5
|
+
describe('genres.ts', () => {
|
|
6
|
+
describe('genreSlugsToNames', () => {
|
|
7
|
+
it('Should return genre names for given slugs', () => {
|
|
8
|
+
expect(genreSlugsToNames(['101', '103'])).toEqual(['Action', 'Kids'])
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
it('Should exclude slugs that were not found', () => {
|
|
12
|
+
expect(genreSlugsToNames(['101', 'not-found'])).toEqual(['Action'])
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
it('Should return an empty array if no slugs were found', () => {
|
|
16
|
+
expect(genreSlugsToNames(['not-found'])).toEqual([])
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
it('Should return an empty array when no slugs were given', () => {
|
|
20
|
+
expect(genreSlugsToNames([])).toEqual([])
|
|
21
|
+
})
|
|
22
|
+
})
|
|
23
|
+
})
|
|
@@ -121,7 +121,7 @@ describe('$lib/tracking', () => {
|
|
|
121
121
|
expect(global.fetch).toHaveBeenCalledWith(
|
|
122
122
|
expect.any(String),
|
|
123
123
|
expect.objectContaining({
|
|
124
|
-
body: expect.stringContaining(`"original_title":"${title.original_title}","title":"${title.title}","title_sid":"${title.sid}","title_type":"${title.type}"`),
|
|
124
|
+
body: expect.stringContaining(`"original_title":"${title.original_title}","title":"${title.title}","title_sid":"${title.sid}","title_type":"${title.type}","genres":["Action","Adventure","Sci-Fi","Drama"]`),
|
|
125
125
|
}),
|
|
126
126
|
)
|
|
127
127
|
})
|