forked from kipusoep/UrlTracker
-
Notifications
You must be signed in to change notification settings - Fork 1
/
UrlTrackerSettings.cs
156 lines (153 loc) · 5.9 KB
/
UrlTrackerSettings.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;
using umbraco;
namespace InfoCaster.Umbraco.UrlTracker
{
public static class UrlTrackerSettings
{
public const string TableName = "icUrlTracker";
public const string OldTableName = "infocaster301";
public const string HttpModuleCheck = "890B748D-E226-49FA-A0D7-9AFD3A359F88";
/// <summary>
/// Returns wether or not the UrlTracker is disabled
/// </summary>
/// <remarks>
/// appSetting: 'urlTracker:disabled'
/// </remarks>
public static bool IsDisabled
{
get
{
if (!_isDisabled.HasValue)
{
bool isDisabled = false;
if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["urlTracker:disabled"]))
{
bool parsedAppSetting;
if (bool.TryParse(ConfigurationManager.AppSettings["urlTracker:disabled"], out parsedAppSetting))
isDisabled = parsedAppSetting;
}
_isDisabled = isDisabled;
}
return _isDisabled.Value;
}
}
/// <summary>
/// Returns wether or not logging for the UrlTracker is enabled
/// </summary>
/// <remarks>
/// appSettings: 'urlTracker:enableLogging' & 'umbracoDebugMode'
/// </remarks>
public static bool EnableLogging
{
get
{
if (!_enableLogging.HasValue)
{
bool enableLogging = false;
if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["urlTracker:enableLogging"]))
{
bool parsedAppSetting;
if (bool.TryParse(ConfigurationManager.AppSettings["urlTracker:enableLogging"], out parsedAppSetting))
enableLogging = parsedAppSetting;
}
_enableLogging = enableLogging;
}
return _enableLogging.Value && GlobalSettings.DebugMode;
}
}
/// <summary>
/// Returns the URLs to ignore for 404 Not Found logging
/// </summary>
/// <remarks>
/// appSetting: 'urlTracker:404UrlsToIgnore'
/// </remarks>
public static string[] NotFoundUrlsToIgnore
{
get
{
if (_notFoundUrlsToIgnore == null)
{
_notFoundUrlsToIgnore = new string[] { "favicon.ico" };
if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["urlTracker:404UrlsToIgnore"]))
_notFoundUrlsToIgnore = _notFoundUrlsToIgnore.Union(ConfigurationManager.AppSettings["urlTracker:404UrlsToIgnore"].Split(',')).ToArray();
}
return _notFoundUrlsToIgnore;
}
}
/// <summary>
/// Returns the regex patterns for NotFound urls to ignore
/// </summary>
public static Regex[] RegexNotFoundUrlsToIgnore
{
get
{
return new Regex[] { new Regex("__browserLink/requestData/.*", RegexOptions.Compiled), new Regex("[^/]/arterySignalR/ping", RegexOptions.Compiled) };
}
}
/// <summary>
/// Returns the UrlTracker UI URL to ignore as referrer
/// </summary>
public static string ReferrerToIgnore
{
get { return "Umbraco/UrlTracker/InfoCaster.Umbraco.UrlTracker.UI"; }
}
/// <summary>
/// Returns wether or not tracking URL changes is disabled
/// </summary>
/// <remarks>
/// appSetting: 'urlTracker:trackingDisabled'
/// </remarks>
public static bool IsTrackingDisabled
{
get
{
if (!_isTrackingDisabled.HasValue)
{
bool isTrackingDisabled = false;
if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["urlTracker:trackingDisabled"]))
{
bool parsedAppSetting;
if (bool.TryParse(ConfigurationManager.AppSettings["urlTracker:trackingDisabled"], out parsedAppSetting))
isTrackingDisabled = parsedAppSetting;
}
_isTrackingDisabled = isTrackingDisabled;
}
return _isTrackingDisabled.Value;
}
}
/// <summary>
/// Returns wether or not not found (404) tracking is disabled
/// </summary>
/// <remarks>
/// appSetting: 'urlTracker:notFoundTrackingDisabled'
/// </remarks>
public static bool IsNotFoundTrackingDisabled
{
get
{
if (!_isNotFoundTrackingDisabled.HasValue)
{
bool isNotFoundTrackingDisabled = false;
if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["urlTracker:notFoundTrackingDisabled"]))
{
bool parsedAppSetting;
if (bool.TryParse(ConfigurationManager.AppSettings["urlTracker:notFoundTrackingDisabled"], out parsedAppSetting))
isNotFoundTrackingDisabled = parsedAppSetting;
}
_isNotFoundTrackingDisabled = isNotFoundTrackingDisabled;
}
return _isNotFoundTrackingDisabled.Value;
}
}
static bool? _isDisabled;
static bool? _enableLogging;
static string[] _notFoundUrlsToIgnore;
static bool? _isTrackingDisabled;
static bool? _isNotFoundTrackingDisabled;
}
}