コード例 #1
0
        public async Task <HttpResponseMessage> TrackAsync(string Event)
        {
            JObject joProperties = new JObject();

            joProperties.Add(MPReservedNames.TrackToken, APIToken);
            var MixPanelEvent = new MixPanelBaseRequestEvent <JObject>(Event, joProperties);

            return(await EndPointClient.SendData(MixPanelEvent, MixPanelType.track));
        }
コード例 #2
0
        public async Task <HttpResponseMessage> TrackAsync(string Event, object Properties)
        {
            JObject joProperties = new JObject();

            joProperties = ReflectionPropertyAdder(joProperties, Properties);
            joProperties.Add(MPReservedNames.TrackToken, APIToken);

            joProperties.Add(MPReservedNames.TrackDistinctId, joProperties.GetValue(nameof(MPSet.DistinctId)));
            joProperties.Remove(nameof(MPSet.DistinctId));

            var MixPanelEvent = new MixPanelBaseRequestEvent <JObject>(Event, joProperties);

            return(await EndPointClient.SendData(MixPanelEvent, MixPanelType.track));
        }
コード例 #3
0
        public async Task <HttpResponseMessage> TrackAsync <E, T>(E Event, T Properties) where E : class where T : class
        {
            DataInputCleaning.validateOnlyPrimitiveTypes <E>();
            DataInputCleaning.validateNoPrimitiveTypes <T>();

            JObject joProperties = JObject.FromObject(Properties);

            joProperties = ReflectionPropertyAdder(joProperties, Properties);

            joProperties.Add(MPReservedNames.TrackToken, APIToken);
            joProperties.Add(MPReservedNames.TrackDistinctId, joProperties.GetValue(nameof(MPSet.DistinctId)));
            joProperties.Remove(nameof(MPSet.DistinctId));

            var MixPanelEvent = new MixPanelBaseRequestEvent <JObject>(Event.ToString(), joProperties);

            return(await EndPointClient.SendData(MixPanelEvent, MixPanelType.track));
        }
コード例 #4
0
        internal async Task <HttpResponseMessage> BaseOperation <T>(string OperationName, T Properties) where T : class
        {
            ValidatePremises <T>();
            JObject joProperties = AssignUserIdentity();

            try
            {
                joProperties.Add(OperationName, JToken.FromObject(new Dictionary <object, object>()));
                var     tmpSet       = joProperties.GetValue(OperationName);
                JObject tmpSetValues = JObject.FromObject(Properties);
                tmpSet.Replace(tmpSetValues);
            }
            catch (Exception e)
            {
                throw new Exception("Operation " + OperationName + " not defined. :" + e.Message);
            }
            return(await EndPointClient.SendData(joProperties, MixPanelType.engage));
        }
コード例 #5
0
        public async Task <HttpResponseMessage> TrackAsync <T>(string Event, T Properties) where T : IBaseUserTrackingRequest
        {
            DataInputCleaning.validateNoPrimitiveTypes <T>(); //T cannot be Struct types
            HttpResponseMessage result       = new HttpResponseMessage();
            JObject             joProperties = JObject.FromObject(Properties);

            if (Properties != null)
            {
                joProperties = ReflectionPropertyAdder(joProperties, Properties);
                joProperties.Add(MPReservedNames.TrackToken, APIToken);
                joProperties.Add(MPReservedNames.TrackDistinctId, joProperties.GetValue(nameof(MPSet.DistinctId)));
                joProperties.Remove(nameof(MPSet.DistinctId));
                var MixPanelEvent = new MixPanelBaseRequestEvent <JObject>(Event, joProperties);
                result = await EndPointClient.SendData(MixPanelEvent, MixPanelType.track);
            }
            else
            {
                result = await TrackAsync(Event);
            }
            return(result);
        }