1
1
using System ;
2
2
using System . Web ;
3
+ using Exceptionless . Dependency ;
3
4
using Exceptionless . Plugins ;
4
5
using Exceptionless . Extensions ;
5
6
using Exceptionless . Logging ;
6
7
using Exceptionless . Models ;
7
- using Exceptionless . Models . Data ;
8
8
9
9
namespace Exceptionless . Web {
10
10
[ Priority ( 90 ) ]
11
11
internal class ExceptionlessWebPlugin : IEventPlugin {
12
12
private const string TAGS_HTTP_CONTEXT_NAME = "Exceptionless.Tags" ;
13
13
14
14
public void Run ( EventPluginContext context ) {
15
- HttpContextBase httpContext = context . ContextData . GetHttpContext ( ) ;
15
+ var httpContext = context . ContextData . GetHttpContext ( ) ;
16
16
17
17
// if the context is not passed in, try and grab it
18
18
if ( httpContext == null && HttpContext . Current != null )
19
19
httpContext = HttpContext . Current . ToWrapped ( ) ;
20
20
21
21
if ( httpContext == null )
22
22
return ;
23
-
24
- // ev.ExceptionlessClientInfo.Platform = ".NET Web";
25
- if ( context . Client . Configuration . IncludePrivateInformation
26
- && httpContext . User != null
27
- && httpContext . User . Identity . IsAuthenticated )
28
- context . Event . SetUserIdentity ( httpContext . User . Identity . Name ) ;
23
+
24
+ var serializer = context . Client . Configuration . Resolver . GetJsonSerializer ( ) ;
25
+ if ( context . Client . Configuration . IncludePrivateInformation && httpContext . User != null && httpContext . User . Identity . IsAuthenticated ) {
26
+ var user = context . Event . GetUserIdentity ( serializer ) ;
27
+ if ( user == null )
28
+ context . Event . SetUserIdentity ( httpContext . User . Identity . Name ) ;
29
+ }
29
30
30
31
var tags = httpContext . Items [ TAGS_HTTP_CONTEXT_NAME ] as TagSet ;
31
32
if ( tags != null )
32
33
context . Event . Tags . UnionWith ( tags ) ;
34
+
35
+ var ri = context . Event . GetRequestInfo ( serializer ) ;
36
+ if ( ri != null )
37
+ return ;
33
38
34
- RequestInfo requestInfo = null ;
35
39
try {
36
- requestInfo = httpContext . GetRequestInfo ( context . Client . Configuration ) ;
40
+ ri = httpContext . GetRequestInfo ( context . Client . Configuration ) ;
37
41
} catch ( Exception ex ) {
38
42
context . Log . Error ( typeof ( ExceptionlessWebPlugin ) , ex , "Error adding request info." ) ;
39
43
}
40
44
41
- if ( requestInfo == null )
45
+ if ( ri == null )
42
46
return ;
43
47
44
48
var httpException = context . ContextData . GetException ( ) as HttpException ;
45
49
if ( httpException != null ) {
46
50
int httpCode = httpException . GetHttpCode ( ) ;
47
51
if ( httpCode == 404 ) {
48
52
context . Event . Type = Event . KnownTypes . NotFound ;
49
- context . Event . Source = requestInfo . GetFullPath ( includeHttpMethod : true , includeHost : false , includeQueryString : false ) ;
53
+ context . Event . Source = ri . GetFullPath ( includeHttpMethod : true , includeHost : false , includeQueryString : false ) ;
50
54
}
51
55
}
52
56
53
- context . Event . AddRequestInfo ( requestInfo ) ;
57
+ context . Event . AddRequestInfo ( ri ) ;
54
58
}
55
59
}
56
60
}
0 commit comments