Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9312348
api.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
api.js
View Options
import
{
urlEncode
,
makeDsn
,
dsnToString
}
from
'@sentry/utils'
;
var
SENTRY_API_VERSION
=
'7'
;
/** Returns the prefix to construct Sentry ingestion API endpoints. */
function
getBaseApiEndpoint
(
dsn
)
{
var
protocol
=
dsn
.
protocol
?
`
${
dsn
.
protocol
}
:`
:
''
;
var
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
)
{
return
`
${
getBaseApiEndpoint
(
dsn
)
}${
dsn
.
projectId
}
/envelope/`
;
}
/** Returns a URL-encoded string with auth config suitable for a query string. */
function
_encodedAuth
(
dsn
,
sdkInfo
)
{
return
urlEncode
({
// We send only the minimum set of required information. See
// https://github.com/getsentry/sentry-javascript/issues/2572.
sentry_key
:
dsn
.
publicKey
,
sentry_version
:
SENTRY_API_VERSION
,
...(
sdkInfo
&&
{
sentry_client
:
`
${
sdkInfo
.
name
}
/
${
sdkInfo
.
version
}
`
}),
});
}
/**
* 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.
*/
function
getEnvelopeEndpointWithUrlEncodedAuth
(
dsn
,
// TODO (v8): Remove `tunnelOrOptions` in favor of `options`, and use the substitute code below
// options: ClientOptions = {} as ClientOptions,
tunnelOrOptions
=
{}
,
)
{
// TODO (v8): Use this code instead
// const { tunnel, _metadata = {} } = options;
// return tunnel ? tunnel : `${_getIngestEndpoint(dsn)}?${_encodedAuth(dsn, _metadata.sdk)}`;
var
tunnel
=
typeof
tunnelOrOptions
===
'string'
?
tunnelOrOptions
:
tunnelOrOptions
.
tunnel
;
var
sdkInfo
=
typeof
tunnelOrOptions
===
'string'
||
!
tunnelOrOptions
.
_metadata
?
undefined
:
tunnelOrOptions
.
_metadata
.
sdk
;
return
tunnel
?
tunnel
:
`
${
_getIngestEndpoint
(
dsn
)
}
?
${
_encodedAuth
(
dsn
,
sdkInfo
)
}
`
;
}
/** Returns the url to the report dialog endpoint. */
function
getReportDialogEndpoint
(
dsnLike
,
dialogOptions
,
)
{
var
dsn
=
makeDsn
(
dsnLike
);
var
endpoint
=
`
${
getBaseApiEndpoint
(
dsn
)
}
embed/error-page/`
;
let
encodedOptions
=
`dsn=
${
dsnToString
(
dsn
)
}
`
;
for
(
var
key
in
dialogOptions
)
{
if
(
key
===
'dsn'
)
{
continue
;
}
if
(
key
===
'user'
)
{
var
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
]
)
}
`
;
}
}
return
`
${
endpoint
}
?
${
encodedOptions
}
`
;
}
export
{
getEnvelopeEndpointWithUrlEncodedAuth
,
getReportDialogEndpoint
};
//# sourceMappingURL=api.js.map
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Thu, Jul 3, 10:50 AM (2 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3378177
Attached To
rDWAPPS Web applications
Event Timeline
Log In to Comment