@@ -7,7 +7,7 @@ const SENTRY_API_VERSION = '7';
7
7
/** Helper class to provide urls to different Sentry endpoints. */
8
8
export class API {
9
9
/** The internally used DSN object. */
10
- private dsnObject : DSN ;
10
+ private readonly dsnObject : DSN ;
11
11
/** Create a new instance of API */
12
12
public constructor ( public dsn : DSNLike ) {
13
13
this . dsnObject = new DSN ( dsn ) ;
@@ -23,6 +23,7 @@ export class API {
23
23
return `${ this . getBaseUrl ( ) } ${ this . getStoreEndpointPath ( ) } ` ;
24
24
}
25
25
26
+ /** Returns the store endpoint with auth added in url encoded. */
26
27
public getStoreEndpointWithUrlEncodedAuth ( ) : string {
27
28
const dsn = this . dsnObject ;
28
29
const auth = {
@@ -62,23 +63,26 @@ export class API {
62
63
}
63
64
64
65
/** Returns the url to the report dialog endpoint. */
65
- public getReportDialogEndpoint ( dialogOptions : { [ key : string ] : any } = { } ) : string {
66
+ public getReportDialogEndpoint (
67
+ dialogOptions : {
68
+ [ key : string ] : any ;
69
+ user ?: { name ?: string ; email ?: string } ;
70
+ } = { } ,
71
+ ) : string {
66
72
const dsn = this . dsnObject ;
67
73
const endpoint = `${ this . getBaseUrl ( ) } ${ dsn . path ? `/${ dsn . path } ` : '' } /api/embed/error-page/` ;
68
74
69
75
const encodedOptions = [ ] ;
70
76
for ( const key in dialogOptions ) {
71
77
if ( key === 'user' ) {
72
- const user = dialogOptions . user ;
73
- if ( ! user ) {
78
+ if ( ! dialogOptions . user ) {
74
79
continue ;
75
80
}
76
-
77
- if ( user . name ) {
78
- encodedOptions . push ( `name=${ encodeURIComponent ( user . name ) } ` ) ;
81
+ if ( dialogOptions . user . name ) {
82
+ encodedOptions . push ( `name=${ encodeURIComponent ( dialogOptions . user . name ) } ` ) ;
79
83
}
80
- if ( user . email ) {
81
- encodedOptions . push ( `email=${ encodeURIComponent ( user . email ) } ` ) ;
84
+ if ( dialogOptions . user . email ) {
85
+ encodedOptions . push ( `email=${ encodeURIComponent ( dialogOptions . user . email ) } ` ) ;
82
86
}
83
87
} else {
84
88
encodedOptions . push ( `${ encodeURIComponent ( key ) } =${ encodeURIComponent ( dialogOptions [ key ] as string ) } ` ) ;
0 commit comments