1 | |
2 | |
3 | * List an organizations selectors |
4 | * Return a list of selectors for a given organization. |
5 | */ |
6 | export async function main( |
7 | auth: RT.Sentry, |
8 | environment?: string | undefined, |
9 | statsPeriod?: string | undefined, |
10 | start?: string | undefined, |
11 | end?: string | undefined, |
12 | project?: string | undefined, |
13 | projectSlug?: string | undefined, |
14 | sort?: string | undefined, |
15 | sortBy?: string | undefined, |
16 | orderBy?: string | undefined, |
17 | cursor?: string | undefined, |
18 | per_page?: string | undefined, |
19 | query?: string | undefined |
20 | ) { |
21 | const url = new URL( |
22 | `https://${auth.region}.sentry.io/api/0/organizations/${auth.organizationSlug}/replay-selectors/` |
23 | ) |
24 | for (const [k, v] of [ |
25 | ['environment', environment], |
26 | ['statsPeriod', statsPeriod], |
27 | ['start', start], |
28 | ['end', end], |
29 | ['project', project], |
30 | ['projectSlug', projectSlug], |
31 | ['sort', sort], |
32 | ['sortBy', sortBy], |
33 | ['orderBy', orderBy], |
34 | ['cursor', cursor], |
35 | ['per_page', per_page], |
36 | ['query', query] |
37 | ]) { |
38 | if (v !== undefined && v !== '') { |
39 | url.searchParams.append(k, v) |
40 | } |
41 | } |
42 | const response = await fetch(url, { |
43 | method: 'GET', |
44 | headers: { |
45 | Authorization: 'Bearer ' + auth.token |
46 | }, |
47 | body: undefined |
48 | }) |
49 | if (!response.ok) { |
50 | const text = await response.text() |
51 | throw new Error(`${response.status} ${text}`) |
52 | } |
53 | return await response.json() |
54 | } |
55 |
|