Edits history of script submission #20303 for ' Update a client key (sentry)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Update a client key
     * Update various settings for a client key.
     */
    export async function main(
    	auth: RT.Sentry,
    	project_id_or_slug: string,
    	key_id: string,
    	body: Body
    ) {
    	const url = new URL(
    		`https://${auth.region}.sentry.io/api/0/projects/${auth.organizationSlug}/${project_id_or_slug}/keys/${key_id}/`
    	)
    
    	const response = await fetch(url, {
    		method: 'PUT',
    		headers: {
    			'Content-Type': 'application/json',
    			Authorization: 'Bearer ' + auth.token
    		},
    		body: JSON.stringify(body)
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.json()
    }
    
    /* eslint-disable */
    /**
     * This file was automatically generated by json-schema-to-typescript.
     * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
     * and run json-schema-to-typescript to regenerate this file.
     */
    
    export interface Body {
    	/**
    	 * The name for the client key
    	 */
    	name?: string
    	/**
    	 * Activate or deactivate the client key.
    	 */
    	isActive?: boolean
    	/**
    	 * Applies a rate limit to cap the number of errors accepted during a given time window. To
    	 * disable entirely set `rateLimit` to null.
    	 * ```json
    	 * {
    	 *     "rateLimit": {
    	 *         "window": 7200, // time in seconds
    	 *         "count": 1000 // error cap
    	 *     }
    	 * }
    	 * ```
    	 */
    	rateLimit?: {
    		count?: number
    		window?: number
    		[k: string]: unknown
    	}
    	/**
    	 * The Sentry Javascript SDK version to use. The currently supported options are:
    	 *
    	 * * `latest` - Most recent version
    	 * * `7.x` - Version 7 releases
    	 */
    	browserSdkVersion?: 'latest' | '7.x'
    	/**
    	 * Configures multiple options for the Javascript Loader Script.
    	 * - `Performance Monitoring`
    	 * - `Debug Bundles & Logging`
    	 * - `Session Replay` - Note that the loader will load the ES6 bundle instead of the ES5 bundle.
    	 * ```json
    	 * {
    	 *     "dynamicSdkLoaderOptions": {
    	 *         "hasReplay": true,
    	 *         "hasPerformance": true,
    	 *         "hasDebug": true
    	 *     }
    	 * }
    	 * ```
    	 */
    	dynamicSdkLoaderOptions?: {
    		hasReplay?: boolean
    		hasPerformance?: boolean
    		hasDebug?: boolean
    		[k: string]: unknown
    	}
    	[k: string]: unknown
    }
    

    Submitted by hugo697 235 days ago