-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(node): Move default option handling from init
to NodeClient
#16353
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: develop
Are you sure you want to change the base?
Conversation
size-limit report 📦
|
❌ Unsupported file format
|
c9cdd5b
to
0fa085a
Compare
0fa085a
to
8e0b4d5
Compare
8e0b4d5
to
6fc5ba3
Compare
packages/node/src/sdk/index.ts
Outdated
* This is an internal method the SDK uses under the hood to set up things - you should not use this as a user! | ||
* Instead, use `init()` to initialize the SDK. | ||
* | ||
* @hidden | ||
* @internal |
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.
This function isn't exported, do we need to mention it shouldn't be used?
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 yeah, I moved stuff around a bit here, you are right :)
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.
@timfish does this impact electron?
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 need to think about how this will impact the Electron SDK. Currently we can skip over everything in init by simply using the Node client.
After these changes, spotlight will always be included in production bundles and release/environment/etc will automatically be pulled from environment variables at runtime which we don't want.
Possibly relevant changes: * `client.startClientReportTracking()` is now called in the NodeClient constructor - so unless `sendClientReports: false` is configured, this will always be setup now, even for manual clients. * Env. vars will automatically be picked up and put on the current scope in the NodeClient constructor * `Failed to register ESM hook` warning is now a `console.warn`, not using the logger - this means we do not need to manually enable the logger before we call `initAndBind` anymore. * spotlight is now properly handled like a default integration
Co-authored-by: Andrei <[email protected]>
dea8972
to
b7abc65
Compare
Ah, valid points!
Anyways will move this to draft until we verified it will not interfere with Electron negatively! |
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 think this is generally fine but agree with waiting on checking for electron.
@timfish RE Spotlight: Is having it in the server-side bundle a concern? It shouldn't do anything unless it's enabled by users, so it would primarily be "just" bloat (which I agree with is far from optimal but we lost that battle a long time ago for the Node SDK)
Correct and it doesn't look like it's a huge amount of code either. It looks like spotlight can be enabled simply by setting the
As long as it can be excluded by default, I have no concerns.
We do set a default My preference would always be to not have code included when it's not used, but I can see why this needed changing. The options and config split across init and the client has always felt strange! It will almost certainly make sense for Electron to have it's own client so we can exclude this unused code. Would this be a breaking change? We do currently export the |
…init()` (#16354) Similar to #16353, this changes how default options for BrowserClient are handled. Instead of building this in `init`, we now do (some) of it in BrowserClient. Additionally, this also adjusts what we do if we detect a browser extension: Instead of skipping the setup, we now just disable the client. This streamlines this a bit and also ensures that we actually always return a `Client` from init. It also fixes the type for `BrowserOption` to actually allow to configure `cdnBaseUrl`, which was actually only set for the ClientOptions, oops. The reason for this is to streamline the `init` code, making it easier to extend/adjust it. Right now, there is a lot going on in different places there. By moving as much as we can (and makes sense) to `BrowserClient` this becomes a bit easier. While playing with different ways to handle the browser extension stuff, I ended up landing on just disabling the SDK in this scenario.
While working on #15307, I noticed that for the Node SDK init, in contrast to most other init functions, we have a lot of logic in the
init
function itself, instead of handling stuff in theNodeClient
itself. This is likely still that way since we moved the NodeClient stuff over to OTEL, where a bunch of this was initially re-implemented.Now, this has a few problems:
init()
, as there is a lot going on.initAndBind
which we have in other places.Possibly relevant changes:
client.startClientReportTracking()
is now called in the NodeClient constructor - so unlesssendClientReports: false
is configured, this will always be setup now, even for manual clients.Failed to register ESM hook
warning is now aconsole.warn
, not using the logger - this means we do not need to manually enable the logger before we callinitAndBind
anymore.Extracted this out of #15307