Exemple #1
0
        /// <summary>
        /// Track event.
        /// </summary>
        public void TrackEvent(EventData eventitem)
        {
            eventitem.SetToken(Token);
            string queryString = $"data={eventitem.ToBase64()}";

            if (IsOpenIP)
            {
                queryString += "&i=1";
            }
            if (NetworkTool.IsNetworkAvailable)
            {
                var task = httpService.SendRequest(CommonDefine.TRACK_URI, queryString);
            }
            else
            {
                TempEventCollection.Add(eventitem);
            }
        }
Exemple #2
0
        /// <summary>
        /// Save cache Track events.
        /// </summary>
        /// <returns></returns>
        public async Task <bool> SaveMixpanelTempData()
        {
            EventDataCollection collectionItem = null;
            var tempJson = await ReadFile();

            if (!string.IsNullOrEmpty(tempJson))
            {
                collectionItem = JsonConvert.DeserializeObject <EventDataCollection>(tempJson);
            }
            if (collectionItem == null)
            {
                collectionItem = new EventDataCollection();
            }
            collectionItem.Collection.AddRange(TempEventCollection);
            TempEventCollection.Clear();
            string newJson = JsonConvert.SerializeObject(collectionItem);

            await WriteFile(newJson);

            return(true);
        }