mirror of
https://git.teknik.io/Teknikode/Teknik.git
synced 2023-08-02 14:16:22 +02:00
Modified tracking to use JS and removed download tracking
This commit is contained in:
parent
ec8517d3d4
commit
e2abc55872
@ -32,7 +32,7 @@ namespace Teknik.Areas.API.Controllers
|
||||
try
|
||||
{
|
||||
if (!doNotTrack)
|
||||
Tracking.TrackPageView(Request, "Upload");
|
||||
Tracking.TrackPageView(Request, Config, "Upload");
|
||||
if (file != null)
|
||||
{
|
||||
if (file.ContentLength <= Config.UploadConfig.MaxUploadSize)
|
||||
@ -133,7 +133,7 @@ namespace Teknik.Areas.API.Controllers
|
||||
try
|
||||
{
|
||||
if (!doNotTrack)
|
||||
Tracking.TrackPageView(Request, "Paste");
|
||||
Tracking.TrackPageView(Request, Config, "Paste");
|
||||
Paste.Models.Paste paste = PasteHelper.CreatePaste(code, title, syntax, expireUnit, expireLength, password, hide);
|
||||
|
||||
db.Pastes.Add(paste);
|
||||
@ -163,7 +163,7 @@ namespace Teknik.Areas.API.Controllers
|
||||
try
|
||||
{
|
||||
if (!doNotTrack)
|
||||
Tracking.TrackPageView(Request, "Shorten");
|
||||
Tracking.TrackPageView(Request, Config, "Shorten");
|
||||
if (url.IsValidUrl())
|
||||
{
|
||||
ShortenedUrl newUrl = Shortener.Shortener.ShortenUrl(url, Config.ShortenerConfig.UrlLength);
|
||||
|
@ -146,9 +146,6 @@ namespace Teknik.Areas.Upload.Controllers
|
||||
|
||||
Response.AppendHeader("Content-Disposition", cd.ToString());
|
||||
|
||||
// Handle Piwik Tracking if enabled
|
||||
Tracking.TrackAction(Request, Request.Url.ToString());
|
||||
|
||||
return File(data, upload.ContentType);
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,8 @@ namespace Teknik.Filters
|
||||
{
|
||||
title = page.Title;
|
||||
}
|
||||
Tracking.TrackPageView(filterContext.HttpContext.Request, title);
|
||||
Config config = Config.Load();
|
||||
Tracking.TrackPageView(filterContext.HttpContext.Request, config, title);
|
||||
|
||||
base.OnActionExecuted(filterContext);
|
||||
}
|
||||
|
@ -52,16 +52,6 @@ namespace Teknik
|
||||
{
|
||||
HttpContext context = HttpContext.Current;
|
||||
|
||||
// Handle Piwik
|
||||
string title = string.Empty;
|
||||
Page page = HttpContext.Current.Handler as Page;
|
||||
|
||||
if (page != null)
|
||||
{
|
||||
title = page.Title;
|
||||
}
|
||||
Tracking.TrackPageView(new HttpRequestWrapper(context.Request), title);
|
||||
|
||||
Stopwatch stopwatch = (Stopwatch)context.Items["Stopwatch"];
|
||||
stopwatch.Stop();
|
||||
|
||||
|
@ -11,9 +11,8 @@ namespace Teknik.Helpers
|
||||
{
|
||||
public static class Tracking
|
||||
{
|
||||
public static void TrackPageView(HttpRequestBase request, string title)
|
||||
public static void TrackPageView(HttpRequestBase request, Config config, string title)
|
||||
{
|
||||
Config config = Config.Load();
|
||||
// Handle Piwik Tracking if enabled
|
||||
if (config.PiwikConfig.Enabled)
|
||||
{
|
||||
@ -24,10 +23,9 @@ namespace Teknik.Helpers
|
||||
{
|
||||
sub = request.Url.AbsoluteUri.GetSubdomain();
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(title))
|
||||
if (config.DevEnvironment)
|
||||
{
|
||||
title = config.Title;
|
||||
sub = "dev - " + sub;
|
||||
}
|
||||
|
||||
PiwikTracker.URL = config.PiwikConfig.Url;
|
||||
@ -48,7 +46,7 @@ namespace Teknik.Helpers
|
||||
tracker.setUrlReferrer(request.UrlReferrer.ToString());
|
||||
|
||||
tracker.setRequestTimeout(5);
|
||||
tracker.doTrackPageView(string.Format("{0} / {1}", sub, title));
|
||||
tracker.doTrackPageView(string.Format("{0}/{1}", sub, title));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -1,8 +1,36 @@
|
||||
@model Teknik.ViewModels.ViewModelBase
|
||||
|
||||
@using Teknik.Helpers
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
@if (Model.Config.PiwikConfig.Enabled)
|
||||
{
|
||||
string sub = Request.RequestContext.RouteData.Values["sub"].ToString();
|
||||
if (Model.Config.DevEnvironment)
|
||||
{
|
||||
sub = "dev - " + sub;
|
||||
}
|
||||
|
||||
<!-- Piwik -->
|
||||
<script type="text/javascript">
|
||||
var _paq = _paq || [];
|
||||
_paq.push(["setDocumentTitle", "@sub/@ViewBag.Title"]);
|
||||
_paq.push(["setCookieDomain", "*.teknik.io"]);
|
||||
_paq.push(["setDomains", ["*.teknik.io"]]);
|
||||
_paq.push(['trackPageView']);
|
||||
_paq.push(['enableLinkTracking']);
|
||||
(function() {
|
||||
var u="//stats.teknik.io/";
|
||||
_paq.push(['setTrackerUrl', u+'piwik.php']);
|
||||
_paq.push(['setSiteId', 1]);
|
||||
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
|
||||
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
|
||||
})();
|
||||
</script>
|
||||
<!-- End Piwik Code -->
|
||||
}
|
||||
<script type="text/javascript">
|
||||
var startTime = new Date();
|
||||
</script>
|
||||
@ -51,33 +79,6 @@
|
||||
@RenderBody()
|
||||
</div>
|
||||
@Html.Partial("_Footer")
|
||||
|
||||
@if (Model.Config.PiwikConfig.Enabled)
|
||||
{
|
||||
string sub = Request.RequestContext.RouteData.Values["sub"].ToString();
|
||||
if (Model.Config.DevEnvironment)
|
||||
{
|
||||
sub = "dev - " + sub;
|
||||
}
|
||||
|
||||
<!-- Piwik -->
|
||||
<script type="text/javascript">
|
||||
var _paq = _paq || [];
|
||||
_paq.push(["setDocumentTitle", "@sub/" + document.title]);
|
||||
_paq.push(["setCookieDomain", "*.teknik.io"]);
|
||||
_paq.push(["setDomains", ["*.teknik.io"]]);
|
||||
_paq.push(['trackPageView']);
|
||||
_paq.push(['enableLinkTracking']);
|
||||
(function() {
|
||||
var u="//stats.teknik.io/";
|
||||
_paq.push(['setTrackerUrl', u+'piwik.php']);
|
||||
_paq.push(['setSiteId', 1]);
|
||||
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
|
||||
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
|
||||
})();
|
||||
</script>
|
||||
<!-- End Piwik Code -->
|
||||
}
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {pageloadDoTimer();});
|
||||
|
Loading…
Reference in New Issue
Block a user