Browse Source

add bugsnag error reporting to the default theme

sisyphus
Dustin Falgout 9 years ago
parent
commit
9a2f681e39
  1. 5
      NEWS
  2. 2
      configure.ac
  3. 46
      src/lightdm-webkit2-greeter-ext.c
  4. 2
      src/lightdm-webkit2-greeter.c
  5. 1
      themes/_vendor/js/Makefile.am
  6. 12
      themes/_vendor/js/mock.js
  7. 5
      themes/antergos/js/greeter.js

5
NEWS

@ -1,3 +1,8 @@
Overview of changes in lightdm-webkit2-greeter 2.1.5
* Added bugsnag automated error reporting to the default greeter theme.
* Updated translations.
Overview of changes in lightdm-webkit2-greeter 2.1.4
* Implemented a theme heartbeat to allow the greeter to detect and respond to theme failures.

2
configure.ac

@ -1,6 +1,8 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(lightdm-webkit2-greeter, 2.1.5)
AC_DEFINE(GREETER_VERSION, "2.1.5", Greeter Version)
AC_SUBST(THEME_DIR)
AC_CONFIG_HEADER(config.h)
AC_PREREQ([2.59])

46
src/lightdm-webkit2-greeter-ext.c

@ -1435,34 +1435,6 @@ static const JSClassDefinition greeter_util_definition = {
};
static void
inject_bugsnag_script(WebKitScriptWorld *world, WebKitFrame *frame) {
gchar *bugsnag, *string;
JSGlobalContextRef jsContext;
JSStringRef command;
bugsnag = "4ea62a82"
"03b5b1af"
"7c33da0d"
"c2f6a60f";
string = g_strdup_printf(
"var s = document.createElement('script');"
"s.src = '../_vendor/js/bugsnag-2.5.0.min.js"
"s['data-apikey'] = %s;"
"$('head').append(s);",
bugsnag
);
jsContext = webkit_frame_get_javascript_context_for_script_world(frame, world);
command = JSStringCreateWithUTF8CString(string);
JSEvaluateScript(jsContext, command, NULL, NULL, 0, NULL);
g_free(bugsnag);
g_free(string);
}
static void
window_object_cleared_callback(WebKitScriptWorld *world,
WebKitWebPage *web_page,
@ -1477,11 +1449,11 @@ window_object_cleared_callback(WebKitScriptWorld *world,
config_file_object,
greeter_util_object,
globalObject;
JSStringRef command;
gboolean report_errors;
gchar *message = "LockHint";
gchar *theme;
gchar *theme, *bugsnag, *string;;
page_id = webkit_web_page_get_id(web_page);
jsContext = webkit_frame_get_javascript_context_for_script_world(frame, world);
globalObject = JSContextGetGlobalObject(jsContext);
@ -1542,8 +1514,18 @@ window_object_cleared_callback(WebKitScriptWorld *world,
theme = g_key_file_get_string(keyfile, "greeter", "theme", NULL);
report_errors = g_key_file_get_boolean(keyfile, "greeter", "report-errors", NULL);
if (strcmp("antergos", theme) == 0 && report_errors) {
inject_bugsnag_script(world, frame);
if (report_errors && strcmp("antergos", theme) == 0) {
bugsnag = "4ea62a82"
"03b5b1af"
"7c33da0d"
"c2f6a60f";
string = g_strdup_printf("window._inject_bugsnag('%s', '%s');", bugsnag, GREETER_VERSION);
command = JSStringCreateWithUTF8CString(string);
JSEvaluateScript(jsContext, command, NULL, NULL, 0, NULL);
g_free(bugsnag);
g_free(string);
}
g_free(theme);

2
src/lightdm-webkit2-greeter.c

@ -348,7 +348,7 @@ main(int argc, char **argv) {
webkit_web_view_set_background_color(WEBKIT_WEB_VIEW(web_view), gdk_rgba_copy(&bg_color));
/* Maybe disable the context (right-click) menu. */
g_signal_connect(web_view, "context-menu", G_CALLBACK(context_menu_cb), NULL);
//g_signal_connect(web_view, "context-menu", G_CALLBACK(context_menu_cb), NULL);
/* There's no turning back now, let's go! */
gtk_container_add(GTK_CONTAINER(window), web_view);

1
themes/_vendor/js/Makefile.am vendored

@ -1,6 +1,7 @@
vendorjsdir = $(THEME_DIR)/_vendor/js
vendorjs_DATA = \
bootstrap.min.js \
bugsnag-2.5.0.min.js \
jquery.min.js \
js.cookie.min.js \
mock.js \

12
themes/_vendor/js/mock.js vendored

@ -299,4 +299,14 @@ function _lightdm_mock_get_user( username ) {
}
}
return user;
}
}
window._inject_bugsnag = function(num, ver) {
var s = document.createElement('script');
s.src = '../_vendor/js/bugsnag-2.5.0.min.js';
jQuery('head').append(s);
setTimeout(function() {
Bugsnag.apiKey = num;
Bugsnag.appVersion = ver;
}, 500);
};

5
themes/antergos/js/greeter.js

@ -46,7 +46,6 @@ String.prototype.capitalize = function() {
/**
* This should be the base class for all the theme's components. However, webkit's
* support of extending (subclassing) ES6 classes is not stable enough to use.
@ -95,7 +94,7 @@ class AntergosThemeUtils {
this.heartbeat = setInterval(() => {
++heartbeats;
window.webkit.messageHandlers.GreeterBridge.postMessage('Heartbeat');
if (heartbeats < 20) {
if (heartbeats < 5) {
console.log('Sending heartbeat...');
}
}, 5000);
@ -897,8 +896,6 @@ class AntergosTheme {
/**
* Initialize the theme once the window has loaded.
*/

Loading…
Cancel
Save