Browse Source

add bugsnag automated error reporting

sisyphus
Dustin Falgout 9 years ago
parent
commit
70ae8d2168
  1. 4
      configure.ac
  2. 2
      data/lightdm-webkit2-greeter.conf
  3. 47
      src/lightdm-webkit2-greeter-ext.c
  4. 4
      src/lightdm-webkit2-greeter.c
  5. 1
      themes/_vendor/js/bugsnag-2.5.0.min.js

4
configure.ac

@ -1,6 +1,6 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(lightdm-webkit2-greeter, 2.1.4)
AC_INIT(lightdm-webkit2-greeter, 2.1.5)
AC_SUBST(THEME_DIR)
AC_CONFIG_HEADER(config.h)
AC_PREREQ([2.59])
@ -27,7 +27,7 @@ PKG_CHECK_MODULES([GREETER], [
])
PKG_CHECK_MODULES([WEB_EXTENSION], [
webkit2gtk-web-extension-4.0 >= 2.10.8
webkit2gtk-web-extension-4.0 >= 2.10.7
])
PKG_CHECK_MODULES([GREETER], [gtk+-3.0 >= 3.20],

2
data/lightdm-webkit2-greeter.conf

@ -3,12 +3,14 @@
# webkit-theme = Webkit theme to use. (Default: antergos)
# debug_mode = Greeter theme debug mode. (Default: false)
# screensaver-timeout = Blank the screen after this many seconds of inactivity. (Default: 300)
# report-errors = Automatically report errors to the developers--anonymously. (Default: true)
#
[greeter]
webkit-theme = antergos
debug_mode = false
screensaver-timeout = 300
report-errors = true
#
# [branding]

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

@ -1435,6 +1435,34 @@ 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,
@ -1447,6 +1475,8 @@ window_object_cleared_callback(WebKitScriptWorld *world,
WebKitDOMDocument *dom_document;
WebKitDOMDOMWindow *dom_window;
gchar *message = "LockHint";
gchar *theme;
gboolean report_errors;
page_id = webkit_web_page_get_id(web_page);
@ -1498,19 +1528,28 @@ window_object_cleared_callback(WebKitScriptWorld *world,
kJSPropertyAttributeNone,
NULL);
/* If the greeter was started as a lock-screen, send message to our UI process. */
if (lightdm_greeter_get_lock_hint(greeter)) {
dom_document = webkit_web_page_get_dom_document(web_page);
dom_window = webkit_dom_document_get_default_view(dom_document);
if (dom_window) {
webkit_dom_dom_window_webkit_message_handlers_post_message(dom_window,
"GreeterBridge", message);
webkit_dom_dom_window_webkit_message_handlers_post_message(
dom_window, "GreeterBridge", message
);
}
}
/* If the default theme is active & error reporting is enabled, inject bugsnag script */
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);
}
g_free(theme);
}

4
src/lightdm-webkit2-greeter.c

@ -245,8 +245,8 @@ message_received_cb(WebKitUserContentManager *manager,
static void
quit_cb(void) {
gtk_widget_destroy(WEBKIT_WEB_VIEW(web_view));
gtk_widget_destroy(GTK_WINDOW(window));
gtk_widget_destroy(GTK_WIDGET(web_view));
gtk_widget_destroy(GTK_WIDGET(window));
gtk_main_quit();
}

1
themes/_vendor/js/bugsnag-2.5.0.min.js vendored

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save