-
Notifications
You must be signed in to change notification settings - Fork 6
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
[rum] Inject browser sdk #119
base: master
Are you sure you want to change the base?
Conversation
47ec98f
to
73486c7
Compare
a305acd
to
fceab29
Compare
fceab29
to
3c35484
Compare
84950be
to
74d2575
Compare
e401db0
to
d66990f
Compare
d66990f
to
5f3ea86
Compare
5f3ea86
to
f158564
Compare
datadogWebpackPlugin({ | ||
rum?: { | ||
disabled?: boolean, | ||
sdk?: { |
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.
Maybe we could use the RUM type directly here, no?
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.
That's a very good idea, I'll check if I can.
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 put that on the wrong file, oops, this is the README, not the source types
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.
yeah nice Idea!
packages/plugins/rum/README.md
Outdated
- [rum.sdk.applicationId](#rumsdkapplicationid) | ||
- [rum.sdk.clientToken](#rumsdkclienttoken) | ||
- [rum.sdk.site](#rumsdksite) |
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.
Similarly, maybe we don't need to document all of those. Instead we could reference the general doc in the public documentation website, WDYT?
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.
Makes sense, I'm afraid of getting out of sync, but I do prefer having a single source of truth.
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.
If you want only 1 source of truth, you'd need to add a dependency on @datadog/browser-rum
instead of checking the global DD_RUM
(right now you're only using a devDep)
DD_RUM.addAction('custom_click', { | ||
bundler: '{{bundler}}', | ||
}); |
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.
❤️
|
||
import { datadogRum } from '@datadog/browser-rum'; | ||
|
||
// To please TypeScript. |
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.
😂
globalAny.DD_RUM = globalAny.DD_RUM || {}; | ||
globalAny.DD_RUM = { | ||
...globalAny.DD_RUM, | ||
...datadogRum, |
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 don't have any knowledge on whether window.DD_RUM
and datadogRum
share the exact same API. I'll let @Miz85 review this one
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 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.
Yes they are the same.
But we should choose on strategy for the injection and roll with that, why do we want to support both the CDN and the npm install methods?
const sdkWithDefault: SDKOptionsWithDefaults = { | ||
applicationId: 'unknown_application_id', | ||
allowUntrustedEvents: false, | ||
compressIntakeRequests: false, | ||
defaultPrivacyLevel: 'mask', | ||
enablePrivacyForActionName: false, | ||
sessionReplaySampleRate: 0, | ||
sessionSampleRate: 100, | ||
silentMultipleInit: false, | ||
site: 'datadoghq.com', | ||
startSessionReplayRecordingManually: false, | ||
storeContextsAcrossPages: false, | ||
telemetrySampleRate: 20, | ||
traceSampleRate: 100, | ||
trackingConsent: 'granted', | ||
trackLongTasks: false, | ||
trackResources: false, | ||
trackUserInteractions: false, | ||
trackViewsManually: false, | ||
}; |
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.
Same here: Idk if we should re-code the SDK defaults. Is it possible to get them from the SDK package itself? (I'd prefer to avoid duplicating code, specially if they decide to change their defaults)
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.
Fair, I'll look into it.
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.
Edit: as you're fully pinning a version of the browser SDK, hard coding values is not needed (as you can decide to update those when updating the underlying RUM version)
Idk if you want to manually check that the default values are the same, so it could still be good, but it's not required
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.
Nice!
// Also them to the global DD_RUM object. | ||
globalAny.DD_RUM = globalAny.DD_RUM || {}; | ||
globalAny.DD_RUM = { | ||
...globalAny.DD_RUM, |
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.
Now that I better understand the fact that we are using a pre-bundled version of the SDK, does it make sense to try to inject here both ...DD_RUM, ...datadogRum
? (As those 2 could be using different versions)
Why not just doing globalAny.DD_RUM = datadogRum
? (also IIRC, even the npm datadogRum should write in DD_RUM 🤔)
telemetrySampleRate?: number; | ||
traceSampleRate?: number; | ||
trackingConsent?: 'granted' | 'not_granted'; | ||
trackLongTasks?: boolean; |
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.
A few of these options were removed from the browser sdk config in v6. I guess this works still as it will work for v5 and prior and just do nothing for v6+ but just a heads up.
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 you know which ones? Because they all are still in the doc.
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.
Ah you're right, they're still there. They just default to true
so we removed them from the default config. You can keep them!
datadogWebpackPlugin({ | ||
rum?: { | ||
disabled?: boolean, | ||
sdk?: { |
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.
yeah nice Idea!
globalAny.DD_RUM = globalAny.DD_RUM || {}; | ||
globalAny.DD_RUM = { | ||
...globalAny.DD_RUM, | ||
...datadogRum, |
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.
Yes they are the same.
But we should choose on strategy for the injection and roll with that, why do we want to support both the CDN and the npm install methods?
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.
lgtm
d228bf1
to
f1c79e3
Compare
17e30b5
to
73662a4
Compare
68f129f
to
378742a
Compare
Co-authored-by: Benjamin Koltes <[email protected]>
378742a
to
d8d6d43
Compare
What and why?
Automatically inject RUM's Browser SDK into the bundle.
How?
A few updates were necessary:
doRequest
helper, so we can fetch the correctclientToken
in case the customer didn't add it to the rum's configuration.rum-browser-sdk.js
which is used for the injection.TODO