Comparing version 2.4.1 to 2.5.0-beta.1
@@ -176,6 +176,12 @@ 'use strict'; | ||
} | ||
this.request = | ||
"request" in options.event | ||
? this.toSentryRequest(options.event.request) | ||
: undefined; | ||
// This is to maintain backwards compatibility for 'event' option. When we remove it, all this complex logic can go away. | ||
if ("context" in options && options.context.request) { | ||
this.request = this.toSentryRequest(options.context.request); | ||
} | ||
else if ("request" in options && options.request) { | ||
this.request = this.toSentryRequest(options.request); | ||
} | ||
else if ("event" in options && "request" in options.event) { | ||
this.request = this.toSentryRequest(options.event.request); | ||
} | ||
this.beforeSend = this.beforeSend.bind(this); | ||
@@ -272,3 +278,9 @@ /** | ||
return; | ||
this.options.event.waitUntil(this.reportException(event, exception)); | ||
// This is to maintain backwards compatibility for 'event' option. When we remove it, all this complex logic can go away. | ||
if ("context" in this.options) { | ||
this.options.context.waitUntil(this.reportException(event, exception)); | ||
} | ||
else { | ||
this.options.event.waitUntil(this.reportException(event, exception)); | ||
} | ||
return event.event_id; | ||
@@ -288,3 +300,8 @@ } | ||
return; | ||
this.options.event.waitUntil(this.reportMessage(event)); | ||
if ("context" in this.options) { | ||
this.options.context.waitUntil(this.reportMessage(event)); | ||
} | ||
else { | ||
this.options.event.waitUntil(this.reportMessage(event)); | ||
} | ||
return event.event_id; | ||
@@ -343,3 +360,3 @@ } | ||
"Content-Type": "application/json", | ||
"User-Agent": "toucan-js/2.4.1", | ||
"User-Agent": "toucan-js/2.5.0-beta.1", | ||
}; | ||
@@ -414,3 +431,3 @@ // Build headers | ||
name: "toucan-js", | ||
version: "2.4.1", | ||
version: "2.5.0-beta.1", | ||
}, | ||
@@ -417,0 +434,0 @@ }; |
@@ -174,6 +174,12 @@ import { API } from '@sentry/core'; | ||
} | ||
this.request = | ||
"request" in options.event | ||
? this.toSentryRequest(options.event.request) | ||
: undefined; | ||
// This is to maintain backwards compatibility for 'event' option. When we remove it, all this complex logic can go away. | ||
if ("context" in options && options.context.request) { | ||
this.request = this.toSentryRequest(options.context.request); | ||
} | ||
else if ("request" in options && options.request) { | ||
this.request = this.toSentryRequest(options.request); | ||
} | ||
else if ("event" in options && "request" in options.event) { | ||
this.request = this.toSentryRequest(options.event.request); | ||
} | ||
this.beforeSend = this.beforeSend.bind(this); | ||
@@ -270,3 +276,9 @@ /** | ||
return; | ||
this.options.event.waitUntil(this.reportException(event, exception)); | ||
// This is to maintain backwards compatibility for 'event' option. When we remove it, all this complex logic can go away. | ||
if ("context" in this.options) { | ||
this.options.context.waitUntil(this.reportException(event, exception)); | ||
} | ||
else { | ||
this.options.event.waitUntil(this.reportException(event, exception)); | ||
} | ||
return event.event_id; | ||
@@ -286,3 +298,8 @@ } | ||
return; | ||
this.options.event.waitUntil(this.reportMessage(event)); | ||
if ("context" in this.options) { | ||
this.options.context.waitUntil(this.reportMessage(event)); | ||
} | ||
else { | ||
this.options.event.waitUntil(this.reportMessage(event)); | ||
} | ||
return event.event_id; | ||
@@ -341,3 +358,3 @@ } | ||
"Content-Type": "application/json", | ||
"User-Agent": "toucan-js/2.4.1", | ||
"User-Agent": "toucan-js/2.5.0-beta.1", | ||
}; | ||
@@ -412,3 +429,3 @@ // Build headers | ||
name: "toucan-js", | ||
version: "2.4.1", | ||
version: "2.5.0-beta.1", | ||
}, | ||
@@ -415,0 +432,0 @@ }; |
@@ -7,4 +7,14 @@ /// <reference types="@cloudflare/workers-types" /> | ||
}; | ||
export declare type Options = { | ||
export declare type Context = { | ||
waitUntil: (promise: Promise<any>) => void; | ||
request?: Request; | ||
}; | ||
declare type WithEvent = { | ||
event: FetchEvent | ScheduledEvent; | ||
}; | ||
declare type WithContext = { | ||
context: Context; | ||
request?: Request; | ||
}; | ||
declare type OtherOptions = { | ||
dsn?: SentryOptions["dsn"]; | ||
@@ -25,2 +35,3 @@ allowedCookies?: string[] | RegExp; | ||
}; | ||
export declare type Options = (WithEvent & OtherOptions) | (WithContext & OtherOptions); | ||
export declare type Level = "critical" | "fatal" | "error" | "warning" | "info" | "log" | "debug"; | ||
@@ -27,0 +38,0 @@ export declare type Breadcrumb = Compute<Omit<SentryBreadcrumb, "level"> & { |
{ | ||
"name": "toucan-js", | ||
"version": "2.4.1", | ||
"version": "2.5.0-beta.1", | ||
"description": "Cloudflare Workers client for Sentry", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.cjs.js", |
@@ -82,28 +82,30 @@ <p align="center"> | ||
| Option | Type | Description | | ||
| ------ | ------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| event | \*FetchEvent \| ScheduledEvent | Workers event. Toucan needs this to be able to call [waitUntil](https://developers.cloudflare.com/workers/about/tips/fetch-event-lifecycle/). | | ||
| dsn | string | Sentry [Data Source Name](https://docs.sentry.io/error-reporting/quickstart/?platform=javascript#configure-the-sdk). If an empty DSN is passed, we treat it as valid option which signifies disabling the SDK. | | ||
| Option | Type | Description | | ||
| ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| context | \*Context | Only available in `2.5.0-beta.1` and optional if `event` is set. This can be any object that contains [waitUntil](https://developers.cloudflare.com/workers/about/tips/fetch-event-lifecycle/), and optionally [request](https://developers.cloudflare.com/workers/runtime-apis/request). It is the most universal way to instantiate Toucan in any kind of Cloudflare Worker. It can be [FetchEvent](https://developers.cloudflare.com/workers/runtime-apis/fetch-event), [ScheduledEvent](https://developers.cloudflare.com/workers/runtime-apis/scheduled-event), [DurableObjectState](https://developers.cloudflare.com/workers/runtime-apis/durable-objects), or [.mjs context](https://community.cloudflare.com/t/2021-4-15-workers-runtime-release-notes/261917). Note that DurableObjectState and .mjs ctx don't include request, you will need to set it as 'request' option. | | ||
| event | \*[FetchEvent](https://developers.cloudflare.com/workers/runtime-apis/fetch-event) \| [ScheduledEvent](https://developers.cloudflare.com/workers/runtime-apis/scheduled-event) | Workers event. Toucan needs this to be able to call [waitUntil](https://developers.cloudflare.com/workers/about/tips/fetch-event-lifecycle/). Optional in `2.5.0-beta.1` if `context` is set. | | ||
| dsn | string | Sentry [Data Source Name](https://docs.sentry.io/error-reporting/quickstart/?platform=javascript#configure-the-sdk). If an empty DSN is passed, we treat it as valid option which signifies disabling the SDK. | | ||
## Other options | ||
| Option | Type | Description | | ||
| ------------------- | --------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| allowedCookies | string[] \| RegExp | Array of allowed cookies, or a regular expression used to explicitly allow cookies of incoming request. If not provided, cookies will not be logged. No effect without request in context. | | ||
| allowedHeaders | string[] \| RegExp | Array of allowed headers, or a regular expression used to explicitly allow headers of incoming request. If not provided, headers will not be logged. No effect without request in context. | | ||
| allowedSearchParams | string[] \| RegExp | Array of allowed search params, or a regular expression used to explicitly allow search params of incoming request. If not provided, search params will not be logged. No effect without request in context. | | ||
| attachStacktrace | boolean | Attaches stacktraces to capture message. Default true. | | ||
| beforeSend | (event: Event) => Event | This function is applied to all events before sending to Sentry. If provided, all allowlists are ignored. | | ||
| debug | boolean | Turns debug mode on or off. If debug is enabled, toucan-js will attempt to print out useful debugging information. | | ||
| environment | string | Your application's environment (production/staging/...). | | ||
| maxBreadcrumbs | number | This variable controls the total amount of breadcrumbs that should be captured. This defaults to 100. | | ||
| pkg | object | Essentially your package.json. Toucan will use it to read project name, version, dependencies, and devDependencies. | | ||
| release | string | Release tag. | | ||
| rewriteFrames | { root?: string, iteratee?: (frame: StackFrame) => StackFrame } | Allows you to apply a transformation to each frame of the stack trace. `root` path will be appended to the basename of the current frame's url. `iteratee` is a function that takes the frame, applies any transformation on it and returns it back. | | ||
| sampleRate | number | Configures the sample rate as a percentage of events to be sent in the range of 0.0 to 1.0. The default is 1.0 which means that 100% of events are sent. If set to 0.1 only 10% of events will be sent. Events are picked randomly. | | ||
| transportOptions | { headers?: Record<string, string> } | Custom headers to be passed to Sentry. | | ||
| Option | Type | Description | | ||
| ------------------- | ------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| allowedCookies | string[] \| RegExp | Array of allowed cookies, or a regular expression used to explicitly allow cookies of incoming request. If not provided, cookies will not be logged. No effect without request in context. | | ||
| allowedHeaders | string[] \| RegExp | Array of allowed headers, or a regular expression used to explicitly allow headers of incoming request. If not provided, headers will not be logged. No effect without request in context. | | ||
| allowedSearchParams | string[] \| RegExp | Array of allowed search params, or a regular expression used to explicitly allow search params of incoming request. If not provided, search params will not be logged. No effect without request in context. | | ||
| attachStacktrace | boolean | Attaches stacktraces to capture message. Default true. | | ||
| beforeSend | (event: Event) => Event | This function is applied to all events before sending to Sentry. If provided, all allowlists are ignored. | | ||
| debug | boolean | Turns debug mode on or off. If debug is enabled, toucan-js will attempt to print out useful debugging information. | | ||
| environment | string | Your application's environment (production/staging/...). | | ||
| maxBreadcrumbs | number | This variable controls the total amount of breadcrumbs that should be captured. This defaults to 100. | | ||
| pkg | object | Essentially your package.json. Toucan will use it to read project name, version, dependencies, and devDependencies. | | ||
| release | string | Release tag. | | ||
| request | [Request](https://developers.cloudflare.com/workers/runtime-apis/request) | Only available in `2.5.0-beta.1`. You will want to use this option in Durable Object or .mjs Worker, where `request` isn't included in `context`. | | ||
| rewriteFrames | { root?: string, iteratee?: (frame: StackFrame) => StackFrame } | Allows you to apply a transformation to each frame of the stack trace. `root` path will be appended to the basename of the current frame's url. `iteratee` is a function that takes the frame, applies any transformation on it and returns it back. | | ||
| sampleRate | number | Configures the sample rate as a percentage of events to be sent in the range of 0.0 to 1.0. The default is 1.0 which means that 100% of events are sent. If set to 0.1 only 10% of events will be sent. Events are picked randomly. | | ||
| transportOptions | { headers?: Record<string, string> } | Custom headers to be passed to Sentry. | | ||
## Sensitive data | ||
Toucan does not send [PII (Personally Identifiable Information)](https://docs.sentry.io/data-management/sensitive-data/) by default. | ||
By default, Toucan does not send any Request property that could carry [PII (Personally Identifiable Information)](https://docs.sentry.io/data-management/sensitive-data/) to Sentry. | ||
@@ -117,3 +119,3 @@ This includes: | ||
You will need to explicitly allow potentially sensitive data using: | ||
You will need to explicitly allow these data using: | ||
@@ -123,3 +125,3 @@ - allowedHeaders option (array of headers or Regex) | ||
- allowedSearchParams option (array of search params or Regex) | ||
- toucan.setRequestBody function (stringified JSON) | ||
- toucan.setRequestBody function | ||
- beforeSend option (if you need more flexibility than allowedX functions) | ||
@@ -126,0 +128,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
89091
1765
165
1