Exemple #1
0
 public override Task SendHit(HitAbstract hit)
 {
     return(Task.Factory.StartNew(() =>
     {
         Log("SendHit");
     }));
 }
Exemple #2
0
        protected HitAbstract GetHitFromContent(JObject content)
        {
            HitAbstract hit = null;

            switch (content["Type"].ToObject <HitType>())
            {
            case HitType.EVENT:
                hit = content.ToObject <Event>();
                break;

            case HitType.ITEM:
                hit = content.ToObject <Item>();
                break;

            case HitType.PAGEVIEW:
                hit = content.ToObject <Page>();
                break;

            case HitType.SCREENVIEW:
                hit = content.ToObject <Screen>();
                break;

            case HitType.TRANSACTION:
                hit = content.ToObject <Transaction>();
                break;
            }

            return(hit);
        }
Exemple #3
0
        public override async Task SendHit(HitAbstract hit)
        {
            const string functionName = "SendHit";

            try
            {
                if (hit == null)
                {
                    Log.LogError(Config, Constants.HIT_NOT_NULL, functionName);
                    return;
                }

                hit.VisitorId   = Visitor.VisitorId;
                hit.DS          = Constants.SDK_APP;
                hit.Config      = Config;
                hit.AnonymousId = Visitor.AnonymousId;

                if (!hit.IsReady())
                {
                    Log.LogError(Config, hit.GetErrorMessage(), functionName);
                    return;
                }

                await TrackingManager.SendHit(hit);
            }
            catch (Exception ex)
            {
                Visitor.GetStrategy().CacheHit(hit);
                Log.LogError(Config, ex.Message, functionName);
            }
        }
Exemple #4
0
        public async Task SendHit(HitAbstract hit)
        {
            var requestMessage = new HttpRequestMessage(HttpMethod.Post, Constants.HIT_API_URL);
            var postDatajson   = JsonConvert.SerializeObject(hit.ToApiKeys());

            var stringContent = new StringContent(postDatajson, Encoding.UTF8, Constants.HEADER_APPLICATION_JSON);

            requestMessage.Content = stringContent;

            await HttpClient.SendAsync(requestMessage);
        }
Exemple #5
0
        public virtual async void CacheHit(HitAbstract hit)
        {
            try
            {
                var hitCacheInstance = Config?.HitCacheImplementation;
                if (hitCacheInstance == null || Config.DisableCache)
                {
                    return;
                }

                var hitDataString = BuildHitCacheData(hit, (HitCacheType)hit.Type);

                await hitCacheInstance.CacheHit(Visitor.VisitorId, hitDataString);
            }
            catch (Exception ex)
            {
                Logger.Log.LogError(Config, ex.Message, "CacheHit");
            }
        }
Exemple #6
0
 public override void CacheHit(HitAbstract hit)
 {
     //
 }
Exemple #7
0
 public override Task SendHit(HitAbstract hit)
 {
     return(GetStrategy().SendHit(hit));
 }
Exemple #8
0
 abstract public Task SendHit(HitAbstract hit);