0

Retrieve a count of replays for a given issue or transaction

by
Published Oct 17, 2025

Return a count of replays for a list of issue or transaction IDs. The `query` parameter is required. It is a search query that includes exactly one of `issue.id`, `transaction`, or `replay_id` (string or list of strings).

Script sentry Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Retrieve a count of replays for a given issue or transaction
4
 * Return a count of replays for a list of issue or transaction IDs.
5

6
The `query` parameter is required. It is a search query that includes exactly one of `issue.id`, `transaction`, or `replay_id` (string or list of strings).
7
 */
8
export async function main(
9
	auth: RT.Sentry,
10
	environment?: string | undefined,
11
	start?: string | undefined,
12
	end?: string | undefined,
13
	statsPeriod?: string | undefined,
14
	project_id_or_slug?: string | undefined,
15
	query?: string | undefined
16
) {
17
	const url = new URL(
18
		`https://${auth.region}.sentry.io/api/0/organizations/${auth.organizationSlug}/replay-count/`
19
	)
20
	for (const [k, v] of [
21
		['environment', environment],
22
		['start', start],
23
		['end', end],
24
		['statsPeriod', statsPeriod],
25
		['project_id_or_slug', project_id_or_slug],
26
		['query', query]
27
	]) {
28
		if (v !== undefined && v !== '') {
29
			url.searchParams.append(k, v)
30
		}
31
	}
32
	const response = await fetch(url, {
33
		method: 'GET',
34
		headers: {
35
			Authorization: 'Bearer ' + auth.token
36
		},
37
		body: undefined
38
	})
39
	if (!response.ok) {
40
		const text = await response.text()
41
		throw new Error(`${response.status} ${text}`)
42
	}
43
	return await response.json()
44
}
45