Giter Site home page Giter Site logo

segmentio / analytics.net Goto Github PK

View Code? Open in Web Editor NEW
107.0 44.0 60.0 900 KB

The hassle-free way to integrate analytics into any C# / .NET application.

Home Page: https://segment.io/libraries/.net

License: MIT License

C# 99.55% Makefile 0.05% Shell 0.26% PowerShell 0.13%

analytics.net's Introduction

Analytics.NET

Analytics.NET is a .NET / C# / F# client for Segment.

⚠️ Community ⚠️

This library is community supported. Segment does not manage or update this library. We suggest forking the repo if changes are needed for your project.

We highly recommend using our upgraded Analytics-CSharp to benefit from feature enhancements and ongoing support.

You can't fix what you can't measure

Analytics helps you measure your users, product, and business. It unlocks insights into your app's funnel, core business metrics, and whether you have product-market fit.

How to get started

  1. Collect analytics data from your app(s).
    • The top 200 Segment companies collect data from 5+ source types (web, mobile, server, CRM, etc.).
  2. Send the data to analytics tools (for example, Google Analytics, Amplitude, Mixpanel).
    • Over 250+ Segment companies send data to eight categories of destinations such as analytics tools, warehouses, email marketing and remarketing systems, session recording, and more.
  3. Explore your data by creating metrics (for example, new signups, retention cohorts, and revenue generation).
    • The best Segment companies use retention cohorts to measure product market fit. Netflix has 70% paid retention after 12 months, 30% after 7 years.

Segment collects analytics data and allows you to send it to more than 250 apps (such as Google Analytics, Mixpanel, Optimizely, Facebook Ads, Slack, Sentry) just by flipping a switch. You only need one Segment code snippet, and you can turn integrations on and off at will, with no additional code. Sign up with Segment today.

Why?

  1. Power all your analytics apps with the same data. Instead of writing code to integrate all of your tools individually, send data to Segment, once.

  2. Install tracking for the last time. We're the last integration you'll ever need to write. You only need to instrument Segment once. Reduce all of your tracking code and advertising tags into a single set of API calls.

  3. Send data from anywhere. Send Segment data from any device, and we'll transform and send it on to any tool.

  4. Query your data in SQL. Slice, dice, and analyze your data in detail with Segment SQL. We'll transform and load your customer behavioral data directly from your apps into Amazon Redshift, Google BigQuery, or Postgres. Save weeks of engineering time by not having to invent your own data warehouse and ETL pipeline.

    For example, you can capture data on any app:

    analytics.track('Order Completed', { price: 99.84 })

    Then, query the resulting data in SQL:

    select * from app.order_completed
    order by price desc

🚀 Startup Program

If you are part of a new startup (<$5M raised, <2 years since founding), we just launched a new startup program for you. You can get a Segment Team plan (up to $25,000 value in Segment credits) for free up to 2 years — apply here!

Documentation

Documentation is available at https://segment.com/libraries/.net.

analytics.net's People

Contributors

alanjcharles avatar b-dur avatar bitdeli-chef avatar brennan avatar cgalan-applaudostudios avatar dailycoding avatar daletskyi avatar dependabot[bot] avatar didiergarcia avatar dmitry-me avatar edsonjab avatar f2prateek avatar hatton avatar ianstormtaylor avatar imedoc2023 avatar jdconley avatar juliette-ruchel avatar julietteruchel avatar jzebedee avatar lubird avatar nd4p90x avatar nhi-nguyen avatar pooyaj avatar reinpk avatar rmiranda-applaudostudios avatar spewu avatar squid-box avatar steroberts89 avatar suvjunmd avatar wenxi-zeng 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  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

analytics.net's Issues

Timestamp is parsed wrongly if set

We experienced some events created on Thursday Sep. 3'rd that they where timestamped as March 9'th.

The error is due to bad formatted datetime sent by BaseAction.cs

If Timestamp is set it will send the data as Timestamp.ToString() instead of .ToString("o") as when it has not been set.

if (options.Timestamp.HasValue)
                this.Timestamp = options.Timestamp.ToString ();
            else
                this.Timestamp = DateTime.Now.ToString("o");

https://github.com/segmentio/Analytics.NET/blob/master/Analytics/Model/BaseAction.cs#L39

Inverted logic for "send"

