Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rum] Add RUM's plugin documentation #144

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
85 changes: 85 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ To interact with Datadog directly from your builds.
- [`customPlugins`](#customplugins)
- [Features](#features)
- [Error Tracking](#error-tracking-----)
- [RUM](#rum-----)
- [Telemetry](#telemetry-----)
- [Contributing](#contributing)
- [License](#license)
Expand Down Expand Up @@ -103,6 +104,38 @@ Follow the specific documentation for each bundler:
service: string;
};
};
rum?: { // BETA, the feature may misbehave in edgiest cases.
disabled?: boolean;
sdk?: {
actionNameAttribute?: string;
allowedTracingUrls?: string[];
allowUntrustedEvents?: boolean;
applicationId: string;
clientToken?: string;
compressIntakeRequests?: boolean;
defaultPrivacyLevel?: 'mask' | 'mask-user-input' | 'allow';
enablePrivacyForActionName?: boolean;
env?: string;
excludedActivityUrls?: string[];
proxy?: string;
service?: string;
sessionReplaySampleRate?: number;
sessionSampleRate?: number;
silentMultipleInit?: boolean;
site?: string;
startSessionReplayRecordingManually?: boolean;
storeContextsAcrossPages?: boolean;
telemetrySampleRate?: number;
traceSampleRate?: number;
trackingConsent?: 'granted' | 'not_granted';
trackLongTasks?: boolean;
trackResources?: boolean;
trackUserInteractions?: boolean;
trackViewsManually?: boolean;
version?: string;
workerUrl?: string;
};
};
telemetry?: {
disabled?: boolean;
enableTracing?: boolean;
Expand Down Expand Up @@ -246,6 +279,58 @@ 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.
>
> Interact with Real User Monitoring (RUM) directly from your build system.

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

<details>

<summary>Configuration</summary>

```typescript
datadogWebpackPlugin({
rum?: { // BETA, the feature may misbehave in edgiest cases.
disabled?: boolean,
sdk?: {
actionNameAttribute?: string,
allowedTracingUrls?: string[],
allowUntrustedEvents?: boolean,
applicationId: string,
clientToken?: string,
compressIntakeRequests?: boolean,
defaultPrivacyLevel?: 'mask' | 'mask-user-input' | 'allow',
enablePrivacyForActionName?: boolean,
env?: string,
excludedActivityUrls?: string[],
proxy?: string,
service?: string,
sessionReplaySampleRate?: number,
sessionSampleRate?: number,
silentMultipleInit?: boolean,
site?: string,
startSessionReplayRecordingManually?: boolean,
storeContextsAcrossPages?: boolean,
telemetrySampleRate?: number,
traceSampleRate?: number,
trackingConsent?: 'granted' | 'not_granted',
trackLongTasks?: boolean,
trackResources?: boolean,
trackUserInteractions?: boolean,
trackViewsManually?: boolean,
version?: string,
workerUrl?: string,
},
}
});
```

</details>

### Telemetry <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" />

> Display and send telemetry data as metrics to Datadog.
Expand Down
119 changes: 119 additions & 0 deletions packages/plugins/rum/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# 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?: { // BETA, the feature may misbehave in edgiest cases.
disabled?: boolean;
sdk?: {
actionNameAttribute?: string;
allowedTracingUrls?: string[];
allowUntrustedEvents?: boolean;
applicationId: string;
clientToken?: string;
compressIntakeRequests?: boolean;
defaultPrivacyLevel?: 'mask' | 'mask-user-input' | 'allow';
enablePrivacyForActionName?: boolean;
env?: string;
excludedActivityUrls?: string[];
proxy?: string;
service?: string;
sessionReplaySampleRate?: number;
sessionSampleRate?: number;
silentMultipleInit?: boolean;
site?: string;
startSessionReplayRecordingManually?: boolean;
storeContextsAcrossPages?: boolean;
telemetrySampleRate?: number;
traceSampleRate?: number;
trackingConsent?: 'granted' | 'not_granted';
trackLongTasks?: boolean;
trackResources?: boolean;
trackUserInteractions?: boolean;
trackViewsManually?: boolean;
version?: string;
workerUrl?: string;
};
}
```

</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.

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.

```ts
import type { RumTypes: { RumPublicApi } } from '@datadog/webpack-plugin';
Copy link
Member Author

Choose a reason for hiding this comment

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

This is not working because the dts() bundling doesn't bundle in @datadog/browser-rum for some reason.

Needs a fix before merging.

declare global {
type DD_RUM = 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.
7 changes: 1 addition & 6 deletions packages/tools/src/commands/integrity/readme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,7 @@ type BundlerMetadata = {
usage: string;
};

const README_EXCEPTIONS = [
// We decided to not publicly communicate about the rum-plugin yet.
// But we keep its sources in so it can be tested internally
// and evolve with the rest of the ecosystem.
'@dd/rum-plugin',
];
const README_EXCEPTIONS: string[] = [];

const error = red('Error|README');
// Matches image tags individually with surrounding whitespaces.
Expand Down
Loading