0
Get visits orphan ur ls
One script reply has been approved by the moderators Verified

List of Orphan URLs.

Created by hugo697 52 days ago Viewed 627 times
0
Submitted by hugo697 Bun
Verified 52 days ago
1
//native
2
type Botify = {
3
	token: string
4
}
5
/**
6
 * Get visits orphan ur ls
7
 * List of Orphan URLs.
8
 */
9
export async function main(
10
	auth: Botify,
11
	username: string,
12
	project_slug: string,
13
	analysis_slug: string,
14
	medium: string,
15
	source: string,
16
	page: string | undefined,
17
	size: string | undefined
18
) {
19
	const url = new URL(
20
		`https://api.botify.com/analyses/${username}/${project_slug}/${analysis_slug}/features/visits/orphan_urls/${medium}/${source}`
21
	)
22
	for (const [k, v] of [
23
		['page', page],
24
		['size', size]
25
	]) {
26
		if (v !== undefined && v !== '' && k !== undefined) {
27
			url.searchParams.append(k, v)
28
		}
29
	}
30
	const response = await fetch(url, {
31
		method: 'GET',
32
		headers: {
33
			Authorization: 'Token ' + auth.token
34
		},
35
		body: undefined
36
	})
37
	if (!response.ok) {
38
		const text = await response.text()
39
		throw new Error(`${response.status} ${text}`)
40
	}
41
	return await response.text()
42
}
43