forked from exceptionless/Exceptionless.JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDefaultRequestInfoCollector.ts
More file actions
29 lines (25 loc) · 1016 Bytes
/
DefaultRequestInfoCollector.ts
File metadata and controls
29 lines (25 loc) · 1016 Bytes
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
import { IRequestInfo } from '../models/IRequestInfo';
import { IRequestInfoCollector } from 'IRequestInfoCollector';
import { EventPluginContext } from '../plugins/EventPluginContext';
import { Utils } from '../Utils';
export class DefaultRequestInfoCollector implements IRequestInfoCollector {
public getRequestInfo(context:EventPluginContext): IRequestInfo {
if (!document || !navigator || !location) {
return null;
}
var requestInfo:IRequestInfo = {
user_agent: navigator.userAgent,
is_secure: location.protocol === 'https:',
host: location.hostname,
port: location.port && location.port !== '' ? parseInt(location.port) : 80,
path: location.pathname,
//client_ip_address: 'TODO',
cookies: Utils.getCookies(document.cookie),
query_string: Utils.parseQueryString(location.search.substring(1))
};
if (document.referrer && document.referrer !== '') {
requestInfo.referrer = document.referrer;
}
return requestInfo;
}
}