mirror of
https://git.teknik.io/Teknikode/Teknik.git
synced 2023-08-02 14:16:22 +02:00
Added tracking as a global filter.
This commit is contained in:
parent
9d68a3aab0
commit
e95f2cf101
@ -1,5 +1,6 @@
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using Teknik.Filters;
|
||||
|
||||
namespace Teknik
|
||||
{
|
||||
@ -10,6 +11,7 @@ namespace Teknik
|
||||
//filters.Add(new HandleErrorAttribute());
|
||||
filters.Add(new AuthorizeAttribute());
|
||||
filters.Add(new RequireHttpsAttribute());
|
||||
filters.Add(new TrackingFilterAttribute());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,8 +32,6 @@ namespace Teknik.Areas.API.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!doNotTrack)
|
||||
Tracking.TrackPageView(Request, Config, "Upload");
|
||||
if (file != null)
|
||||
{
|
||||
if (file.ContentLength <= Config.UploadConfig.MaxUploadSize)
|
||||
@ -164,8 +162,6 @@ namespace Teknik.Areas.API.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!doNotTrack)
|
||||
Tracking.TrackPageView(Request, Config, "Paste");
|
||||
Paste.Models.Paste paste = PasteHelper.CreatePaste(code, title, syntax, expireUnit, expireLength, password, hide);
|
||||
|
||||
db.Pastes.Add(paste);
|
||||
@ -196,8 +192,6 @@ namespace Teknik.Areas.API.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!doNotTrack)
|
||||
Tracking.TrackPageView(Request, Config, "Shorten");
|
||||
if (url.IsValidUrl())
|
||||
{
|
||||
ShortenedUrl newUrl = Shortener.Shortener.ShortenUrl(url, Config.ShortenerConfig.UrlLength);
|
||||
|
@ -27,11 +27,17 @@ namespace Teknik.Filters
|
||||
{
|
||||
title = page.Title;
|
||||
}
|
||||
Config config = Config.Load();
|
||||
Tracking.TrackPageView(filterContext.HttpContext.Request, config, title);
|
||||
HttpRequestBase request = filterContext.HttpContext.Request;
|
||||
// Fire and forget. Don't need to wait for it.
|
||||
Task.Run(() => AsyncTrackPageView(request, title));
|
||||
|
||||
base.OnActionExecuted(filterContext);
|
||||
}
|
||||
|
||||
private void AsyncTrackPageView(HttpRequestBase request, string title)
|
||||
{
|
||||
Config config = Config.Load();
|
||||
Tracking.TrackPageView(request, config, title);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ namespace Teknik.Helpers
|
||||
if (request.UrlReferrer != null)
|
||||
tracker.setUrlReferrer(request.UrlReferrer.ToString());
|
||||
|
||||
tracker.setRequestTimeout(5);
|
||||
tracker.setRequestTimeout(15);
|
||||
tracker.doTrackPageView(string.Format("{0}/{1}", sub, title));
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -14,7 +14,7 @@
|
||||
}
|
||||
|
||||
<!-- Piwik -->
|
||||
<script type="text/javascript">
|
||||
@*<script type="text/javascript">
|
||||
var _paq = _paq || [];
|
||||
_paq.push(["setDocumentTitle", "@sub/@ViewBag.Title"]);
|
||||
_paq.push(["setCookieDomain", "*.teknik.io"]);
|
||||
@ -28,7 +28,7 @@
|
||||
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>
|
||||
</script>*@
|
||||
<!-- End Piwik Code -->
|
||||
}
|
||||
<script type="text/javascript">
|
||||
@ -58,12 +58,12 @@
|
||||
</div>
|
||||
<!-- NoScript Alert -->
|
||||
<noscript>
|
||||
@if (Model.Config.PiwikConfig.Enabled)
|
||||
@*@if (Model.Config.PiwikConfig.Enabled)
|
||||
{
|
||||
<!-- Piwik Image Tracker-->
|
||||
<img src="https://stats.teknik.io/piwik.php?idsite=1&rec=1" style="border:0" alt="" />
|
||||
<!-- End Piwik -->
|
||||
}
|
||||
}*@
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-xs-12 text-center">
|
||||
|
Loading…
Reference in New Issue
Block a user