eealeivan / mixpanel-csharp

Mixpanel C# integration library
MIT License
63 stars 15 forks source link

Is the library capable of supporting .NET MAUI mobile apps? #40

Closed kyurkchyan closed 1 year ago

kyurkchyan commented 1 year ago

I have two main questions.

  1. Are there any known usages of this library in .NET MAUI or Xamarin forms apps? Is the library tested in mobile scenarios?
  2. Can the library cache the items and send them in batches? This feature is essential for two reasons a) Conserving battery life as a single batched HTTP call is more efficient than dozens of individual calls b) Caching the messages locally when the app is offline and sending them back when the app becomes online
eealeivan commented 1 year ago

Hi,

  1. mixpanel-csharp supports .NET Standard 2.0 so latest vesrsions of .NET MAUI or Xamarin Forms should be able to use it.
  2. Yes, this is possible. The details are described in documentation. The main idea is that you can create message objects and send them later. Important note is that it is your responsibility to save and keep the messages.
var mc = new MixpanelClient("e3bc4100330c35722740fb8c6f5abddc");

// Get message but not send it yet (token will be in the message)
MixpanelMessage msg = mc.GetTrackMessage("Level Complete", new 
{ 
    DistinctId = "12345",
    LevelNumber = 5,
    Duration = TimeSpan.FromMinutes(1)
});

await mc.SendAsync(msg);
kyurkchyan commented 1 year ago

Hey @eealeivan thanks for getting back. I hoped that the SDK would handle the storage, as it's the case with native iOS/Android SDKs. I will try to share my storage/queueing implementation after it works properly for our app. Perhaps, we could include that implementation in the library.