1 | |
2 | |
3 | * List a projects error events |
4 | * Return a list of events bound to a project. |
5 | */ |
6 | export async function main( |
7 | auth: RT.Sentry, |
8 | project_id_or_slug: string, |
9 | statsPeriod?: string | undefined, |
10 | start?: string | undefined, |
11 | end?: string | undefined, |
12 | cursor?: string | undefined, |
13 | full?: string | undefined, |
14 | sample?: string | undefined |
15 | ) { |
16 | const url = new URL( |
17 | `https://${auth.region}.sentry.io/api/0/projects/${auth.organizationSlug}/${project_id_or_slug}/events/` |
18 | ) |
19 | for (const [k, v] of [ |
20 | ['statsPeriod', statsPeriod], |
21 | ['start', start], |
22 | ['end', end], |
23 | ['cursor', cursor], |
24 | ['full', full], |
25 | ['sample', sample] |
26 | ]) { |
27 | if (v !== undefined && v !== '') { |
28 | url.searchParams.append(k, v) |
29 | } |
30 | } |
31 | const response = await fetch(url, { |
32 | method: 'GET', |
33 | headers: { |
34 | Authorization: 'Bearer ' + auth.token |
35 | }, |
36 | body: undefined |
37 | }) |
38 | if (!response.ok) { |
39 | const text = await response.text() |
40 | throw new Error(`${response.status} ${text}`) |
41 | } |
42 | return await response.json() |
43 | } |
44 |
|