Skip to content
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

feat: Add spotlightBrowser integration #13263

Merged
merged 14 commits into from
Aug 12, 2024
Merged

feat: Add spotlightBrowser integration #13263

merged 14 commits into from
Aug 12, 2024

Conversation

BYK
Copy link
Member

@BYK BYK commented Aug 7, 2024

No description provided.

@BYK BYK marked this pull request as ready for review August 8, 2024 13:44
@BYK BYK requested a review from Lms24 August 8, 2024 13:44
Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making the changes! One question but otherwise it looks good to me!

// don't support the `spotlight` option there and rely on the users
// adding the `spotlightBrowserIntegration()` to their integrations which
// wouldn't get initialized with the check below when there's no DSN set.
this._options.integrations.some(({ name }) => name.startsWith('Spotlight'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine given spotlight is pretty much a one-off at the moment. Another option would be to adjust our integrations API to acomodate for such scenarios, say in an afterSdkInit hook that's aways invoked, regardless if the SDK is enabled or not. Will bring this up with the team but let's not block the PR on this as it's easily changeable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I thought about adding a special property like forced or something like that on the integration but I'll leave that debate to you folks

@@ -140,13 +140,19 @@ function _init(
const scope = getCurrentScope();
scope.update(options.initialScope);

if (options.spotlight && options.integrations.some(({ name }) => name !== SPOTLIGHT_INTEGRATION_NAME)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

m: My brain is a bit fried already today but the the .some check isn't correct right? We only want to add the integration if it hasn't been added to options.integrations before. I think we can use .find instead

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, I got confused! Fix coming out that said I prefer .some() to .find() as we don't really need the first found value, we just want to check if there is anything that matches the criteria. They probably work the same underneath but they don't have as you can optimize .some() in different ways if you wanted to.

if (isEnabled(client)) {
client.init();
}
client.init();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was a bit scared when I saw this but as far as I can tell we don't extend the init from BaseClient in the derived client classes. Given we guard the base client init implementation this should be fine.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Event if we extend, aren't we supposed to call super()? I think that's the responsibility of downstream class implementors and not something we should be worried about here?

@BYK BYK requested a review from Lms24 August 9, 2024 17:17
@@ -140,7 +140,7 @@ function _init(
const scope = getCurrentScope();
scope.update(options.initialScope);

if (options.spotlight && options.integrations.some(({ name }) => name !== SPOTLIGHT_INTEGRATION_NAME)) {
if (options.spotlight && !options.integrations.some(({ name }) => name === SPOTLIGHT_INTEGRATION_NAME)) {
Copy link
Member Author

@BYK BYK Aug 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can also do

Suggested change
if (options.spotlight && !options.integrations.some(({ name }) => name === SPOTLIGHT_INTEGRATION_NAME)) {
if (options.spotlight && options.integrations.every(({ name }) => name !== SPOTLIGHT_INTEGRATION_NAME)) {

But I think the current version expresses the intent a bit more clearly: if there are no integrations matching this name, add it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with any of these, as long as we only add the integration if it isn't yet present 👍
Thanks for fixing!

Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making the changes! Looks fine to me!

@@ -140,7 +140,7 @@ function _init(
const scope = getCurrentScope();
scope.update(options.initialScope);

if (options.spotlight && options.integrations.some(({ name }) => name !== SPOTLIGHT_INTEGRATION_NAME)) {
if (options.spotlight && !options.integrations.some(({ name }) => name === SPOTLIGHT_INTEGRATION_NAME)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with any of these, as long as we only add the integration if it isn't yet present 👍
Thanks for fixing!

BYK added a commit that referenced this pull request Nov 7, 2024
…ser package

Follow up to #13263 where we forgot to export it from the main package 🤦
BYK added a commit that referenced this pull request Nov 8, 2024
…ser package (#14208)

Follow up to #13263 where we forgot to export it from the main package
:facepalm:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants