コード例 #1
0
        /// <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();
        }
コード例 #2
0
        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;
        }
コード例 #3
0
        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;
        }
コード例 #4
0
        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;
        }
コード例 #5
0
        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;
        }
コード例 #6
0
 /// <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;
 }
コード例 #7
0
        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);
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        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);
        }
コード例 #10
0
        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);
        }
コード例 #11
0
        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);
        }
コード例 #12
0
        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);
        }
コード例 #13
0
 /// <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;
 }
コード例 #14
0
 static MixpanelConfig()
 {
     Global = new MixpanelConfig();
 }
コード例 #15
0
 public static bool AsyncHttpPostFnSet(MixpanelConfig config)
 {
     return
         (MixpanelConfig.Global.AsyncHttpPostFn != null ||
          (config != null && config.AsyncHttpPostFn != null));
 }
コード例 #16
0
 public static bool SerializeJsonFnSet(MixpanelConfig config)
 {
     return
         (MixpanelConfig.Global.SerializeJsonFn != null ||
          (config != null && config.SerializeJsonFn != null));
 }
コード例 #17
0
 static MixpanelConfig()
 {
     Global = new MixpanelConfig();
 }
コード例 #18
0
 /// <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;
 }
コード例 #19
0
 public static bool SerializeJsonFnSet(MixpanelConfig config)
 {
     return
         MixpanelConfig.Global.SerializeJsonFn != null ||
         (config != null && config.SerializeJsonFn != null);
 }
コード例 #20
0
 public static bool HttpPostFnSet(MixpanelConfig config)
 {
     return
         MixpanelConfig.Global.HttpPostFn != null ||
         (config != null && config.HttpPostFn != null);
 }
コード例 #21
0
 /// <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;
 }