|
| 1 | +The below system integrations are part of the standard library or the interpreter itself and are enabled by default. To understand what they do and how to disable them if they cause issues, read on. |
| 2 | + |
| 3 | +## What's Enabled by Default |
| 4 | + |
| 5 | +### InboundFilters |
| 6 | + |
| 7 | +_Import name: `Sentry.Integrations.InboundFilters`_ |
| 8 | + |
| 9 | +This integration allows you to ignore specific errors based on the type, |
| 10 | +message, or URLs in a given exception. |
| 11 | + |
| 12 | +By default, it'll ignore errors that start with `Script error` or `Javascript error: Script error`. |
| 13 | + |
| 14 | +To configure this integration, use the `ignoreErrors`, `ignoreTransactions`, `denyUrls`, |
| 15 | +and `allowUrls` SDK options directly. Keep in mind that `denyURLs` and `allowURLs` |
| 16 | +only work for captured exceptions, not raw message events. |
| 17 | + |
| 18 | +### FunctionToString |
| 19 | + |
| 20 | +_Import name: `Sentry.Integrations.FunctionToString`_ |
| 21 | + |
| 22 | +This integration allows the SDK to provide original functions and method names, even when those functions or methods are wrapped by our error or breadcrumb handlers. |
| 23 | + |
| 24 | +<PlatformSection notSupported={["react-native"]}> |
| 25 | + |
| 26 | +### TryCatch |
| 27 | + |
| 28 | +_Import name: `Sentry.Integrations.TryCatch`_ |
| 29 | + |
| 30 | +This integration wraps native time and events APIs (`setTimeout`, `setInterval`, `requestAnimationFrame`, `addEventListener/removeEventListener`) in `try/catch` blocks to handle async exceptions. |
| 31 | + |
| 32 | +</PlatformSection> |
| 33 | + |
| 34 | +### Breadcrumbs |
| 35 | + |
| 36 | +_Import name: `Sentry.Integrations.Breadcrumbs`_ |
| 37 | + |
| 38 | +This integration wraps native APIs to capture breadcrumbs. By default, the Sentry SDK wraps all APIs. |
| 39 | + |
| 40 | +Available options: |
| 41 | + |
| 42 | +```javascript |
| 43 | +{ |
| 44 | + // Log calls to `console.log`, `console.debug`, etc |
| 45 | + console: boolean; |
| 46 | + |
| 47 | + // Log all click and keypress events |
| 48 | + // - When an object with `serializeAttribute` key is provided, |
| 49 | + // Breadcrumbs integration will look for given attribute(s) in DOM elements, |
| 50 | + // while generating the breadcrumb trails. |
| 51 | + // Matched elements will be followed by their custom attributes, |
| 52 | + // instead of their `id`s or `class` names. |
| 53 | + dom: boolean | { serializeAttribute: string | string[] }; |
| 54 | + |
| 55 | + // Log HTTP requests done with the Fetch API |
| 56 | + fetch: boolean; |
| 57 | + |
| 58 | + // Log calls to `history.pushState` and friends |
| 59 | + history: boolean; |
| 60 | + |
| 61 | + // Log whenever we send an event to the server |
| 62 | + sentry: boolean; |
| 63 | + |
| 64 | + // Log HTTP requests done with the XHR API |
| 65 | + xhr: boolean; |
| 66 | +} |
| 67 | +``` |
| 68 | + |
| 69 | +<PlatformSection notSupported={["react-native"]}> |
| 70 | + |
| 71 | +### GlobalHandlers |
| 72 | + |
| 73 | +_Import name: `Sentry.Integrations.GlobalHandlers`_ |
| 74 | + |
| 75 | +This integration attaches global handlers to capture uncaught exceptions and unhandled rejections. |
| 76 | + |
| 77 | +Available options: |
| 78 | + |
| 79 | +```javascript |
| 80 | +{ |
| 81 | + onerror: boolean; |
| 82 | + onunhandledrejection: boolean; |
| 83 | +} |
| 84 | +``` |
| 85 | + |
| 86 | +</PlatformSection> |
| 87 | + |
| 88 | +### LinkedErrors |
| 89 | + |
| 90 | +_Import name: `Sentry.Integrations.LinkedErrors`_ |
| 91 | + |
| 92 | +This integration allows you to configure linked errors. They’ll be recursively read up to a specified limit, and lookup will be performed by a specific key. By default, the Sentry SDK sets the limit to five and the key used is `"cause"`. |
| 93 | + |
| 94 | +Available options: |
| 95 | + |
| 96 | +```javascript |
| 97 | +{ |
| 98 | + key: string; |
| 99 | + limit: number; |
| 100 | +} |
| 101 | +``` |
| 102 | + |
| 103 | +Here is a code example of how this could be implemented: |
| 104 | + |
| 105 | +<PlatformContent includePath="configuration/linked-errors" /> |
| 106 | + |
| 107 | +### HttpContext |
| 108 | + |
| 109 | +_(Previously: `UserAgent`)_ |
| 110 | + |
| 111 | +_Import name: `Sentry.Integrations.HttpContext`_ |
| 112 | + |
| 113 | +<PlatformSection notSupported={["react-native"]}> |
| 114 | + |
| 115 | +<Note> |
| 116 | + |
| 117 | +Before version 7.0.0 of the Sentry SDK, this integration was called `UserAgent`. |
| 118 | +It was renamed because the integration handles more than user-agent data. |
| 119 | + |
| 120 | +_Import name: `Sentry.Integrations.UserAgent`_ |
| 121 | + |
| 122 | +</Note> |
| 123 | + |
| 124 | +</PlatformSection> |
| 125 | + |
| 126 | +This integration attaches HTTP request information, such as URL, user-agent, referrer, and other headers to the event. |
| 127 | +It allows us to correctly catalog and tag events with specific OS, browser, and version information. |
| 128 | + |
| 129 | +### Dedupe |
| 130 | + |
| 131 | +_Import name: `Sentry.Integrations.Dedupe`_ |
| 132 | + |
| 133 | +This integration is enabled by default for Browser, but only deduplicates certain events. It can be helpful if you're receiving many duplicate errors. Note, that Sentry only compares stack traces and fingerprints. |
| 134 | + |
| 135 | +<PlatformContent includePath="configuration/dedupe" /> |
| 136 | + |
| 137 | +<PlatformSection supported={["javascript.nextjs", "javascript.remix"]}> |
| 138 | + |
| 139 | +### RequestData |
| 140 | + |
| 141 | +_(New in version 7.17.1.)_ |
| 142 | + |
| 143 | +_Import name: `Sentry.Integrations.RequestData`_ |
| 144 | + |
| 145 | +This integration adds data from incoming requests to transaction and error events that occur during request handling done by the backend. |
| 146 | + |
| 147 | +Available options: |
| 148 | + |
| 149 | +```javascript |
| 150 | +{ |
| 151 | + // Controls what types of data are added to the event |
| 152 | + include: { |
| 153 | + cookies: boolean // default: true, |
| 154 | + data: boolean // default: true, |
| 155 | + headers: boolean // default: true, |
| 156 | + ip: boolean // default: false, |
| 157 | + query_string: boolean // default: true, |
| 158 | + url: boolean // default: true, |
| 159 | + user: boolean | { |
| 160 | + id: boolean // default: true, |
| 161 | + username: boolean // default: true, |
| 162 | + email: boolean // default: true, |
| 163 | + }, |
| 164 | + }, |
| 165 | + // Controls how the transaction will be reported. Options are 'path' (`/some/route`), |
| 166 | + // 'methodPath' (`GET /some/route`), and 'handler' (the name of the route handler |
| 167 | + // function, if available) |
| 168 | + transactionNamingScheme: string // default: 'methodPath', |
| 169 | +}; |
| 170 | +``` |
| 171 | + |
| 172 | +</PlatformSection> |
| 173 | + |
| 174 | +## Modifying System Integrations |
| 175 | + |
| 176 | +To disable system integrations, set `defaultIntegrations: false` when calling `init()`. |
| 177 | + |
| 178 | +To override their settings, provide a new instance with your config to the `integrations` option. For example, to turn off browser capturing console calls: |
| 179 | + |
| 180 | +```javascript |
| 181 | +Sentry.init({ |
| 182 | + dsn: "___PUBLIC_DSN___", |
| 183 | + |
| 184 | + integrations: [ |
| 185 | + new Sentry.Integrations.Breadcrumbs({ |
| 186 | + console: false, |
| 187 | + }), |
| 188 | + ], |
| 189 | +}); |
| 190 | +``` |
| 191 | + |
| 192 | +### Removing an Integration |
| 193 | + |
| 194 | +This example removes the default-enabled integration for adding breadcrumbs to the event: |
| 195 | + |
| 196 | +```javascript |
| 197 | +Sentry.init({ |
| 198 | + // ... |
| 199 | + integrations: function (integrations) { |
| 200 | + // integrations will be all default integrations |
| 201 | + return integrations.filter(function (integration) { |
| 202 | + return integration.name !== "Breadcrumbs"; |
| 203 | + }); |
| 204 | + }, |
| 205 | +}); |
| 206 | +``` |
0 commit comments