Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lists always serialized to empty arrays #37

Open
jfrueh opened this issue Mar 24, 2023 · 3 comments
Open

Lists always serialized to empty arrays #37

jfrueh opened this issue Mar 24, 2023 · 3 comments

Comments

@jfrueh
Copy link

jfrueh commented Mar 24, 2023

Thanks for the great library! I'm running into an issue with tracking events that have List properties. The message being sent to Mixpanel always contains an empty array after serialization (this happens whether I use the built in serializer or a different one).

Here is a really quick repro:

// Create a simple test event class:
public class TestEvent
{
    public List Items { get; set; }
    public class Item
    {
        public string Id { get; set; }
    }
}

// now just send the event (which is just a list of objects)
var client = new MixpanelClient("your_token");
var data = new TestEvent
{
    Items = new List {
        new TestEvent.Item { Id = "1" },
        new TestEvent.Item { Id = "2" },
        new TestEvent.Item { Id = "3" }
    }
};

var message = client.GetTrackMessage("test", data);

I would expect message to have a property called 'Items' that has a Count of 3. It has the Items property but it's an empty array (Count 0).

Any ideas what I'm doing wrong? I feel like this has to be a really common use case to send a list and that I'm just missing something.

Thanks for the help.

@eealeivan
Copy link
Owner

Current version of the library doesn't support complex objects as a list item. It will ignore anything else than: string, bool, char, number (int, double etc), Guid, DateTime, DateTimeOffset or TimeSpan.

So with your example if all you need is the list of ids I would suggest to convert Items to List<string>.

@cyh0530
Copy link

cyh0530 commented Jan 19, 2024

Is there a plan to support complex objects? It will be greatly appreciated! 😃

@bgp1
Copy link

bgp1 commented Jun 7, 2024

I am also interested in knowing if this will be supported in the future. This is a pretty critical thing to support for ecommerce tracking to be able to include specific item purchase data.

Spec on Mixpanel itself on the topic: https://docs.mixpanel.com/docs/features/advanced#use-cases-1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants