Stop Monitor - JavaScript

4 posts, 0 answers
  1. John
    John avatar
    22 posts
    Member since:
    Apr 2012

    Posted 06 Aug 2013 Link to this post

    I am trying to stop the monitor when a user leaves an Eqatec monitored page. I hooked the event handler to do this, but it appears that monitor.status() reporting isStarted as false as soon as the XHR request is fired, rather than when it returns. How can I keep the user on the page long enough to stop the monitor?

    window.addEventListener("beforeunload", function () {
                page.monitor.stop();
                //attempt to wait for async call to complete
                for (var i = 1; i < 100000; i++)
                {
                    var status = page.monitor.status();
                    if (!status.isStarted)
                    {
                        return "got it on the " + i + " attempt";
                    }
                }
                return "didn't get it";
     
            });
  2. Soren
    Admin
    Soren avatar
    44 posts

    Posted 07 Aug 2013 Link to this post

    Hi John,

    We are aware of the issues with stopping the javascript monitor when a user leaves a page. From our testing it seems that there is no consistent browser support for doing this (some browsers allow us to send the stop message, some send empty request and some don't send at all). Stopping the monitor only involves sending an explicit stop message to our servers and it is the confirmed delivery of this message that is hard, if not impossible, to obtained.

    Our current recommendation is to simply call the stop method once and not delay the end user any further. Dependent upon the browser, the stop message will be delivered and processed by our servers and the server reply (which is just an empty confirmation) may or may not reach the browser. This is not a fool proof way of stopping the session but the side effects of not ensuring that the stop message is delivered will mostly be a slightly inaccuracy in the sessionlength statistics.

    So for now, there is no need to try to keep the user on the page, you should simply just stop the monitor and continue. Are you experiencing other issues from not stopping the monitor that we should be aware of?

    Hope this helps

     

    Regards,
    Soren
    Telerik
    JAVASCRIPT MONITOR (BETA) AVAILABLE FOR DOWNLOAD.
    Monitor web applications with the new EQATEC Application Analytics JS library. Compatible with all modern browsers.
    Test it today >>
  3. John
    John avatar
    22 posts
    Member since:
    Apr 2012

    Posted 07 Aug 2013 Link to this post

    Hello Soren,

    Thanks for the information.

    My precieved issue is that each call to monitor.start() counts as a installation. But in reality I only want an installation to be registered once for each unique InstallationID. See code below. Can this be accomplished? If not, could a timeout be established to "kill" abandoned sessions?
    var settings = _eqatec.createSettings('MY_PRODUCT_KEY');
                // your adjustments to the settings...
                settings.useCookies = true;           
                var eqatecVersion = myVersionString.toString().split("");
                settings.version = (eqatecVersion[0] + "." + eqatecVersion[1] + "." + eqatecVersion[2] + "." + eqatecVersion[3]);
                this.monitor = _eqatec.createMonitor(settings);
                if (typeof USER_NAME === 'undefined') {
                    this.monitor.setInstallationID("DefaultUserName");
                }
                else
                {
                    this.monitor.setInstallationID(USER_NAME);               
                }
                this.monitor.start();
  4. Soren
    Admin
    Soren avatar
    44 posts

    Posted 09 Aug 2013 Link to this post

    Hi John,

    I'm not sure I completely follow your desire for registering installation IDs. Our library by default counts unique users by counting unique machines(actually browsers) but you seem to want something different. Could you perhaps add a few lines on what you are trying to achieve in terms of counting users, installations,etc. and  I'll be happy to help out with how the library can help you.

    Looking forward to hearing back you

    Regards,
    Soren
    Telerik
    JAVASCRIPT MONITOR (BETA) AVAILABLE FOR DOWNLOAD.
    Monitor web applications with the new EQATEC Application Analytics JS library. Compatible with all modern browsers.
    Test it today >>
Back to Top