Coder Social home page Coder Social logo

Comments (23)

damieng avatar damieng commented on July 19, 2024

AutoAnalytics.StartAsync should be called directly before Window.Current.Activate() in your App.xaml.cs

If you start it too soon then yes, the Window.Current won't be initialized yet.

from csharpanalytics.

kpantos avatar kpantos commented on July 19, 2024

I do call AutoAnalytics.StartAsync right before Window.Current.Activate(); in my App.xaml.cs as mentioned in the documentation but still got the same problem.

from csharpanalytics.

damieng avatar damieng commented on July 19, 2024

Are you sure Window.Current is null or is it Window.Current.CoreWindow?

If Window.Current is null then the very next line, Window.Current.Activate, would also throw a null ref errror.

Have you changed anything else in your OnLaunched method?

from csharpanalytics.

kpantos avatar kpantos commented on July 19, 2024

Yes I'm sure Window.Current is null.

As for your next argument unfortunately that is not true. The problem is that the call that is throwing the exception is made from an other thread and not the UI one. In the UI thread Window.Current is not null, in the thread that is picking the screen size though, it is.

Hope this helps.

from csharpanalytics.

g10kumar avatar g10kumar commented on July 19, 2024

@damieng : Firstly thanks for this solution of yours. It is helping us a lot . :)
You are suggesting that we should add the call to AutoAnalytics.StartAsync in OnLaunched() , but the thing is that this is making the application launch slow . When the windows.current line is executed the splash page is removed and the user is able to see the application default page. We used it the first time as suggested , and the application didn't passed the windows certification giving reason that the application launch time was too much . So we moved the call to the OnNavigation() of the default page. This time we passed the store certification.
In our next release after we added some features to the application, on checking the application with the windows certification kit , the application failed, In the event logs, we found out that the application was failing with an exception in the CSharpAnalytics.WindowsStore assembly . So we removed all the calls to the reference assembly , and compiled the same. This time the application passed the certification.
Is it possible to remove the functionality to check the resolution of the user device , because that is where I think the exception is occurring , also one can work without this functionality.
Thanks.

from csharpanalytics.

damieng avatar damieng commented on July 19, 2024

At least some of AutoAnalytics.StartAsync will need to be on the UI thread but most of it is very lightweight - about the only thing that could cause much of a delay would be restoring the queue of pending requests (CSharpAnalytics-RequestQueue in the LocalState folder)

Where is your AutoAnalytics.StartAsync() line right now when you get the null ref?

from csharpanalytics.

damieng avatar damieng commented on July 19, 2024

Also check that CSharpAnalytics-RequestQueue file and see how bit it is. If it is large, did you change any of the CSharpAnalytics configuration? The sample app on my machine runs AutoAnalytics.StartAsync in ~100ms.

from csharpanalytics.

kpantos avatar kpantos commented on July 19, 2024

Hello Damien,
Regarding my null reference exception, the code is exactly as described in the documentation in the OnLaunched I call :

//Google Analytics
await AutoAnalytics.StartAsync(new UrchinConfiguration("XXXXXXXXX", "YYYYYYYYYY"));

// Ensure the current window is active
Window.Current.Activate();

SettingsPane.GetForCurrentView().CommandsRequested += App_CommandsRequested;

from csharpanalytics.

damieng avatar damieng commented on July 19, 2024

I'm very confused. I thought you said you had moved this code because it was slow? Or was the change made elsewhere?

If you comment out the AutoAnalytics line in the code above does Window.Current.Activate not also throw a null ref?

from csharpanalytics.

kpantos avatar kpantos commented on July 19, 2024

I'm not the one that made the comment about being slow.
It works quickly with me and had no problem passing certification.

from csharpanalytics.

kpantos avatar kpantos commented on July 19, 2024

P.S. To work around the issue I have commented out the code that measures the window height.

from csharpanalytics.

damieng avatar damieng commented on July 19, 2024

I see. @g10kumar can you put your issue on a new thread please, thanks!

