Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
83 lines (69 loc) · 2.61 KB

File metadata and controls

83 lines (69 loc) · 2.61 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import type { ReportDialogOptions } from './report-dialog';
import type { DsnComponents, DsnLike, SdkInfo } from './types-hoist';
import { dsnToString, makeDsn } from './utils-hoist/dsn';
const SENTRY_API_VERSION = '7';
/** Returns the prefix to construct Sentry ingestion API endpoints. */
function getBaseApiEndpoint(dsn: DsnComponents): string {
const protocol = dsn.protocol ? `${dsn.protocol}:` : '';
const port = dsn.port ? `:${dsn.port}` : '';
return `${protocol}//${dsn.host}${port}${dsn.path ? `/${dsn.path}` : ''}/api/`;
}
/** Returns the ingest API endpoint for target. */
function _getIngestEndpoint(dsn: DsnComponents): string {
return `${getBaseApiEndpoint(dsn)}${dsn.projectId}/envelope/`;
}
/** Returns a URL-encoded string with auth config suitable for a query string. */
function _encodedAuth(dsn: DsnComponents, sdkInfo: SdkInfo | undefined): string {
const params: Record<string, string> = {
sentry_version: SENTRY_API_VERSION,
};
if (dsn.publicKey) {
// We send only the minimum set of required information. See
// https://github.com/getsentry/sentry-javascript/issues/2572.
params.sentry_key = dsn.publicKey;
}
if (sdkInfo) {
params.sentry_client = `${sdkInfo.name}/${sdkInfo.version}`;
}
return new URLSearchParams(params).toString();
}
/**
* Returns the envelope endpoint URL with auth in the query string.
*
* Sending auth as part of the query string and not as custom HTTP headers avoids CORS preflight requests.
*/
export function getEnvelopeEndpointWithUrlEncodedAuth(dsn: DsnComponents, tunnel?: string, sdkInfo?: SdkInfo): string {
return tunnel ? tunnel : `${_getIngestEndpoint(dsn)}?${_encodedAuth(dsn, sdkInfo)}`;
}
/** Returns the url to the report dialog endpoint. */
export function getReportDialogEndpoint(dsnLike: DsnLike, dialogOptions: ReportDialogOptions): string {
const dsn = makeDsn(dsnLike);
if (!dsn) {
return '';
}
const endpoint = `${getBaseApiEndpoint(dsn)}embed/error-page/`;
let encodedOptions = `dsn=${dsnToString(dsn)}`;
for (const key in dialogOptions) {
if (key === 'dsn') {
continue;
}
if (key === 'onClose') {
continue;
}
if (key === 'user') {
const user = dialogOptions.user;
if (!user) {
continue;
}
if (user.name) {
encodedOptions += `&name=${encodeURIComponent(user.name)}`;
}
if (user.email) {
encodedOptions += `&email=${encodeURIComponent(user.email)}`;
}
} else {
encodedOptions += `&${encodeURIComponent(key)}=${encodeURIComponent(dialogOptions[key] as string)}`;
}
}
return `${endpoint}?${encodedOptions}`;
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.