ApplicationInsights-JS icon indicating copy to clipboard operation
ApplicationInsights-JS copied to clipboard

[BUG] Types of property 'processTelemetry' are incompatible.

Open abbodh opened this issue 6 years ago • 5 comments

Description/Screenshot npm install is failing in Azure app services with below error

TypeScript error in D:/home/site/repository/Source/Microsoft.Teams.Apps.SubmitIdea/ClientApp/src/helpers/app-insights.ts(17,30):
  Type 'ReactPlugin' is not assignable to type 'ITelemetryPlugin'.
    Types of property 'processTelemetry' are incompatible.
      Type '(event: ITelemetryItem, itemCtx?: IProcessTelemetryContext | undefined) => void' is not assignable to type '(env: ITelemetryItem, itemCtx?: IProcessTelemetryContext | undefined) => void'.
        Types of parameters 'itemCtx' and 'itemCtx' are incompatible.
          Type 'import("D:/home/site/repository/Source/Microsoft.Teams.Apps.SubmitIdea/ClientApp/node_modules/@microsoft/applicationinsights-web/node_modules/@microsoft/applicationinsights-core-js/types/JavaScriptSDK.Interfaces/IProcessTelemetryContext").IProcessTelemetryContext | undefined' is not assignable to type 'import("D:/home/site/repository/Source/Microsoft.Teams.Apps.SubmitIdea/ClientApp/node_modules/@microsoft/applicationinsights-core-js/types/JavaScriptSDK.Interfaces/IProcessTelemetryContext").IProcessTelemetryContext | undefined'.
            Type 'import("D:/home/site/repository/Source/Microsoft.Teams.Apps.SubmitIdea/ClientApp/node_modules/@microsoft/applicationinsights-web/node_modules/@microsoft/applicationinsights-core-js/types/JavaScriptSDK.Interfaces/IProcessTelemetryContext").IProcessTelemetryContext' is not assignable to type 'import("D:/home/site/repository/Source/Microsoft.Teams.Apps.SubmitIdea/ClientApp/node_modules/@microsoft/applicationinsights-core-js/types/JavaScriptSDK.Interfaces/IProcessTelemetryContext").IProcessTelemetryContext'.
              The types returned by 'core()' are incompatible between these types.
                Type 'IAppInsightsCore' is missing the following properties from type 'IAppInsightsCore': getNotifyMgr, getPerfMgr, setPerfMgr  TS2322
  
      15 |             config: {
      16 |                 instrumentationKey: telemetry,
    > 17 |                 extensions: [reactPlugin],
         |                              ^
      18 |                 extensionConfig: {
      19 |                     [reactPlugin.identifier]: { history: browserHistory }
      20 |                 }
  

Steps to Reproduce

package versions: "@microsoft/applicationinsights-web": "2.5.5", "@microsoft/applicationinsights-react-js": "3.0.0",

sample script which is using extensions of reactPlugin.

import { ApplicationInsights } from "@microsoft/applicationinsights-web";
import { ReactPlugin } from "@microsoft/applicationinsights-react-js";

export const getApplicationInsightsInstance = (telemetry: any, browserHistory: any): any => {
    // Initialize application insights for logging events and errors.

    let reactPlugin = new ReactPlugin();
    let appInsights: any = null;
    try {
        appInsights = new ApplicationInsights({
            config: {
                instrumentationKey: telemetry,
                extensions: [reactPlugin],
                extensionConfig: {
                    [reactPlugin.identifier]: { history: browserHistory }
                }
            }
        });
        appInsights.loadAppInsights();
        return appInsights;
    }

Additional context Updating the version to 2.5.7 did not throw any error.

abbodh avatar Aug 19 '20 20:08 abbodh

This happens when the applicationinsights-web semver requested by the react plugin does not match the semver of your own applicationinsights-web version. This causes it pulls in 2 copies of the SDK. Updating both should resolve the issue and prevent you from shipping 2 copies of this SDK with your app.

markwolff avatar Aug 19 '20 20:08 markwolff

It's a little messy at the moment because of the release pipeline, but the releases do need to be kept in step with each other.

I believe that I addressed this as part of the 2.5.7 release. By releasing the react and react native extensions after releasing the core packages so that they reference the most up to date core versions.

So react 3.0.2 uses ^2.5.7 and the next release 3.0.3 will use ^2.5.8 (or whatever the versions end up being)

MSNev avatar Aug 26 '20 23:08 MSNev

Hi @MSNev , it seems the build is failing again due to 3.0.2 failing with 2.5.7 and worked after updating to 2.5.8. We have an open source application for Teams which uses this library and is frequently failing due to version mismatch. Any recommendation for us to keep track of changes done at appinsights-react packages which can potentially break. Thank you!

abbodh avatar Sep 23 '20 19:09 abbodh

These breaks are not the expected "norm" use case and as we (normally) rarely change the extensions directly you should not expected this to be a normal scenario. These types of breaks have bee introduced because of the current need to build the core of AI with TS 2.5.3 while the react, react-native and angular plugins are build with different versions of typescript, this change happened as part of the 3.0.0 release for react :-(

In terms of tracking changes, the release notes are the high level (https://github.com/microsoft/ApplicationInsights-JS/blob/master/RELEASES.md) which are derived from the commits.

Because of the build steps required, we have changed the release process slightly to try and avoid these types of breaks, which involves.

  • Bump version of AI Core and release
  • Bump version of React, React native and Angular extensions to use newly published AI Core version and release

So while there is a small window of time (hours normally) where this may be an issue, it keeps the builds in a more lockstep approach.

Sorry for the issues this caused, as you are probably an internal MS team you can also ping us on the 1DS alias as well.

MSNev avatar Sep 24 '20 01:09 MSNev

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

github-actions[bot] avatar Sep 25 '21 00:09 github-actions[bot]