Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ To interact with Datadog directly from your builds.
- [Error Tracking](#error-tracking-----)
- [Metrics](#metrics-----)
- [Output](#output-----)
- [RUM](#rum-----)
- [Contributing](#contributing)
- [License](#license)
<!-- #toc -->
Expand Down Expand Up @@ -137,6 +138,14 @@ Follow the specific documentation for each bundler:
warnings?: boolean | string;
};
};
rum?: {
enable?: boolean;
sdk?: {
applicationId: string;
clientToken?: string;
// [...] See https://docs.datadoghq.com/real_user_monitoring/browser/setup/client?tab=rum#configuration for all options.
};
};
}
```
<!-- #full-configuration -->
Expand Down Expand Up @@ -372,6 +381,34 @@ datadogWebpackPlugin({
});
```

</details>

### RUM <img src="packages/assets/src/esbuild.svg" alt="ESBuild" width="17" /> <img src="packages/assets/src/rollup.svg" alt="Rollup" width="17" /> <img src="packages/assets/src/rspack.svg" alt="Rspack" width="17" /> <img src="packages/assets/src/vite.svg" alt="Vite" width="17" /> <img src="packages/assets/src/webpack.svg" alt="Webpack" width="17" />

> [!NOTE]
> This feature is in **beta** and may misbehave in edgiest cases.
> <br/>
> Interact with Real User Monitoring (RUM) directly from your build system.

#### [📝 Full documentation ➡️](/packages/plugins/rum#readme)

<details>

<summary>Configuration</summary>

```typescript
datadogWebpackPlugin({
rum?: {
enable?: boolean,
sdk?: {
applicationId: string,
clientToken?: string,
// [...] See https://docs.datadoghq.com/real_user_monitoring/browser/setup/client?tab=rum#configuration for all options.
},
}
});
```

</details>
<!-- #list-of-packages -->

Expand Down
100 changes: 100 additions & 0 deletions packages/plugins/rum/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# RUM Plugin <!-- #omit in toc -->

> [!NOTE]
> This feature is in **beta** and may misbehave in edgiest cases.

Interact with Real User Monitoring (RUM) directly from your build system.

<!-- The title and the following line will both be added to the root README.md -->

## Table of content <!-- #omit in toc -->

<!-- This is auto generated with yarn cli integrity -->

<!-- #toc -->
- [Configuration](#configuration)
- [Browser SDK Injection](#browser-sdk-injection)
- [Using global `DD_RUM`](#using-global-ddrum)
- [rum.sdk.applicationId](#rumsdkapplicationid)
- [rum.sdk.clientToken](#rumsdkclienttoken)
<!-- #toc -->

## Configuration

<details>
<summary>Full configuration</summary>

```ts
rum?: {
enable?: boolean;
sdk?: {
applicationId: string;
clientToken?: string;
// [...] See https://docs.datadoghq.com/real_user_monitoring/browser/setup/client?tab=rum#configuration for all options.
};
}
```

</details>

**Minimal configuration**:

```ts
rum: {
sdk: {
applicationId: 'your_application_id',
}
}
```

## Browser SDK Injection

Automatically inject the RUM SDK v6 into your application and initialize it.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Latest version is now v7

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the heads up!
I'll fix this in a separate PR.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened a separate PR here: #389
If you could have a quick look @bdibon 🙏


Full documentation can be found in the [Datadog documentation](https://docs.datadoghq.com/real_user_monitoring/browser/setup/client?tab=rum#configuration).

### Using global `DD_RUM`

You can use [the global `DD_RUM` object](https://docs.datadoghq.com/real_user_monitoring/browser/advanced_configuration/?tab=cdnasync) to interact with the RUM SDK.

> [!NOTE]
> You don't need to use `DD_RUM.onReady()` to wrap your code,
> the plugin makes sure the SDK is loaded before executing your code.

For TypeScript projects, you can declare the global type using the types bundled with the plugin:

```ts
import type { RumTypes } from '@datadog/webpack-plugin'; // or rollup-plugin, vite-plugin, etc.

declare global {
interface Window {
DD_RUM?: RumTypes['RumPublicApi'];
}
}
```

You can also configure `eslint` to recognize the global `DD_RUM` object:

```json
{
"globals": {
"DD_RUM": "readonly"
}
}
```

### rum.sdk.applicationId

> required

The RUM application ID. [Create a new application if necessary](https://app.datadoghq.com/rum/list/create).

### rum.sdk.clientToken

> optional, will be fetched if missing

A [Datadog client token](https://docs.datadoghq.com/account_management/api-app-keys/#client-tokens).

> [!NOTE]
> If not provided, the plugin will attempt to fetch the client token using the API.
> You need to provide both `auth.apiKey` and `auth.appKey` with the `rum_apps_read` permission.
1 change: 0 additions & 1 deletion packages/plugins/rum/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"directory": "packages/plugins/rum"
},
"buildPlugin": {
"hideFromRootReadme": true,
"inlinedLibraries": [
"@datadog/browser-core",
"@datadog/browser-rum-core"
Expand Down
1 change: 0 additions & 1 deletion packages/plugins/rum/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export const helpers = {
};

export type types = {
// Add the types you'd like to expose here.
RumOptions: RumOptions;
RumPublicApi: RumPublicApi;
RumInitConfiguration: RumInitConfiguration;
Expand Down
3 changes: 1 addition & 2 deletions packages/plugins/rum/src/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2019-Present Datadog, Inc.

import type { Site } from '@datadog/browser-rum';
import type { Logger, Options, OptionsWithDefaults } from '@dd/core/types';
import chalk from 'chalk';

Expand Down Expand Up @@ -108,7 +107,7 @@ export const validateSDKOptions = (
sessionReplaySampleRate: 0,
sessionSampleRate: 100,
silentMultipleInit: false,
site: (options.auth.site as Site) || 'datadoghq.com',
site: options.auth.site || 'datadoghq.com',
startSessionReplayRecordingManually: false,
storeContextsAcrossPages: false,
telemetrySampleRate: 20,
Expand Down
Loading