Skip to content

Commit a66f50b

Browse files
authored
Add Flutter network headers capture documentation (#37440)
* Add Flutter network headers capture documentation Documents the `trackResourceHeaders` / `ResourceHeadersExtractor` API in the Flutter RUM advanced configuration page, aligning with the Android and iOS sections added in #36291. * Apply review suggestions
1 parent b985a5b commit a66f50b

1 file changed

Lines changed: 37 additions & 2 deletions

File tree

layouts/shortcodes/mdoc/en/sdk/advanced_config/flutter.mdoc.md

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ The flavor (variant) of the application. For stack trace deobfuscation, this mus
6666
`firstPartyHosts`
6767
: Optional
6868
**Type**: List<String>
69-
A list of first party hosts, used in conjunction with Datadog network tracking packages. Overrides any values set in `firstPartyHostsWithTracinHeaders`. To specify different headers per host, use `firstPartyHostsWithTracingHeaders` instead.
69+
A list of first party hosts, used in conjunction with Datadog network tracking packages. Overrides any values set in `firstPartyHostsWithTracingHeaders`. To specify different headers per host, use `firstPartyHostsWithTracingHeaders` instead.
7070

7171
`firstPartyHostsWithTracingHeaders`
7272
: Optional
@@ -208,9 +208,44 @@ To enable Datadog [distributed tracing][13], you must set the `DatadogConfigurat
208208

209209
- `DatadogRumConfiguration.traceSampleRate` sets a default sampling rate of 20%. If you want all resources requests to generate a full distributed trace, set this value to `100.0`.
210210

211+
### Capture resource headers
212+
213+
When [tracking resources automatically][10], you can capture HTTP request and response headers on RUM Resources by setting `trackResourceHeaders` on `DatadogRumConfiguration`. This option applies to all Datadog HTTP tracking clients (Tracking HTTP Client, `DatadogClient`, Dio Interceptor, and GQL Link), but does not apply to the gRPC Interceptor. This option is disabled by default.
214+
215+
Captured headers appear on the RUM Resource event under `resource.request.headers` and `resource.response.headers`. You can query them in the RUM Explorer.
216+
217+
```dart
218+
DatadogRumConfiguration(
219+
applicationId: '<rum-application-id>',
220+
trackResourceHeaders: ResourceHeadersExtractor(),
221+
)
222+
```
223+
224+
With no arguments, `ResourceHeadersExtractor` captures a predefined set of safe headers:
225+
226+
| Direction | Headers |
227+
|-----------|---------|
228+
| Request | `cache-control`, `content-type` |
229+
| Response | `age`, `cache-control`, `content-encoding`, `content-length`, `content-type`, `etag`, `expires`, `server-timing`, `vary`, `x-cache` |
230+
231+
To capture additional headers in addition to the defaults, pass them through `captureHeaders`. To skip the defaults, set `includeDefaults: false`.
232+
233+
```dart
234+
DatadogRumConfiguration(
235+
applicationId: '<rum-application-id>',
236+
trackResourceHeaders: ResourceHeadersExtractor(
237+
captureHeaders: ['x-request-id', 'x-custom-header'],
238+
),
239+
)
240+
```
241+
242+
{% alert level="info" %}
243+
Sensitive headers, such as tokens and API keys, are filtered out automatically, even if you list them explicitly.
244+
{% /alert %}
245+
211246
### Track resources from other packages
212247

213-
While `Datadog Tracking HTTP Client` can track most common network calls in Flutter, Datadog supplies packages for integration into specific networking libraries, including gRPC, GraphQL and Dio. For more information about these libraries, see [Integrated Libraries][22].
248+
While [Datadog Tracking HTTP Client][10] can track most common network calls in Flutter, Datadog supplies packages for integration into specific networking libraries, including gRPC, GraphQL and Dio. For more information about these libraries, see [Integrated Libraries][22].
214249

215250
## Enrich user sessions
216251

0 commit comments

Comments
 (0)