|
1 |
| -/* eslint-disable max-lines */ |
2 | 1 | import {
|
3 | 2 | SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
|
4 | 3 | getClient,
|
@@ -34,15 +33,20 @@ export interface RequestInstrumentationOptions {
|
34 | 33 | * List of strings and/or Regular Expressions used to determine which outgoing requests will have `sentry-trace` and `baggage`
|
35 | 34 | * headers attached.
|
36 | 35 | *
|
37 |
| - * By default, if this option is not provided, tracing headers will be attached to all outgoing requests to the same origin as the current page. |
| 36 | + * **Default:** If this option is not provided, tracing headers will be attached to all outgoing requests. |
| 37 | + * If you are using a browser SDK, by default, tracing headers will only be attached to outgoing requests to the same origin. |
38 | 38 | *
|
39 |
| - * NOTE: Carelessly setting this option may result into CORS errors. |
| 39 | + * **Disclaimer:** Carelessly setting this option in browser environments may result into CORS errors! |
| 40 | + * Only attach tracing headers to requests to the same origin, or to requests to services you can control CORS headers of. |
| 41 | + * Cross-origin requests, meaning requests to a different domain, for example a request to `https://api.example.com/` while you're on `https://example.com/`, take special care. |
| 42 | + * If you are attaching headers to cross-origin requests, make sure the backend handling the request returns a `"Access-Control-Allow-Headers: sentry-trace, baggage"` header to ensure your requests aren't blocked. |
40 | 43 | *
|
41 |
| - * If you provide a `tracePropagationTargets` array, the entries you provide will be matched against two values: |
42 |
| - * - The entire URL of the outgoing request. |
43 |
| - * - The pathname of the outgoing request (only if it is a same-origin request) |
| 44 | + * If you provide a `tracePropagationTargets` array, the entries you provide will be matched against the entire URL of the outgoing request. |
| 45 | + * If you are using a browser SDK, the entries will also be matched against the pathname of the outgoing requests. |
| 46 | + * This is so you can have matchers for relative requests, for example, `/^\/api/` if you want to trace requests to your `/api` routes on the same domain. |
44 | 47 | *
|
45 | 48 | * If any of the two match any of the provided values, tracing headers will be attached to the outgoing request.
|
| 49 | + * Both, the string values, and the RegExes you provide in the array will match if they partially match the URL or pathname. |
46 | 50 | *
|
47 | 51 | * Examples:
|
48 | 52 | * - `tracePropagationTargets: [/^\/api/]` and request to `https://same-origin.com/api/posts`:
|
@@ -246,7 +250,6 @@ export function shouldAttachHeaders(
|
246 | 250 | *
|
247 | 251 | * @returns Span if a span was created, otherwise void.
|
248 | 252 | */
|
249 |
| -// eslint-disable-next-line complexity |
250 | 253 | export function xhrCallback(
|
251 | 254 | handlerData: HandlerDataXhr,
|
252 | 255 | shouldCreateSpan: (url: string) => boolean,
|
|
0 commit comments