1
0
mirror of https://git.teknik.io/Teknikode/Teknik.git synced 2023-08-02 14:16:22 +02:00

Fixed title and language/plugins for tracking.

This commit is contained in:
Uncled1023 2016-05-26 14:40:36 -07:00
parent e95f2cf101
commit 3f497b3de1
2 changed files with 17 additions and 11 deletions

View File

@ -21,11 +21,9 @@ namespace Teknik.Filters
public override void OnActionExecuted(ActionExecutedContext filterContext)
{
string title = string.Empty;
Page page = filterContext.HttpContext.Handler as Page;
if (page != null)
if (filterContext.Controller.ViewBag != null)
{
title = page.Title;
title = filterContext.Controller.ViewBag.Title;
}
HttpRequestBase request = filterContext.HttpContext.Request;
// Fire and forget. Don't need to wait for it.

View File

@ -31,20 +31,28 @@ namespace Teknik.Helpers
PiwikTracker.URL = config.PiwikConfig.Url;
PiwikTracker tracker = new PiwikTracker(config.PiwikConfig.SiteId);
tracker.setUserAgent(request.UserAgent);
tracker.setResolution(request.Browser.ScreenPixelsWidth, request.Browser.ScreenPixelsHeight);
tracker.setBrowserHasCookies(request.Browser.Cookies);
// Get Request Info
string ipAddress = request.ClientIPFromRequest(true);
tracker.setIp(ipAddress);
tracker.setTokenAuth(config.PiwikConfig.TokenAuth);
tracker.setUrl(request.Url.ToString());
tracker.setUserAgent(request.UserAgent);
// Get browser info
tracker.setResolution(request.Browser.ScreenPixelsWidth, request.Browser.ScreenPixelsHeight);
tracker.setBrowserHasCookies(request.Browser.Cookies);
if (!string.IsNullOrEmpty(request.Headers["Accept-Language"]))
tracker.setBrowserLanguage(request.Headers["Accept-Language"]);
BrowserPlugins plugins = new BrowserPlugins();
plugins.java = request.Browser.JavaApplets;
tracker.setPlugins(plugins);
// Get Referral
if (request.UrlReferrer != null)
tracker.setUrlReferrer(request.UrlReferrer.ToString());
// Send the tracking request
tracker.setRequestTimeout(15);
tracker.doTrackPageView(string.Format("{0}/{1}", sub, title));
}