<commit_before>﻿using System;
using System.Configuration;
using System.Net;
using System.Net.Http;
using System.Web;

public class TrackHandler : IHttpHandler
{
	private static string TrackingID = ConfigurationManager.AppSettings["TrackingID"];
	private static string BaseUrl = ConfigurationManager.AppSettings["RedirectTo"];

	public bool IsReusable { get { return true; } }

	public void ProcessRequest (HttpContext context)
	{
		var client = new HttpClient ();
		var redirectUrl = new Uri (new Uri (BaseUrl), context.Request.Path);

		var content = @"v=1
&tid=" + TrackingID + @"
&cid=555
&t=pageview
&dh=" + redirectUrl.Host + @"
&dp=" + context.Request.Path + @"
&dt=" + context.Request.QueryString["t"] ?? context.Request.QueryString["title"] ?? context.Request.Path;

		var clientIp = IPAddress.Parse (context.Request.UserHostAddress);
		if (!IPAddress.IsLoopback (clientIp))
			content += @"
&uip=" + context.Request.UserHostAddress;

		if (!string.IsNullOrEmpty (context.Request.UserAgent))
			content += @"
&ua=" + context.Request.UserAgent;

		client.PostAsync ("http://www.google-analytics.com/collect", new StringContent (content));
		context.Response.Redirect (redirectUrl.ToString ());
	}
}<commit_msg>If no ?t=[title] is provided, use the simple file name<commit_after>﻿using System;
using System.Configuration;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Web;

public class TrackHandler : IHttpHandler
{
	private static string TrackingID = ConfigurationManager.AppSettings["TrackingID"];
	private static string BaseUrl = ConfigurationManager.AppSettings["RedirectTo"];

	public bool IsReusable { get { return true; } }

	public void ProcessRequest (HttpContext context)
	{
		var client = new HttpClient ();
		var redirectUrl = new Uri (new Uri (BaseUrl), context.Request.Url.PathAndQuery);

		var content = @"v=1
&tid=" + TrackingID + @"
&cid=555
&t=pageview
&dh=" + redirectUrl.Host + @"
&dp=" + context.Request.Path + @"
&dt=" + context.Request.QueryString["t"] ?? context.Request.QueryString["title"] ?? Path.GetFileName(context.Request.Url.AbsolutePath);

		var clientIp = IPAddress.Parse (context.Request.UserHostAddress);
		if (!IPAddress.IsLoopback (clientIp))
			content += @"
&uip=" + context.Request.UserHostAddress;

		if (!string.IsNullOrEmpty (context.Request.UserAgent))
			content += @"
&ua=" + context.Request.UserAgent;

		client.PostAsync ("http://www.google-analytics.com/collect", new StringContent (content));
		context.Response.Redirect (redirectUrl.ToString ());
	}
}
{'fraction_non_alphanumeric': 0.14285714285714285, 'fraction_numerical': 0.0031570639305445935, 'mean_word_length': 5.3059701492537314, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6225527', 'n_tokens_mistral': 811, 'n_tokens_neox': 755, 'n_words': 181}