I mus admit that having send=false that means "don't don't send the data to segment = send the data to segment" is pretty confusing.

Please make it simple to understand send=false should mean "do not send". The default parameter should therefore by send=true.

image

3.0.0 nuget package still targeting .Net 3.5 framework

Hey, thanks for posting a new version on nuget!

I have been trying to use this package for a netcore1.0 library and the only way I currently can do it is to clone this repo and pull the Analytics project directly into my solution. For build to production sake, I'd like to pull in the nuget package instead.

When I try to reference the 3.0.0 nuget package, it throws this error:

Restoring packages for xxx.csproj...
  GET http://nuget/nuget/FindPackagesById()?id='Analytics'
  GET https://api.nuget.org/v3-flatcontainer/analytics/index.json
  OK http://nuget/nuget/FindPackagesById()?id='Analytics' 6ms
  OK https://api.nuget.org/v3-flatcontainer/analytics/index.json 284ms
  GET https://api.nuget.org/v3-flatcontainer/analytics/3.0.0/analytics.3.0.0.nupkg
  OK https://api.nuget.org/v3-flatcontainer/analytics/3.0.0/analytics.3.0.0.nupkg 193ms
Installing Analytics 3.0.0.
Package Analytics 3.0.0 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package Analytics 3.0.0 supports: net (.NETFramework,Version=v0.0)
Package restore failed. Rolling back package changes for 'xxx'.
Time Elapsed: 00:00:01.0880009

It appears the project config/csproj file is correct at targeting the netstandard1.3, but the nuspec file needs to be updated to allow for the newer frameworks to be targeted.

Making flushing thread a background thread.

Hi,
My company is using your library in a console that we run as a nightly job. Today I noticed that the background job no longer shuts down properly. After running NewRelic's thread profiler in production I noticed that thread that was still running:

