@sentry/cloudflare 8.21.0 → 8.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +132 -8
- package/build/cjs/d1.js +157 -0
- package/build/cjs/d1.js.map +1 -0
- package/build/cjs/handler.js +45 -75
- package/build/cjs/handler.js.map +1 -1
- package/build/cjs/index.js +7 -0
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/pages-plugin.js +52 -0
- package/build/cjs/pages-plugin.js.map +1 -0
- package/build/cjs/request.js +84 -0
- package/build/cjs/request.js.map +1 -0
- package/build/cjs/scope-utils.js +33 -0
- package/build/cjs/scope-utils.js.map +1 -0
- package/build/cjs/sdk.js +8 -3
- package/build/cjs/sdk.js.map +1 -1
- package/build/esm/d1.js +155 -0
- package/build/esm/d1.js.map +1 -0
- package/build/esm/handler.js +43 -73
- package/build/esm/handler.js.map +1 -1
- package/build/esm/index.js +4 -1
- package/build/esm/index.js.map +1 -1
- package/build/esm/pages-plugin.js +50 -0
- package/build/esm/pages-plugin.js.map +1 -0
- package/build/esm/request.js +82 -0
- package/build/esm/request.js.map +1 -0
- package/build/esm/scope-utils.js +29 -0
- package/build/esm/scope-utils.js.map +1 -0
- package/build/esm/sdk.js +5 -3
- package/build/esm/sdk.js.map +1 -1
- package/build/types/d1.d.ts +17 -0
- package/build/types/d1.d.ts.map +1 -0
- package/build/types/handler.d.ts +2 -2
- package/build/types/handler.d.ts.map +1 -1
- package/build/types/index.d.ts +4 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/pages-plugin.d.ts +35 -0
- package/build/types/pages-plugin.d.ts.map +1 -0
- package/build/types/request.d.ts +13 -0
- package/build/types/request.d.ts.map +1 -0
- package/build/types/scope-utils.d.ts +15 -0
- package/build/types/scope-utils.d.ts.map +1 -0
- package/build/types/sdk.d.ts +4 -3
- package/build/types/sdk.d.ts.map +1 -1
- package/build/types-ts3.8/d1.d.ts +17 -0
- package/build/types-ts3.8/handler.d.ts +2 -2
- package/build/types-ts3.8/index.d.ts +4 -1
- package/build/types-ts3.8/pages-plugin.d.ts +35 -0
- package/build/types-ts3.8/request.d.ts +13 -0
- package/build/types-ts3.8/scope-utils.d.ts +15 -0
- package/build/types-ts3.8/sdk.d.ts +4 -3
- package/package.json +6 -7
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pages-plugin.js","sources":["../../src/pages-plugin.ts"],"sourcesContent":["import { setAsyncLocalStorageAsyncContextStrategy } from './async';\nimport type { CloudflareOptions } from './client';\nimport { wrapRequestHandler } from './request';\n\n/**\n * Plugin middleware for Cloudflare Pages.\n *\n * Initializes the SDK and wraps cloudflare pages requests with SDK instrumentation.\n *\n * @example Simple usage\n *\n * ```javascript\n * // functions/_middleware.js\n * import * as Sentry from '@sentry/cloudflare';\n *\n * export const onRequest = Sentry.sentryPagesPlugin({\n * dsn: process.env.SENTRY_DSN,\n * tracesSampleRate: 1.0,\n * });\n * ```\n *\n * @example Usage with handler function to access context for environmental variables\n *\n * ```javascript\n * import * as Sentry from '@sentry/cloudflare';\n *\n * const const onRequest = Sentry.sentryPagesPlugin((context) => ({\n * dsn: context.env.SENTRY_DSN,\n * tracesSampleRate: 1.0,\n * })\n * ```\n *\n * @param handlerOrOptions Configuration options or a function that returns configuration options.\n * @returns A plugin function that can be used in Cloudflare Pages.\n */\nexport function sentryPagesPlugin<\n Env = unknown,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Params extends string = any,\n Data extends Record<string, unknown> = Record<string, unknown>,\n // Although it is not ideal to use `any` here, it makes usage more flexible for different setups.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n PluginParams = any,\n>(\n handlerOrOptions:\n | CloudflareOptions\n | ((context: EventPluginContext<Env, Params, Data, PluginParams>) => CloudflareOptions),\n): PagesPluginFunction<Env, Params, Data, PluginParams> {\n setAsyncLocalStorageAsyncContextStrategy();\n return context => {\n const options = typeof handlerOrOptions === 'function' ? handlerOrOptions(context) : handlerOrOptions;\n return wrapRequestHandler({ options, request: context.request, context }, () => context.next());\n };\n}\n"],"names":[],"mappings":";;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,iBAAiB;;AAQjC;AACA,EAAE,gBAAgB;AACd;AACA;AACJ,EAAwD;AACxD,EAAE,wCAAwC,EAAE,CAAA;AAC5C,EAAE,OAAO,WAAW;AACpB,IAAI,MAAM,OAAA,GAAU,OAAO,gBAAiB,KAAI,UAAW,GAAE,gBAAgB,CAAC,OAAO,CAAA,GAAI,gBAAgB,CAAA;AACzG,IAAI,OAAO,kBAAkB,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,OAAQ,EAAC,EAAE,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC,CAAA;AACnG,GAAG,CAAA;AACH;;;;"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { withIsolationScope, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_OP, continueTrace, startSpan, setHttpStatus, captureException, flush } from '@sentry/core';
|
|
2
|
+
import { stripUrlQueryAndFragment } from '@sentry/utils';
|
|
3
|
+
import { addCloudResourceContext, addRequest, addCultureContext } from './scope-utils.js';
|
|
4
|
+
import { init } from './sdk.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Wraps a cloudflare request handler in Sentry instrumentation
|
|
8
|
+
*/
|
|
9
|
+
function wrapRequestHandler(
|
|
10
|
+
wrapperOptions,
|
|
11
|
+
handler,
|
|
12
|
+
) {
|
|
13
|
+
return withIsolationScope(async isolationScope => {
|
|
14
|
+
const { options, request, context } = wrapperOptions;
|
|
15
|
+
const client = init(options);
|
|
16
|
+
isolationScope.setClient(client);
|
|
17
|
+
|
|
18
|
+
const attributes = {
|
|
19
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.cloudflare',
|
|
20
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',
|
|
21
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'http.server',
|
|
22
|
+
['http.request.method']: request.method,
|
|
23
|
+
['url.full']: request.url,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const contentLength = request.headers.get('content-length');
|
|
27
|
+
if (contentLength) {
|
|
28
|
+
attributes['http.request.body.size'] = parseInt(contentLength, 10);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let pathname = '';
|
|
32
|
+
try {
|
|
33
|
+
const url = new URL(request.url);
|
|
34
|
+
pathname = url.pathname;
|
|
35
|
+
attributes['server.address'] = url.hostname;
|
|
36
|
+
attributes['url.scheme'] = url.protocol.replace(':', '');
|
|
37
|
+
} catch (e2) {
|
|
38
|
+
// skip
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
addCloudResourceContext(isolationScope);
|
|
42
|
+
if (request) {
|
|
43
|
+
addRequest(isolationScope, request);
|
|
44
|
+
if (request.cf) {
|
|
45
|
+
addCultureContext(isolationScope, request.cf);
|
|
46
|
+
attributes['network.protocol.name'] = request.cf.httpProtocol;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const routeName = `${request.method} ${pathname ? stripUrlQueryAndFragment(pathname) : '/'}`;
|
|
51
|
+
|
|
52
|
+
return continueTrace(
|
|
53
|
+
{ sentryTrace: request.headers.get('sentry-trace') || '', baggage: request.headers.get('baggage') },
|
|
54
|
+
() => {
|
|
55
|
+
// Note: This span will not have a duration unless I/O happens in the handler. This is
|
|
56
|
+
// because of how the cloudflare workers runtime works.
|
|
57
|
+
// See: https://developers.cloudflare.com/workers/runtime-apis/performance/
|
|
58
|
+
return startSpan(
|
|
59
|
+
{
|
|
60
|
+
name: routeName,
|
|
61
|
+
attributes,
|
|
62
|
+
},
|
|
63
|
+
async span => {
|
|
64
|
+
try {
|
|
65
|
+
const res = await handler();
|
|
66
|
+
setHttpStatus(span, res.status);
|
|
67
|
+
return res;
|
|
68
|
+
} catch (e) {
|
|
69
|
+
captureException(e, { mechanism: { handled: false, type: 'cloudflare' } });
|
|
70
|
+
throw e;
|
|
71
|
+
} finally {
|
|
72
|
+
context.waitUntil(flush(2000));
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
);
|
|
76
|
+
},
|
|
77
|
+
);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export { wrapRequestHandler };
|
|
82
|
+
//# sourceMappingURL=request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.js","sources":["../../src/request.ts"],"sourcesContent":["import type { ExecutionContext, IncomingRequestCfProperties } from '@cloudflare/workers-types';\n\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n captureException,\n continueTrace,\n flush,\n setHttpStatus,\n startSpan,\n withIsolationScope,\n} from '@sentry/core';\nimport type { SpanAttributes } from '@sentry/types';\nimport { stripUrlQueryAndFragment } from '@sentry/utils';\nimport type { CloudflareOptions } from './client';\nimport { addCloudResourceContext, addCultureContext, addRequest } from './scope-utils';\nimport { init } from './sdk';\n\ninterface RequestHandlerWrapperOptions {\n options: CloudflareOptions;\n request: Request<unknown, IncomingRequestCfProperties<unknown>>;\n context: ExecutionContext;\n}\n\n/**\n * Wraps a cloudflare request handler in Sentry instrumentation\n */\nexport function wrapRequestHandler(\n wrapperOptions: RequestHandlerWrapperOptions,\n handler: (...args: unknown[]) => Response | Promise<Response>,\n): Promise<Response> {\n return withIsolationScope(async isolationScope => {\n const { options, request, context } = wrapperOptions;\n const client = init(options);\n isolationScope.setClient(client);\n\n const attributes: SpanAttributes = {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.cloudflare',\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'http.server',\n ['http.request.method']: request.method,\n ['url.full']: request.url,\n };\n\n const contentLength = request.headers.get('content-length');\n if (contentLength) {\n attributes['http.request.body.size'] = parseInt(contentLength, 10);\n }\n\n let pathname = '';\n try {\n const url = new URL(request.url);\n pathname = url.pathname;\n attributes['server.address'] = url.hostname;\n attributes['url.scheme'] = url.protocol.replace(':', '');\n } catch {\n // skip\n }\n\n addCloudResourceContext(isolationScope);\n if (request) {\n addRequest(isolationScope, request);\n if (request.cf) {\n addCultureContext(isolationScope, request.cf);\n attributes['network.protocol.name'] = request.cf.httpProtocol;\n }\n }\n\n const routeName = `${request.method} ${pathname ? stripUrlQueryAndFragment(pathname) : '/'}`;\n\n return continueTrace(\n { sentryTrace: request.headers.get('sentry-trace') || '', baggage: request.headers.get('baggage') },\n () => {\n // Note: This span will not have a duration unless I/O happens in the handler. This is\n // because of how the cloudflare workers runtime works.\n // See: https://developers.cloudflare.com/workers/runtime-apis/performance/\n return startSpan(\n {\n name: routeName,\n attributes,\n },\n async span => {\n try {\n const res = await handler();\n setHttpStatus(span, res.status);\n return res;\n } catch (e) {\n captureException(e, { mechanism: { handled: false, type: 'cloudflare' } });\n throw e;\n } finally {\n context.waitUntil(flush(2000));\n }\n },\n );\n },\n );\n });\n}\n"],"names":[],"mappings":";;;;;AAyBA;AACA;AACA;AACO,SAAS,kBAAkB;AAClC,EAAE,cAAc;AAChB,EAAE,OAAO;AACT,EAAqB;AACrB,EAAE,OAAO,kBAAkB,CAAC,MAAM,kBAAkB;AACpD,IAAI,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAA,EAAU,GAAE,cAAc,CAAA;AACxD,IAAI,MAAM,MAAO,GAAE,IAAI,CAAC,OAAO,CAAC,CAAA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scope.
|
|
5
|
+
*/
|
|
6
|
+
function addCloudResourceContext(scope) {
|
|
7
|
+
scope.setContext('cloud_resource', {
|
|
8
|
+
'cloud.provider': 'cloudflare',
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Set culture context on scope
|
|
14
|
+
*/
|
|
15
|
+
function addCultureContext(scope, cf) {
|
|
16
|
+
scope.setContext('culture', {
|
|
17
|
+
timezone: cf.timezone,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Set request data on scope
|
|
23
|
+
*/
|
|
24
|
+
function addRequest(scope, request) {
|
|
25
|
+
scope.setSDKProcessingMetadata({ request: winterCGRequestToRequestData(request) });
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { addCloudResourceContext, addCultureContext, addRequest };
|
|
29
|
+
//# sourceMappingURL=scope-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope-utils.js","sources":["../../src/scope-utils.ts"],"sourcesContent":["import type { IncomingRequestCfProperties } from '@cloudflare/workers-types';\n\nimport type { Scope } from '@sentry/types';\nimport { winterCGRequestToRequestData } from '@sentry/utils';\n\n/**\n * Set cloud resource context on scope.\n */\nexport function addCloudResourceContext(scope: Scope): void {\n scope.setContext('cloud_resource', {\n 'cloud.provider': 'cloudflare',\n });\n}\n\n/**\n * Set culture context on scope\n */\nexport function addCultureContext(scope: Scope, cf: IncomingRequestCfProperties): void {\n scope.setContext('culture', {\n timezone: cf.timezone,\n });\n}\n\n/**\n * Set request data on scope\n */\nexport function addRequest(scope: Scope, request: Request): void {\n scope.setSDKProcessingMetadata({ request: winterCGRequestToRequestData(request) });\n}\n"],"names":[],"mappings":";;AAKA;AACA;AACA;AACO,SAAS,uBAAuB,CAAC,KAAK,EAAe;AAC5D,EAAE,KAAK,CAAC,UAAU,CAAC,gBAAgB,EAAE;AACrC,IAAI,gBAAgB,EAAE,YAAY;AAClC,GAAG,CAAC,CAAA;AACJ,CAAA;AACA;AACA;AACA;AACA;AACO,SAAS,iBAAiB,CAAC,KAAK,EAAS,EAAE,EAAqC;AACvF,EAAE,KAAK,CAAC,UAAU,CAAC,SAAS,EAAE;AAC9B,IAAI,QAAQ,EAAE,EAAE,CAAC,QAAQ;AACzB,GAAG,CAAC,CAAA;AACJ,CAAA;AACA;AACA;AACA;AACA;AACO,SAAS,UAAU,CAAC,KAAK,EAAS,OAAO,EAAiB;AACjE,EAAE,KAAK,CAAC,wBAAwB,CAAC,EAAE,OAAO,EAAE,4BAA4B,CAAC,OAAO,CAAE,EAAC,CAAC,CAAA;AACpF;;;;"}
|
package/build/esm/sdk.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { _nullishCoalesce } from '@sentry/utils';
|
|
1
2
|
import { dedupeIntegration, inboundFiltersIntegration, functionToStringIntegration, linkedErrorsIntegration, requestDataIntegration, getIntegrationsToSetup, initAndBind } from '@sentry/core';
|
|
2
3
|
import { stackParserFromStackParserOptions } from '@sentry/utils';
|
|
3
4
|
import { CloudflareClient } from './client.js';
|
|
@@ -6,14 +7,15 @@ import { makeCloudflareTransport } from './transport.js';
|
|
|
6
7
|
import { defaultStackParser } from './vendor/stacktrace.js';
|
|
7
8
|
|
|
8
9
|
/** Get the default integrations for the Cloudflare SDK. */
|
|
9
|
-
function getDefaultIntegrations(
|
|
10
|
+
function getDefaultIntegrations(options) {
|
|
11
|
+
const sendDefaultPii = _nullishCoalesce(options.sendDefaultPii, () => ( false));
|
|
10
12
|
return [
|
|
11
13
|
dedupeIntegration(),
|
|
12
14
|
inboundFiltersIntegration(),
|
|
13
15
|
functionToStringIntegration(),
|
|
14
16
|
linkedErrorsIntegration(),
|
|
15
17
|
fetchIntegration(),
|
|
16
|
-
requestDataIntegration(),
|
|
18
|
+
requestDataIntegration(sendDefaultPii ? undefined : { include: { cookies: false } }),
|
|
17
19
|
];
|
|
18
20
|
}
|
|
19
21
|
|
|
@@ -22,7 +24,7 @@ function getDefaultIntegrations(_options) {
|
|
|
22
24
|
*/
|
|
23
25
|
function init(options) {
|
|
24
26
|
if (options.defaultIntegrations === undefined) {
|
|
25
|
-
options.defaultIntegrations = getDefaultIntegrations();
|
|
27
|
+
options.defaultIntegrations = getDefaultIntegrations(options);
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
const clientOptions = {
|
package/build/esm/sdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.js","sources":["../../src/sdk.ts"],"sourcesContent":["import {\n dedupeIntegration,\n functionToStringIntegration,\n getIntegrationsToSetup,\n inboundFiltersIntegration,\n initAndBind,\n linkedErrorsIntegration,\n requestDataIntegration,\n} from '@sentry/core';\nimport type { Integration
|
|
1
|
+
{"version":3,"file":"sdk.js","sources":["../../src/sdk.ts"],"sourcesContent":["import {\n dedupeIntegration,\n functionToStringIntegration,\n getIntegrationsToSetup,\n inboundFiltersIntegration,\n initAndBind,\n linkedErrorsIntegration,\n requestDataIntegration,\n} from '@sentry/core';\nimport type { Integration } from '@sentry/types';\nimport { stackParserFromStackParserOptions } from '@sentry/utils';\nimport type { CloudflareClientOptions, CloudflareOptions } from './client';\nimport { CloudflareClient } from './client';\n\nimport { fetchIntegration } from './integrations/fetch';\nimport { makeCloudflareTransport } from './transport';\nimport { defaultStackParser } from './vendor/stacktrace';\n\n/** Get the default integrations for the Cloudflare SDK. */\nexport function getDefaultIntegrations(options: CloudflareOptions): Integration[] {\n const sendDefaultPii = options.sendDefaultPii ?? false;\n return [\n dedupeIntegration(),\n inboundFiltersIntegration(),\n functionToStringIntegration(),\n linkedErrorsIntegration(),\n fetchIntegration(),\n requestDataIntegration(sendDefaultPii ? undefined : { include: { cookies: false } }),\n ];\n}\n\n/**\n * Initializes the cloudflare SDK.\n */\nexport function init(options: CloudflareOptions): CloudflareClient | undefined {\n if (options.defaultIntegrations === undefined) {\n options.defaultIntegrations = getDefaultIntegrations(options);\n }\n\n const clientOptions: CloudflareClientOptions = {\n ...options,\n stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser),\n integrations: getIntegrationsToSetup(options),\n transport: options.transport || makeCloudflareTransport,\n };\n\n return initAndBind(CloudflareClient, clientOptions) as CloudflareClient;\n}\n"],"names":[],"mappings":";;;;;;;;AAkBA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,EAAA,CAAA;AACO,CAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAsB,CAAC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,EAAoC;EAChF,CAAM,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAe,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,CAAC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAe,UAAG,CAAK,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;EACtD,CAAO,CAAA,CAAA,CAAA,CAAA,EAAA;IACL,iBAAiB,CAAE,CAAA;IACnB,yB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AAA,CAAA,CAAA,CAAA,CAAC,gBAAgB,EAAE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAa,EAAE;AACtD;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { D1Database } from '@cloudflare/workers-types';
|
|
2
|
+
/**
|
|
3
|
+
* Instruments Cloudflare D1 bindings with Sentry.
|
|
4
|
+
*
|
|
5
|
+
* Currently, only prepared statements are instrumented. `db.exec` and `db.batch` are not instrumented.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
*
|
|
9
|
+
* ```js
|
|
10
|
+
* // env.DB is the D1 DB binding configured in your `wrangler.toml`
|
|
11
|
+
* const db = instrumentD1WithSentry(env.DB);
|
|
12
|
+
* // Now you can use the database as usual
|
|
13
|
+
* await db.prepare('SELECT * FROM table WHERE id = ?').bind(1).run();
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function instrumentD1WithSentry(db: D1Database): D1Database;
|
|
17
|
+
//# sourceMappingURL=d1.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"d1.d.ts","sourceRoot":"","sources":["../../src/d1.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAmC,MAAM,2BAA2B,CAAC;AAiI7F;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,UAAU,GAAG,UAAU,CAUjE"}
|
package/build/types/handler.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ExportedHandler } from '@cloudflare/workers-types';
|
|
2
|
-
import type {
|
|
2
|
+
import type { CloudflareOptions } from './client';
|
|
3
3
|
/**
|
|
4
4
|
* Extract environment generic from exported handler.
|
|
5
5
|
*/
|
|
@@ -15,6 +15,6 @@ type ExtractEnv<P> = P extends ExportedHandler<infer Env> ? Env : never;
|
|
|
15
15
|
* @param handler {ExportedHandler} The handler to wrap.
|
|
16
16
|
* @returns The wrapped handler.
|
|
17
17
|
*/
|
|
18
|
-
export declare function withSentry<E extends ExportedHandler<any>>(optionsCallback: (env: ExtractEnv<E>) =>
|
|
18
|
+
export declare function withSentry<E extends ExportedHandler<any>>(optionsCallback: (env: ExtractEnv<E>) => CloudflareOptions, handler: E): E;
|
|
19
19
|
export {};
|
|
20
20
|
//# sourceMappingURL=handler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EAGhB,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EAGhB,MAAM,2BAA2B,CAAC;AAUnC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAKlD;;GAEG;AACH,KAAK,UAAU,CAAC,CAAC,IAAI,CAAC,SAAS,eAAe,CAAC,MAAM,GAAG,CAAC,GAAG,GAAG,GAAG,KAAK,CAAC;AAExE;;;;;;;;;;GAUG;AAEH,wBAAgB,UAAU,CAAC,CAAC,SAAS,eAAe,CAAC,GAAG,CAAC,EACvD,eAAe,EAAE,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,iBAAiB,EAC1D,OAAO,EAAE,CAAC,GACT,CAAC,CAiEH"}
|
package/build/types/index.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
export type { Breadcrumb, BreadcrumbHint, PolymorphicRequest, Request, SdkInfo, Event, EventHint, ErrorEvent, Exception, Session, SeverityLevel, Span, StackFrame, Stacktrace, Thread, User, } from '@sentry/types';
|
|
2
2
|
export type { AddRequestDataToEventOptions } from '@sentry/utils';
|
|
3
3
|
export type { CloudflareOptions } from './client';
|
|
4
|
-
export { addEventProcessor, addBreadcrumb, addIntegration, captureException, captureEvent, captureMessage, captureFeedback, close, createTransport, lastEventId, flush, getClient, isInitialized, getCurrentScope, getGlobalScope, getIsolationScope, setCurrentClient, Scope, SDK_VERSION, setContext, setExtra, setExtras, setTag, setTags, setUser, getSpanStatusFromHttpCode, setHttpStatus, withScope, withIsolationScope, captureCheckIn, withMonitor, setMeasurement, getActiveSpan, getRootSpan, startSpan, startInactiveSpan, startSpanManual, startNewTrace, withActiveSpan, getSpanDescendants, continueTrace, metrics, functionToStringIntegration, inboundFiltersIntegration, linkedErrorsIntegration, requestDataIntegration, extraErrorDataIntegration, debugIntegration, dedupeIntegration, rewriteFramesIntegration, captureConsoleIntegration, moduleMetadataIntegration, zodErrorsIntegration, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, trpcMiddleware, spanToJSON, spanToTraceHeader, spanToBaggageHeader, } from '@sentry/core';
|
|
4
|
+
export { addEventProcessor, addBreadcrumb, addIntegration, captureException, captureEvent, captureMessage, captureFeedback, close, createTransport, lastEventId, flush, getClient, isInitialized, getCurrentScope, getGlobalScope, getIsolationScope, setCurrentClient, Scope, SDK_VERSION, setContext, setExtra, setExtras, setTag, setTags, setUser, getSpanStatusFromHttpCode, setHttpStatus, withScope, withIsolationScope, captureCheckIn, withMonitor, setMeasurement, getActiveSpan, getRootSpan, getTraceData, startSpan, startInactiveSpan, startSpanManual, startNewTrace, withActiveSpan, getSpanDescendants, continueTrace, metrics, functionToStringIntegration, inboundFiltersIntegration, linkedErrorsIntegration, requestDataIntegration, extraErrorDataIntegration, debugIntegration, dedupeIntegration, rewriteFramesIntegration, captureConsoleIntegration, moduleMetadataIntegration, zodErrorsIntegration, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, trpcMiddleware, spanToJSON, spanToTraceHeader, spanToBaggageHeader, } from '@sentry/core';
|
|
5
5
|
export { withSentry } from './handler';
|
|
6
|
+
export { sentryPagesPlugin } from './pages-plugin';
|
|
7
|
+
export { wrapRequestHandler } from './request';
|
|
6
8
|
export { CloudflareClient } from './client';
|
|
7
9
|
export { getDefaultIntegrations } from './sdk';
|
|
8
10
|
export { fetchIntegration } from './integrations/fetch';
|
|
11
|
+
export { instrumentD1WithSentry } from './d1';
|
|
9
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,UAAU,EACV,cAAc,EACd,kBAAkB,EAClB,OAAO,EACP,OAAO,EACP,KAAK,EACL,SAAS,EACT,UAAU,EACV,SAAS,EACT,OAAO,EACP,aAAa,EACb,IAAI,EACJ,UAAU,EACV,UAAU,EACV,MAAM,EACN,IAAI,GACL,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,4BAA4B,EAAE,MAAM,eAAe,CAAC;AAElE,YAAY,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAElD,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,eAAe,EACf,KAAK,EACL,eAAe,EACf,WAAW,EACX,KAAK,EACL,SAAS,EACT,aAAa,EACb,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,EACL,WAAW,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,MAAM,EACN,OAAO,EACP,OAAO,EACP,yBAAyB,EACzB,aAAa,EACb,SAAS,EACT,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,cAAc,EACd,aAAa,EACb,WAAW,EACX,SAAS,EACT,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,OAAO,EACP,2BAA2B,EAC3B,yBAAyB,EACzB,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,EACzB,gBAAgB,EAChB,iBAAiB,EACjB,wBAAwB,EACxB,yBAAyB,EACzB,yBAAyB,EACzB,oBAAoB,EACpB,4BAA4B,EAC5B,gCAAgC,EAChC,gCAAgC,EAChC,qCAAqC,EACrC,cAAc,EACd,UAAU,EACV,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,UAAU,EACV,cAAc,EACd,kBAAkB,EAClB,OAAO,EACP,OAAO,EACP,KAAK,EACL,SAAS,EACT,UAAU,EACV,SAAS,EACT,OAAO,EACP,aAAa,EACb,IAAI,EACJ,UAAU,EACV,UAAU,EACV,MAAM,EACN,IAAI,GACL,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,4BAA4B,EAAE,MAAM,eAAe,CAAC;AAElE,YAAY,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAElD,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,eAAe,EACf,KAAK,EACL,eAAe,EACf,WAAW,EACX,KAAK,EACL,SAAS,EACT,aAAa,EACb,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,EACL,WAAW,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,MAAM,EACN,OAAO,EACP,OAAO,EACP,yBAAyB,EACzB,aAAa,EACb,SAAS,EACT,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,cAAc,EACd,aAAa,EACb,WAAW,EACX,YAAY,EACZ,SAAS,EACT,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,OAAO,EACP,2BAA2B,EAC3B,yBAAyB,EACzB,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,EACzB,gBAAgB,EAChB,iBAAiB,EACjB,wBAAwB,EACxB,yBAAyB,EACzB,yBAAyB,EACzB,oBAAoB,EACpB,4BAA4B,EAC5B,gCAAgC,EAChC,gCAAgC,EAChC,qCAAqC,EACrC,cAAc,EACd,UAAU,EACV,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAE,MAAM,OAAO,CAAC;AAE/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAAE,sBAAsB,EAAE,MAAM,MAAM,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/// <reference types="@cloudflare/workers-types" />
|
|
2
|
+
import type { CloudflareOptions } from './client';
|
|
3
|
+
/**
|
|
4
|
+
* Plugin middleware for Cloudflare Pages.
|
|
5
|
+
*
|
|
6
|
+
* Initializes the SDK and wraps cloudflare pages requests with SDK instrumentation.
|
|
7
|
+
*
|
|
8
|
+
* @example Simple usage
|
|
9
|
+
*
|
|
10
|
+
* ```javascript
|
|
11
|
+
* // functions/_middleware.js
|
|
12
|
+
* import * as Sentry from '@sentry/cloudflare';
|
|
13
|
+
*
|
|
14
|
+
* export const onRequest = Sentry.sentryPagesPlugin({
|
|
15
|
+
* dsn: process.env.SENTRY_DSN,
|
|
16
|
+
* tracesSampleRate: 1.0,
|
|
17
|
+
* });
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @example Usage with handler function to access context for environmental variables
|
|
21
|
+
*
|
|
22
|
+
* ```javascript
|
|
23
|
+
* import * as Sentry from '@sentry/cloudflare';
|
|
24
|
+
*
|
|
25
|
+
* const const onRequest = Sentry.sentryPagesPlugin((context) => ({
|
|
26
|
+
* dsn: context.env.SENTRY_DSN,
|
|
27
|
+
* tracesSampleRate: 1.0,
|
|
28
|
+
* })
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @param handlerOrOptions Configuration options or a function that returns configuration options.
|
|
32
|
+
* @returns A plugin function that can be used in Cloudflare Pages.
|
|
33
|
+
*/
|
|
34
|
+
export declare function sentryPagesPlugin<Env = unknown, Params extends string = any, Data extends Record<string, unknown> = Record<string, unknown>, PluginParams = any>(handlerOrOptions: CloudflareOptions | ((context: EventPluginContext<Env, Params, Data, PluginParams>) => CloudflareOptions)): PagesPluginFunction<Env, Params, Data, PluginParams>;
|
|
35
|
+
//# sourceMappingURL=pages-plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pages-plugin.d.ts","sourceRoot":"","sources":["../../src/pages-plugin.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAGlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,GAAG,OAAO,EAEb,MAAM,SAAS,MAAM,GAAG,GAAG,EAC3B,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAG9D,YAAY,GAAG,GAAG,EAElB,gBAAgB,EACZ,iBAAiB,GACjB,CAAC,CAAC,OAAO,EAAE,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,CAAC,KAAK,iBAAiB,CAAC,GACxF,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,CAAC,CAMtD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ExecutionContext, IncomingRequestCfProperties } from '@cloudflare/workers-types';
|
|
2
|
+
import type { CloudflareOptions } from './client';
|
|
3
|
+
interface RequestHandlerWrapperOptions {
|
|
4
|
+
options: CloudflareOptions;
|
|
5
|
+
request: Request<unknown, IncomingRequestCfProperties<unknown>>;
|
|
6
|
+
context: ExecutionContext;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Wraps a cloudflare request handler in Sentry instrumentation
|
|
10
|
+
*/
|
|
11
|
+
export declare function wrapRequestHandler(wrapperOptions: RequestHandlerWrapperOptions, handler: (...args: unknown[]) => Response | Promise<Response>): Promise<Response>;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAe/F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAIlD,UAAU,4BAA4B;IACpC,OAAO,EAAE,iBAAiB,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,2BAA2B,CAAC,OAAO,CAAC,CAAC,CAAC;IAChE,OAAO,EAAE,gBAAgB,CAAC;CAC3B;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,cAAc,EAAE,4BAA4B,EAC5C,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,GAC5D,OAAO,CAAC,QAAQ,CAAC,CAmEnB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { IncomingRequestCfProperties } from '@cloudflare/workers-types';
|
|
2
|
+
import type { Scope } from '@sentry/types';
|
|
3
|
+
/**
|
|
4
|
+
* Set cloud resource context on scope.
|
|
5
|
+
*/
|
|
6
|
+
export declare function addCloudResourceContext(scope: Scope): void;
|
|
7
|
+
/**
|
|
8
|
+
* Set culture context on scope
|
|
9
|
+
*/
|
|
10
|
+
export declare function addCultureContext(scope: Scope, cf: IncomingRequestCfProperties): void;
|
|
11
|
+
/**
|
|
12
|
+
* Set request data on scope
|
|
13
|
+
*/
|
|
14
|
+
export declare function addRequest(scope: Scope, request: Request): void;
|
|
15
|
+
//# sourceMappingURL=scope-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope-utils.d.ts","sourceRoot":"","sources":["../../src/scope-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAE7E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAG3C;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAI1D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,2BAA2B,GAAG,IAAI,CAIrF;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAE/D"}
|
package/build/types/sdk.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { Integration
|
|
1
|
+
import type { Integration } from '@sentry/types';
|
|
2
|
+
import type { CloudflareOptions } from './client';
|
|
2
3
|
import { CloudflareClient } from './client';
|
|
3
4
|
/** Get the default integrations for the Cloudflare SDK. */
|
|
4
|
-
export declare function getDefaultIntegrations(
|
|
5
|
+
export declare function getDefaultIntegrations(options: CloudflareOptions): Integration[];
|
|
5
6
|
/**
|
|
6
7
|
* Initializes the cloudflare SDK.
|
|
7
8
|
*/
|
|
8
|
-
export declare function init(options:
|
|
9
|
+
export declare function init(options: CloudflareOptions): CloudflareClient | undefined;
|
|
9
10
|
//# sourceMappingURL=sdk.d.ts.map
|
package/build/types/sdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/sdk.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/sdk.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,KAAK,EAA2B,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAM5C,2DAA2D;AAC3D,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,iBAAiB,GAAG,WAAW,EAAE,CAUhF;AAED;;GAEG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,iBAAiB,GAAG,gBAAgB,GAAG,SAAS,CAa7E"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { D1Database } from '@cloudflare/workers-types';
|
|
2
|
+
/**
|
|
3
|
+
* Instruments Cloudflare D1 bindings with Sentry.
|
|
4
|
+
*
|
|
5
|
+
* Currently, only prepared statements are instrumented. `db.exec` and `db.batch` are not instrumented.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
*
|
|
9
|
+
* ```js
|
|
10
|
+
* // env.DB is the D1 DB binding configured in your `wrangler.toml`
|
|
11
|
+
* const db = instrumentD1WithSentry(env.DB);
|
|
12
|
+
* // Now you can use the database as usual
|
|
13
|
+
* await db.prepare('SELECT * FROM table WHERE id = ?').bind(1).run();
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function instrumentD1WithSentry(db: D1Database): D1Database;
|
|
17
|
+
//# sourceMappingURL=d1.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ExportedHandler } from '@cloudflare/workers-types';
|
|
2
|
-
import {
|
|
2
|
+
import { CloudflareOptions } from './client';
|
|
3
3
|
/**
|
|
4
4
|
* Extract environment generic from exported handler.
|
|
5
5
|
*/
|
|
@@ -15,6 +15,6 @@ type ExtractEnv<P> = P extends ExportedHandler<infer Env> ? Env : never;
|
|
|
15
15
|
* @param handler {ExportedHandler} The handler to wrap.
|
|
16
16
|
* @returns The wrapped handler.
|
|
17
17
|
*/
|
|
18
|
-
export declare function withSentry<E extends ExportedHandler<any>>(optionsCallback: (env: ExtractEnv<E>) =>
|
|
18
|
+
export declare function withSentry<E extends ExportedHandler<any>>(optionsCallback: (env: ExtractEnv<E>) => CloudflareOptions, handler: E): E;
|
|
19
19
|
export {};
|
|
20
20
|
//# sourceMappingURL=handler.d.ts.map
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
export { Breadcrumb, BreadcrumbHint, PolymorphicRequest, Request, SdkInfo, Event, EventHint, ErrorEvent, Exception, Session, SeverityLevel, Span, StackFrame, Stacktrace, Thread, User, } from '@sentry/types';
|
|
2
2
|
export { AddRequestDataToEventOptions } from '@sentry/utils';
|
|
3
3
|
export { CloudflareOptions } from './client';
|
|
4
|
-
export { addEventProcessor, addBreadcrumb, addIntegration, captureException, captureEvent, captureMessage, captureFeedback, close, createTransport, lastEventId, flush, getClient, isInitialized, getCurrentScope, getGlobalScope, getIsolationScope, setCurrentClient, Scope, SDK_VERSION, setContext, setExtra, setExtras, setTag, setTags, setUser, getSpanStatusFromHttpCode, setHttpStatus, withScope, withIsolationScope, captureCheckIn, withMonitor, setMeasurement, getActiveSpan, getRootSpan, startSpan, startInactiveSpan, startSpanManual, startNewTrace, withActiveSpan, getSpanDescendants, continueTrace, metrics, functionToStringIntegration, inboundFiltersIntegration, linkedErrorsIntegration, requestDataIntegration, extraErrorDataIntegration, debugIntegration, dedupeIntegration, rewriteFramesIntegration, captureConsoleIntegration, moduleMetadataIntegration, zodErrorsIntegration, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, trpcMiddleware, spanToJSON, spanToTraceHeader, spanToBaggageHeader, } from '@sentry/core';
|
|
4
|
+
export { addEventProcessor, addBreadcrumb, addIntegration, captureException, captureEvent, captureMessage, captureFeedback, close, createTransport, lastEventId, flush, getClient, isInitialized, getCurrentScope, getGlobalScope, getIsolationScope, setCurrentClient, Scope, SDK_VERSION, setContext, setExtra, setExtras, setTag, setTags, setUser, getSpanStatusFromHttpCode, setHttpStatus, withScope, withIsolationScope, captureCheckIn, withMonitor, setMeasurement, getActiveSpan, getRootSpan, getTraceData, startSpan, startInactiveSpan, startSpanManual, startNewTrace, withActiveSpan, getSpanDescendants, continueTrace, metrics, functionToStringIntegration, inboundFiltersIntegration, linkedErrorsIntegration, requestDataIntegration, extraErrorDataIntegration, debugIntegration, dedupeIntegration, rewriteFramesIntegration, captureConsoleIntegration, moduleMetadataIntegration, zodErrorsIntegration, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, trpcMiddleware, spanToJSON, spanToTraceHeader, spanToBaggageHeader, } from '@sentry/core';
|
|
5
5
|
export { withSentry } from './handler';
|
|
6
|
+
export { sentryPagesPlugin } from './pages-plugin';
|
|
7
|
+
export { wrapRequestHandler } from './request';
|
|
6
8
|
export { CloudflareClient } from './client';
|
|
7
9
|
export { getDefaultIntegrations } from './sdk';
|
|
8
10
|
export { fetchIntegration } from './integrations/fetch';
|
|
11
|
+
export { instrumentD1WithSentry } from './d1';
|
|
9
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/// <reference types="@cloudflare/workers-types" />
|
|
2
|
+
import { CloudflareOptions } from './client';
|
|
3
|
+
/**
|
|
4
|
+
* Plugin middleware for Cloudflare Pages.
|
|
5
|
+
*
|
|
6
|
+
* Initializes the SDK and wraps cloudflare pages requests with SDK instrumentation.
|
|
7
|
+
*
|
|
8
|
+
* @example Simple usage
|
|
9
|
+
*
|
|
10
|
+
* ```javascript
|
|
11
|
+
* // functions/_middleware.js
|
|
12
|
+
* import * as Sentry from '@sentry/cloudflare';
|
|
13
|
+
*
|
|
14
|
+
* export const onRequest = Sentry.sentryPagesPlugin({
|
|
15
|
+
* dsn: process.env.SENTRY_DSN,
|
|
16
|
+
* tracesSampleRate: 1.0,
|
|
17
|
+
* });
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @example Usage with handler function to access context for environmental variables
|
|
21
|
+
*
|
|
22
|
+
* ```javascript
|
|
23
|
+
* import * as Sentry from '@sentry/cloudflare';
|
|
24
|
+
*
|
|
25
|
+
* const const onRequest = Sentry.sentryPagesPlugin((context) => ({
|
|
26
|
+
* dsn: context.env.SENTRY_DSN,
|
|
27
|
+
* tracesSampleRate: 1.0,
|
|
28
|
+
* })
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @param handlerOrOptions Configuration options or a function that returns configuration options.
|
|
32
|
+
* @returns A plugin function that can be used in Cloudflare Pages.
|
|
33
|
+
*/
|
|
34
|
+
export declare function sentryPagesPlugin<Env = unknown, Params extends string = any, Data extends Record<string, unknown> = Record<string, unknown>, PluginParams = any>(handlerOrOptions: CloudflareOptions | ((context: EventPluginContext<Env, Params, Data, PluginParams>) => CloudflareOptions)): PagesPluginFunction<Env, Params, Data, PluginParams>;
|
|
35
|
+
//# sourceMappingURL=pages-plugin.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ExecutionContext, IncomingRequestCfProperties } from '@cloudflare/workers-types';
|
|
2
|
+
import { CloudflareOptions } from './client';
|
|
3
|
+
interface RequestHandlerWrapperOptions {
|
|
4
|
+
options: CloudflareOptions;
|
|
5
|
+
request: Request<unknown, IncomingRequestCfProperties<unknown>>;
|
|
6
|
+
context: ExecutionContext;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Wraps a cloudflare request handler in Sentry instrumentation
|
|
10
|
+
*/
|
|
11
|
+
export declare function wrapRequestHandler(wrapperOptions: RequestHandlerWrapperOptions, handler: (...args: unknown[]) => Response | Promise<Response>): Promise<Response>;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=request.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IncomingRequestCfProperties } from '@cloudflare/workers-types';
|
|
2
|
+
import { Scope } from '@sentry/types';
|
|
3
|
+
/**
|
|
4
|
+
* Set cloud resource context on scope.
|
|
5
|
+
*/
|
|
6
|
+
export declare function addCloudResourceContext(scope: Scope): void;
|
|
7
|
+
/**
|
|
8
|
+
* Set culture context on scope
|
|
9
|
+
*/
|
|
10
|
+
export declare function addCultureContext(scope: Scope, cf: IncomingRequestCfProperties): void;
|
|
11
|
+
/**
|
|
12
|
+
* Set request data on scope
|
|
13
|
+
*/
|
|
14
|
+
export declare function addRequest(scope: Scope, request: Request): void;
|
|
15
|
+
//# sourceMappingURL=scope-utils.d.ts.map
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { Integration
|
|
1
|
+
import { Integration } from '@sentry/types';
|
|
2
|
+
import { CloudflareOptions } from './client';
|
|
2
3
|
import { CloudflareClient } from './client';
|
|
3
4
|
/** Get the default integrations for the Cloudflare SDK. */
|
|
4
|
-
export declare function getDefaultIntegrations(
|
|
5
|
+
export declare function getDefaultIntegrations(options: CloudflareOptions): Integration[];
|
|
5
6
|
/**
|
|
6
7
|
* Initializes the cloudflare SDK.
|
|
7
8
|
*/
|
|
8
|
-
export declare function init(options:
|
|
9
|
+
export declare function init(options: CloudflareOptions): CloudflareClient | undefined;
|
|
9
10
|
//# sourceMappingURL=sdk.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/cloudflare",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.23.0",
|
|
4
4
|
"description": "Offical Sentry SDK for Cloudflare Workers and Pages",
|
|
5
5
|
"repository": "git://github.com/getsentry/sentry-javascript.git",
|
|
6
6
|
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/cloudflare",
|
|
@@ -39,18 +39,17 @@
|
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@sentry/core": "8.
|
|
43
|
-
"@sentry/types": "8.
|
|
44
|
-
"@sentry/utils": "8.
|
|
42
|
+
"@sentry/core": "8.23.0",
|
|
43
|
+
"@sentry/types": "8.23.0",
|
|
44
|
+
"@sentry/utils": "8.23.0"
|
|
45
45
|
},
|
|
46
46
|
"optionalDependencies": {
|
|
47
47
|
"@cloudflare/workers-types": "^4.x"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@cloudflare/workers-types": "^4.
|
|
50
|
+
"@cloudflare/workers-types": "^4.20240725.0",
|
|
51
51
|
"@types/node": "^14.18.0",
|
|
52
|
-
"
|
|
53
|
-
"wrangler": "^3.65.1"
|
|
52
|
+
"wrangler": "^3.67.1"
|
|
54
53
|
},
|
|
55
54
|
"scripts": {
|
|
56
55
|
"build": "run-p build:transpile build:types",
|