Skip to content

Uncaught TypeError: Cannot redefine property: pathname when calling appInsights.loadAppInsights(); #43

@tom-faber-seekout

Description

@tom-faber-seekout

Description/Screenshot
Uncaught TypeError: Cannot redefine property: pathname
when calling appInsights.loadAppInsights();

image

Crashes app before react component is rendered, so web page just shows blank. I reproduced this with a simple Vite app, just adding the two app-insights packages and the initialization code below.

Steps to Reproduce

  • OS/Browser: MacOS latest version
  • SDK Version [e.g. 22]:
   "@microsoft/applicationinsights-react-js": "3.4.2",
   "@microsoft/applicationinsights-web": "3.0.1",
  • Node version: 18.5.0

  • created app with Vite using react-ts template

  • How you initialized the SDK:

const browserHistory = createBrowserHistory();
const reactPlugin = new ReactPlugin();
const appInsights = new ApplicationInsights({
  config: {
    connectionString,
    distributedTracingMode: DistributedTracingModes.W3C,
    enableAutoRouteTracking: true,
    extensions: [reactPlugin as unknown as ITelemetryPlugin],
    extensionConfig: {
      [reactPlugin.identifier]: { history: browserHistory },
    },
  },
});
appInsights.loadAppInsights();

Expected behavior
no crash, app renders

Additional context
Perhaps this is just incompatible versions of applicationinsights-react-js and applicationinsights-web? If I downgrade applicationinsights-web to 2.8.13, the problem goes away. Still, glad I'm entering this so that the next person who encounters it will see this in a search.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions