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