Skip to content

Commit

Permalink
sentry [nfc]: add Scope and related functions to Sentry defs
Browse files Browse the repository at this point in the history
  • Loading branch information
rk-for-zulip authored and gnprice committed Jan 1, 2020
1 parent 52b6dff commit 9f2e1be
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion flow-typed/@sentry/react-native_v1.x.x.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ declare module '@sentry/react-native' {

/* This field is declared as optional in TypeScript, but it's not: the iOS
implementation will redbox if it's omitted from the `init()` call. The
underlying issue has been filed as sentry/sentry-cocoa#347.
underlying issue has been filed as getsentry/sentry-cocoa#347.
In the meantime, { dsn: 'https://none@localhost:0/_/_' } may have the
same effect. */
Expand Down Expand Up @@ -99,6 +99,23 @@ declare module '@sentry/react-native' {
captureMessage(message: string, level?: SeverityType, eventHint?: EventHint): string,
};

// Taken from @sentry/{minimal,types}/src/scope.ts.
// More methods are available.
declare export class Scope {
/**
* Set key:value that will be sent as extra data with the event.
* @param key String of extra
* @param extra Any kind of data. This data will be normalized.
*/
setExtra(key: string, extra: any): this;

/**
* Set an object that will be merged sent as extra data with the event.
* @param extras Extras object to merge into current context.
*/
setExtras(extras: { [key: string]: any }): this;
}

// Adapted from @sentry/types/src/client.ts, with some specialization.
declare export type Client = {
getOptions(): Options,
Expand All @@ -117,4 +134,17 @@ declare module '@sentry/react-native' {
declare export function captureException(exception: mixed): string;
declare export function captureMessage(message: string, level?: $Values<typeof Severity>): string;
declare export function addBreadcrumb(breadcrumb: Breadcrumb): void;

/* Modifies the current scope. Avoid in favor of `withScope` wherever
possible. */
declare export function configureScope(callback: (scope: Scope) => void): void;

/**
* Performs actions in a new subscope.
*
* Note that an exception which escapes this scope will not necessarily have
* the relevant scope-changes applied to its Sentry event! This scope is only
* consulted when the event is finally captured for logging.
*/
declare export function withScope(callback: (scope: Scope) => void): void;
}

0 comments on commit 9f2e1be

Please sign in to comment.