mirror of
https://git.teknik.io/Teknikode/Teknik.git
synced 2023-08-02 14:16:22 +02:00
Modified back to use static function for tracking.
Added action tracking function.
This commit is contained in:
parent
26b9284f77
commit
07ae28b7e2
@ -147,7 +147,7 @@ namespace Teknik.Areas.Upload.Controllers
|
||||
Response.AppendHeader("Content-Disposition", cd.ToString());
|
||||
|
||||
// Handle Piwik Tracking if enabled
|
||||
Tracking.TrackPageView(Request, ViewBag.Title, Subdomain);
|
||||
Tracking.TrackAction(Request.UserAgent, Request.Url.ToString());
|
||||
|
||||
return File(data, upload.ContentType);
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ using Teknik.Filters;
|
||||
|
||||
namespace Teknik.Controllers
|
||||
{
|
||||
[TrackingFilter]
|
||||
public class DefaultController : Controller
|
||||
{
|
||||
private Config _config;
|
||||
|
@ -46,6 +46,34 @@ namespace Teknik
|
||||
var stopwatch = new Stopwatch();
|
||||
HttpContext.Current.Items["Stopwatch"] = stopwatch;
|
||||
stopwatch.Start();
|
||||
|
||||
// Handle Piwik Tracking if enabled
|
||||
Config config = Config.Load();
|
||||
if (config.PiwikConfig.Enabled)
|
||||
{
|
||||
try
|
||||
{
|
||||
HttpRequest request = base.Request;
|
||||
|
||||
string sub = request.RequestContext.RouteData.Values["sub"].ToString();
|
||||
if (string.IsNullOrEmpty(sub))
|
||||
{
|
||||
sub = request.Url.AbsoluteUri.GetSubdomain();
|
||||
}
|
||||
string title = config.Title;
|
||||
Page page = HttpContext.Current.Handler as Page;
|
||||
|
||||
if (page != null)
|
||||
{
|
||||
title = page.Title;
|
||||
}
|
||||
Tracking.TrackPageView(new HttpRequestWrapper(request), title, sub);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void Application_EndRequest(object sender, EventArgs e)
|
||||
@ -66,33 +94,6 @@ namespace Teknik
|
||||
{
|
||||
context.Response.AppendHeader("Access-Control-Allow-Origin", origin);
|
||||
}
|
||||
|
||||
//// Handle Piwik Tracking if enabled
|
||||
//Config config = Config.Load();
|
||||
//if (config.PiwikConfig.Enabled)
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// string sub = context.Request.RequestContext.RouteData.Values["sub"].ToString();
|
||||
// if (string.IsNullOrEmpty(sub))
|
||||
// {
|
||||
// sub = context.Request.Url.AbsoluteUri.GetSubdomain();
|
||||
// }
|
||||
// string title = config.Title;
|
||||
// Page page = HttpContext.Current.Handler as Page;
|
||||
|
||||
// if (page != null)
|
||||
// {
|
||||
// title = page.Title;
|
||||
// }
|
||||
// var newContext = ((HttpApplication)sender).Context;
|
||||
// Tracking.TrackPageView(new HttpRequestWrapper(newContext.Request), title, sub);
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
protected void Application_PostAuthenticateRequest(Object sender, EventArgs e)
|
||||
|
@ -43,5 +43,27 @@ namespace Teknik.Helpers
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void TrackAction(string userAgent, string url)
|
||||
{
|
||||
Config config = Config.Load();
|
||||
// Handle Piwik Tracking if enabled
|
||||
if (config.PiwikConfig.Enabled)
|
||||
{
|
||||
try
|
||||
{
|
||||
PiwikTracker.URL = config.PiwikConfig.Url;
|
||||
PiwikTracker tracker = new PiwikTracker(config.PiwikConfig.SiteId);
|
||||
|
||||
tracker.setUserAgent(userAgent);
|
||||
|
||||
tracker.doTrackAction(url, PiwikTracker.ActionType.download);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user