Esempio n. 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();
        }
Esempio n. 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;
        }
Esempio n. 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;
        }
Esempio n. 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;
        }
Esempio n. 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;
        }
 /// <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;
 }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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;
 }
Esempio n. 14
0
 static MixpanelConfig()
 {
     Global = new MixpanelConfig();
 }
Esempio n. 15
0
 public static bool AsyncHttpPostFnSet(MixpanelConfig config)
 {
     return
         (MixpanelConfig.Global.AsyncHttpPostFn != null ||
          (config != null && config.AsyncHttpPostFn != null));
 }
Esempio n. 16
0
 public static bool SerializeJsonFnSet(MixpanelConfig config)
 {
     return
         (MixpanelConfig.Global.SerializeJsonFn != null ||
          (config != null && config.SerializeJsonFn != null));
 }
Esempio n. 17
0
 static MixpanelConfig()
 {
     Global = new MixpanelConfig();
 }
Esempio n. 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;
 }
Esempio n. 19
0
 public static bool SerializeJsonFnSet(MixpanelConfig config)
 {
     return
         MixpanelConfig.Global.SerializeJsonFn != null ||
         (config != null && config.SerializeJsonFn != null);
 }
Esempio n. 20
0
 public static bool HttpPostFnSet(MixpanelConfig config)
 {
     return
         MixpanelConfig.Global.HttpPostFn != null ||
         (config != null && config.HttpPostFn != null);
 }
Esempio n. 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;
 }