Skip to content

10 files changed

+99
-62
lines changed

dist/exceptionless.js

Lines changed: 29 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/exceptionless.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/exceptionless.min.js

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/exceptionless.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/exceptionless.node.js

Lines changed: 29 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/exceptionless.node.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/index.html

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
22
<html>
33
<head lang="en">
44
<meta charset="UTF-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
56
<title>Exceptionless Test</title>
67
</head>
78
<body>
8-
<script type="application/javascript" src="../dist/exceptionless.js?apiKey=LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw"></script>
9-
10-
<script type="application/javascript" src="math.js"></script>
11-
<script type="application/javascript" src="index.js"></script>
12-
<script type="application/javascript">
13-
'use strict';
14-
9+
<script type="text/javascript" src="exceptionless.js?apiKey=LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw"></script>
10+
<script type="text/javascript" src="math.js"></script>
11+
<script type="text/javascript" src="index.js"></script>
12+
<script type="text/javascript">
1513
var client = exceptionless.ExceptionlessClient.default;
1614
client.config.serverUrl = 'http://localhost:50000';
1715
client.config.useDebugLogger();

src/Utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ export class Utils {
168168
});
169169
}
170170

171-
if (toString.call(data) === '[object Array]') {
171+
if (({}).toString.call(data) === '[object Array]') {
172172
var result = [];
173173
for (var index = 0; index < data.length; index++) {
174174
result[index] = JSON.parse(stringifyImpl(data[index], exclusions || []));

src/queue/DefaultEventQueue.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export class DefaultEventQueue implements IEventQueue {
167167
}
168168

169169
if (!response.success) {
170-
log.error(`Error submitting events: ${ response.message}`);
170+
log.error(`Error submitting events: ${response.message || 'Please check the network tab for more info.'}`);
171171
this.suspendProcessing();
172172
}
173173
}

src/submission/DefaultSubmissionClient.ts

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ export class DefaultSubmissionClient implements ISubmissionClient {
5555

5656
public sendRequest(config:Configuration, method:string, path:string, data:string, callback: (status:number, message:string, data?:string, headers?:Object) => void): void {
5757
var isCompleted = false;
58-
function complete(xhr:XMLHttpRequest) {
58+
var useSetTimeout = false;
59+
60+
function complete(mode:string, xhr:XMLHttpRequest) {
5961
function parseResponseHeaders(headerStr) {
6062
var headers = {};
6163
var headerPairs = (headerStr || '').split('\u000d\u000a');
@@ -77,11 +79,15 @@ export class DefaultSubmissionClient implements ISubmissionClient {
7779
} else {
7880
isCompleted = true;
7981
}
80-
82+
8183
var message:string;
82-
if (xhr.status === 0) {
84+
var status:number = xhr.status;
85+
if (mode === 'timeout' || status === 0) {
8386
message = 'Unable to connect to server.';
84-
} else if (xhr.status < 200 || xhr.status > 299) {
87+
status = 0;
88+
} else if (mode === 'loaded' && !status) {
89+
status = method === 'POST' ? 202 : 200;
90+
} else if (status < 200 || status > 299) {
8591
if (!!xhr.responseBody && !!xhr.responseBody.message) {
8692
message = xhr.responseBody.message;
8793
} else if (!!xhr.responseText && xhr.responseText.indexOf('message') !== -1) {
@@ -95,26 +101,27 @@ export class DefaultSubmissionClient implements ISubmissionClient {
95101
}
96102
}
97103

98-
callback(xhr.status || 500, message, xhr.responseText, parseResponseHeaders(xhr.getAllResponseHeaders()));
104+
callback(status || 500, message || '', xhr.responseText, parseResponseHeaders(xhr.getAllResponseHeaders && xhr.getAllResponseHeaders()));
99105
}
100106

101107
function createRequest(config:Configuration, method:string, url:string): XMLHttpRequest {
102108
var xhr:any = new XMLHttpRequest();
103109
if ('withCredentials' in xhr) {
104110
xhr.open(method, url, true);
111+
112+
xhr.setRequestHeader('X-Exceptionless-Client', config.userAgent);
113+
if (method === 'POST') {
114+
xhr.setRequestHeader('Content-Type', 'application/json');
115+
}
105116
} else if (typeof XDomainRequest != 'undefined') {
117+
useSetTimeout = true;
106118
xhr = new XDomainRequest();
107-
xhr.open(method, url);
119+
xhr.open(method, location.protocol === 'http:' ? url.replace('https:', 'http:') : url);
108120
} else {
109121
xhr = null;
110122
}
111123

112124
if (xhr) {
113-
xhr.setRequestHeader('X-Exceptionless-Client', config.userAgent);
114-
if (method === 'POST' && xhr.setRequestHeader) {
115-
xhr.setRequestHeader('Content-Type', 'application/json');
116-
}
117-
118125
xhr.timeout = 10000;
119126
}
120127

@@ -134,14 +141,19 @@ export class DefaultSubmissionClient implements ISubmissionClient {
134141
return;
135142
}
136143

137-
complete(xhr);
144+
complete('loaded', xhr);
138145
};
139146
}
140147

141-
xhr.ontimeout = () => complete(xhr);
142-
xhr.onerror = () => complete(xhr);
143-
xhr.onload = () => complete(xhr);
148+
xhr.onprogress = () => {};
149+
xhr.ontimeout = () => complete('timeout', xhr);
150+
xhr.onerror = () => complete('error', xhr);
151+
xhr.onload = () => complete('loaded', xhr);
144152

145-
xhr.send(data);
153+
if (useSetTimeout) {
154+
setTimeout(() => xhr.send(data), 500);
155+
} else {
156+
xhr.send(data);
157+
}
146158
}
147159
}

0 commit comments

Comments
 (0)