diff --git a/src/Mixpanel/Mixpanel/MessageBuilders/Track/TrackMessageBuilder.cs b/src/Mixpanel/Mixpanel/MessageBuilders/Track/TrackMessageBuilder.cs index dbcb852..f08491a 100644 --- a/src/Mixpanel/Mixpanel/MessageBuilders/Track/TrackMessageBuilder.cs +++ b/src/Mixpanel/Mixpanel/MessageBuilders/Track/TrackMessageBuilder.cs @@ -71,7 +71,17 @@ public static MessageBuildResult Build( string formattedPropertyName = pair.Key; ObjectProperty objectProperty = pair.Value; - ValueParseResult result = GenericPropertyParser.Parse(objectProperty.Value, allowCollections: true); + ValueParseResult result; + + if (config.CustomPropertiesParser != null) + { + result = config.CustomPropertiesParser(objectProperty.Value, true); + } + else + { + result = GenericPropertyParser.Parse(objectProperty.Value, allowCollections: true); + } + if (!result.Success) { continue; diff --git a/src/Mixpanel/Mixpanel/MixpanelConfig.cs b/src/Mixpanel/Mixpanel/MixpanelConfig.cs index e49b9b4..fa0b29f 100644 --- a/src/Mixpanel/Mixpanel/MixpanelConfig.cs +++ b/src/Mixpanel/Mixpanel/MixpanelConfig.cs @@ -1,4 +1,5 @@ -using System; +using Mixpanel.Parsers; +using System; using System.Threading; using System.Threading.Tasks; @@ -49,6 +50,11 @@ public class MixpanelConfig /// public static MixpanelConfig Global { get; } + /// + /// With this property you can create your own Parser to handle custom properties. + /// + public Func CustomPropertiesParser { get; set; } + static MixpanelConfig() { Global = new MixpanelConfig(); diff --git a/src/Mixpanel/Mixpanel/Parsers/ValueParseResult.cs b/src/Mixpanel/Mixpanel/Parsers/ValueParseResult.cs index 4a74024..61e5182 100644 --- a/src/Mixpanel/Mixpanel/Parsers/ValueParseResult.cs +++ b/src/Mixpanel/Mixpanel/Parsers/ValueParseResult.cs @@ -1,6 +1,6 @@ namespace Mixpanel.Parsers { - internal sealed class ValueParseResult + public sealed class ValueParseResult { public bool Success { get; } public object Value { get; }