monitor.start & stop in ASP.NET application

8 posts, 0 answers
  1. Tomica
    Tomica avatar
    147 posts
    Member since:
    Apr 2008

    Posted 05 Sep 2013 Link to this post

    On my first day with Eqatec, I have learned that I can run feature tracking on a page as follows:

    I understand the need to declare the monitor and get it started.

    I am not sure if I need to explicitly stop the monitor, as any resources allocated within IIS when the page executes should be disposed of when the page has finished loading on the client machine.

    Assuming this page gets access 1,000 times a day, am I accumulating any "crud" on my server or causing any strain on your servers?

    Ideally I would like to create the monitor once, start it at the beginning of each user session, then close at the end of the session, but I don't know how. (I have posted another thread for this question)
  2. Soren
    Admin
    Soren avatar
    44 posts

    Posted 06 Sep 2013 Link to this post

    Hi Thomas,

    Our monitor library should only be started once within the application, so for ASP.NET you should typically start and stop the monitor instance within your Global.asax page. With regards to starting and stopping on user sessions, there is an important realization to be made when using the monitor serverside, namely that you'll not be tracking users but the server application it self. You can read a bit more about this here (http://www.telerik.com/analytics/resources/blog/13-06-26/eqatec-analytics-in-asp.net) which includes a few tips on what kinds of data you'll be able to collect from an ASP.NET project.

    So to answer your question from this email. You should start a single instance of the monitor and this instance will accumulate all the tracking data that you throw at it without any real overhead (as it is combining the tracking points and sending the data asynchronously). On Application_End, you should
    Stop and Dispose the monitor instance

    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. Tomica
    Tomica avatar
    147 posts
    Member since:
    Apr 2008

    Posted 06 Sep 2013 Link to this post

    Soren, thanks for your reply.

    As a long-time subscriber to Telerik's development tools I have become accustomed to viewing actual, practical code examples in VB.NET. In fact, I tell my colleagues and clients that the reason I recommend Telerik so strongly is just that: true support for the VB programmer, along with superior technical support when needed.

    The example linked to is a good start, but I am still faced with the cryptic explanation quoted below. As my job involves daily deliverables, I don't have the luxury of pondering the in's and out's of "dependency injection", I just need ONE solid example of how to initialize the monitor in my Global.asx, and then how to reference that same monitor is the code of an ASPX page.

    If EQATEC claims compatibility with VB.NET then somebody must have a working example, right?
    ........................................

    Dependent upon your specific architecture you can then make this instance accessible from the rest of your application either directly or through e.g. some dependency injection scheme. You can use the monitor instance by calling the various methods on it from within your application to track the various aspects of your web application.
  4. Soren
    Admin
    Soren avatar
    44 posts

    Posted 09 Sep 2013 Link to this post

    Hi Thomas,

    I apologize for the somewhat fluffy content in the last post. It is hard providing sample code that fits all purposes. I could have provided a simple sample that stored the instantiated monitor in a static variable that could be referenced from the rest of the pages, but for some, the use of static variables is a bit of a code smell so that led me to the somewhat vague description.

    The basic premise for instantiating and sharing the monitor instance within an application is: Create a single monitor instance (typically done in Global.asax or other bootstrapping/initialization code) and make this instance accessible to the rest of the application (typically using either a static variable, or wrapping the monitor behind your own interface and use existing techniques to share components with your application).

    As for VB.NET, you are correct that most of our current samples are exposed in C#. I've attached a simple example of the Global.asax initialization and calling the monitor from a page in this reply:

    'Global.asax.vb
    Public Class Global_asax
        Inherits HttpApplication
     
        Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
            ' Fires when the application is started
            AuthConfig.RegisterOpenAuth()
            RouteConfig.RegisterRoutes(RouteTable.Routes)
     
            ' Creating monitor instance and assigning to a static variable
            FeatureTracking.Monitor = EQATEC.Analytics.Monitor.AnalyticsMonitorFactory.CreateMonitor("Your-Product-Key")
            FeatureTracking.Monitor.Start()
        End Sub
    End Class
     
    ' FetureTracking.vb
    Public Class FeatureTracking
        Public Shared Monitor As EQATEC.Analytics.Monitor.IAnalyticsMonitor
    End Class
     
    ' Default.aspx.vb
    Public Class _Default
        Inherits Page
     
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
            ' example of tracking named feature
            FeatureTracking.Monitor.TrackFeature("Default.Loaded")
        End Sub
    End Class

    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 >>
  5. Tomica
    Tomica avatar
    147 posts
    Member since:
    Apr 2008

    Posted 09 Sep 2013 Link to this post

    Soren,

    Sometimes "fluffy" is a good thing, but this tangible example is much better.

    No matter that I have been doing ASP development for 10 years, the concept of persistence is not in my vocabulary, each ASPX page is a standalone entity, relying on IIS session variables or calling externally implemented classes in VB modules.

    I did take a stab at the shared monitor with a public class, but it seems to be somewhat unreliable, so I will make sure to fit your code in its place.

    I would again like to emphasize that tangible examples in the preferred language are key selling points for me, no matter how pretty & smooth the marketing pages are, behind the scenes I need to get things DONE. The days of approaching my work as a R&D adventure are long past!

    TG
  6. Soren
    Admin
    Soren avatar
    44 posts

    Posted 09 Sep 2013 Link to this post

    Hi Thomas,

    I'm glad the VB.NET sample, though brief, seemed to have provided some clarity. I'll take your feedback on language equality in the samples to heart and push it up the chain.

    If you have any further question, please let me know
     
    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 >>
  7. Tomica
    Tomica avatar
    147 posts
    Member since:
    Apr 2008

    Posted 09 Sep 2013 Link to this post

    Are the following lines required for tracking?

    I do not understand their use in this context.


            AuthConfig.RegisterOpenAuth()

            RouteConfig.RegisterRoutes(RouteTable.Routes)

     

  8. Soren
    Admin
    Soren avatar
    44 posts

    Posted 10 Sep 2013 Link to this post

    Hi Thomas,

    Feel free to disregard those two lines, which were standard parts of the small test project I created. In retrospect, I should have excluded those line to keep the sample even more concise.

     

    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