Cette page n'est pas encore disponible en français, sa traduction est en cours.
Si vous avez des questions ou des retours sur notre projet de traduction actuel,
n'hésitez pas à nous contacter.
Overview
Datadog build plugins integrate with your JavaScript bundler to automate common RUM tasks during your build process. They are available for webpack, Vite, esbuild, Rollup, and Rspack.
Build plugins are complementary to the RUM Browser SDK. You still need to configure the SDK as described in the Browser Monitoring Setup.
Installation
Install the Datadog build plugin package for your bundler:
npm install --save-dev @datadog/webpack-plugin
// webpack.config.js
const { datadogWebpackPlugin } = require('@datadog/webpack-plugin');
module.exports = {
plugins: [
datadogWebpackPlugin({
// configuration
}),
],
};
npm install --save-dev @datadog/vite-plugin
// vite.config.js
import { datadogVitePlugin } from '@datadog/vite-plugin';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [
datadogVitePlugin({
// configuration
}),
],
});
npm install --save-dev @datadog/esbuild-plugin
// esbuild.config.js
const { datadogEsbuildPlugin } = require('@datadog/esbuild-plugin');
require('esbuild').build({
plugins: [
datadogEsbuildPlugin({
// configuration
}),
],
});
npm install --save-dev @datadog/rollup-plugin
// rollup.config.js
import { datadogRollupPlugin } from '@datadog/rollup-plugin';
export default {
plugins: [
datadogRollupPlugin({
// configuration
}),
],
};
npm install --save-dev @datadog/rspack-plugin
// rspack.config.js
const { datadogRspackPlugin } = require('@datadog/rspack-plugin');
module.exports = {
plugins: [
datadogRspackPlugin({
// configuration
}),
],
};
Configuration
The following shared configuration options apply to all plugins:
| Parameter | Type | Required | Default | Description |
|---|
auth.apiKey | String | Yes (Source Maps only) | None | Your Datadog API key. Can also be set with the DATADOG_API_KEY environment variable. |
auth.site | String | No | datadoghq.com | Your Datadog site. Can also be set with the DATADOG_SITE or DD_SITE environment variable. |
logLevel | String | No | warn | Log verbosity level. One of debug, info, warn, error, or none. |
The following example shows the full configuration structure:
datadogWebpackPlugin({
auth: {
apiKey: process.env.DATADOG_API_KEY,
site: 'datadoghq.com',
},
logLevel: 'warn',
// Source map uploads (see Source Maps plugin page)
errorTracking: {
sourcemaps: { /* ... */ },
},
// RUM build-time features (see individual plugin pages)
rum: {
privacy: { /* ... */ },
sourceCodeContext: { /* ... */ },
},
})
Available plugins
Configure individual build plugins:
Further reading
Documentation, liens et articles supplémentaires utiles: