File tree Expand file tree Collapse file tree 13 files changed +30
-58
lines changed Expand file tree Collapse file tree 13 files changed +30
-58
lines changed Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ export enum InjectPosition {
8585export type ToInjectItem = {
8686 type : 'file' | 'code' ;
8787 value : InjectedValue ;
88- position : InjectPosition ;
88+ position ? : InjectPosition ;
8989 fallback ?: ToInjectItem ;
9090} ;
9191
@@ -149,7 +149,7 @@ export interface Options extends BaseOptions {
149149 customPlugins ?: GetCustomPlugins ;
150150}
151151
152- export type GetPluginsOptions = Required < BaseOptions > ;
152+ export type GetPluginsOptions = BaseOptions ;
153153export type OptionsWithDefaults = Assign < Options , GetPluginsOptions > ;
154154
155155export type PluginName = `datadog-${Lowercase < string > } -plugin`;
Original file line number Diff line number Diff line change 33// Copyright 2019-Present Datadog, Inc.
44
55import { doRequest , truncateString } from '@dd/core/helpers' ;
6- import type { InjectPosition , Logger , ToInjectItem } from '@dd/core/types' ;
6+ import type { Logger , ToInjectItem } from '@dd/core/types' ;
7+ import { InjectPosition } from '@dd/core/types' ;
78import { getAbsolutePath } from '@dd/internal-build-report-plugin/helpers' ;
89import { readFile } from 'fs/promises' ;
910
@@ -86,7 +87,7 @@ export const processInjections = async (
8687 // eslint-disable-next-line no-await-in-loop
8788 const value = await processItem ( item , log ) ;
8889 if ( value ) {
89- toReturn . set ( id , { value, position : item . position } ) ;
90+ toReturn . set ( id , { value, position : item . position ?? InjectPosition . AFTER } ) ;
9091 }
9192 }
9293
Original file line number Diff line number Diff line change @@ -46,11 +46,6 @@ export const getPlugins: GetPlugins<OptionsWithRum> = (
4646 position : InjectPosition . MIDDLE ,
4747 value : path . join ( __dirname , './rum-react-plugin.js' ) ,
4848 } ) ;
49- context . inject ( {
50- type : 'file' ,
51- position : InjectPosition . MIDDLE ,
52- value : path . join ( __dirname , './rum-react-router-6.js' ) ,
53- } ) ;
5449 }
5550
5651 context . inject ( {
@@ -90,7 +85,11 @@ export const getPlugins: GetPlugins<OptionsWithRum> = (
9085 return updatedCode ;
9186 } ,
9287 transformInclude ( id ) {
93- return id . match ( new RegExp ( / .* \. ( j s | j s x | t s | t s x ) $ / ) ) !== null ;
88+ return (
89+ // @ts -ignore
90+ options ?. react ?. router === true &&
91+ id . match ( new RegExp ( / .* \. ( j s | j s x | t s | t s x ) $ / ) ) !== null
92+ ) ;
9493 } ,
9594 } ,
9695 ] ;
Original file line number Diff line number Diff line change @@ -16,9 +16,16 @@ type RumAppResponse = {
1616} ;
1717
1818const getContent = ( opts : RumOptionsWithDefaults ) => {
19- const pluginContent = opts . react ? ', plugins: [reactPlugin({ router: true})]' : '' ;
20- return `DD_RUM.init({${ JSON . stringify ( opts . sdk ) . replace ( / ( ^ { | } $ ) / g, '' ) } ${ pluginContent } });
21- ` ;
19+ const pluginContent = opts . react
20+ ? // @ts -ignore
21+ `, plugins: [reactPlugin({router: ${ opts . react . router } })]`
22+ : '' ;
23+ const sessionReplayStartCommand = opts . startSessionReplayRecording
24+ ? 'DD_RUM.startSessionReplayRecording();\n'
25+ : '' ;
26+
27+ return `DD_RUM.init({${ JSON . stringify ( opts . sdk ) . replace ( / ( ^ { | } $ ) / g, '' ) } ${ pluginContent } });${ sessionReplayStartCommand }
28+ ` ;
2229} ;
2330
2431export const getInjectionValue = (
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ export type RumOptions = {
1010 disabled ?: boolean ;
1111 sdk ?: SDKOptions ;
1212 react ?: ReactOptions ;
13+ startSessionReplayRecording ?: boolean ;
1314} ;
1415
1516export type SDKOptions = {
@@ -68,6 +69,7 @@ export type RumOptionsWithDefaults = {
6869 disabled ?: boolean ;
6970 sdk ?: SDKOptionsWithDefaults ;
7071 react ?: ReactOptionsWithDefaults ;
72+ startSessionReplayRecording ?: boolean ;
7173} ;
7274
7375export type RumOptionsWithSdk = {
Original file line number Diff line number Diff line change 2121 "main" : " ./dist/src/index.js" ,
2222 "module" : " ./dist/src/index.mjs" ,
2323 "exports" : {
24- "./package.json" : " ./package.json" ,
25- "." : {
26- "import" : " ./dist/src/index.mjs" ,
27- "require" : " ./dist/src/index.js" ,
28- "types" : " ./dist/src/index.d.ts"
29- }
24+ "." : " ./src/index.ts"
3025 },
3126 "publishConfig" : {
3227 "access" : " public" ,
Original file line number Diff line number Diff line change 2121 "main" : " ./dist/src/index.js" ,
2222 "module" : " ./dist/src/index.mjs" ,
2323 "exports" : {
24- "./package.json" : " ./package.json" ,
25- "." : {
26- "import" : " ./dist/src/index.mjs" ,
27- "require" : " ./dist/src/index.js" ,
28- "types" : " ./dist/src/index.d.ts"
29- }
24+ "." : " ./src/index.ts"
3025 },
3126 "publishConfig" : {
3227 "access" : " public" ,
Original file line number Diff line number Diff line change 2121 "main" : " ./dist/src/index.js" ,
2222 "module" : " ./dist/src/index.mjs" ,
2323 "exports" : {
24- "./package.json" : " ./package.json" ,
25- "." : {
26- "import" : " ./dist/src/index.mjs" ,
27- "require" : " ./dist/src/index.js" ,
28- "types" : " ./dist/src/index.d.ts"
29- }
24+ "." : " ./src/index.ts"
3025 },
3126 "publishConfig" : {
3227 "access" : " public" ,
Original file line number Diff line number Diff line change 2121 "main" : " ./dist/src/index.js" ,
2222 "module" : " ./dist/src/index.mjs" ,
2323 "exports" : {
24- "./package.json" : " ./package.json" ,
25- "." : {
26- "import" : " ./dist/src/index.mjs" ,
27- "require" : " ./dist/src/index.js" ,
28- "types" : " ./dist/src/index.d.ts"
29- }
24+ "." : " ./src/index.ts"
3025 },
3126 "publishConfig" : {
3227 "access" : " public" ,
Original file line number Diff line number Diff line change 2121 "main" : " ./dist/src/index.js" ,
2222 "module" : " ./dist/src/index.mjs" ,
2323 "exports" : {
24- "./package.json" : " ./package.json" ,
25- "." : {
26- "import" : " ./dist/src/index.mjs" ,
27- "require" : " ./dist/src/index.js" ,
28- "types" : " ./dist/src/index.d.ts"
29- }
24+ "." : " ./src/index.ts"
3025 },
3126 "publishConfig" : {
3227 "access" : " public" ,
You can’t perform that action at this time.
0 commit comments