microsoft / ApplicationInsights-JS

Microsoft Application Insights SDK for JavaScript
MIT License
648 stars 239 forks source link

[BUG] Stops recording AJAX dependencies after 15 to 30 minutes #2088

Closed jdudleyie closed 1 year ago

jdudleyie commented 1 year ago

Description/Screenshot

I am finding that Application Insights SDK stops calling the track endpoint and hence stops sending AJAX dependency call information after 15 to 30 minutes.

Steps to Reproduce

appInsights.ts

import { ApplicationInsights } from "@microsoft/applicationinsights-web";
import { ReactPlugin } from "@microsoft/applicationinsights-react-js";
import { createBrowserHistory } from "history";
import { appInsightsConnectionString } from "core/env";

const browserHistory = createBrowserHistory();
const reactPlugin = new ReactPlugin();
const appInsights = new ApplicationInsights({
    config: {
        connectionString: appInsightsConnectionString,
        autoTrackPageVisitTime: true,
        extensions: [reactPlugin],
        extensionConfig: {
            [reactPlugin.identifier]: { history: browserHistory },
        },
    },
});
appInsights.loadAppInsights();
export { reactPlugin, appInsights };

app.tsx

import { AppInsightsContext } from "@microsoft/applicationinsights-react-js";
import { reactPlugin } from "core/appInsights";

<AppInsightsContext.Provider value={reactPlugin}>
    ...app goes here 
</AppInsightsContext.Provider>

Expected behavior

I would expect/hope that as long as there are AJAX requests being made, SDK would continue to send the data.

Is it possible that it stops due to user inactivity? Our users do often leave the page open for hours at a time without interacting with it as they are mainly looking at the data which is updating in realtime.

Additional context Add any other context about the problem here.

MSNev commented 1 year ago

I would expect/hope that as long as there are AJAX requests being made, SDK would continue to send the data.

Yes, so would we.

Is it possible that it stops due to user inactivity?

No, the only way that the Ajax should be stopped getting recorded woudl be that the SDK has been either unloaded or the page restarted. Or with the new v3.x you can "disable" on the fly by changing the configuration to disable the elements.

I think this is the key bit of data

Due to a SignalR connection, the react app triggers AJAX requests every 10 seconds or so, requesting new data which is populated in the page

By default, there is a configuration maxAjaxCallsPerView which is set to 500, I suspect that you are hitting this limit (you can change limit) and if you set to -1 it disables this limit.

jdudleyie commented 1 year ago

Thank you - this makes sense - this is most likely the reason then - I will try this out.

github-actions[bot] commented 3 months ago

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.