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

Dictionary properties always serialized to empty arrays #43

Open
TomSendrovich opened this issue Dec 21, 2023 · 1 comment
Open

Dictionary properties always serialized to empty arrays #43

TomSendrovich opened this issue Dec 21, 2023 · 1 comment

Comments

@TomSendrovich
Copy link

Thanks for the great library! I'm running into an issue with tracking events that have Dictionary properties. The message sent to Mixpanel looks fine, but the specific Dictionary<string, object> property always contains an empty array after serialization.

Here is a quick example:

var client = new MixpanelClient("your_token");
Dictionary<string, object> properties = new Dictionary<string, object>();

Dictionary<string, object> Items = new Dictionary<string, object> {
{"property1", 1},
{"property2", 2},
{"property3", 3}};

properties.Add("Custom Property", Items);

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

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

Thanks for the help.

@ulf-melin-sveasolar
Copy link

Does anyone know if this is the way it should work? I tried v 5.1.0 and 6.0.0 with the same result. Dictionary<string, object> properties are not passed into the SerializeJsonFn

MixpanelConfig config = new MixpanelConfig()
{
SerializeJsonFn = MixpanelJsonSerializer.Serialize,
};
MixpanelClient client = new MixpanelClient("wdqwdqwdqwfwgwegwefgw", config);

    Dictionary<string, object> props = new Dictionary<string, object>
    {
        {"WorksNicely", "Hog" },
        {"BecomesEmptyArray", new[] {new Dictionary<string, object> {
            {"Test", "Best" }
        }
        } },
        {"NotHandledAtAll", new { Bos = true} }
    };.

var testMess = client.PeopleSetTest(Guid.NewGuid().ToString(), props);

This is what's in testMess.Json:

{"$set":{"WorksNicely":"Hog","BecomesEmptyArray":[]},"$token":"wdqwdqwdqwfwgwegwefgw","$distinct_id":"8e6b2a37-0e9a-4e15-a5bf-abc76da7ba70"}

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

2 participants