You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en/logs/log_collection/javascript.md
+95-6Lines changed: 95 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ With the browser logs SDK, you can send logs directly to Datadog from web browse
17
17
- Record real client IP addresses and user agents.
18
18
- Optimized network usage with automatic bulk posts.
19
19
20
-
**Notes**:
20
+
**Notes**:
21
21
-**Independent of the RUM SDK**: The Browser Logs SDK can be used without the RUM SDK.
22
22
23
23
## Setup
@@ -406,12 +406,12 @@ The following parameters are available to configure the Datadog browser logs SDK
406
406
|`sessionSampleRate`| Number | No |`100`| The percentage of sessions to track: `100` for all, `0` for none. Only tracked sessions send logs. It applies only to logs collected via the Browser Logs SDK and is independent of RUM data. |
407
407
|`trackingConsent`|`"granted"` or `"not-granted"`| No |`"granted"`| Set the initial user tracking consent state. See [User Tracking Consent][15]. |
408
408
|`silentMultipleInit`| Boolean | No || Prevent logging errors while having multiple init. |
409
-
|`proxy`| String | No || Optional proxy URL (ex: `https://www.proxy.com/path`), see the full [proxy setup guide][6] for more information. |
409
+
|`proxy`| String | No || Optional proxy URL (ex: `https://www.proxy.com/path`), see the full [proxy setup guide][6] for more information. |
410
+
|`usePciIntake`| Boolean | No |`false`| Use PCI-compliant intake. See [PCI DSS Compliance][20] for more information. |
410
411
|`telemetrySampleRate`| Number | No |`20`| Telemetry data (error, debug logs) about SDK execution is sent to Datadog in order to detect and solve potential issues. Set this option to `0` to opt out from telemetry collection. |
411
412
|`storeContextsAcrossPages`| Boolean | No || Store global context and user context in `localStorage` to preserve them along the user navigation. See [Contexts life cycle][11] for more details and specific limitations. |
412
413
|`allowUntrustedEvents`| Boolean | No || Allow capture of [untrusted events][13], for example in automated UI tests. |
413
-
| `sendLogsAfterSessionExpiration` | Boolean | No | | Keep sending logs after the session expires.
414
-
|`allowedTrackingOrigins`| Array | No || List of origins where the SDK is allowed to run. |
414
+
|`allowedTrackingOrigins`| Array | No || List of origins where the SDK is allowed to run. |
415
415
416
416
417
417
Options that must have a matching configuration when using the `RUM` SDK:
**Note**: The `window.DD_LOGS` check prevents issues when a loading failure occurs with the SDK.
1044
1044
1045
+
#### Account context
1046
+
1047
+
The Datadog logs SDK provides convenient functions to associate an `Account` with generated logs.
1048
+
1049
+
- Set the account for all your loggers with the `setAccount (newAccount: Account)` API.
1050
+
- Add or modify an account property to all your loggers with the `setAccountProperty (key: string, value: any)` API.
1051
+
- Get the currently stored account with the `getAccount ()` API.
1052
+
- Remove an account property with the `removeAccountProperty (key: string)` API.
1053
+
- Clear all existing account properties with the `clearAccount ()` API.
1054
+
1055
+
**Note**: The account context is applied before the global context. Hence, every account property included in the global context will override the account context when generating logs.
window.DD_LOGS.getAccount() // => {id: '1234', name: 'My Company Name'}
1098
+
})
1099
+
1100
+
window.DD_LOGS.onReady(function () {
1101
+
window.DD_LOGS.clearAccount()
1102
+
})
1103
+
1104
+
window.DD_LOGS.onReady(function () {
1105
+
window.DD_LOGS.getAccount() // => {}
1106
+
})
1107
+
```
1108
+
1109
+
**Note**: Early API calls must be wrapped in the `window.DD_LOGS.onReady()` callback. This ensures the code only gets executed once the SDK is properly loaded.
1110
+
1111
+
##### CDN sync
1112
+
1113
+
For CDN sync, use:
1114
+
1115
+
```javascript
1116
+
window.DD_LOGS&&window.DD_LOGS.setAccount({ id:'1234', name:'My Company Name' })
By default, no sampling is applied on the number of collected sessions. To apply a relative sampling (in percent) to the number of sessions collected, use the `sessionSampleRate` parameter when initializing RUM.
0 commit comments