Edits history of script submission #20281 for ' Retrieve an organizations release (sentry)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Retrieve an organizations release
     * Return details on an individual release.
     */
    export async function main(
    	auth: RT.Sentry,
    	version: string,
    	project_id?: string | undefined,
    	health?: string | undefined,
    	adoptionStages?: string | undefined,
    	summaryStatsPeriod?:
    		| '14d'
    		| '1d'
    		| '1h'
    		| '24h'
    		| '2d'
    		| '30d'
    		| '48h'
    		| '7d'
    		| '90d'
    		| undefined,
    	healthStatsPeriod?: '14d' | '1d' | '1h' | '24h' | '2d' | '30d' | '48h' | '7d' | '90d' | undefined,
    	sort?: 'crash_free_sessions' | 'crash_free_users' | 'date' | 'sessions' | 'users' | undefined,
    	status?: 'archived' | 'open' | undefined,
    	query?: string | undefined
    ) {
    	const url = new URL(
    		`https://${auth.region}.sentry.io/api/0/organizations/${auth.organizationSlug}/releases/${version}/`
    	)
    	for (const [k, v] of [
    		['project_id', project_id],
    		['health', health],
    		['adoptionStages', adoptionStages],
    		['summaryStatsPeriod', summaryStatsPeriod],
    		['healthStatsPeriod', healthStatsPeriod],
    		['sort', sort],
    		['status', status],
    		['query', query]
    	]) {
    		if (v !== undefined && v !== '') {
    			url.searchParams.append(k, v)
    		}
    	}
    	const response = await fetch(url, {
    		method: 'GET',
    		headers: {
    			Authorization: 'Bearer ' + auth.token
    		},
    		body: undefined
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.json()
    }
    

    Submitted by hugo697 235 days ago