Browse Source

Made tracking a synchronous process

tags/3.0.0
Teknikode 2 years ago
parent
commit
c695051a9b

+ 2
- 7
Teknik/Filters/TrackDownload.cs View File

@@ -28,7 +28,7 @@ namespace Teknik.Filters
{
string userAgent = request.UserAgent;

string ipAddress = request.ClientIPFromRequest(true);
string clientIp = request.ClientIPFromRequest(true);

string urlReferrer = request.UrlReferrer?.ToString();

@@ -37,15 +37,10 @@ namespace Teknik.Filters
url = request.Url.ToString();

// Fire and forget. Don't need to wait for it.
Task.Run(() => AsyncTrackDownload(userAgent, ipAddress, url, urlReferrer));
Tracking.TrackDownload(userAgent, clientIp, url, urlReferrer);
}

base.OnActionExecuted(filterContext);
}

private static void AsyncTrackDownload(string userAgent, string clientIp, string url, string urlReferrer)
{
Tracking.TrackDownload(userAgent, clientIp, url, urlReferrer);
}
}
}

+ 2
- 7
Teknik/Filters/TrackLink.cs View File

@@ -27,7 +27,7 @@ namespace Teknik.Filters
{
string userAgent = request.UserAgent;

string ipAddress = request.ClientIPFromRequest(true);
string clientIp = request.ClientIPFromRequest(true);

string urlReferrer = request.UrlReferrer?.ToString();

@@ -36,15 +36,10 @@ namespace Teknik.Filters
url = request.Url.ToString();

// Fire and forget. Don't need to wait for it.
Task.Run(() => AsyncTrackLink(userAgent, ipAddress, url, urlReferrer));
Tracking.TrackLink(userAgent, clientIp, url, urlReferrer);
}

base.OnActionExecuted(filterContext);
}

private static void AsyncTrackLink(string userAgent, string clientIp, string url, string urlReferrer)
{
Tracking.TrackLink(userAgent, clientIp, url, urlReferrer);
}
}
}

+ 2
- 7
Teknik/Filters/TrackPageView.cs View File

@@ -34,7 +34,7 @@ namespace Teknik.Filters
sub = request.Url?.AbsoluteUri.GetSubdomain();
}

string ipAddress = request.ClientIPFromRequest(true);
string clientIp = request.ClientIPFromRequest(true);

string url = string.Empty;
if (request.Url != null)
@@ -54,15 +54,10 @@ namespace Teknik.Filters
bool hasJava = request.Browser.JavaApplets;

// Fire and forget. Don't need to wait for it.
Task.Run(() => AsyncTrackPageView(title, sub, ipAddress, url, urlReferrer, userAgent,pixelWidth, pixelHeight, hasCookies, acceptLang, hasJava));
Tracking.TrackPageView(title, sub, clientIp, url, urlReferrer, userAgent, pixelWidth, pixelHeight, hasCookies, acceptLang, hasJava);
}

base.OnActionExecuted(filterContext);
}

private static void AsyncTrackPageView(string title, string sub, string clientIp, string url, string urlReferrer, string userAgent, int pixelWidth, int pixelHeight, bool hasCookies, string acceptLang, bool hasJava)
{
Tracking.TrackPageView(title, sub, clientIp, url, urlReferrer, userAgent, pixelWidth, pixelHeight, hasCookies, acceptLang, hasJava);
}
}
}

+ 10
- 12
Utilities/Utilities/ResponseHelper.cs View File

@@ -20,13 +20,6 @@ namespace Teknik.Utilities
int bytesToRead = chunkSize;
do
{
// Flush the response
if (flush)
{
//response.OutputStream.Write(buffer, 0, 1);
response.Flush();
}

if (chunkSize > bytesRemaining)
{
bytesToRead = bytesRemaining;
@@ -37,10 +30,18 @@ namespace Teknik.Utilities
{
response.OutputStream.Write(buffer, 0, processedBytes);

// Flush the response
if (flush)
{
response.Flush();
}

// Clear the buffer
Array.Clear(buffer, 0, chunkSize);

// decrement the total bytes remaining to process
bytesRemaining -= processedBytes;
}
bytesRemaining -= processedBytes;
}
while (processedBytes > 0 && bytesRemaining > 0);
}
@@ -51,10 +52,7 @@ namespace Teknik.Utilities
finally
{
// dispose of file stream
if (stream != null)
{
stream.Dispose();
}
stream?.Dispose();
}
}
}

Loading…
Cancel
Save