Coder Social home page Coder Social logo

csharpanalytics's People

Contributors

andrewatavenza avatar angularsen avatar damieng avatar huseyint avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

csharpanalytics's Issues

ASP.NET support

Has anybody considered adding support for ASP.NET projects so we track our server-side C# code in webform and/or MVC applications?

Setting SetOptOut before Start causes crash

If the user sets 'SetOptOut' before calling Start the library throws an IOException when trying to save session settings.

This is causes due to thread race when SetOptOut saves the session (BaseAutoMeasurement line:157) and Start tries to do the same (BaseAutoMeasurement line:77).

Exception on Start()

Just wanted to give this library a whirl. Seems pretty easy to use, which was a big bonus for me. I had things working with these lines for my setup:

AutoMeasurement.Instance = new WinFormAutoMeasurement();
AutoMeasurement.Instance.Start(new MeasurementConfiguration("UA-60679857-1", Application.ProductName, Application.ProductVersion), "Debug");

And then on a screen I'd call

AutoMeasurement.Client.TrackScreenView("My Screen");

Now on startup (specifically, only if I include the .Start() line, I get the following exception:

There was an error deserializing the object of type System.Collections.Generic.List1[[System.Uri, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]. The data at the root level is invalid. Line 1, position 1. at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver) at System.Runtime.Serialization.XmlObjectSerializer.ReadObject(XmlDictionaryReader reader) at System.Runtime.Serialization.XmlObjectSerializer.ReadObject(Stream stream) at CSharpAnalytics.Serializers.AppDataContractSerializer.<Restore>d__01.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at CSharpAnalytics.WinFormAutoMeasurement.<Load>d__01.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at CSharpAnalytics.BaseAutoMeasurement.d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at CSharpAnalytics.BaseAutoMeasurement.d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.b__1(Object state)
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
The data at the root level is invalid. Line 1, position 1.
at System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader, String res, String arg1, String arg2, String arg3)
at System.Xml.XmlUTF8TextReader.Read()
at System.Xml.XmlBaseReader.IsStartElement()
at System.Xml.XmlBaseReader.IsStartElement(XmlDictionaryString localName, XmlDictionaryString namespaceUri)
at System.Runtime.Serialization.XmlReaderDelegator.IsStartElement(XmlDictionaryString localname, XmlDictionaryString ns)
at System.Runtime.Serialization.XmlObjectSerializer.IsRootElement(XmlReaderDelegator reader, DataContract contract, XmlDictionaryString name, XmlDictionaryString ns)
at System.Runtime.Serialization.DataContractSerializer.InternalIsStartObject(XmlReaderDelegator reader)
at System.Runtime.Serialization.DataContractSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)

I feel like it's trying to restore some state or something, but I've blown away my bin directory and I've checked source control to ensure I have no other changes. It just stopped working out of (seemingly) nowhere and now I can't really do all that much.

Definite props for putting something together that's so easy to use though.

proxy support

Hi is there a way to set a proxy to AutoMeasurement?

Incorrect ApplicationVersion tracked

Application version is tracked as Major.Minor.Revision.Build , which is not the same pattern as in AssemblyInfo nor in the package manifest.
Application version should be tracked as Major.Minor.Build.Revision

MeasurementConfiguration.FormatVersion

Session start and session end time stamps registered at GA are very often too late relative to other events

Session start and session end time stamps registered at GA are very often too late relative to other events.
This happens when session start and session end events are queued when there is no internet connection.
But it also happens whith all session end events, because session end events are only sent at the time when a new session is started.

Problem source: “QT” (Queue Time ) parameter is not appended to “SC” (Session Control) events.

Steps to Reproduce:

  • Disconnect your client system from the internet.
  • Do some tracking from your application: Start a session, genereate some other events, close session, wait for some seconds, start a new session.
  • Re-connect to internet
  • Login to analytics.google.com and open the according tracker
  • Navigate to Audience / User Explorer, find your Client ID (by looking into the data),
  • now here you can see all single events and check the timewise position.

sessions not ending properly

I have been testing our this library and the Measurement Protocol in general. I cant seem to get sessions to end correctly. I have a very basic application to test with. In the example below I start the app, view one screen and close the app; then I repeat this one time with the same cid. I see the data come in with GA real time. I would expect to see 1 user and 2 sessions; but I don't... I see 1 user and 1 session. Im assuming that session management isn't being handled correctly on the client side and its falling back to GA's default of 30 min to define a session. Any ideas?

SESSION START
v=1&tid=UA-42299003-2&cid=efcca950-c40d-4932-af8f-01f7da12dbb3&aip=0&an=Tester&av=1.0.0&ul=en-us&sr=800x600&t=appview&cd=app&sc=start&z=527986040

