Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hello bros,
i need to track user activity in the way of: date + ip + url + some other data. Becaose of datamining (yes we are using Google Analytics, but we need to do more custom tasks).
Question: Which event i should use? I found EndRequest and LogRequest these events handles every request (including images, api calls etc.). Regarding to this thread it is becaose of local IIS http://forums.asp.net/t/1027556.aspx?HttpModule+s+BeginRequest+event
Example for logged urls:
/umbraco/RestServices/ScheduledPublish/Index /Docs/image.jpg /umbraco/ping.aspx ...all request made by browser (around 40 for one page load )
So i need to do stuff like this to get rid of this mess:
if (!url.EndsWith(".js") && !url.EndsWith(".css") && !url.EndsWith(".jpg") && ...etc... !url.EndsWith(".aspx") && !url.Contains("_browserLink")) { UserLogService.AddActivity(GetIPAddress(), url); }
But isnt there any better way? Any other event i should use or better way to filter request?
Becaose there will be long list of stuff tu exclude from log. What about performance? I know these operations for filtering are fast, but still...
Thank you for your ideas and hints. M.
Hello, if someone need my solution - im using this code:
var url = Current.Request.Url.LocalPath.ToString(); if (!url.EndsWith(".js") && !url.EndsWith(".css") && !url.EndsWith(".jpg") && !url.EndsWith(".png") && !url.EndsWith(".ttf") && !url.EndsWith(".woff") && !url.EndsWith(".svg") && !url.EndsWith(".aspx") && !url.EndsWith(".html") && !url.EndsWith(".ashx") && !url.EndsWith(".axd") && !url.Contains("app_plugins") && !url.Contains("App_Plugins") && !url.Contains("umbraco") && !url.Contains("_browserLink")) { UserLogService.AddActivity(IPAddresHelper.GetIPAddress(), url); }
But where are you pasting this code?
Hello, Im using this code in ApplicationEventHandler as follows:
public class EventLogUser : ApplicationEventHandler { private Stopwatch stopwatch;
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) { UmbracoApplicationBase.ApplicationInit += UmbracoApplicationBase_ApplicationInit; } /// <summary> /// Bind to the events of the HttpApplication /// </summary> void UmbracoApplicationBase_ApplicationInit(object sender, EventArgs e) { var app = (HttpApplication)sender; //Good for performance tests //app.EndRequest += umbracoApplication_EndRequest; app.BeginRequest += app_BeginRequest; app.PostAuthorizeRequest += umbracoApplication_EndRequest; } void app_BeginRequest(object sender, EventArgs e) { stopwatch = new Stopwatch(); stopwatch.Start(); } void umbracoApplication_EndRequest(object sender, EventArgs e) { var url = HttpContext.Current.Request.Url.LocalPath.ToString(); if (!url.EndsWith(".js") && !url.EndsWith(".css") && !url.EndsWith(".jpg") && !url.EndsWith(".ico") && !url.EndsWith(".png") && !url.EndsWith(".ttf") && !url.EndsWith(".woff") && !url.EndsWith(".svg") && !url.EndsWith(".aspx") && !url.EndsWith(".html") && !url.EndsWith(".ashx") && !url.EndsWith(".axd") && !url.Contains("app_plugins") && !url.Contains("App_Plugins") && !url.Contains("bundles") && !url.Contains("umbraco") && !url.Contains("_browserLink")) { stopwatch.Stop(); UserLogService.AddActivity(IPAddresHelper.GetIPAddress(), url, stopwatch.ElapsedMilliseconds,""); } } }
Hope this helps you. M.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
User tracking - filter events
Hello bros,
i need to track user activity in the way of: date + ip + url + some other data. Becaose of datamining (yes we are using Google Analytics, but we need to do more custom tasks).
Question: Which event i should use? I found EndRequest and LogRequest these events handles every request (including images, api calls etc.). Regarding to this thread it is becaose of local IIS http://forums.asp.net/t/1027556.aspx?HttpModule+s+BeginRequest+event
Example for logged urls:
So i need to do stuff like this to get rid of this mess:
But isnt there any better way? Any other event i should use or better way to filter request?
Becaose there will be long list of stuff tu exclude from log. What about performance? I know these operations for filtering are fast, but still...
Thank you for your ideas and hints. M.
Hello, if someone need my solution - im using this code:
But where are you pasting this code?
Hello, Im using this code in ApplicationEventHandler as follows:
public class EventLogUser : ApplicationEventHandler { private Stopwatch stopwatch;
Hope this helps you. M.
is working on a reply...