eealeivan/mixpanel-csharp

Tracking returns false

Closed this issue · 8 comments

I've tried your simple use case just to test, and it fails to track. Everything seems to be setup fine, and the track event is called - however it returns false.

I've also added a local and a global error logging function to just print the failures to the console, but it doesn't print anything.

var conf = new MixpanelConfig() {
    ErrorLogFn = (msg, ex) => {
        Console.WriteLine("ERROR!");
        Console.WriteLine(ex.Message);
        Console.WriteLine(msg);
    },
    SerializeJsonFn = JsonConvert.SerializeObject
};

mc = new MixpanelClient(<token>, conf);

MixpanelConfig.Global.SerializeJsonFn = JsonConvert.SerializeObject;
MixpanelConfig.Global.ErrorLogFn = (message, exception) => {
    Console.WriteLine("ERROR!");
    Console.WriteLine(message);
};

When I then call Track it just returns false.

var ret = mc.Track(evt.ToString(), new
{
    Time = new DateTime(2013, 9, 26, 22, 33, 44, DateTimeKind.Utc)
});

Console.WriteLine("ret: " + ret);

Am I doing something wrong?

When looking in the log for Android I can see the following:

[Mono] Assembly Loader probing location: '/storage/emulated/0/Android/data/<packagename>/files/.__override__/Mixpanel.dll'.
[Mono] Image addref Mixpanel[0xe4fe0a20] -> /storage/emulated/0/Android/data/<packagename>/files/.__override__/Mixpanel.dll[0xe1f5be00]: 2
[Mono] Prepared to set up assembly 'Mixpanel' (/storage/emulated/0/Android/data/<packagename>/files/.__override__/Mixpanel.dll)
[Mono] Assembly Mixpanel[0xe4fe0a20] added to domain RootDomain, ref_count=1
[Mono] AOT: image '/storage/emulated/0/Android/data/<packagename>/files/.__override__/Mixpanel.dll.so' not found: dlopen failed: library "/data/app/<packagename>-1/lib/arm/libaot-Mixpanel.dll.so" not found
[Mono] AOT: image '/usr/local/lib/mono/aot-cache/arm/Mixpanel.dll.so' not found: dlopen failed: library "/data/app/<packagename>-1/lib/arm/libaot-Mixpanel.dll.so" not found
[Mono] Assembly Loader loaded assembly from location: '/storage/emulated/0/Android/data/<packagename>/files/.__override__/Mixpanel.dll'.
[Mono] Config attempting to parse: '/storage/emulated/0/Android/data/<packagename>/files/.__override__/Mixpanel.dll.config'.
[Mono] Config attempting to parse: '/usr/local/etc/mono/assemblies/Mixpanel/Mixpanel.config'.

It says it can't find the dll, is that expected?

Hi,

Can you provide more details about your environment so I can reproduce the error?

Thanks for replying.

I'm using Xamarin.Forms (2.5.0) on Android, iOS and UWP. Using both VS for mac and VS pro.

Anything else you're interested in?

garie commented

Mixpanel discards events that are more than 5 days old (reference). You need to set the event's time to a more recent date. It might be a good idea to change the example to use DateTime.Now, though, because I did the same thing at first.

@garie That's embarrassing, I should've picked up on that too. Thanks.

I removed date from code sample for now.

Hi,

I could not found the information about 5 days.
Here says it can be any date within last 5 years, instead:

Time: A unix epoch style timestamp in UTC that tells Mixpanel when the event fired. This can be any time in the last 5 years.

It works with date in curl, but returns false in TrackAsync method.

curl --request POST \
     --url 'https://api.mixpanel.com/import?strict=1&project_id=<ID>' \
     --header 'Accept: application/json' \
     --header 'Authorization: Basic <AUTH>' \
     --header 'Content-Type: application/json' \
     --data '
[
     {
        "event": "pagamento_efetuado",
        "properties": {
            "distinct_id": "cbfabfc8-ddde-44b1-9dff-829b109b9d61",
            "time": 1613990024,
            "token": "<TOKEN>",
            "$insert_id": "123456",
            "plano": "PRO",
            "valor": 400.00,
            "primeiro_pagamento": false
        }
    }
]'

Could you help me please?

Sorry, the reference link from @garie was old.
Here is the new reference about 5 days limitation of /track endpoint: https://developer.mixpanel.com/reference/track-event

Could I workaround to user /import endpoint instead?

Thanks!