System.Threading.ThreadHelper:ThreadStart
System.Threading.ExecutionContext:Run
System.Threading.ExecutionContext:Run
System.Threading.ExecutionContext:RunInternal
System.Threading.ThreadHelper:ThreadStart_Context
Segmentio.Flush.AsyncFlushHandler:Loop
Segmentio.Flush.BlockingQueue`1:Dequeue
System.Threading.Monitor:Wait
System.Threading.Monitor:Wait

I'm guessing that this thread is not running with IsBackground set to true? http://msdn.microsoft.com/en-us/library/system.threading.thread.isbackground(v=vs.110).aspx

I'd very much appreciate if you would change that. Thanks!

Tracking events that occur when no network connection is available are discarded

In testing Segment Analytics on mobile devices under Xamarin, I've noticed any events that occur while the device is offline are discarded. It appears the event queue is being flushed even if the events fail to send to segment.io.

[Analytics] [DEBUG] Dequeued action in async loop. message id: d0fe64a7-7715-465a-bf4a-08f8189dba3d, queue size: 0,
[Analytics] [DEBUG] Created flush batch. batch size: 1,
[Analytics] [INFO] Sending analytics request to Segment.io .. batch id: f552873c-7656-485c-83e9-f79c22c15809, json size: 513, batch size: 1,
[Analytics] [DEBUG] Enqueued action in queue. queue size: 0,
[Analytics] [INFO] Segment.io request failed. batch id: f552873c-7656-485c-83e9-f79c22c15809, reason: Error: ConnectFailure (Network is unreachable), duration (ms): 0,
[Analytics] [DEBUG] Queue is empty, flushing is finished.

In a server environment this might not be a big deal but on mobile devices which frequently lose connection it seems a more robust queuing strategy is needed. Other analytics libraries I've used such as Xamarin Insights and Google Analytics have this capability.

Context properties are not being transmitted

Using the 19 August head (9912dc4). (But this didn't work with the 1.1. version released on nuget either.)

Given:
Segmentio.Analytics.Client.Identify("100", new Traits() { {"firstName", "Vincent"}, {"lastName", "Vangogh"}, {"email", "[email protected]"} }, new Context().SetIp("71.198.218.39"));

Then in BlockingRequestHandler.cs, line 30:

string json = JsonConvert.SerializeObject(batch, settings);

json lack the contents of the context we just set:

{
    "secret": "--------",
    "batch": [{
        "action": "identify",
        "userId": "100",
        "traits": {
            "firstName": "Vincent",
            "lastName": "Vangogh",
            "email": "[email protected]"
        },
        "timestamp": null,
        "context": {}    <----------------
    }],
    "context": {
        "library": "analytics-.NET"
    }
}

At this point in the code, the "batch" has 2 Context objects: The one that is a direct property of "batch" has this library property, and makes it out to the json. However the other one, the one inside which has the Identify has the IP, Language, and Providers, does not make it out into the json, and is not transmitted to segmentio.

The cause is a well-known (disputed) bug in json.net: http://json.codeplex.com/workitem/23769.

Inconsistent capitalization for "anonymousId" in error message

class Client has a number of public methods and they all verify userId. Most of them use this line to signal the userId is invalid:

  throw new InvalidOperationException("Please supply a valid userId or anonymousId to SOMETHING.");

here anonymousId is spelled in camelCase. But Group() uses this string:

  throw new InvalidOperationException("Please supply a valid userId or anonymousID to call #Group.");

here anonymousID is spelled with ID rather than with Id as in other methods. This serves no good purpose, this is simply a typo.

Publish non-alpha Package v2

Its been a couple of months-ish since clfetchers original question so I thought I'd ask again. Those of us that really need .net standard support would really like to see a non-alpha library for Segment up on Nuget, is this something you could see happening in the near future?

I can see some quite sensible PRs from daletskyi that are waiting for approval still. Perhaps we could at least have a 3.4.0 alpha library on nuget with those fixes in?

Segment stops responding

Hi,

We have an ASP.NET Core server running on Azure with analytics.NET 3.3.0-alpha, and it's configured to send user events to Segment using Analytics.Client.Track(). It's initialized using this line:

Analytics.Initialize(
    apiKey,
    new Config().setAsync(true).SetTimeout(100).SetMaxQueueSize(10000));

After a while (around 1h or so) segment stops confirming the reception of the tracked events. There are no new entries in the debug panel, meaning they don't arrive to Segment. It all starts working when we republish the app, probably because the program restarts.

For instance, this is the last event that was successfully sent a couple of days ago:

2018-07-03 07:53:42,915 36 INFO  Analytics - Segment.io request successful.
  batch id: c5a1b751-c683-430b-b31d-5c30bb0eacf0
  duration (ms): 87
2018-07-03 07:53:42,916 5 DEBUG Analytics - Queue is empty, flushing is finished.
2018-07-03 07:53:43,738 59 DEBUG Analytics - Blocking flush waiting until the queue if fully empty ..
2018-07-03 07:53:43,739 59 DEBUG Analytics - Blocking flush completed. 
2018-07-03 07:53:55,741 59 DEBUG Analytics - Enqueued action in queue.
  queue size: 1
2018-07-03 07:53:55,741 5 DEBUG Analytics - Dequeued action in async loop.
  message id: 4766d95e-d101-4215-a935-ca942e955559
  queue size: 0
2018-07-03 07:53:55,742 5 DEBUG Analytics - Created flush batch.
  batch size: 1
2018-07-03 07:53:55,743 59 DEBUG Analytics - Enqueued action in queue.
  queue size: 1

After that, no matter what we do, segment says "sending request" but never says "request successful" again:

2018-07-03 07:53:55,743 5 INFO  Analytics - Sending analytics request to Segment.io ..
  batch id: cd65ad4c-6ea3-43c9-b030-22205ac7a7a2
  json size: 448
  batch size: 1

Could this be related to #83 ? We also contacted Segment support, so I'll update this issue when we have more details.

Thanks!
Miguel

Identify call without userId?

We use some integrations that take advantage of identify calls without user id's (Drip, Salesforce). These work fine in Analytics.js, but this .NET client throws an InvalidOperationException if you attempt to call Identify without the userId parameter. Is there some way to mimic the behavior in Analytics.JS so we can call this before we have a User Id in our system?

Publish non-alpha Package

Is it possible to publish a non-alpha version of the Nuget package? We're getting build warnings because were dependant on an alpha version of your package. Unfortunately 3.0 (the last non alpha version) is not suitable for us because we need the newer .net standard support.
If it helps we've been using the package along with over 12,000 other people without issue: https://www.nuget.org/packages/Analytics/

Thanks

Incompatible with the Universal Windows Platform

Developing a Windows 10 Phone App, using the Universal Windows Platform and installing with NuGet results in this error:

"Install-Package : Analytics 2.0.2 is not compatible with UAP,Version=v10.0."

add convenience method for context.traits?

a customer was asking about it earlier, would make the interface for adding traits a bit nicer.

would solve this kind of thing:

Analytics.Client.Track("hj2kf92ds212", "ate a bagel",
  new Context() {
    { "traits", new Props() {
        {  "email", "[email protected]" }
      }
    }
  }
});

Events lost before reaching the segment servers

When using Analytics.NET version 3.4.2-beta, I found out thta a few analytics events per hour are not successfully sent to the segment servers. To troubleshoot this, I configured the Segment.Client.Failed callback:

private void LogFailure(SegmentSdk.Model.BaseAction action, Exception e)
{
    _logger.LogError(e, $"Failed to send analytic event {action.Type} for user {action.UserId} to segment.io server");
}

myClient.Failed += LogFailure;

With this in-place, I now see this error log pop-up a few times per hour. Here's what the error looks like this (The response ended prematurely):

Failed to send analytic event track for user c08cb1fb-f963-4238-b075-570f08a88892 to segment.io server
System.Net.Http.HttpRequestException: An error occurred while sending the request.
 ---> System.IO.IOException: The response ended prematurely.
   at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.SendWithNtConnectionAuthAsync(HttpConnection connection, HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
   at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.DiagnosticsHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
   at Segment.Request.BlockingRequestHandler.MakeRequest(Batch batch)

From what I can see, the events are then completely lost. The consequence of this are pretty bad for us:

  • we do an Identify to set a few traits on the user.
  • these traits are then used by the customer.io destination to send some promotional messages and communications
  • since some events are lost, it means that customer.io sends the wrong communications to a few of our users

Chameleon is also used to create some on-boarding flows. Since the traits are not always sent correctly, it means that some users see the wrong on-boarding flows.

After looking at the Analytics.NET code, I can see that all unexpected exceptions are not retried:

Fail(batch, e, watch.ElapsedMilliseconds);

So my question is:

  • would it be possible for you to retry exceptions like this?

This would clearly help in having more accurate analytics.

Regards,
Maxime

Mismatched Dependency

Ticket Ref:

https://segment.zendesk.com/agent/tickets/33879

You have mismatch in your nuget package dependencies declaration and what the real dependency your dll uses 
Here you from source 
<Reference Include="Newtonsoft.Json"> 
<HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net35\Newtonsoft.Json.dll</HintPath> 
</Reference 
Here is you package dependency 
<dependencies> 
<group targetFramework=".NETFramework3.5"> 
<dependency id="Newtonsoft.Json" version="4.5.11" /> 
</group> 
</dependencies>

Support through a proxy?

I'm trying to see how I could update my .NET server-to-server code to send the Segment Identify and Track requests through a proxy.

We're moving to a more secure environment that requires outbound calls from the API server to pass through a proxy. Thank you for the info; we love Segment!

Ryan

Events not sent to Segment servers: "Unexpected Status Code"

In order to get the fix for #156, I used version 3.6.0 of Analytics.Net. Unfortunately, I still get some errors that tell me that messages are lost.

First, here's what my Failed callback looks like:

private void Initialize()
{
    // ...
    client = new SegmentSdk.Client(...);
    client.Failed += LogFailure;
    // ...
}

private void LogFailure(SegmentSdk.Model.BaseAction action, Exception e)
{
    string details = null;
    if (e != null)
    {
        details = e.Message;

        if (e is SegmentSdk.Exception.APIException apiException)
        {
            details = $"Code={apiException.Code}, message={apiException.message}, Message={apiException.Message}";
        }
    }

    _logger.LogError(LoggingEvents.SegmentFailure, e, $"Failed to send analytic event {action.Type} for user {action.UserId} and message {action.MessageId} to segment.io server. Details: {details}");
}

With this, I got these error logs:


timestamp | "json.message"
-- | --
2021-03-12 02:02:53.419 -05:00 | Failed to send analytic event   track for user e0f68aac-7b92-4703-85d3-d967354a5f0a and message   7559433d-46fb-435a-9c50-3bc550cf1e9b to segment.io server. Details:   Code=Unexpected Status Code, message=, Message=     Segment.Exception.APIException
2021-03-12 02:02:53.338 -05:00 | Failed to send analytic event   identify for user e0f68aac-7b92-4703-85d3-d967354a5f0a and message   25935a15-91e1-4fc9-8e0c-ccadaac0fe30 to segment.io server. Details:   Code=Unexpected Status Code, message=, Message=     Segment.Exception.APIException
2021-03-12 02:02:53.256 -05:00 | Failed to send analytic event   track for user e0f68aac-7b92-4703-85d3-d967354a5f0a and message   a1ab9ca6-a4fc-4231-b635-7df0ca46a9a7 to segment.io server. Details:   Code=Unexpected Status Code, message=, Message=     Segment.Exception.APIException
2021-03-12 02:02:53.172 -05:00 | Failed to send analytic event   identify for user e0f68aac-7b92-4703-85d3-d967354a5f0a and message   4c28eca2-5f10-4918-bec3-713b40db1160 to segment.io server. Details:   Code=Unexpected Status Code, message=, Message=     Segment.Exception.APIException
2021-03-12 00:22:59.675 -05:00 | Failed to send analytic event   track for user 9ef95e43-c067-46f0-be51-d1587824095a and message   8417e505-4dad-4f58-af94-deda74882d30 to segment.io server. Details:   Code=Unexpected Status Code, message=, Message=     Segment.Exception.APIException
2021-03-12 00:22:59.672 -05:00 | Failed to send analytic event   identify for user 9ef95e43-c067-46f0-be51-d1587824095a and message   097f39e5-dd64-4b9f-8ed9-daec648471be to segment.io server. Details:   Code=Unexpected Status Code, message=, Message=     Segment.Exception.APIException
2021-03-11 22:24:33.093 -05:00 | Failed to send analytic event   track for user eb845629-2532-4a27-8786-8c37b8413c7a and message   bf41100a-72b0-4769-adc0-db659de47522 to segment.io server. Details:   Code=Unexpected Status Code, message=, Message=     Segment.Exception.APIException
2021-03-11 22:24:33.091 -05:00 | Failed to send analytic event   identify for user eb845629-2532-4a27-8786-8c37b8413c7a and message   f0052abf-1627-41fd-824b-df59ef6a674c to segment.io server. Details:   Code=Unexpected Status Code, message=, Message=     Segment.Exception.APIException

These errors come from this code:
image

On top of fixing the issue, I highly suggest a few code improvements:

  1. get rid of the message property in APIException. It is a duplicate of the Message property in the base class.
  2. enhance your APIException class so that the value of Code ends up diplayed by ToString(). Here's an example of how to do it:
public class APIException : System.Exception
{
    public string Code { get; set; }

    public APIException(string code, string message) : base($"{code}: {message}")
    {
        this.Code = code;
    }
}
  1. enhance the users of the APIException to include more details. For examples, here's the critical piece of code that should be enhanced:
if (_backo.HasReachedMax || statusCode != (int)HttpStatusCode.OK)
{
    var message = $"has reached max = {_backo.HasReachedMax}, statusCode = {statusCode}, response={responseStr}";
    Fail(batch, new APIException("Failed to send message", message), watch.ElapsedMilliseconds);
    if (_backo.HasReachedMax)
    {
        _backo.Reset();
    }
}
  1. Make sure that responseStr is initialized in all error scenarios (including the missing else):

image

  1. Consider calling Logger.Handlers whenever there is a retry in that loop.

Without these changes, we are in the dark and I can't help you with proper logs.

Setting context providers doesn't work

Since a picture is worth a thousand words:

image

I believe I'm doing this by the book, so pretty sure it's not a problem with my code...

The result is that these events (which are only supposed to go to Google Analytics) are ending up in the dashboards for other analytics providers.

Am I doing something stupid here?

Ongoing changes for API v2

https://github.com/segmentio/spec

  • Use HTTP Basic Auth with the project's Write Key.
  • Rename to anonymousId from sessionId for clarity.
  • Separate integrations (was providers) object from context, for cleaner logs.
  • Add requestId for easily tracing calls through to the raw logs.
  • Change library to be a object with name and version for consistency.

Statistics signed integers blindly incremented

Here's the definition of Statistics:

public class Statistics
{
    public int Submitted { get; set; }
    public int Succeeded { get; set; }
    public int Failed { get; set; }
}

All members are signed. The typical line of code dealing with them looks like this:

_client.Statistics.Failed += 1;

If code runs long enough then counters may reach Int32.MaxValue. Depending on whether code runs in checked or unchecked context subsequent behavior varies. If code happens to run in unchecked context then counters overflow and become negative which makes no sense. If code happens to run in checked context then subsequent increments fail with OverflowException.

Counters should be unsigned. Code manipulating them should be explicitly wrapped in unchecked {}.

Catch PostAsync Network exceptions and Retry

The pull request #96 proposes a change to account for Network related exceptions when attempting to send the batches. The current code does not account for the exceptions thrown by the PostAsync method and could result on some batches not being sent in those cases. The pull request proposes a retry if failed approach in order to solve the issue.

.NET documentation on PostAsync : https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient.postasync?view=net-5.0

The #96 is a 2 year old pull request which merging it to our current version of the code will lead to conflicts that will need to be resolved. It's not recommended to do so, since it's logic as well has not evolved as our current versions.

Dropped message because queue is too full

After many years of using Segment, I just realized that we sometimes call the "Identify" or "Track" method and events are lost because of this code (note that we are using version 3.3.1-alpha):

image

So no exceptions are raised. There is only a warning being triggered. Pretty annoying. For me, it's like doing an SQL INSERT where the database answered "success" when in fact it did "well you know, I was too busy. I just dropped your request... without letting you know. Oh yeah, I sent you a letter about it. If you're lucky you will receive it. But note that the letter will not let you know what I dropped exactly. It will just let you know that I was too busy."

What is your suggestion to make sure that no events are lost?

Xamarin support

What's the current state of this library with respect to Xamarin support? Can we test it to see what can be done to make this work? Or does it already support Xamarin after the last few updates?

Add time-based flush test

  1. Perform action
  2. Wait larger than time triggered flush
  3. Perform another action
  4. Check that the flush and successful matches 2

Updating nuget metadata

Two suggestion for improving the nuget metadata in Analytics.csproj.

Replace PackageLicenseFile with <PackageLicenseExpression>MIT</PackageLicenseExpression>
This makes it more visible that the packages is released under the MIT license.

Add

<RepositoryUrl>https://github.com/segmentio/Analytics.NET.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>

This adds a link from nuget.org directly to the github repository.

https://www.nuget.org/packages/Analytics/3.5.0
image

https://www.nuget.org/packages/FluentAssertions/5.10.3
image

Events not sent to Segment servers: "Unexpected Status Code"

In order to get the fix for #156, I used version 3.7.0 of Analytics.Net. Unfortunately, I still get some errors that tell me that messages are lost.

First, here's what my Failed callback looks like:

private void Initialize()
{
    // ...
    client = new SegmentSdk.Client(...);
    client.Failed += LogFailure;
    // ...
}

private void LogFailure(SegmentSdk.Model.BaseAction action, Exception e)
{
    string details = null;
    if (e != null)
    {
        details = e.Message;
    }

    _logger.LogError(LoggingEvents.SegmentFailure, e, $"Failed to send analytic event {action.Type} for user {action.UserId} and message {action.MessageId} to segment.io server. Details: {details}");
}

With this, I got these error logs after a few hours:

Failed to send analytic event track for user 831ba960-a73c-49b7-be6b-771d2233ce2d and message 5c72ec76-0044-407b-8c69-9a8c3edb9aef to segment.io server. Details: Status Code: 0, Message: Has Backoff reached max: True with number of Attempts:8,
 Status Code: 0
, response message: 
Segment.Exception.APIException: Status Code: 0, Message: Has Backoff reached max: True with number of Attempts:8,
 Status Code: 0
, response message: 

Failed to send analytic event identify for user 831ba960-a73c-49b7-be6b-771d2233ce2d and message 2a2d3b52-2b01-4b21-9178-4876f1e725e8 to segment.io server. Details: Status Code: 0, Message: Has Backoff reached max: True with number of Attempts:8,
 Status Code: 0
, response message: 
Segment.Exception.APIException: Status Code: 0, Message: Has Backoff reached max: True with number of Attempts:8,
 Status Code: 0
, response message: 

Is there anything that I could do to help you troubleshoot this?

Can't use non-Segment types for parameters

Currently, consumers of this library have to either use or extend the Dict/Properties/Traits classes in order to call Segment client methods. This adds unnecessary complexity and an explicit dependency on Segment, not to mention violating the I in SOLID. 😛

I'd like to see this changed to only require the dictionary interface (IDictionary<string, object>) for Segment methods instead of the concrete classes. This way, we can pass in custom dictionary objects or just a regular Dictionary without having to derive from a class provided by Segment.

See also:
"Why not inherit from List?"
http://stackoverflow.com/a/21694054/102351

"Is it correct to use inheritance instead of name aliasing in c#?"
http://stackoverflow.com/q/147049/102351

"C#: How to create 'aliases' for classes"
http://stackoverflow.com/q/7082238/102351

Inconsistent phrasing in error messages for public methods of class Client

class Client has a number of methods which accept userId and a second parameter which varies from one method to another. Validation code uses line like this to throw:

 throw new InvalidOperationException("Please supply a valid userId or anonymousId to SOMETHING.");

and

 throw new InvalidOperationException("Please supply a valid PARAMNAME to SOMETHING");

Although only method names should differ the actual wording for SOMETHING is inconsistent.

  1. Group() says to call #Group for both checks.
  2. Track() says to Track - no "call" and no #.
  3. Page() says to #Page - no "call"
  4. Screen() says to #Screen - no "call"

Segment now breaks on reference in CLS-compliant .NET platforms

@f2prateek @Dmitry-Me I think there are some problems with PR #41. Adding the unchecked blocks is unnecessary, but harmless, since the default behavior is to silently overflow:

For non-constant expressions (expressions that are evaluated at run-time) that are not enclosed by any checked or unchecked operators or statements, the default overflow checking context is unchecked unless external factors (such as compiler switches and execution environment configuration) call for checked evaluation.

However, changing the properties from int to uint will break CLS compliance (MSDN), which is a huge deal for a library project. As of this change, any code written in a .NET language that doesn't support uints will break on reference once this goes out.

3.4.1-alpha tag not found

On nuget.org, I see that the latest version of the library is 3.4.1-alpha. Unfortunately, there is no tag in github for this version. It is therefore impossible to look at the code at this exact version:

> git tag --list
2.0.0
2.0.1
2.0.2
2.0.3
3.0.0
3.1.0-alpha
3.2.0-alpha
3.3.0-alpha
3.3.1-alpha
3.4.0-alpha

Using Segment.NET Library on F# Project

An example of Segment.NET library being used on an F# project should be developed in order to understand it can be called perfectly well with its different functions

Writekey displayed in Segment data object

When using 'track' or 'identify', write key is also displayed in the segment event data.
Is there a specific reason for this?
I understand that write key is required to make an authentication token while posting to Segment API endpoint. But it only needs to be in the http-client headers. Or is there something I am missing here?

Why have new versions of Analytics.NET been in alpha for two years?

See here: https://www.nuget.org/packages/Analytics/

Look at version history.

For people using .NET Core (pretty much all new greenfield development) they're going to get warnings like this:

 [NU1701] Package 'Analytics 3.0.0' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.1'. This package may not be fully compatible with your project.

It's been two years, might as well take the alpha off.

Impossible to specify destination specific option

Hi,

The client library is very well made, but it's currently impossible to add destinations specific option.
In my particular case, I want to be able to add or remove a Tag when using the Identify call and Vero destination. In the documentation it says to pass an object called tags in the Vero integration object for example:

analytics.identify('324LKJF', {
    email: '[email protected]'
}, {
    integrations: {
        Vero: {
            tags: {
                id: '235FAG', // This is optional! If not defined, we default to the event's userId (ie: 324LKJF)
                action: 'add',
                values: ['warriors', 'giants', 'niners']
            }
        }
    }
})

But the .NET library only support setting an individual integration to true or false via the SetIntegration("Vero", true) method.

It would be nice to not have to call the HTTP API endpoint in order to succesfully pass the tags.

Thanks

.NET Core / .NET Stard support

It looks like the versions that support .NET Core have been in alpha for more than a year.
Is there any plan to release them as stable versions?

Retroactive events

How do I track events retroactively?

eg. I want to send now an event that happened last week

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.