This page is not yet available in Spanish. We are working on its translation. If you have any questions or feedback about our current translation project, feel free to reach out to us!
The Datadog Content Security Policy (CSP) integration sends logs to Datadog from web browsers as they interpret your CSP and detect violations. By using the CSP integration, you don’t have to host or manage a dedicated endpoint to aggregate your CSP data.
For security reasons, you must use a client token to collect logs from web browsers. You cannot use Datadog API keys to configure the Datadog Browser Logs SDK as they would be exposed client-side. For more information, see the client token documentation for more details.
Datadog recommends embedding the Content Security Policy in an HTTP header. You can either use the report-uri directive or the reporting-endpoints directive. The reporting-endpoints directive will eventually supersede report-uri, but is not yet supported by all browsers.
Alternatively, starting from version 4.47.0, you can self-host the Datadog Browser SDK Worker JavaScript file and provide the workerUrl option to initialize the RUM Browser SDK by doing one of the following:
Make sure the Worker major version matches the Browser SDK version you are using.
Host the file on the same origin as your web application. Due to browser restrictions, it cannot be hosted on a separate domain (for example, a third-party CDN host) or a different scheme.