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

Type 'AngularPlugin' is not assignable to type 'ITelemetryPlugin', Angular 15 ( "@angular/common": "15.1.0") error when trying to build the project #97

Open
hladysh opened this issue Feb 17, 2023 · 10 comments
Assignees

Comments

@hladysh
Copy link

hladysh commented Feb 17, 2023

error TS2322: Type 'AngularPlugin' is not assignable to type 'ITelemetryPlugin'.
Types of property 'setNextPlugin' are incompatible.

import { AngularPlugin } from '@microsoft/applicationinsights-angularplugin-js';

    const angularPlugin = new AngularPlugin();
    this.appInsights = new ApplicationInsights({
        config: {
            instrumentationKey: 'key',
            enableAutoRouteTracking: false, // option to log all route changes
            enableCorsCorrelation: true,
            extensions: [angularPlugin],
            extensionConfig: {
                [angularPlugin.identifier]: { router: this.router },
            },
        },
    });
    this.appInsights.loadAppInsights();

extensions: [angularPlugin],
                            ~~~~~~~~~~~~~

"@microsoft/applicationinsights-angularplugin-js": "3.0.1",
"@microsoft/applicationinsights-web": "2.8.9",
"@angular/common": "15.1.0",
"typescript": "4.9.4",

@MSNev
Copy link
Contributor

MSNev commented Feb 17, 2023

Which versions of the plugin and ApplicationInsights are you using?

We recently release v3.0.1 of the angular plugin which moved the base version of Application Insights to 2.8.10 to address this issue (which is typescript being more pedantic than necessary) #76

You can safely cast to any to bypass the error, we believe we tracked this down to a change we made to introduce an optional unload function. As we support backward compatibility of the newer ApplicationInsights using older components (plugins).

If your not using 3.0.1 and 2.8.10 can you please upgrade both (or use the workaround by casting as any to avoid TypeScript complaining).

@hladysh
Copy link
Author

hladysh commented Feb 20, 2023

problem was fixed after the update "@microsoft/applicationinsights-web": "2.8.9", to "@microsoft/applicationinsights-web": "2.8.10"

@OzBob
Copy link

OzBob commented May 12, 2023

@MSNev the dependencies between the 2 projects are inconsistent.
Will these old versions ^2.8.12 be upgraded to ^3.0.1?
https://github.com/microsoft/applicationinsights-angularplugin-js/blob/main/package.json#L67

   "@microsoft/applicationinsights-common": "^2.8.12",
    "@microsoft/applicationinsights-core-js": "^2.8.12",
    "@microsoft/applicationinsights-properties-js": "^2.8.12",

To match the dependencies of '@microsoft/applicationinsights-web'? i.e. v3.0.1?

For now I will experiment and downgrade @microsoft/applicationinsights-web to v2.8.13

@siyuniu-ms siyuniu-ms self-assigned this Jun 22, 2023
@david-brink-talogy
Copy link

Is there any update? This still occurs when using the most current version of both these packages

    "@microsoft/applicationinsights-angularplugin-js": "^3.0.1",
    "@microsoft/applicationinsights-web": "^3.0.2",

@MSNev
Copy link
Contributor

MSNev commented Jul 13, 2023

Still in progress (sorry delay as I was OOF last week), the plan is to finalize the updates and release the update by / before the end of July 23.

@david-brink-talogy
Copy link

Doesn't appear there's been a release still. Can we get this fixed?

@MSNev
Copy link
Contributor

MSNev commented Aug 1, 2023

Correct, some other items got in the way of completing and publishing an update, and as part of the next release we want to bump the major version number we also want to consider including some of the community PR's as part of the release(s) (as one of them is bumping to Angular 15) So unlike the react / react-native plugins (which we have release) this one requires some additional time. But we are still working towards publishing as soon as possible (which is now mid to end of Aug 23 ☹️ )

@david-brink-talogy
Copy link

That's unfortunate a seemingly small issue with dependency versions has lingered for so long. You're aware Angular 16 has been out for three months already?

@MSNev
Copy link
Contributor

MSNev commented Aug 1, 2023

Yes, it is unfortunate. 😦

On the Angular 16, No we didn't know (as we don't actual code in Angular, React or React-Native except for these plugins) we are relying on the community to keep us up to date and then we "attempt" (not very well recently) to keep things in sync.

Or primary goal is to provide a standard (which often means lowest common denominator) "support" for the current frameworks with the current release of Application Insights. AI 3.x is a significant internal change and has required a lot more time than originally estimated.

One of the reasons for the renumbering (which will also require branching) is so that we can better support multiple versions of the framework with less cognitive hoops (compatibility lookup tables) so that
plugin 14 => Angular 14
plugin 15 => Angular 15
plugin 16 => Angular 16

Where the main branch will always be the "current" and we will create branches for the older versions (to enable patching) at the point of upgrading main to a newer release.

Not that any of the above wording helps you and the current state.

We are hoping that once we complete the v14 release with AI v3.x support (we already have this 2nd part checked in) things should get smoother.
To complete v14 we need to review the changes proposed in #103 and potentially #114 and take over / incorporate into a new PR's, but as this is not our primary domain we also need to ramp up and understand the changes (after we finish the current tasks which are affecting the timeline)

@siyuniu-ms
Copy link
Contributor

for angular v14, the bug is solved at ver 14.0.0 https://github.com/microsoft/applicationinsights-angularplugin-js/releases/tag/14.0.0

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

No branches or pull requests

5 participants