Applicationinsights-js: ReactPlugin becomes undefined after certain amount of time

Created on 20 Sep 2019  路  6Comments  路  Source: microsoft/ApplicationInsights-JS

We've been trying to integrate the react SDK of this into our project that uses redux with persistent states but it seems to be after a certain amount of time the React plugin object becomes undefined resulting in an exception which stops the page from loading

"TypeError: reactPlugin.trackMetric is not a function"

Most helpful comment

People: I've just found out a possible outcome:

in the TelemetryService.js file theres this code

let reactPlugin = null;

and then this inside the initialize function:

reactPlugin = new ReactPlugin();

I've replaced the first one with:

const reactPlugin = new ReactPlugin();

and commented the second one and it somehow fixed the issue, but I cant tell yet if this breaks something else.

All 6 comments

Yes, this happens to me as well. Using the code from the react demo and on component unmount of the withAITracking it is undefined.

TypeError: Cannot read property 'trackMetric' of undefined
class_1.componentWillUnmount

Same here :(

Facing the same issue, Any solution for this ?? Thanks

Same here, did anyone find a workaroud to avoid this?

People: I've just found out a possible outcome:

in the TelemetryService.js file theres this code

let reactPlugin = null;

and then this inside the initialize function:

reactPlugin = new ReactPlugin();

I've replaced the first one with:

const reactPlugin = new ReactPlugin();

and commented the second one and it somehow fixed the issue, but I cant tell yet if this breaks something else.

Same here - Do we have any updates / solutions for this please ?

Was this page helpful?
0 / 5 - 0 ratings