-
Notifications
You must be signed in to change notification settings - Fork 8
[rum-privacy] add sourcemaps and telemetry #187
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
base: master
Are you sure you want to change the base?
Conversation
eaaf2b5
to
ecceaf7
Compare
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.
Looks great! I posted a few nits below:
packages/tests/src/e2e/privacyPluginTypescript/privacyPluginTypescript.spec.ts
Outdated
Show resolved
Hide resolved
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.
Started a review, will continue later on.
pluginOptions.module === 'cjs' ? './privacy-helpers.js' : './privacy-helpers.mjs', | ||
); | ||
|
||
const privacyHelpersModuleId = pluginOptions.helpersModule ?? PRIVACY_HELPERS_MODULE_ID; |
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 we need the ?? ...
part?
We don't do it in buildTransformOptions()
.
ff4c50b
to
cdbd040
Compare
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.
I'm not a fan of the addition to the verifyProjectBuild
.
It's very complex, I'll have a look, but I think this can be simplified.
|
||
// Get the entry for this specific bundler | ||
const bundlerEntry = buildConfigOverride?.entry?.[bundler] || './index.js'; | ||
|
||
// Handle TypeScript compilation for each bundler | ||
const additionalPlugins = [...(buildConfigOverride?.plugins || [])]; | ||
|
||
// Check if any entry is a TypeScript file | ||
const hasTypeScriptEntries = Object.values(buildConfigOverride?.entry || {}).some((entry) => | ||
entry.endsWith('.ts'), | ||
); | ||
|
||
if (hasTypeScriptEntries) { | ||
if (bundler === 'rollup' || bundler === 'vite') { | ||
// Use @rollup/plugin-typescript for Rollup and Vite | ||
additionalPlugins.push( | ||
typescript({ | ||
tsconfig: path.resolve(cwd, 'tsconfig.json'), | ||
}), | ||
); | ||
} | ||
// ESBuild has built-in TypeScript support, no additional plugins needed | ||
} | ||
|
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.
Can't this logic live at the test level?
As-in, if your test requires to override the build's configuration, it should also handle this part as well (adding the ts plugin to the build).
Can you also give me more details on why you need this @rollup/plugin-typescript
plugin exactly and not re-use the esbuild
plugin?
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.
I did try this, but it requires changing the params for verifyProjectBuild
even more, as we need to be able to accept different plugins for different bundlers. We are using @rollup/plugin-typescript
to isolate issues of generated sourcemaps and avoid having two bundlers for the same build, per discussions in slack previously.
2b630f6
to
8a0f8ab
Compare
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.
Very good update!
Left some comments and nits.
// FIXME: Handle sourcemaps. | ||
await fsp.writeFile(output, data.code); | ||
} catch (e) { | ||
// skip if the file doesn't exist |
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.
Can you specify the error if we only want to skip if the file doesn't exist?
// skip if the file doesn't exist | |
// Skip if the file doesn't exist | |
if (e.code !== 'ENOENT') { | |
throw e; | |
} |
Also, in which circonstances will it happen?
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.
For example, when we have sub-builds in web-ui, the build entries are not actual entries and it may not exist when injecting. I'm not sure we should throw the error when the file does not exist, as it is not the entry file we want to inject anyway. I added comments and a log here instead.
"./dist-basic/src": "./dist-basic/src/index.js", | ||
"./dist-basic/src/*": "./dist-basic/src/*", |
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.
I believe this got removed automatically once again.
The process has been fixed in a separate branch.
packages/plugins/rum/src/index.ts
Outdated
@@ -55,12 +55,15 @@ export const getPlugins: GetPlugins = ({ options, context }) => { | |||
}); | |||
} | |||
|
|||
if (validatedOptions.privacy) { | |||
if (validatedOptions.privacy && !validatedOptions.privacy.disabled) { |
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.
NIT: This should be handled in the validate process.
The same as for the sdk
counterpart.
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.
I removed the privacy.disabled
option as well, per bug bash feedback.
@@ -35,7 +35,7 @@ describe('RUM Plugin', () => { | |||
}, | |||
{ | |||
type: 'sdk', | |||
config: { sdk: { applicationId: 'app-id' } }, | |||
config: { sdk: { applicationId: 'app-id', clientToken: '123' } }, |
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.
Weird, what was the issue with this, how did we miss it before?
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.
There is no longer an issue after restoring to previous types. clientToken
is not required. I restored this as well.
Co-authored-by: Yoann Moinet <[email protected]>
What and why?
Improve the privacy plugin and update to the latest
js-instrument-wasm
library.We want to add sourcemaps and telemetry to our privacy plugin.
How?
Change
enforce: pre
topost
for privacy pluginMake sdk injection plugin optional when opt-in for rum plugin
Add
Typescript
end to end testing and supportUpdate transform options to make sourcemaps working
Add logs for observability