-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d66990f
commit 61cce9f
Showing
14 changed files
with
201 additions
and
6 deletions.
There are no files selected for viewing
Binary file added
BIN
+51 KB
.yarn/cache/@datadog-browser-rum-react-npm-6.0.0-c26f101832-f13aec89de.zip
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// 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 { createBrowserRouter } from '@datadog/browser-rum-react/react-router-v6'; | ||
import { reactPlugin } from '@datadog/browser-rum-react'; | ||
|
||
// To please TypeScript. | ||
const globalAny: any = global; | ||
|
||
// Have them globally available. | ||
globalAny.reactPlugin = reactPlugin; | ||
globalAny.createBrowserRouter = createBrowserRouter; | ||
|
||
// Also them to the global DD_RUM object. | ||
globalAny.DD_RUM = globalAny.DD_RUM || {}; | ||
globalAny.DD_RUM.reactPlugin = reactPlugin; | ||
globalAny.DD_RUM.createBrowserRouter = createBrowserRouter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// 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 { PluginOptions } from '@dd/core/types'; | ||
|
||
export const getReactPlugin = (): PluginOptions => { | ||
return { | ||
name: 'datadog-rum-react-plugin', | ||
transform(code) { | ||
let updatedCode = code; | ||
const createBrowserRouterImportRegExp = new RegExp( | ||
/(import \{.*)createBrowserRouter[,]?(.*\} from "react-router-dom")/g, | ||
); | ||
const hasCreateBrowserRouterImport = | ||
code.match(createBrowserRouterImportRegExp) !== null; | ||
|
||
if (hasCreateBrowserRouterImport) { | ||
// Remove the import of createBrowserRouter | ||
updatedCode = updatedCode.replace(createBrowserRouterImportRegExp, (_, p1, p2) => { | ||
return `${p1}${p2}`; | ||
}); | ||
|
||
// replace all occurences of `createBrowserRouter` with `DD_RUM.createBrowserRouter` | ||
updatedCode = updatedCode.replace( | ||
new RegExp(/createBrowserRouter/g), | ||
'DD_RUM.createBrowserRouter', | ||
); | ||
} | ||
|
||
return updatedCode; | ||
}, | ||
transformInclude(id) { | ||
return id.match(new RegExp(/.*\.(js|jsx|ts|tsx)$/)) !== null; | ||
}, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters