Closed strizzwald closed 1 year ago
You can achieve it by providing the corresponding value with MixpanelConfig
:
var mc = new MixpanelClient("xxx", new MixpanelConfig
{
DataResidencyHandling = MixpanelDataResidencyHandling.EU
});
Or alternatively by setting it globally:
MixpanelConfig.Global.DataResidencyHandling = MixpanelDataResidencyHandling.EU;
Thanks
I'm experiencing another issue where tracking events while a user is still anonymous does not send the distinct_id
, even though the mixpanel cookie is set.
Project: .NET Core MVC with Razor Pages Framework: .NET 6.0 mixpanel-csharp: 5.0.0
public async Task OnGetAsync(string returnUrl = null)
{
await base.OnGetAsync();
var mixPanelCookie = HttpContext.Request.Cookies
.Where(x => x.Key.EndsWith("_mixpanel", StringComparison.OrdinalIgnoreCase))
.Select(x => x.Value)
.FirstOrDefault();
var mixPanelDistinctId = JsonConvert.DeserializeObject<dynamic>(mixPanelCookie).distinct_id;
var success = await _mixpanelClient.TrackAsync(KnownMixpanelEvent.ViewLoginPage, new Dictionary<string, object>
{
{ MixpanelProperty.DistinctId, mixPanelDistinctId },
{ MixpanelProperty.Token, _mixpanelProjectToken },
{ MixpanelProperty.Ip, Request.GetIpAddress() }
});
}
Initially, I tracked the event without setting distinct_id
. I thought the library would read the _mixpanel
cookie before sending the event to Mixpanel.
This is what that's logged to Mixpanel looks like
Both the IP Address and distinct_id are not being logged. Please advise on where I could be going wrong.
Thanks
My guess would be that the types of DistinctId and Ip are different from what Mixpanel C# supports. You can see the parsing logic in DistinctIdParser and IpParser.
Most likely just calling ToString
method on you variables before passing them to TrackAsync
should solve your problems.
You should also consider configuring the error logging
Another approach is to call TrackTest
method which will return all the details f building a message including the possible errors. It is very handy to use while debugging.
Thanks again @eealeivan calling ToString
helped. The distinct_id
I was attempting to use was of type dynamic
👍
Mixpanel APIs support two domains, api.mixpanel.com and api-eu.mixpanel.com. The EU domain is used to store event data in Mixpanel's EU data center.
https://help.mixpanel.com/hc/en-us/articles/360039135652-Data-Residency-in-EU
I'm unable to configure the
mixpanel-csharp
library to send events using the EU domain