public override void Process(CreateVisitArgs args)
        {
            string ip = new IPAddress(Sitecore.Analytics.Tracker.Current.Interaction.Ip).ToString();
            var ipQueryString = args.Request.QueryString["ip"].ToString(); ///Get Query String IP value
            if (ip != "0.0.0.0" && ip != "127.0.0.1" && string.IsNullOrEmpty(ipQueryString))
            {
                return;
            }
            IPAddress address;
            if (IPAddress.TryParse(ipQueryString, out address))
            {
                args.Interaction.Ip = address.GetAddressBytes();
                var whoIsInfo = Sitecore.CES.GeoIp.Core.Lookups.LookupManager.GetWhoIsInformationByIp(ip);
                var result = Sitecore.Analytics.Lookups.GeoIpManager.GetGeoIpData(new Sitecore.Analytics.Lookups.GeoIpOptions() { Ip = address });
                //args.Interaction.SetGeoData(new Sitecore.Analytics.Model.WhoIsInformation()
                //{
                //    AreaCode = whoIsInfo.AreaCode,
                //    BusinessName = whoIsInfo.BusinessName,
                //    Country = whoIsInfo.Country,
                //    City = whoIsInfo.City,
                //    Dns = whoIsInfo.Dns,
                //    Isp = whoIsInfo.Isp,
                //    Latitude = whoIsInfo.Latitude,
                //    Longitude = whoIsInfo.Longitude,
                //    Region = whoIsInfo.Region,
                //    MetroCode = whoIsInfo.MetroCode,
                //    PostalCode = whoIsInfo.PostalCode
                //});
                args.Interaction.SetGeoData(result.GeoIpData);


                args.Interaction.UpdateLocationReference();
            }
        }
예제 #2
0
        public override void Process(CreateVisitArgs args)
        {
            Log.Debug("Entry ParseGoogleAdWordsParameters->Process");

            //Guard clauses
            Assert.ArgumentNotNull(args, "args");
            Assert.ArgumentNotNull(args.Request, "args.Request");
            Assert.ArgumentNotNull(args.Interaction, "args.Interaction");
            Log.Debug("args" + args.ToString());

            //Get the current URL
            var url = args.Request.Url;

            Log.Debug("Uri = " + url.ToString());

            //Get current Interaction
            var currentInteraction = args.Interaction;

            Log.Debug("currentInteraction = " + currentInteraction.ToString());

            ParseGoogleAdWordsParametersPipeline.Run(new ParseGoogleAdWordsParametersArgs()
            {
                Url         = url,
                Interaction = currentInteraction
            });

            Log.Debug("Exit ParseGoogleAdWordsParameters->Process");
        }
 public override void Process(CreateVisitArgs args)
 {
     try
     {
         Assert.ArgumentNotNull(args, "args");
         this.Parse(args.Request, args.Visit);
     }
     catch (Exception exp)
     {
         Log.Error("Traffic generator parse referrer pipeline: " + exp.InnerException, this);
     }
 }
예제 #4
0
        private static string GetClientIp(CreateVisitArgs args)
        {
            var clientIp = args.Session.Interaction.Ip[0] + "."
                           + args.Session.Interaction.Ip[1] + "."
                           + args.Session.Interaction.Ip[2] + "."
                           + args.Session.Interaction.Ip[3];

            if (args.Request.Params["Spoof"] != null)
            {
                clientIp = args.Request.Params["Spoof"];
            }
            return(clientIp);
        }
        public override void Process(CreateVisitArgs args)
        {
            if (args.Request.Params["geoip"] != null)
            {
                var geoip     = args.Request.Params["geoip"];
                var ipAddress = IPAddress.Parse(geoip);
                args.Interaction.Ip = ipAddress.GetAddressBytes();
            }

            if (args.Request.Params["identifier"] != null)
            {
                var identifier = args.Request.Params["identifier"];
                args.Session.Identify(identifier);
            }
        }
        public override void Process(CreateVisitArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

            var intSetting = Settings.GetIntSetting("HTML5.Geolocation.Timeout", 120);

            var html5GeolocationSuccess = GeoIpHelper.UpdateGeoIpFromCookie(args.Interaction);;

            if (!html5GeolocationSuccess)
            {
                //We can fallback to other methods of geolocation if it failed.
                Log.Info("Analytics - HTML5 geolocation is not allowed by user. Falling back to IP lookup.", this);
                args.Interaction.UpdateGeoIpData(TimeSpan.FromSeconds(intSetting));
            }
        }
