/// <summary> /// Creates an instance of <see cref="MixpanelClient"/>. This constructor is usually used /// when you want to call only 'Send' and 'SendAsync' methods, because in this case /// token is already specified in each <see cref="MixpanelMessage"/>. /// </summary> /// <param name="config"> /// Configuration for this particular client. Set properties from this class will override global properties. /// </param> /// <param name="superProperties"> /// Object with properties that will be attached to every message for the current mixpanel client. /// If some of the properties are not valid mixpanel properties they will be ignored. Check documentation /// on project page https://github.com/eealeivan/mixpanel-csharp for valid property types. /// </param> public MixpanelClient(MixpanelConfig config = null, object superProperties = null) { this.config = config; UtcNow = () => DateTime.UtcNow; // Parse super properties only one time this.superProperties = PropertiesDigger.Get(superProperties, PropertyOrigin.SuperProperty).ToList(); }
public static Func<string, string, bool> GetHttpPostFn(MixpanelConfig config) { if (config != null && config.HttpPostFn != null) return config.HttpPostFn; if (MixpanelConfig.Global.HttpPostFn != null) return MixpanelConfig.Global.HttpPostFn; return new DefaultHttpClient().Post; }
public static Action<string, Exception> GetErrorLogFn(MixpanelConfig config) { if (config != null && config.ErrorLogFn != null) return config.ErrorLogFn; if (MixpanelConfig.Global.ErrorLogFn != null) return MixpanelConfig.Global.ErrorLogFn; return null; }
public static Func<string, string, Task<bool>> GetAsyncHttpPostFn(MixpanelConfig config) { if (config != null && config.AsyncHttpPostFn != null) return config.AsyncHttpPostFn; if (MixpanelConfig.Global.AsyncHttpPostFn != null) return MixpanelConfig.Global.AsyncHttpPostFn; return new DefaultHttpClient().PostAsync; }
public static Func<object, string> GetSerializeJsonFn(MixpanelConfig config) { if (config != null && config.SerializeJsonFn != null) return config.SerializeJsonFn; if (MixpanelConfig.Global.SerializeJsonFn != null) return MixpanelConfig.Global.SerializeJsonFn; return new DefaultJsonSerializer().Serialize; }
/// <summary> /// Creates an instance of <see cref="MixpanelClient"/>. /// </summary> /// <param name="token"> /// The Mixpanel token associated with your project. You can find your Mixpanel token in the /// project settings dialog in the Mixpanel app. Events without a valid token will be ignored.</param> /// <param name="config"> /// Configuration for this particular client. Set properties from this class will override global properties. /// </param> /// <param name="superProperties"> /// Object with properties that will be attached to every message for the current mixpanel client. /// If some of the properties are not valid mixpanel properties they will be ignored. Check documentation /// on project page https://github.com/eealeivan/mixpanel-csharp for valid property types. /// </param> public MixpanelClient(string token, MixpanelConfig config = null, object superProperties = null) { if (token.IsNullOrWhiteSpace()) { throw new ArgumentNullException("token"); } _token = token; _config = config; SetSuperProperties(superProperties); UtcNow = () => DateTime.UtcNow; }
public static Func <object, string> GetSerializeJsonFn(MixpanelConfig config) { if (config != null && config.SerializeJsonFn != null) { return(config.SerializeJsonFn); } if (MixpanelConfig.Global.SerializeJsonFn != null) { return(MixpanelConfig.Global.SerializeJsonFn); } return(new DefaultJsonSerializer().Serialize); }
public static MixpanelPropertyNameFormat GetMixpanelPropertyNameFormat(MixpanelConfig config) { if (config != null && config.MixpanelPropertyNameFormat != null) { return(config.MixpanelPropertyNameFormat.Value); } if (MixpanelConfig.Global.MixpanelPropertyNameFormat != null) { return(MixpanelConfig.Global.MixpanelPropertyNameFormat.Value); } return(MixpanelPropertyNameFormat.None); }
public static Func <string, string, Task <bool> > GetAsyncHttpPostFn(MixpanelConfig config) { if (config != null && config.AsyncHttpPostFn != null) { return(config.AsyncHttpPostFn); } if (MixpanelConfig.Global.AsyncHttpPostFn != null) { return(MixpanelConfig.Global.AsyncHttpPostFn); } return(new DefaultHttpClient().PostAsync); }
public static Action <string, Exception> GetErrorLogFn(MixpanelConfig config) { if (config != null && config.ErrorLogFn != null) { return(config.ErrorLogFn); } if (MixpanelConfig.Global.ErrorLogFn != null) { return(MixpanelConfig.Global.ErrorLogFn); } return(null); }
public static MixpanelIpAddressHandling GetIpAddressHandling(MixpanelConfig config) { if (config != null && config.IpAddressHandling != null) { return(config.IpAddressHandling.Value); } if (MixpanelConfig.Global.IpAddressHandling != null) { return(MixpanelConfig.Global.IpAddressHandling.Value); } return(MixpanelIpAddressHandling.None); }
public static Func <string, string, bool> GetHttpPostFn(MixpanelConfig config) { if (config != null && config.HttpPostFn != null) { return(config.HttpPostFn); } if (MixpanelConfig.Global.HttpPostFn != null) { return(MixpanelConfig.Global.HttpPostFn); } return(new DefaultHttpClient().Post); }
/// <summary> /// Creates an instance of <see cref="MixpanelClient"/>. /// </summary> /// <param name="token"> /// The Mixpanel token associated with your project. You can find your Mixpanel token in the /// project settings dialog in the Mixpanel app. Events without a valid token will be ignored.</param> /// <param name="config"> /// Configuration for this particular client. Set properties from this class will override global properties. /// </param> /// <param name="superProperties"> /// Object with properties that will be attached to every message for the current mixpanel client. /// If some of the properties are not valid mixpanel properties they will be ignored. Check documentation /// on project page https://github.com/eealeivan/mixpanel-csharp for valid property types. /// </param> public MixpanelClient(string token, MixpanelConfig config = null, object superProperties = null) : this(config, superProperties) { this.token = token; }
static MixpanelConfig() { Global = new MixpanelConfig(); }
public static bool AsyncHttpPostFnSet(MixpanelConfig config) { return (MixpanelConfig.Global.AsyncHttpPostFn != null || (config != null && config.AsyncHttpPostFn != null)); }
public static bool SerializeJsonFnSet(MixpanelConfig config) { return (MixpanelConfig.Global.SerializeJsonFn != null || (config != null && config.SerializeJsonFn != null)); }
/// <summary> /// Creates an instance of <see cref="MixpanelClient"/>. /// </summary> /// <param name="token"> /// The Mixpanel token associated with your project. You can find your Mixpanel token in the /// project settings dialog in the Mixpanel app. Events without a valid token will be ignored.</param> /// <param name="config"> /// Configuration for this particular client. Set properties from this class will override global properties. /// </param> /// <param name="superProperties"> /// Object with properties that will be attached to every message for the current mixpanel client. /// If some of the properties are not valid mixpanel properties they will be ignored. Check documentation /// on project page https://github.com/eealeivan/mixpanel-csharp for valid property types. /// </param> public MixpanelClient(string token, MixpanelConfig config = null, object superProperties = null) : this(config, superProperties) { _token = token; }
public static bool SerializeJsonFnSet(MixpanelConfig config) { return MixpanelConfig.Global.SerializeJsonFn != null || (config != null && config.SerializeJsonFn != null); }
public static bool HttpPostFnSet(MixpanelConfig config) { return MixpanelConfig.Global.HttpPostFn != null || (config != null && config.HttpPostFn != null); }
/// <summary> /// Creates an instance of <see cref="MixpanelClient"/>. This constructor is isually used /// when you want to call only 'Send' and 'SendAsync' methods, because in this case /// token is already specified in each <see cref="MixpanelMessage"/>. /// </summary> public MixpanelClient(MixpanelConfig config = null, object superProperties = null) { _config = config; SetSuperProperties(superProperties); UtcNow = () => DateTime.UtcNow; }