1 | Object.defineProperty(exports, '__esModule', { value: true });
|
2 |
|
3 | var utils = require('@sentry/utils');
|
4 |
|
5 | var SENTRY_API_VERSION = '7';
|
6 |
|
7 |
|
8 | function getBaseApiEndpoint(dsn) {
|
9 | var protocol = dsn.protocol ? `${dsn.protocol}:` : '';
|
10 | var port = dsn.port ? `:${dsn.port}` : '';
|
11 | return `${protocol}//${dsn.host}${port}${dsn.path ? `/${dsn.path}` : ''}/api/`;
|
12 | }
|
13 |
|
14 |
|
15 | function _getIngestEndpoint(dsn) {
|
16 | return `${getBaseApiEndpoint(dsn)}${dsn.projectId}/envelope/`;
|
17 | }
|
18 |
|
19 |
|
20 | function _encodedAuth(dsn, sdkInfo) {
|
21 | return utils.urlEncode({
|
22 |
|
23 |
|
24 | sentry_key: dsn.publicKey,
|
25 | sentry_version: SENTRY_API_VERSION,
|
26 | ...(sdkInfo && { sentry_client: `${sdkInfo.name}/${sdkInfo.version}` }),
|
27 | });
|
28 | }
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 | function getEnvelopeEndpointWithUrlEncodedAuth(
|
36 | dsn,
|
37 | // TODO (v8): Remove `tunnelOrOptions` in favor of `options`, and use the substitute code below
|
38 | // options: ClientOptions = {} as ClientOptions,
|
39 | tunnelOrOptions = {} ,
|
40 | ) {
|
41 |
|
42 |
|
43 |
|
44 |
|
45 | var tunnel = typeof tunnelOrOptions === 'string' ? tunnelOrOptions : tunnelOrOptions.tunnel;
|
46 | var sdkInfo =
|
47 | typeof tunnelOrOptions === 'string' || !tunnelOrOptions._metadata ? undefined : tunnelOrOptions._metadata.sdk;
|
48 |
|
49 | return tunnel ? tunnel : `${_getIngestEndpoint(dsn)}?${_encodedAuth(dsn, sdkInfo)}`;
|
50 | }
|
51 |
|
52 |
|
53 | function getReportDialogEndpoint(
|
54 | dsnLike,
|
55 | dialogOptions
|
56 |
|
57 | ,
|
58 | ) {
|
59 | var dsn = utils.makeDsn(dsnLike);
|
60 | var endpoint = `${getBaseApiEndpoint(dsn)}embed/error-page/`;
|
61 |
|
62 | let encodedOptions = `dsn=${utils.dsnToString(dsn)}`;
|
63 | for (var key in dialogOptions) {
|
64 | if (key === 'dsn') {
|
65 | continue;
|
66 | }
|
67 |
|
68 | if (key === 'user') {
|
69 | var user = dialogOptions.user;
|
70 | if (!user) {
|
71 | continue;
|
72 | }
|
73 | if (user.name) {
|
74 | encodedOptions += `&name=${encodeURIComponent(user.name)}`;
|
75 | }
|
76 | if (user.email) {
|
77 | encodedOptions += `&email=${encodeURIComponent(user.email)}`;
|
78 | }
|
79 | } else {
|
80 | encodedOptions += `&${encodeURIComponent(key)}=${encodeURIComponent(dialogOptions[key] )}`;
|
81 | }
|
82 | }
|
83 |
|
84 | return `${endpoint}?${encodedOptions}`;
|
85 | }
|
86 |
|
87 | exports.getEnvelopeEndpointWithUrlEncodedAuth = getEnvelopeEndpointWithUrlEncodedAuth;
|
88 | exports.getReportDialogEndpoint = getReportDialogEndpoint;
|
89 |
|