예제 #7
0
        public override void Process(CreateVisitArgs args)
        {
            //var companyService = DependencyResolver.Current.GetService<ICompanyService>();

            Assert.ArgumentNotNull(args, "args");
            Assert.IsNotNull(args.Session, "args.Session is null");
            Assert.IsNotNull(args.Session.Contact, "args.Session.Contact is null");
            Assert.IsNotNull(_companyService, "Company service can not be null");

            // convert the IP from the tracker
            var clientIp = GetClientIp(args);

            Log.Debug("KickFire: ====== Starting Kickfire for " + clientIp + "======", "KickFire");
            Log.Debug("KickFire: GEOIP Country IS : " + Tracker.Current.Session.Interaction.GeoData.Country, "KickFire");

            // make the call
            try
            {
                // check to see if we only want USA to keep the API hits down
                if (!ShouldProcessNonUsa())
                {
                    Log.Debug("KickFire: Not USA, kicking out", "KickFire");
                    return;
                }

                var companyModel = GetKickfireModel(clientIp);

                // Make sure our request is good.
                if (IsRequestValid(companyModel))
                {
                    ProcessValidRequest(companyModel, clientIp);

                    // fire the goals
                    //ProcessGoals(companyModel);
                }
                else
                {
                    ProcessInvalidRequest(companyModel, clientIp);
                }
            }
            catch (Exception ex)
            {
                Log.Error($"KickFire: KickFire Error {ex.Message}", ex, this);
            }
        }
        private VisitorDataSet.VisitsRow CreateVisit(HttpContext httpContext, Visitor visitor)
        {
            VisitorDataSet.VisitsRow currentVisit = visitor.CurrentVisit;
            if (currentVisit == null)
            {
                currentVisit = visitor.CreateVisit(visitor.CookieVisitId);
            }
            currentVisit.AspNetSessionId = WebUtil.GetSessionID();

            HttpRequest request = httpContext.Request;
            byte[] ip = this.GetIp(httpContext);

            string browser = request.Browser.Browser;
            string version = request.Browser.Version;
            string browserVersion = request.Browser.Version;
            string platform = request.Browser.Platform;
            string minorName = string.Empty;
            string operatingSystem = string.Empty;

            currentVisit.Ip = ip;
            currentVisit.Browser = visitor.DataContext.GetBrowser(browser, version, browserVersion);
            currentVisit.UserAgent = visitor.DataContext.GetUserAgent(request.UserAgent ?? string.Empty);
            currentVisit.GeoIp = visitor.DataContext.GetGeoIp(ip);

            var spoofedUserHostName = QueryStringHelper.SessionIPAsString;
            if( !String.IsNullOrEmpty(spoofedUserHostName) )
                currentVisit.RDNS = spoofedUserHostName;
            else
                currentVisit.RDNS = request.UserHostName ?? string.Empty;

            currentVisit.OperatingSystem = visitor.DataContext.GetOperatingSystem(platform, minorName, operatingSystem);
            currentVisit.Screen = visitor.DataContext.GetScreen(this.GetDimensions(request));

            SiteContext site = Context.Site;
            if (site != null)
            {
                currentVisit.MultiSite = site.Name;
            }

            CreateVisitArgs args = new CreateVisitArgs(currentVisit, request);
            CreateVisitPipeline.Run(args);
            return currentVisit;
        }
        public override void Process(CreateVisitArgs args)
        {
            var companyService = DependencyResolver.Current.GetService <ICompanyService>();

            Assert.ArgumentNotNull(args, "args");
            Assert.IsNotNull(args.Session, "args.Session is null");
            Assert.IsNotNull(args.Session.Contact, "args.Session.Contact is null");
            Assert.IsNotNull(companyService, "Company service can not be null");

            // convert the IP from the tracker
            var clientIp = args.Session.Interaction.Ip[0] + "."
                           + args.Session.Interaction.Ip[1] + "."
                           + args.Session.Interaction.Ip[2] + "."
                           + args.Session.Interaction.Ip[3];

            if (args.Request.Params["Spoof"] != null)
            {
                clientIp = args.Request.Params["Spoof"];
            }

            //if (clientIp.StartsWith("127"))
            //    clientIp = "23.0.59.195";

            Log.Info("KickFire: ====== Starting Kickfire for " + clientIp + "======", "KickFire");

            Log.Info("KickFire: GEOIP Country IS : " + Tracker.Current.Session.Interaction.GeoData.Country, "KickFire");

            // make the call
            try
            {
                // check to see if we only want USA to keep the API hits down
                if (AnalyticsConfigurationHelper.OnlyUsa() &&
                    (Tracker.Current.Session.Interaction.GeoData.Country != "United States" &&
                     Tracker.Current.Session.Interaction.GeoData.Country != "US"))
                {
                    Log.Info("KickFire: Not USA, kicking out", "KickFire");
                    return;
                }

                var model = companyService.GetRootObject(clientIp);

                // Make sure our request is good.
                if (model != null &&
                    model.status == "success" &&
                    model.data.Count > 0
                    &&
                    (!AnalyticsConfigurationHelper.SkipIsp() ||
                     (AnalyticsConfigurationHelper.SkipIsp() && model.data[0].isISP == 0)))
                {
                    // add company data to xDB
                    AddCompanyData(model);

                    // add company information node
                    AddCompanyInformation(model);

                    // add the page event
                    //Helpers.Events.PageEvent.RegisterCompanyEvent(model.data[0].name);

                    Log.Info("KickFire: Logged for " + clientIp, "KickFire");

                    var processSicCode = false;
                    bool.TryParse(Sitecore.Configuration.Settings.GetSetting("Bonfire.Kickfire.ProcessSicCode"), out processSicCode);

                    if (processSicCode)
                    {
                        ProcessSicCode(clientIp, model);
                    }

                    // lets kick off the Engagement Plan
                }
                else
                {
                    if (model == null)
                    {
                        Log.Info("KickFire: Model null. IP is " + clientIp, this);
                    }

                    else
                    {
                        if (model.status != "success")
                        {
                            Log.Info("KickFire: Model capture not successful. IP is " + clientIp, "KickFire");
                        }

                        if (model?.data?.Count == 0 && model.data == null)
                        {
                            Log.Info("KickFire: No data records. IP is " + clientIp, "KickFire");
                        }

                        if (model?.data != null && model?.data[0].isISP != 0)
                        {
                            Log.Info("KickFire: Is ISP, skipped. IP is " + clientIp, "KickFire");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error("KickFire: KickFire Error" + ex.Message, ex);
            }
        }