1- import type { Hub } from '@sentry/core' ;
1+ import { getCurrentScope } from '@sentry/core' ;
22import { functionToStringIntegration , inboundFiltersIntegration } from '@sentry/core' ;
33import {
44 captureSession ,
55 getClient ,
6- getCurrentHub ,
76 getIntegrationsToSetup ,
87 getReportDialogEndpoint ,
98 initAndBind ,
109 startSession ,
1110} from '@sentry/core' ;
12- import type { Integration , Options , UserFeedback } from '@sentry/types' ;
11+ import type { DsnLike , Integration , Options , UserFeedback } from '@sentry/types' ;
1312import {
1413 addHistoryInstrumentationHandler ,
1514 logger ,
@@ -20,7 +19,6 @@ import {
2019import type { BrowserClientOptions , BrowserOptions } from './client' ;
2120import { BrowserClient } from './client' ;
2221import { DEBUG_BUILD } from './debug-build' ;
23- import type { ReportDialogOptions } from './helpers' ;
2422import { WINDOW , wrap as internalWrap } from './helpers' ;
2523import { breadcrumbsIntegration } from './integrations/breadcrumbs' ;
2624import { dedupeIntegration } from './integrations/dedupe' ;
@@ -139,42 +137,52 @@ export function init(options: BrowserOptions = {}): void {
139137 }
140138}
141139
142- type NewReportDialogOptions = ReportDialogOptions & { eventId : string } ; // eslint-disable-line
143-
144- interface ShowReportDialogFunction {
145- /**
146- * Present the user with a report dialog.
147- *
148- * @param options Everything is optional, we try to fetch all info need from the global scope.
149- */
150- ( options : NewReportDialogOptions ) : void ;
151-
152- /**
153- * Present the user with a report dialog.
154- *
155- * @param options Everything is optional, we try to fetch all info need from the global scope.
156- *
157- * @deprecated Please always pass an `options` argument with `eventId`. The `hub` argument will not be used in the next version of the SDK.
158- */
159- // eslint-disable-next-line deprecation/deprecation
160- ( options ?: ReportDialogOptions , hub ?: Hub ) : void ;
140+ /**
141+ * All properties the report dialog supports
142+ */
143+ export interface ReportDialogOptions {
144+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
145+ [ key : string ] : any ;
146+ eventId : string ;
147+ dsn ?: DsnLike ;
148+ user ?: {
149+ email ?: string ;
150+ name ?: string ;
151+ } ;
152+ lang ?: string ;
153+ title ?: string ;
154+ subtitle ?: string ;
155+ subtitle2 ?: string ;
156+ labelName ?: string ;
157+ labelEmail ?: string ;
158+ labelComments ?: string ;
159+ labelClose ?: string ;
160+ labelSubmit ?: string ;
161+ errorGeneric ?: string ;
162+ errorFormEntry ?: string ;
163+ successMessage ?: string ;
164+ /** Callback after reportDialog showed up */
165+ onLoad ?( this : void ) : void ;
166+ /** Callback after reportDialog closed */
167+ onClose ?( this : void ) : void ;
161168}
162169
163- export const showReportDialog : ShowReportDialogFunction = (
164- // eslint-disable-next-line deprecation/deprecation
165- options : ReportDialogOptions = { } ,
166- // eslint-disable-next-line deprecation/deprecation
167- hub : Hub = getCurrentHub ( ) ,
168- ) => {
170+ /**
171+ * Present the user with a report dialog.
172+ *
173+ * @param options Everything is optional, we try to fetch all info need from the global scope.
174+ */
175+ export function showReportDialog ( options : ReportDialogOptions ) : void {
169176 // doesn't work without a document (React Native)
170177 if ( ! WINDOW . document ) {
171178 DEBUG_BUILD && logger . error ( 'Global document not defined in showReportDialog call' ) ;
172179 return ;
173180 }
174181
175- // eslint-disable-next-line deprecation/deprecation
176- const { client, scope } = hub . getStackTop ( ) ;
177- const dsn = options . dsn || ( client && client . getDsn ( ) ) ;
182+ const scope = getCurrentScope ( ) ;
183+ const client = scope . getClient ( ) ;
184+ const dsn = client && client . getDsn ( ) ;
185+
178186 if ( ! dsn ) {
179187 DEBUG_BUILD && logger . error ( 'DSN not configured for showReportDialog call' ) ;
180188 return ;
@@ -216,7 +224,7 @@ export const showReportDialog: ShowReportDialogFunction = (
216224 } else {
217225 DEBUG_BUILD && logger . error ( 'Not injecting report dialog. No injection point found in HTML' ) ;
218226 }
219- } ;
227+ }
220228
221229/**
222230 * This function is here to be API compatible with the loader.
0 commit comments