This repository has been archived by the owner on Feb 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhockeyapp.js
70 lines (62 loc) · 1.83 KB
/
hockeyapp.js
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
HockeyApp = {
defaults: {
appID: 'APP_ID',
bundleIdentifier: 'BUNDLE_IDENTIFIER',
url: 'https://rink.hockeyapp.net/api/2/apps/',
version: 'VERSION'
},
settings: {},
init:function(options) {
HockeyApp.settings = $.extend({}, HockeyApp.defaults, options);
},
sendError:function(error, description) {
this.data = [];
this.data.push("Package: " + this.settings.bundleIdentifier);
this.data.push("Version: " + this.settings.version);
this.data.push("Language: " + window.navigator.language);
this.data.push("Platform: " + window.navigator.platform);
this.data.push("User-Agent: " + window.navigator.userAgent);
this.data.push("");
this.data.push(error);
if ((this.data) && (this.settings.url) && (this.settings.appID)) {
var url = this.settings.url + this.settings.appID + "/crashes/js";
url += '?raw=' + escape(this.data.join("\n"));
if (description != null) {
url += '&description=' + escape(description);
}
if ($('#hockeyapp-iframe')[0]) {
$('#hockeyapp-iframe').attr('src', url);
}
else {
$('body').append('<iframe id="hockeyapp-iframe" src="' + url + '" width="1" height="1">');
}
}
},
reportMessage:function(message, method, url, lineNumber) {
if (url != null) {
this.sendError(message + "\n at " + method + " (" + url + ":" + lineNumber + ")");
}
else {
this.sendError(message);
}
},
reportException:function(exception) {
this.sendError(exception.stack);
},
generateTrace:function() {
try {
throw new Error();
}
catch (e) {
if (e.stack) {
lines = e.stack.split("\n");
if (lines.length > 2) {
lines.shift();
lines.shift();
return lines.join("\n");
}
}
}
return ' at unknown';
}
};