Code Monkey home page Code Monkey logo

Comments (7)

MSNev avatar MSNev commented on June 3, 2024 2

This normally means that you are creating multiple instances of the SDK and initializing them.

You are probably not getting them for Page views because a page view is only sent from a specific instance, while the dependency (ajax) requests are indirectly sent because each instance "hooks" the XMLHttpRequest and/or fetch API.

Which means that each "hook" instance monitors that an Ajax request occurred and sends a remote dependency call for each instance. If this is the case I would expect "multiple" calls to track as each instance is managing it's own batching and sending of the events.

There are 2 ways to work around this

  • Make sure you only create and initialize 1 single instance of the SDK for your SPA
  • Before "creating" and initializing a new instance you should call unload() to cause the previous instance to unhook itself, just "replacing" any "global" reference like the window.appInsights will still leave the previous instance intact and sending events for the hooked values.

from applicationinsights-js.

MSNev avatar MSNev commented on June 3, 2024 1

Can I assume that your application is a SPA? And that these page views are all occurring on the client side?

In v3.0.3 we change the way we capture the page load "start time" to use the browser's reported metrics, which might be the source of this issue.

@siyuniu-ms can you please check that whether we are applying the timestamp change to ALL page views for a page or only the first one?

I'm labeling as a bug and assigning to the next release, as I suspect this is the case. If we cannot reproduce then I'll adjust the labelling.

from applicationinsights-js.

gjermshus avatar gjermshus commented on June 3, 2024 1

Your assumption is correct, this is a SPA and all the page views happen on the client side.
Please let me know if I can provide you with more information!

from applicationinsights-js.

JakobMadsen717 avatar JakobMadsen717 commented on June 3, 2024 1

I am using @microsoft/[email protected]

Just more info in case it matters to troubleshooting. Seeing many duplicates in AppInsight logs, my app is SPA. Seeing duplicates (groups of 2, 3 or more) with identical timestamp for Dependency and Event - but for some reason I don't get them for Page Views. I don't always get dups, some sessions have em, some don't. I get dups across devices.

from applicationinsights-js.

JakobMadsen717 avatar JakobMadsen717 commented on June 3, 2024 1

My duplicates have the same timestamp, id, duration, operation_Id, etc. Every property, in a set of duplicates, seem identical to me.

But I think this is unrelated to issue at hand. I see some duplicates dating all the way back to 2023-08-19, so I have a feeling this a Red herring, sorry about that and I will need to investigate more.

from applicationinsights-js.

siyuniu-ms avatar siyuniu-ms commented on June 3, 2024

I am using @microsoft/[email protected]

Just more info in case it matters to troubleshooting. Seeing many duplicates in AppInsight logs, my app is SPA. Seeing duplicates (groups of 2, 3 or more) with identical timestamp for Dependency and Event - but for some reason I don't get them for Page Views. I don't always get dups, some sessions have em, some don't. I get dups across devices.

Hi, correct me if I understand wrong. For depenency and event traces, those who have the same start time does not have the same ingestion time or duration time.

from applicationinsights-js.

JakobMadsen717 avatar JakobMadsen717 commented on June 3, 2024

Thanks MSNev, your comments put me on the path. The duplicates happen when/after my PWA updates itself so something with my service worker reloading app and in the process the "old" SDK instance keeps logging events and dependencies. I think my service worker update process just needs to unload() "old/existing" instance before cutting down the tree it's sitting on. I'll nail it down & thanks for your pointers.

from applicationinsights-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.