Window.Current is initialized in OnLaunched before this line should be hit (Window.Current.Content = rootFrame) Are you perhaps trying to call AutoAnalaytics Track methods before StartAsync?

from csharpanalytics.

kpantos avatar kpantos commented on July 19, 2024

No I don't think so, the code worked perfectly in an older version of CSharpAnalytics. The problem was introduced once I've upgraded to the latest bits.
I haven't made any other changes except the upgrade of CSharpAnalytics.

from csharpanalytics.

damieng avatar damieng commented on July 19, 2024

Can you check your Debug output window to see what the first -Analytics-- block says for Event Type and Event Action?

from csharpanalytics.

kpantos avatar kpantos commented on July 19, 2024

-Analytics-------------------------------------
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
?utmwv=5.3.3csa1&utmn=2077949686&utmul=el&utmcs=UTF-8&utmfl=-&utmje=-&utmsc=32-bit&utmac=ΧΧΧΧΧΧΧ&utmhn=ZouglaW8.gr&aip=1&utmhid=1427415232&utms=14&utmr=http%3A%2F%2FZouglaW8.gr%2FLive&utmcc=__utma%3D1.172746138.1365604681.1365604681.1365604681.1%3B&utme=5%28ApplicationLifecycle%2AStop%29&utmt=event&utmp=%2FLive
Account ID : ΧΧΧΧΧΧΧ
Host Name : ZouglaW8.gr
Page : /Live
Referring URL : http://ZouglaW8.gr/Live
Hit ID : 1427415232
Hit Type : event
Event Type : ApplicationLifecycle
Event Action : Stop
Visitor ID : 172746138
Session Count : 1;
Session Time - First : Wed, 10 Apr 2013 14:38:01 GMT
Session Time - Last : Wed, 10 Apr 2013 14:38:01 GMT
Session Time - Current : Wed, 10 Apr 2013 14:38:01 GMT
Language : el
Encoding : UTF-8
Flash Version : -
'Zougla.exe' (Managed (v4.0.30319)): Loaded 'D:\Work\Zougla\Metro\Zougla\bin\Debug\AppX\Newtonsoft.Json.DLL', Symbols loaded.
Java Enabled : -
Color Depth : 32-bit
Tracking Agent : 5.3.3csa1
Cachebuster : 2077949686
Session Hit Count : 14
Anonymize IP : True

from csharpanalytics.

damieng avatar damieng commented on July 19, 2024

It's strange the first thing it's trying to send is a Stop event. Can you post the stack of the null ref?

from csharpanalytics.

g10kumar avatar g10kumar commented on July 19, 2024

HI,
@kpantos : can you tell me where do I have to make changes to stop the measuring of height .
@damieng :Where I will be able to find the CSharpAnalytics-RequestQueue file . I am calling the AutoAnalytics.StartAsync in the OnNavigatedTo page of the default page . Will this effect the performance.

from csharpanalytics.

damieng avatar damieng commented on July 19, 2024

@g10kumar Please open a separate issue for your performance problems. It is unrelated to the reasons this issue was opened and is confusing the discussion here.

from csharpanalytics.

damieng avatar damieng commented on July 19, 2024

Am now seeing the null ref while using a test app. Investigating.

from csharpanalytics.

damieng avatar damieng commented on July 19, 2024

It appears to happen when tracking unhandled exceptions.

from csharpanalytics.

damieng avatar damieng commented on July 19, 2024

Fix is checked in. Let me know if that solves your problem too @kpantos.

from csharpanalytics.

damieng avatar damieng commented on July 19, 2024

I've also been experimenting with a new start-up process on the Measurement Protocol version of AutoAnalytics (AutoMeasurement). It lets you Track events right away and just buffers them up until StartAsync has done its work (which no longer needs to run on the ui thread). This should resolve the null refs and any perf issues. Let me know if you want to try this.

from csharpanalytics.

damieng avatar damieng commented on July 19, 2024

So the new system is in. You'll need now to add two lines to the app.xaml.cs - see the README - but this new startup process allows tracking activity before initialization (solves nullrefs) and detaches the file io from startup (removes perf impact).

from csharpanalytics.

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.