-
Notifications
You must be signed in to change notification settings - Fork 6
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] Inject browser sdk #119
base: master
Are you sure you want to change the base?
Changes from all commits
9070e03
39ad2cc
7dbe689
4c49cb7
d7bd791
12b30c3
269d0a4
8784499
7cf82c6
03dc253
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
|
@@ -103,6 +104,38 @@ Follow the specific documentation for each bundler: | |
service: string; | ||
}; | ||
}; | ||
rum?: { | ||
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; | ||
|
@@ -246,6 +279,55 @@ 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" /> | ||
|
||
> Interact with Real User Monitoring (RUM) directly from your build system. | ||
|
||
#### [📝 Full documentation ➡️](/packages/plugins/rum#readme) | ||
|
||
<details> | ||
|
||
<summary>Configuration</summary> | ||
|
||
```typescript | ||
datadogWebpackPlugin({ | ||
rum?: { | ||
disabled?: boolean, | ||
sdk?: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we could use the RUM type directly here, no? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a very good idea, I'll check if I can. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I put that on the wrong file, oops, this is the README, not the source types There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah nice Idea! |
||
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. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# RUM Plugin <!-- #omit in toc --> | ||
|
||
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) | ||
- [rum.sdk.applicationId](#rumsdkapplicationid) | ||
- [rum.sdk.clientToken](#rumsdkclienttoken) | ||
<!-- #toc --> | ||
|
||
## Configuration | ||
|
||
<details> | ||
<summary>Full configuration</summary> | ||
|
||
```ts | ||
rum?: { | ||
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 into your application. | ||
|
||
Full documentation can be found in the [Datadog documentation](https://docs.datadoghq.com/real_user_monitoring/browser/setup/client?tab=rum#configuration). | ||
|
||
### 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. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"name": "@dd/rum-plugin", | ||
"packageManager": "[email protected]", | ||
"license": "MIT", | ||
"private": true, | ||
"author": "Datadog", | ||
"description": "Interact with Real User Monitoring (RUM) directly from your build system.", | ||
"homepage": "https://github.com/DataDog/build-plugins/tree/main/packages/plugins/rum#readme", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/DataDog/build-plugins", | ||
"directory": "packages/plugins/rum" | ||
}, | ||
"main": "./src/index.ts", | ||
"toBuild": { | ||
"rum-browser-sdk": { | ||
"entry": "./src/built/rum-browser-sdk.ts" | ||
} | ||
}, | ||
"exports": { | ||
".": "./src/index.ts", | ||
"./*": "./src/*.ts" | ||
}, | ||
"scripts": { | ||
"typecheck": "tsc --noEmit" | ||
}, | ||
"dependencies": { | ||
"@dd/core": "workspace:*", | ||
"chalk": "2.3.1" | ||
}, | ||
"devDependencies": { | ||
"@datadog/browser-rum": "6.0.0" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Unless explicitly stated otherwise all files in this repository are licensed under the MIT License. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
// Copyright 2019-Present Datadog, Inc. | ||
|
||
/* global globalThis */ | ||
|
||
import { datadogRum } from '@datadog/browser-rum'; | ||
Ayc0 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// To please TypeScript. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😂 |
||
const globalAny: any = globalThis; | ||
|
||
// Also them to the global DD_RUM object. | ||
globalAny.DD_RUM = datadogRum; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Unless explicitly stated otherwise all files in this repository are licensed under the MIT License. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
// Copyright 2019-Present Datadog, Inc. | ||
|
||
import type { PluginName } from '@dd/core/types'; | ||
|
||
export const CONFIG_KEY = 'rum' as const; | ||
export const PLUGIN_NAME: PluginName = 'datadog-rum-plugin' as const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few of these options were removed from the browser sdk config in v6. I guess this works still as it will work for v5 and prior and just do nothing for v6+ but just a heads up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know which ones? Because they all are still in the doc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah you're right, they're still there. They just default to
true
so we removed them from the default config. You can keep them!