-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
Datadog RUM (realtime user monitoring) #442
Comments
To integrate RUM (Real User Monitoring) into your React app using the provided root file setup, you'll typically use a RUM tool like Datadog RUM, New Relic, or any other service. Here's an example of how to add Datadog RUM to your React app:
npm install @datadog/browser-rum
Modify your root file ( import { datadogRum } from '@datadog/browser-rum';
// Initialize Datadog RUM
datadogRum.init({
applicationId: 'YOUR_APPLICATION_ID',
clientToken: 'YOUR_CLIENT_TOKEN',
site: 'datadoghq.com',
service: 'your-service-name',
version: '1.0.0',
sampleRate: 100,
trackInteractions: true,
defaultPrivacyLevel: 'mask-user-input'
});
datadogRum.startSessionReplayRecording();
Here's how you can include the Datadog RUM initialization in your import { Provider } from 'react-redux';
import { ThemeProvider } from '~/utils/providers/theme-provider';
import { store } from '~/redux/store';
import App from './App';
import { datadogRum } from '@datadog/browser-rum';
// Initialize Datadog RUM
datadogRum.init({
applicationId: 'YOUR_APPLICATION_ID',
clientToken: 'YOUR_CLIENT_TOKEN',
site: 'datadoghq.com',
service: 'your-service-name',
version: '1.0.0',
sampleRate: 100,
trackInteractions: true,
defaultPrivacyLevel: 'mask-user-input'
});
datadogRum.startSessionReplayRecording();
export default function AppWithTheme() {
return (
<Provider store={store}>
<ThemeProvider>
<App />
</ThemeProvider>
</Provider>
);
}
To keep your application ID and client token secure, you should use environment variables. Create a REACT_APP_DATADOG_APPLICATION_ID=your_application_id
REACT_APP_DATADOG_CLIENT_TOKEN=your_client_token Then, update your initialization code to use these variables: datadogRum.init({
applicationId: process.env.REACT_APP_DATADOG_APPLICATION_ID,
clientToken: process.env.REACT_APP_DATADOG_CLIENT_TOKEN,
site: 'datadoghq.com',
service: 'your-service-name',
version: '1.0.0',
sampleRate: 100,
trackInteractions: true,
defaultPrivacyLevel: 'mask-user-input'
}); By following these steps, you should have Datadog RUM integrated into your React app, providing you with real user monitoring capabilities. Make sure to replace |
To set up Real User Monitoring (RUM) for your React.js application running on Cloudflare Workers, you can use Cloudflare's RUM service or integrate with a third-party RUM tool. Here is a general approach for each option:
Option 1: Using Cloudflare's RUM Service
Enable Cloudflare RUM:
Verify the Integration:
Option 2: Using a Third-Party RUM Tool (e.g., New Relic, Datadog, Sentry)
Choose a RUM Tool:
Install the RUM SDK:
Configure the RUM SDK:
index.js
orApp.js
).Deploy the Application:
Example Worker Script
Here’s an example Cloudflare Worker script that serves a React app and includes necessary headers for a third-party RUM tool:
This example injects the Datadog RUM script directly into the HTML served by the Cloudflare Worker.
By following these steps, you should be able to set up RUM for your React.js application running on Cloudflare Workers. Make sure to consult the specific RUM tool's documentation for any additional configuration or advanced features.
The text was updated successfully, but these errors were encountered: