private static MessageBuildResult Build( string operation, string token, IEnumerable <ObjectProperty> superProperties, object rawProperties, object distinctId, MixpanelConfig config) { MessageCandidate messageCandidate = PeopleMessageBuilderBase.CreateValidMessageCandidate( token, superProperties, rawProperties, distinctId, config, out string messageCandidateErrorMessage); if (messageCandidate == null) { return(MessageBuildResult.CreateFail(messageCandidateErrorMessage)); } var message = new Dictionary <string, object>(); var set = new Dictionary <string, object>(); message[operation] = set; // Special properties PeopleMessageBuilderBase.RunForValidSpecialProperties( messageCandidate, (specialPropertyName, isMessageSpecialProperty, value) => { if (isMessageSpecialProperty) { message[specialPropertyName] = value; } else { set[specialPropertyName] = value; } }); // User properties PeopleMessageBuilderBase.RunForValidUserProperties( messageCandidate, rawValue => GenericPropertyParser.Parse(rawValue, allowCollections: true), (formattedPropertyName, value) => { set[formattedPropertyName] = value; }); return(MessageBuildResult.CreateSuccess(message)); }
// Message example: // { // "$token": "36ada5b10da39a1347559321baf13063", // "$distinct_id": "13793", // "$unset": [ "Days Overdue" ] // } public static MessageBuildResult Build( string token, IEnumerable <ObjectProperty> superProperties, IEnumerable <string> propertyNames, object distinctId, MixpanelConfig config) { MessageCandidate messageCandidate = PeopleMessageBuilderBase.CreateValidMessageCandidate( token, superProperties, null, distinctId, config, out string messageCandidateErrorMessage); if (messageCandidate == null) { return(MessageBuildResult.CreateFail(messageCandidateErrorMessage)); } var message = new Dictionary <string, object>(); // Special properties PeopleMessageBuilderBase.RunForValidSpecialProperties( messageCandidate, (specialPropertyName, isMessageSpecialProperty, value) => { // Ignore non-message specific special properties as they are not valid in profile update messages if (isMessageSpecialProperty) { message[specialPropertyName] = value; } }); message["$unset"] = propertyNames ?? new string[0]; return(MessageBuildResult.CreateSuccess(message)); }