(dsnLike: DsnLike, dialogOptions: ReportDialogOptions)
| 47 | |
| 48 | /** Returns the url to the report dialog endpoint. */ |
| 49 | export function getReportDialogEndpoint(dsnLike: DsnLike, dialogOptions: ReportDialogOptions): string { |
| 50 | const dsn = makeDsn(dsnLike); |
| 51 | if (!dsn) { |
| 52 | return ''; |
| 53 | } |
| 54 | |
| 55 | const endpoint = `${getBaseApiEndpoint(dsn)}embed/error-page/`; |
| 56 | |
| 57 | let encodedOptions = `dsn=${dsnToString(dsn)}`; |
| 58 | for (const key in dialogOptions) { |
| 59 | if (key === 'dsn') { |
| 60 | continue; |
| 61 | } |
| 62 | |
| 63 | if (key === 'onClose') { |
| 64 | continue; |
| 65 | } |
| 66 | |
| 67 | if (key === 'user') { |
| 68 | const user = dialogOptions.user; |
| 69 | if (!user) { |
| 70 | continue; |
| 71 | } |
| 72 | if (user.name) { |
| 73 | encodedOptions += `&name=${encodeURIComponent(user.name)}`; |
| 74 | } |
| 75 | if (user.email) { |
| 76 | encodedOptions += `&email=${encodeURIComponent(user.email)}`; |
| 77 | } |
| 78 | } else { |
| 79 | encodedOptions += `&${encodeURIComponent(key)}=${encodeURIComponent(dialogOptions[key] as string)}`; |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | return `${endpoint}?${encodedOptions}`; |
| 84 | } |
no test coverage detected