Skip to content

[BUG] AppInsights breaks Angular v20.3.* local development #2643

@willyt150

Description

@willyt150

Description/Screenshot
@microsoft/applicationinsights-web breaks running the local development Angular server after upgrading to Angular 20.3.* packages with error Cannot redefine property: name. Prevents anything from working/running.

Uncaught TypeError: Cannot redefine property: name
    at defineProperty (<anonymous>)
    at __name (chunk-TJFVSI2U.js:20:33)
    at AnalyticsPlugin.js:57:10

Steps to Reproduce

Create a brand new Angular 20 application w/ modules (using angular cli global version 20.3.1)

  • ng new cannot-redefine-property --standalone=false --ai-config "none" --style "scss" --ssr false --zoneless false

Install ApplicationInsights-JS

  • npm i @microsoft/applicationinsights-web

Add Application Insights creation to the app.ts constructor

  protected readonly appInsights: ApplicationInsights;

  constructor() {
    this.appInsights = new ApplicationInsights({
      config: {
        instrumentationKey: '<InstrumentationKeyHere>'
      }
    });
  }

Then run the dev server and viewing the browser dev tool console you will see the error.

  • npm start

  • OS/Browser: Windows, Chrome and Edge

  • SDK Version [e.g. 22]: 3.3.9

  • How you initialized the SDK:

    this.appInsights = new ApplicationInsights({
      config: {
        instrumentationKey: '<InstrumentationKeyHere>'
      }
    });

Expected behavior
Error should not occur and the site should run and display.

Additional context
This issue only started occurring when upgrading from Angular 20.2.* versions to 20.3.* in order to resolve dependency vulnerabilities.

Example repo: Angular20.3WithAppInsights

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions