[rum-privacy] add sourcemaps and telemetry - #187
Conversation
eaaf2b5 to
ecceaf7
Compare
sethfowler-datadog
left a comment
There was a problem hiding this comment.
Looks great! I posted a few nits below:
yoannmoinet
left a comment
There was a problem hiding this comment.
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.
Do we need the ?? ... part?
We don't do it in buildTransformOptions().
ff4c50b to
cdbd040
Compare
yoannmoinet
left a comment
There was a problem hiding this comment.
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.
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.
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
yoannmoinet
left a comment
There was a problem hiding this comment.
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.
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.
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.
There was a problem hiding this comment.
You still need to filter on the e.code, otherwise, you will skip every kind of error, and not just the "missing file" error.
My suggestion isn't throwing when the file does not exist, on the contrary, it only throws when it's NOT a missing file error.
There was a problem hiding this comment.
Oh yes indeed! Sorry I read wrong
There was a problem hiding this comment.
Your current code is skipping any error that could happen in fsp.readFile, esbuild.transform and fsp.writeFile, which is not what we want, and not what the comment is suggesting.
There was a problem hiding this comment.
This should be fixed in the latest commit.
Co-authored-by: Yoann Moinet <597828+yoannmoinet@users.noreply.github.com>
yoannmoinet
left a comment
There was a problem hiding this comment.
Small nits.
Waiting for the update on the esbuild skipping errors then I'll ✅
| // Validate and add defaults sub-options. | ||
| const sdkResults = validateSDKOptions(options); | ||
| const privacyResults = validatePrivacyOptions(options); | ||
| const privacyResults = validatePrivacyOptions(options, log); |
There was a problem hiding this comment.
NIT: instead of passing the log here, you could log what you need on line 42.
Co-authored-by: Yoann Moinet <597828+yoannmoinet@users.noreply.github.com>
Co-authored-by: Yoann Moinet <597828+yoannmoinet@users.noreply.github.com>
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
The merge request has been interrupted because the build 0 took longer than expected. The current limit for the base branch 'master' is 120 minutes. Possible reasons:
|
What and why?
Improve the privacy plugin and update to the latest
js-instrument-wasmlibrary.We want to add sourcemaps and telemetry to our privacy plugin.
How?
Change
enforce: pretopostfor privacy pluginMake sdk injection plugin optional when opt-in for rum plugin
Add
Typescriptend to end testing and supportUpdate transform options to make sourcemaps working
Add logs for observability