Browse Source

Modified back to use static function for tracking.

Added action tracking function.
tags/2.0.3
Teknikode 4 years ago
parent
commit
07ae28b7e2

+ 1
- 1
Teknik/Areas/Upload/Controllers/UploadController.cs View File

@@ -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);
}

+ 0
- 1
Teknik/Controllers/DefaultController.cs View File

@@ -13,7 +13,6 @@ using Teknik.Filters;

namespace Teknik.Controllers
{
[TrackingFilter]
public class DefaultController : Controller
{
private Config _config;

+ 28
- 27
Teknik/Global.asax.cs View File

@@ -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)

+ 22
- 0
Teknik/Helpers/Tracking.cs View File

@@ -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…
Cancel
Save