HOME APPVIEW
v=1&tid=UA-42299003-2&cid=efcca950-c40d-4932-af8f-01f7da12dbb3&aip=0&an=Tester&av=1.0.0&ul=en-us&sr=800x600&t=appview&cd=home&z=1994456977

SESSION END
v=1&tid=UA-42299003-2&cid=efcca950-c40d-4932-af8f-01f7da12dbb3&aip=0&an=Tester&av=1.0.0&ul=en-us&sr=800x600&t=appview&cd=app&sc=end&z=2039537302

5s delay...

APP START
v=1&tid=UA-42299003-2&cid=efcca950-c40d-4932-af8f-01f7da12dbb3&aip=0&an=Tester&av=1.0.0&ul=en-us&sr=800x600&t=appview&cd=app&sc=start&z=2090727250

HOME APPVIEW
v=1&tid=UA-42299003-2&cid=efcca950-c40d-4932-af8f-01f7da12dbb3&aip=0&an=Tester&av=1.0.0&ul=en-us&sr=800x600&t=appview&cd=home&z=39349359

SESSION END
v=1&tid=UA-42299003-2&cid=efcca950-c40d-4932-af8f-01f7da12dbb3&aip=0&an=Tester&av=1.0.0&ul=en-us&sr=800x600&t=appview&cd=app&sc=end&z=1496245515

REAL TIME
image

Nuget and Winforms solution

Hi Damien,

The NuGet package seems to miss the Winforms project, it does install only the dll for net45 and so CSharpAnalytics.AutoMeasurement, and others cannot be used.
Building from the sources and using the CSharpAnalytics.WinForms project is working fine.
Can you correct the NuGet package ?

Thanks in advance.

Prior requests cause null exception in BaseAutoMeasurement::Request

I was fiddling with our app's ability to handle network availability and I started getting null reference exceptions in BaseAutoMeasurement::Request(). It was complaining on the first line:

if (sessionManager.VisitorStatus != VisitorStatus.Active)

because sessionManager was still null. I looked into it and I think the problem is in BaseAutoMeasurement::Start(). Currently, it looks like this:

            await StartRequesterAsync();

            var sessionState = await Load<SessionState>(SessionStorageName);
            sessionManager = new SessionManager(sessionState, configuration.SampleRate);
            if (delayedOptOut != null) SetOptOut(delayedOptOut.Value);

But if I change it to:

            var sessionState = await Load<SessionState>(SessionStorageName);
            sessionManager = new SessionManager(sessionState, configuration.SampleRate);
            await StartRequesterAsync();
            if (delayedOptOut != null) SetOptOut(delayedOptOut.Value);

it stops throwing exceptions. I'm guessing because when the Requester is fired up, it immediately checks for prior requests, queues them, and starts processing them. Unfortunately, sessionManager is initialized later, so its not there, and it fails the Request() call.

So simply creating the SessionManager first solves the problem, but maybe there's a good reason it was created in the order its currently created!

Starting multiple instances of a WPF application at same time throws Exception in Start()

We started to use the analytics library and it works ok. Right now if the user starts the WPF application, the Start method will try to save the current session. This ends with a race that one of the instances will throw an exception stating that the file is in use.

Unhandled exception occurred:System.IO.IOException: The process cannot access the file '[SOMEWHERE]\CSharpAnalytics-MeasurementSession' because it is being used by another process.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync)
   at CSharpAnalytics.Serializers.AppDataContractSerializer.<Save>d__71.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at CSharpAnalytics.WpfAutoMeasurement.<Save>d__31.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at CSharpAnalytics.BaseAutoMeasurement.<Start>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>b__0(Object state)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

BUG: TrackContentView in MeasurementActivityExtensions is missing a argument for ContentViewActivity

Great work and I really appreciate it!

The creation of the ContentViewActivity is missing a null in the second argument to make sure the other arguments are correctly mapped to the constructor.

public static void TrackContentView(this MeasurementAnalyticsClient analyticsClient, Uri documentLocation, string contentDescription,
string documentPath = null, string documentHostName = null)
{
if (analyticsClient == null) throw new ArgumentNullException("analyticsClient");
analyticsClient.Track(new ContentViewActivity(documentLocation, null, contentDescription, documentPath, documentHostName));
}

BR,
Peter

Windows Phone 8.1 Support

I've just start using your library -- it's working great! -- but we needed a Windows Phone 8.1 (non-Silverlight) version. I've actually already done the work; do you want me to to push the results back somehow? If so, I'd just need some instruction on how to merge my changes in so I don't clobber the Sliverlight code. I can add the 8.1 project easily enough (renamed as WindowsPhone81) but I had to touch a scattering of code and I'm not sure how to best make that work side-by-side with Silverlight. Use #if & the SILVERLIGHT define?

I've never actually contributed to an existing github project, so I apologize in advance -- I'm not sure what the protocol or procedure is.

Thanks!

TrackEvent exchange parameters action and category

