-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Simplify Angular SDK Provider Setup #9407
Comments
Is it tree-shackable to use these:
Maybe you should import only what you need?
As i can see, there should be minor refactor in |
yes, namespace imports are tree-shakeable in modern bundlers. I'd like to use namespace imports in the documentation later on because it's in line with how we document Sentry SDK usage. However, for implementing this, it shouldn't make a difference.
My idea is that (for the moment) we make this change in the |
Your idea won't work, because @sentry/angular depends on old angular version, where there is no
Which way do you chose? I will create PR |
Oh that's a good catch, thanks! I think then, we should go with option 2 indeed as it gives users the most benefits.
I'd prefer it if we just created one Thanks a lot for working with us! |
Okay. One more question: There is non-angular way to init sentry with explicit call of |
Just to confirm, we're talking about the This needs to stay as-is because the Sentry SDK needs to be initialized as early as possible in the application's life cycle. Otherwise the SDK could miss errors and performance spans that happen before Angular is bootstrapped. The SDK also catches errors without the
hmm I'm not too sure about this. People can technically do all kinds of things before Angular is loaded and coming in as early as possible is especially important for accurate performance monitoring. For instance, this allows keeping track of Angular bootstrapping duration and more accurate pageload spans. Unless I'm totally missing something, let's not do this for the moment and stick with the two provider functions for the error handler and tracing. |
Okay now i am agree with you. I will land new PR’s with a bit changes for providers in few hours. |
Hi again. I will land my PR, but i have some new observations and concerns.
In this case, in legacy branch, you will get "View engine is deprecated" error in console, but the package will work without any issue, because view engine support is removed completely only in v16. In new "angular" package you will make angular v15 as peer dependecy and resolve issue with esbuild. How does it sound to you? I am ready to land PR with providerFunctions but i can't change code for testsing because there literally no tests dedicated to angular v12+ :) |
ah.. i can't land my PR because EnvironmentProviders type is only available from v15. |
Hey @zip-fa, you're bringing up good points and I already thought about the exact package renaming you proposed. I talked with my team about our Angular strategy moving forward and we're probably going to bump the angular-ivy package to NG15. However, we can only do this, when we cut a new major version for the entire JS SDK repo. Dropping version support is a breaking change and we can't do that in a minor version. The new major will likely happen in a few months but not at this moment.
Mostly, yes. For Angular versions pre NG16, our users got build warnings because the
Regarding your renaming proposition: I have to think about this a bit more. I completely agree that this would be the more "organic" or logical naming scheme. We had to introduce "angular-ivy" without renaming because we added the package within the v7 major. Again, renaming a package would be a hard breaking change and can only be done in a major. Alright, so if I understand correctly, we have two problems right now to move forward with this task:
|
Your proposal sounds like hack to me, just to support everything and everywhere. I understand why you chose that way. I don’t think there is something “breaking” in what i proposed. But okay, you who decide here. If i understood correctly, we make this:
I dont think we can re-write tests now, because ng version is still at v12 - no standalone components, to standalone apis. How about creating separate package called angular-next with every new feature, better code organisation, etc? Are you still sure that we need to hack something just to add two little functions? |
Some takes about code structure. With current exports webpack will bundle tracing module (which is very heavy) when it’s not used.
There are many issues related to star exports, eg: I propose to remove this re-export for newer version completly, let user choose what to import and when. proposed imports realisation:
|
Maybe yes, but that's the price we have to pay :/ Also, supporting "everything" is important to us.
There is because:
This breaks everyone who currently uses @sentry/angular because suddenly
This actually breaks everyone who uses @sentry/angular-ivy with NG12-14. There's no guarantee for backwards compatibility of Angular libraries. Also, again, people would need to switch to another package which requires a code change. For basically the same reason, we still publish @sentry/hub and @sentry/tracing, although both packages are no longer used actively and have been hoisted/replaced with other packages. My goal for this task would be to still get the helpers in both packages, if possible. Can we do this for a minimal solution to get started?
If we need to un-link anything then maybe we do it but I don't see why this wouldn't work. |
I don't see why we'd need this. If users don't import
Hmm if this is true even if nothing about tracing ( |
What's the status on this? |
Hi @mackelito, not much movement here since the last answer. We can probably tackle this after we release v8 (main focus right now). Just need some time to implement it. |
Got it! Stay focused! 😉 |
I wanted to add these docs some time ago but didn't get to it: getsentry/sentry-docs#8342 Setup shouldn't be too different from app.module.ts. You mostly just need to add providers in the config: https://angular.io/guide/dependency-injection-providers#configuring-dependency-providers but I fully understand that we should add a better guide for it. I need to do some work for Angular when we work on v8 (soon) so I'll try to get this incorporated. |
I also posted some instruction how to configure sentry in app.config.ts here: #9376 (comment) |
I will close this given that it has been open for quite some time and we didn't get to it. While I think it'd be worthwhile to simplify the setup a bit, we also need to recognize that types and the provider APIs have changed over Angular versions. This might make such a new export from the SDK a bit challenging. If anyone comes across this issue: PRs are still welcome. |
Problem Statement
Currently, users have to add 2 to 3 providers in their
app.module.ts
orapp.config.ts
to fully configure error and performance monitoring in Angular projects. This is a bit cumbersome - let's simplify this setup!Solution Brainstorm
As suggested by @zip-fa, we can reduce the setup to 2 LoC here, by exporting helper functions from the SDK that add the respective provider entries:
AFAICT, these functions should work identically for both,
app.module.ts
andapp.config.ts
files.The text was updated successfully, but these errors were encountered: