Example #1
0
        public async Task <IActionResult> PostUserInfo([FromBody] UserInfoRequest request)
        {
            var info = new PageViewInfo(request);
            await _userStore.StoreInfo(info);

            return(Ok());
        }
        public void LogPageView(PageViewInfo info)
        {
            User          user          = _getCurrentUser.Get();
            var           site          = _session.Get <Site>(_site.Id);
            DateTime      now           = CurrentRequestData.Now;
            AnalyticsUser analyticsUser = GetCurrentUser(user == null ? info.User : user.Guid);
            bool          userIsNew     = analyticsUser == null;

            if (userIsNew)
            {
                analyticsUser = new AnalyticsUser
                {
                    User      = user,
                    CreatedOn = now,
                    UpdatedOn = now,
                };
                analyticsUser.SetGuid(info.User);
                _session.Insert(analyticsUser);
            }
            AnalyticsSession analyticsSession = GetCurrentSession(info.Session);
            bool             sessionIsNew     = analyticsSession == null;

            if (sessionIsNew)
            {
                analyticsSession = new AnalyticsSession
                {
                    AnalyticsUser = analyticsUser,
                    IP            = _request.GetCurrentIP(),
                    UserAgent     = _request.UserAgent,
                    Site          = site,
                    CreatedOn     = now,
                    UpdatedOn     = now,
                };
                analyticsSession.SetGuid(info.Session);
                _session.Insert(analyticsSession);
            }

            var pageView = new AnalyticsPageView
            {
                Webpage          = GetWebpage(info.Url),
                Url              = info.Url,
                AnalyticsSession = analyticsSession,
                Site             = site,
                CreatedOn        = now,
                UpdatedOn        = now,
            };

            _session.Insert(pageView);
        }
Example #3
0
        public Task StoreInfo(PageViewInfo info)
        {
            var exists = _cache.TryGetValue(info.UserId, out List <PageViewInfo> entry);

            if (exists)
            {
                _cache[info.UserId].Add(info);
            }
            else
            {
                _cache.Add(info.UserId, new List <PageViewInfo> {
                    info
                });
            }
            return(Task.CompletedTask);
        }
Example #4
0
        public void LogPageView(PageViewInfo info)
        {
            User          user          = _getCurrentUser.Get();
            var           site          = _session.Get <Site>(_site.Id);
            DateTime      now           = CurrentRequestData.Now;
            AnalyticsUser analyticsUser = GetUser(user == null ? info.User : user.Guid);
            bool          userIsNew     = analyticsUser == null;

            if (userIsNew)
            {
                analyticsUser = new AnalyticsUser
                {
                    User      = user,
                    CreatedOn = now,
                    UpdatedOn = now,
                };
                analyticsUser.SetGuid(info.User);
                _session.Insert(analyticsUser);
            }

            if (analyticsUser.RequiresEmailCheck && _getEmailFromRequest.CanCheck)
            {
                CheckEmail(analyticsUser, now);
            }

            AnalyticsSession analyticsSession = GetCurrentSession(info.Session);
            bool             sessionIsNew     = analyticsSession == null;
            var changedResult = _context.AnalyticsUserGuidHasChanged();

            if (sessionIsNew)
            {
                analyticsSession = new AnalyticsSession
                {
                    AnalyticsUser = analyticsUser,
                    IP            = _context.GetCurrentIP(),
                    UserAgent     = _context.Request.UserAgent,
                    Site          = site,
                    CreatedOn     = now,
                    UpdatedOn     = now,
                };
                analyticsSession.SetGuid(info.Session);
                _session.Insert(analyticsSession);
            }
            // only move it if it's going to a live user
            else if (changedResult.Changed && analyticsUser.User != null)
            {
                UpdateOldUsersSessions(changedResult, analyticsSession, analyticsUser);
            }

            var pageView = new AnalyticsPageView
            {
                Webpage          = GetWebpage(info.Url),
                Url              = info.Url,
                AnalyticsSession = analyticsSession,
                Site             = site,
                CreatedOn        = now,
                UpdatedOn        = now,
            };

            _session.Insert(pageView);
        }
Example #5
0
 public JsonResult LogPageView(PageViewInfo info)
 {
     _logPageViewService.LogPageView(info);
     return(Json(true));
 }
Example #6
0
 public async Task StoreInfo(PageViewInfo info)
 {
     await _session.ExecuteAsync(_insertStatement.Bind(info.UserId, info.TimeStamp, info.PageName));
 }