AutoMeasurement.Client.TrackEvent has parameters TrackEvent(string action, string category, .... But the Google Analytics shows the category first, then the action. More convenient would be to exchaneg these parameters TrackEvent(string category, string action, ...

MeasurementAnalyticsClient.AdjustUriBeforeRequest cuts strings with special chars

Sent strings are malformed in the MeasurementAnalyticsClient.AdjustUriBeforeRequest method, when a string contains chars = or &.

E.g. sending

AutoMeasurement.Client.TrackEvent("My Action", "My Custom Category", "My Label id=345");

results in sending label="My Label id" only.

I've solved problem either by using UriFormat.UriEscaped, or fix GetQueryParameters method by q.Split(new char[] {'='}, 2). (Just one of this fix solved problem.)

Note: Such Uri construction, parsing and again construction is often source of problems. (My experience from several other applications.) Better to avoid it. Just construct the right Uri once and send it.

Google analytics application properties do not show data

Hi,
I'm trying to use your library for a windows 8 app I'm developing.
I followed your instructions and integrated CSharpAnalytics to my project. I can now see get requests going to google analytics (using fiddler) and also see your Debug Info on my output window when debugging.
Everything seams to be working but unfortunately I can't see any data on Google analytics dashboard.
Am I doing something wrong?

WPF support

Do you support WPF? I was looking at the .NET4.5 project, but could not figure out how to use it in a WPF app.

GetEntryAssembly vs GetExecutingAssembly

Hello,

When I'm invoking your lib from a com-visible dll the GetEntryAssembly() is always null and the app crashes do think it is safe to use GetExecutingAssembly() instead?

Thank you

Exception

Exception: System.UnauthorizedAccessException
Message: Access to the path 'C:\Users\jcameron\AppData\Roaming\MangoApps\CSharpAnalytics-MeasurementSession' is denied.
Stack:
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync)
at CSharpAnalytics.Serializers.AppDataContractSerializer.d__71.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at CSharpAnalytics.WinFormAutoMeasurement.<Save>d__31.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at CSharpAnalytics.BaseAutoMeasurement.d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.b__0(Object state) < Less

Make internal classes public

Please, make internal classes in CSharpAnalytics.Environment and CSharpAnalytics.Serializers public, so they may be reused when writing custom AutoMeasurement.

Unhandled Exception

I've seen #43, and I'm using v.1.2.1 via NuGet.
I have multiple machines which get this issue (shown below).
I'm not sure what's causing it, but I simply CANNOT manage to catch the exception! It's always an unhandled exception.
Any suggestions how to handle the exception?

`System.Xml.XmlException: There are multiple root elements. Line 1, position 2.
at System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader, String res, String arg1, String arg2, String arg3)
at System.Xml.XmlBaseReader.EnterScope()
at System.Xml.XmlUTF8TextReader.ReadStartElement()
at System.Xml.XmlUTF8TextReader.Read()
at System.Xml.XmlBaseReader.ReadEndElement()
at System.Runtime.Serialization.XmlReaderDelegator.ReadEndElement()
at System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)
at System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader)
at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, Type declaredType, DataContract& dataContract)
at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, DataContract dataContract, String name, String ns)
at System.Runtime.Serialization.DataContractSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)

System.Runtime.Serialization.SerializationException: There was an error deserializing the object of type CSharpAnalytics.Sessions.SessionState. There are multiple root elements. Line 1, position 2.
at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
at System.Runtime.Serialization.XmlObjectSerializer.ReadObject(XmlDictionaryReader reader)
at System.Runtime.Serialization.XmlObjectSerializer.ReadObject(Stream stream)
at CSharpAnalytics.Serializers.AppDataContractSerializer.d__01.MoveNext() at End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at CSharpAnalytics.WinFormAutoMeasurement.<Load>d__01.MoveNext()
at End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at CSharpAnalytics.BaseAutoMeasurement.d__0.MoveNext()
at End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.b__6_1(Object state)
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()`

Allow to use GA debug URL

Allow to use URL https://www.google-analytics.com/debug/collect or any custom URL to send the requests.

Add a flag AutoMeasurement.Initialized

I am using AutoMeasurement class from a non-gui library and it need to know, if the AutoMeasurement is initialized or not. (AutoMeasurement.Instance throws an exception.) Some flag like

public static bool Initialized
{
    get { return _instance != null; }
}

Build break because of requestUri.ShouldUsePostForRequest()

There is a build break because of ShouldUsePostForRequest in master with no definition. See:

a/Source/CSharpAnalytics/Network/HttpWebRequester.cs:

     internal static HttpWebRequest CreateRequest(Uri requestUri, bool writePostBody = true)
     {
             return requestUri.ShouldUsePostForRequest()
                   ? CreatePostRequest(requestUri, writePostBody)
                  : CreateGetRequest(requestUri);
     }

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.