mirror of
https://github.com/MarSeventh/CloudFlare-ImgBed.git
synced 2026-04-27 15:45:07 +00:00
init
This commit is contained in:
11
node_modules/@sentry-internal/tracing/cjs/common/debug-build.js
generated
vendored
Normal file
11
node_modules/@sentry-internal/tracing/cjs/common/debug-build.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
/**
|
||||
* This serves as a build time flag that will be true by default, but false in non-debug builds or if users replace `__SENTRY_DEBUG__` in their generated code.
|
||||
*
|
||||
* ATTENTION: This constant must never cross package boundaries (i.e. be exported) to guarantee that it can be used for tree shaking.
|
||||
*/
|
||||
const DEBUG_BUILD = (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__);
|
||||
|
||||
exports.DEBUG_BUILD = DEBUG_BUILD;
|
||||
//# sourceMappingURL=debug-build.js.map
|
||||
1
node_modules/@sentry-internal/tracing/cjs/common/debug-build.js.map
generated
vendored
Normal file
1
node_modules/@sentry-internal/tracing/cjs/common/debug-build.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"debug-build.js","sources":["../../../src/common/debug-build.ts"],"sourcesContent":["declare const __DEBUG_BUILD__: boolean;\n\n/**\n * This serves as a build time flag that will be true by default, but false in non-debug builds or if users replace `__SENTRY_DEBUG__` in their generated code.\n *\n * ATTENTION: This constant must never cross package boundaries (i.e. be exported) to guarantee that it can be used for tree shaking.\n */\nexport const DEBUG_BUILD = __DEBUG_BUILD__;\n"],"names":[],"mappings":";;AAEA;AACA;AACA;AACA;AACA;AACO,MAAM,WAAY,IAAE,OAAA,gBAAA,KAAA,WAAA,IAAA,gBAAA;;;;"}
|
||||
191
node_modules/@sentry-internal/tracing/cjs/common/fetch.js
generated
vendored
Normal file
191
node_modules/@sentry-internal/tracing/cjs/common/fetch.js
generated
vendored
Normal file
@@ -0,0 +1,191 @@
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
const core = require('@sentry/core');
|
||||
const utils = require('@sentry/utils');
|
||||
|
||||
/**
|
||||
* Create and track fetch request spans for usage in combination with `addInstrumentationHandler`.
|
||||
*
|
||||
* @returns Span if a span was created, otherwise void.
|
||||
*/
|
||||
function instrumentFetchRequest(
|
||||
handlerData,
|
||||
shouldCreateSpan,
|
||||
shouldAttachHeaders,
|
||||
spans,
|
||||
spanOrigin = 'auto.http.browser',
|
||||
) {
|
||||
if (!core.hasTracingEnabled() || !handlerData.fetchData) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const shouldCreateSpanResult = shouldCreateSpan(handlerData.fetchData.url);
|
||||
|
||||
if (handlerData.endTimestamp && shouldCreateSpanResult) {
|
||||
const spanId = handlerData.fetchData.__span;
|
||||
if (!spanId) return;
|
||||
|
||||
const span = spans[spanId];
|
||||
if (span) {
|
||||
endSpan(span, handlerData);
|
||||
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
||||
delete spans[spanId];
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const scope = core.getCurrentScope();
|
||||
const client = core.getClient();
|
||||
|
||||
const { method, url } = handlerData.fetchData;
|
||||
|
||||
const fullUrl = getFullURL(url);
|
||||
const host = fullUrl ? utils.parseUrl(fullUrl).host : undefined;
|
||||
|
||||
const span = shouldCreateSpanResult
|
||||
? core.startInactiveSpan({
|
||||
name: `${method} ${url}`,
|
||||
onlyIfParent: true,
|
||||
attributes: {
|
||||
url,
|
||||
type: 'fetch',
|
||||
'http.method': method,
|
||||
'http.url': fullUrl,
|
||||
'server.address': host,
|
||||
[core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: spanOrigin,
|
||||
},
|
||||
op: 'http.client',
|
||||
})
|
||||
: undefined;
|
||||
|
||||
if (span) {
|
||||
handlerData.fetchData.__span = span.spanContext().spanId;
|
||||
spans[span.spanContext().spanId] = span;
|
||||
}
|
||||
|
||||
if (shouldAttachHeaders(handlerData.fetchData.url) && client) {
|
||||
const request = handlerData.args[0];
|
||||
|
||||
// In case the user hasn't set the second argument of a fetch call we default it to `{}`.
|
||||
handlerData.args[1] = handlerData.args[1] || {};
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const options = handlerData.args[1];
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access
|
||||
options.headers = addTracingHeadersToFetchRequest(request, client, scope, options, span);
|
||||
}
|
||||
|
||||
return span;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds sentry-trace and baggage headers to the various forms of fetch headers
|
||||
*/
|
||||
function addTracingHeadersToFetchRequest(
|
||||
request, // unknown is actually type Request but we can't export DOM types from this package,
|
||||
client,
|
||||
scope,
|
||||
options
|
||||
|
||||
,
|
||||
requestSpan,
|
||||
) {
|
||||
// eslint-disable-next-line deprecation/deprecation
|
||||
const span = requestSpan || scope.getSpan();
|
||||
|
||||
const isolationScope = core.getIsolationScope();
|
||||
|
||||
const { traceId, spanId, sampled, dsc } = {
|
||||
...isolationScope.getPropagationContext(),
|
||||
...scope.getPropagationContext(),
|
||||
};
|
||||
|
||||
const sentryTraceHeader = span ? core.spanToTraceHeader(span) : utils.generateSentryTraceHeader(traceId, spanId, sampled);
|
||||
|
||||
const sentryBaggageHeader = utils.dynamicSamplingContextToSentryBaggageHeader(
|
||||
dsc ||
|
||||
(span ? core.getDynamicSamplingContextFromSpan(span) : core.getDynamicSamplingContextFromClient(traceId, client, scope)),
|
||||
);
|
||||
|
||||
const headers =
|
||||
options.headers ||
|
||||
(typeof Request !== 'undefined' && utils.isInstanceOf(request, Request) ? (request ).headers : undefined);
|
||||
|
||||
if (!headers) {
|
||||
return { 'sentry-trace': sentryTraceHeader, baggage: sentryBaggageHeader };
|
||||
} else if (typeof Headers !== 'undefined' && utils.isInstanceOf(headers, Headers)) {
|
||||
const newHeaders = new Headers(headers );
|
||||
|
||||
newHeaders.append('sentry-trace', sentryTraceHeader);
|
||||
|
||||
if (sentryBaggageHeader) {
|
||||
// If the same header is appended multiple times the browser will merge the values into a single request header.
|
||||
// Its therefore safe to simply push a "baggage" entry, even though there might already be another baggage header.
|
||||
newHeaders.append(utils.BAGGAGE_HEADER_NAME, sentryBaggageHeader);
|
||||
}
|
||||
|
||||
return newHeaders ;
|
||||
} else if (Array.isArray(headers)) {
|
||||
const newHeaders = [...headers, ['sentry-trace', sentryTraceHeader]];
|
||||
|
||||
if (sentryBaggageHeader) {
|
||||
// If there are multiple entries with the same key, the browser will merge the values into a single request header.
|
||||
// Its therefore safe to simply push a "baggage" entry, even though there might already be another baggage header.
|
||||
newHeaders.push([utils.BAGGAGE_HEADER_NAME, sentryBaggageHeader]);
|
||||
}
|
||||
|
||||
return newHeaders ;
|
||||
} else {
|
||||
const existingBaggageHeader = 'baggage' in headers ? headers.baggage : undefined;
|
||||
const newBaggageHeaders = [];
|
||||
|
||||
if (Array.isArray(existingBaggageHeader)) {
|
||||
newBaggageHeaders.push(...existingBaggageHeader);
|
||||
} else if (existingBaggageHeader) {
|
||||
newBaggageHeaders.push(existingBaggageHeader);
|
||||
}
|
||||
|
||||
if (sentryBaggageHeader) {
|
||||
newBaggageHeaders.push(sentryBaggageHeader);
|
||||
}
|
||||
|
||||
return {
|
||||
...(headers ),
|
||||
'sentry-trace': sentryTraceHeader,
|
||||
baggage: newBaggageHeaders.length > 0 ? newBaggageHeaders.join(',') : undefined,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function getFullURL(url) {
|
||||
try {
|
||||
const parsed = new URL(url);
|
||||
return parsed.href;
|
||||
} catch (e) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function endSpan(span, handlerData) {
|
||||
if (handlerData.response) {
|
||||
core.setHttpStatus(span, handlerData.response.status);
|
||||
|
||||
const contentLength =
|
||||
handlerData.response && handlerData.response.headers && handlerData.response.headers.get('content-length');
|
||||
|
||||
if (contentLength) {
|
||||
const contentLengthNum = parseInt(contentLength);
|
||||
if (contentLengthNum > 0) {
|
||||
span.setAttribute('http.response_content_length', contentLengthNum);
|
||||
}
|
||||
}
|
||||
} else if (handlerData.error) {
|
||||
span.setStatus('internal_error');
|
||||
}
|
||||
span.end();
|
||||
}
|
||||
|
||||
exports.addTracingHeadersToFetchRequest = addTracingHeadersToFetchRequest;
|
||||
exports.instrumentFetchRequest = instrumentFetchRequest;
|
||||
//# sourceMappingURL=fetch.js.map
|
||||
1
node_modules/@sentry-internal/tracing/cjs/common/fetch.js.map
generated
vendored
Normal file
1
node_modules/@sentry-internal/tracing/cjs/common/fetch.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user