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

fix(angular): Set unknown component name default in TraceDirective #6222

Merged
merged 1 commit into from Nov 17, 2022

Conversation

Lms24
Copy link
Member

@Lms24 Lms24 commented Nov 17, 2022

This PR fixes a bug in the Angular SDK's TraceDirective where previously, the fallback UNKNOWN_COMPONENT name wasn't correctly applied to the span description if users didn't specify a manual value for the directive:

<!-- this adds <standalone1> as a span description  -->
<app-my-component trace="standalone1"></app-my-component>

<!-- this used to add <> as a span description  -->
<!-- With this fix, we now get <unknown> as a span description  -->
<app-my-component trace></app-my-component>

Stumbled across this while testing v15 standalone components so... ref #6219

The reason for this bug is that Angular apparently doesn't entirely respect default values for inputs of directives that have the same name as the directive (but we def want this).

Note: We do actually have a test for this and according to that test, everything worked fine before. This, however, was a problem with the test setup because creating a new instance of TraceDirective (which is what the test does) is different behaviour to specifying trace without a name in the component template. With this change now, also this test now fails, if the fallback would not be set correctly so I don't think we strictly need another test here.

Note2: There is another way how to set default values for inputs with the same name as the directive selector. However, I don't consider this particularly cleaner so I opted for this way instead which should also have less bundle size impact than the way above.

@Lms24 Lms24 changed the title fix(angular): Set unknown component name default in TraceDirective fix(angular): Set unknown component name default in TraceDirective Nov 17, 2022
@Lms24 Lms24 requested review from a team, mydea and lobsterkatie and removed request for a team November 17, 2022 10:16
@Lms24 Lms24 changed the title fix(angular): Set unknown component name default in TraceDirective fix(angular): Set unknown component name default in TraceDirective Nov 17, 2022
@Lms24 Lms24 mentioned this pull request Nov 17, 2022
2 tasks
@github-actions
Copy link
Contributor

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 19.51 KB (+0.07% 🔺)
@sentry/browser - ES5 CDN Bundle (minified) 60.36 KB (+0.05% 🔺)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18.17 KB (+0.09% 🔺)
@sentry/browser - ES6 CDN Bundle (minified) 53.71 KB (+0.03% 🔺)
@sentry/browser - Webpack (gzipped + minified) 19.9 KB (+0.04% 🔺)
@sentry/browser - Webpack (minified) 65.12 KB (+0.04% 🔺)
@sentry/react - Webpack (gzipped + minified) 19.93 KB (+0.07% 🔺)
@sentry/nextjs Client - Webpack (gzipped + minified) 45.89 KB (+0.03% 🔺)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 26.33 KB (+0.04% 🔺)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 24.74 KB (+0.06% 🔺)

@Lms24 Lms24 self-assigned this Nov 17, 2022
Copy link
Member

@mydea mydea left a comment

Choose a reason for hiding this comment

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

Seems good, thanks for the description of what's going on and why :D

@Lms24 Lms24 merged commit 62ad0f3 into master Nov 17, 2022
@Lms24 Lms24 deleted the lms-fix-tracedirective-unknown-cmp branch November 17, 2022 13:42
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.

None yet

2 participants