✨ Finalize first version of errortracking plugin
Also add docs for that & the Anonymous Usage Tracking plugin.
This commit is contained in:
1 parent
c2814651f9
commit
0f8f1ec8e0
9 files changed
+292
-18
No files matched your search
@@ -0,0 +1,40 @@
|
||||
.. _sec-bundledplugins-errortracking:
|
||||
|
||||
Error Tracking Plugin
|
||||
=====================
|
||||
|
||||
The Error Tracking plugin will cause any logged exceptions in the server and the browser interface to be sent to
|
||||
OctoPrint's `Sentry instance <https://sentry.io/>`_.
|
||||
|
||||
By enabling it you help to gather detailed information on the cause of bugs or other issues. This is especially
|
||||
valuable on release candidates, which is why this plugin will also prompt you to enable error tracking if it detects
|
||||
that you are subscribed to an RC release channel.
|
||||
|
||||
By default, even when enabled it will only be active if you are running a released OctoPrint version, so either a stable
|
||||
release or a release candidate.
|
||||
|
||||
The Error Tracking plugin is using a Sentry instance kindly provided by `sentry.io <https://sentry.io/>`_. For information on their service
|
||||
please refer to their `Security & Compliance documentation <https://sentry.io/security/>`_
|
||||
and their `Privacy Policy <https://sentry.io/privacy/>`_.
|
||||
|
||||
The Error Tracking plugin has been bundled with OctoPrint since version 1.3.11.
|
||||
|
||||
.. _sec-bundledplugins-errortracking-configuration:
|
||||
|
||||
Configuring the plugin
|
||||
----------------------
|
||||
|
||||
The plugin supports the following configuration keys:
|
||||
|
||||
* ``enabled``: Whether to enable error tracking. Defaults to ``false``.
|
||||
* ``enabled_unreleased``: Whether to also enable tracking on unreleased OctoPrint versions (anything not stable releases
|
||||
or release candidates). Defaults to ``false``.
|
||||
* ``unique_id``: Unique instance identifier, auto generated on first activation
|
||||
|
||||
.. _sec-bundledplugins-errortracking-sourcecode:
|
||||
|
||||
Source Code
|
||||
-----------
|
||||
|
||||
The source of the Error Tracking plugin is bundled with OctoPrint and can be
|
||||
found in its source repository under ``src/octoprint/plugins/errortracking``.
|
||||
@@ -9,10 +9,12 @@ Bundled Plugins
|
||||
|
||||
action_command_prompt.rst
|
||||
announcements.rst
|
||||
tracking.rst
|
||||
appkeys.rst
|
||||
backup.rst
|
||||
cura.rst
|
||||
discovery.rst
|
||||
errortracking.rst
|
||||
forcelogin.rst
|
||||
logging.rst
|
||||
pluginmanager.rst
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
.. _sec-bundledplugins-tracking:
|
||||
|
||||
Anonymous Usage Tracking Plugin
|
||||
===============================
|
||||
|
||||
The Anonymous Usage Tracking plugin provides valuable insights into how many instances running what versions of
|
||||
OctoPrint are out there, whether they are successfully completing print jobs and various other metrics.
|
||||
|
||||
By enabling it you help to identify problems with new releases and release candidates early on, and to better tailor
|
||||
OctoPrint's future development to actual use.
|
||||
|
||||
For details on what gets tracked, please refer to `tracking.octoprint.org <https://tracking.octoprint.org>`_
|
||||
and also the `Privacy Policy at tracking.octoprint.org <https://tracking.octoprint.org/privacy>`_.
|
||||
|
||||
The Anonymous Usage Tracking plugin has been bundled with OctoPrint since version 1.3.10.
|
||||
|
||||
.. _sec-bundledplugins-tracking-configuration:
|
||||
|
||||
Configuring the plugin
|
||||
----------------------
|
||||
|
||||
The plugin supports the following configuration keys:
|
||||
|
||||
* ``enabled``: Whether to enable usage tracking. Defaults to ``false``.
|
||||
* ``unique_id``: Unique instance identifier, auto generated on first activation
|
||||
* ``server``: The tracking server to track against. Defaults to a tracking endpoint on ``https://tracking.octoprint.org``.
|
||||
* ``ping``: How often to send a ``ping`` tracking event, in seconds. Defaults to a 15min interval.
|
||||
* ``events``: Granular configuration of enabled tracking events. All default to ``true``.
|
||||
|
||||
* ``startup``: Whether to track startup/shutdown events
|
||||
* ``printjob``: Whether to track print job related events (start, completion, cancel, ...)
|
||||
* ``commerror``: Whether to track communication errors with the printer
|
||||
* ``plugin``: Whether to track plugin related events (install, uninstall, ...)
|
||||
* ``update``: Whether to track update related events (update successful or not, ...)
|
||||
* ``printer``: Whether to track printer related events (connected, firmware, ...)
|
||||
* ``printer_safety_check``: Whether to track warnings of the :ref:`Printer Safety Check <sec-bundledplugins-printer_safety_check>`
|
||||
* ``throttled``: Whether to track throttle events detected on the underlying system
|
||||
|
||||
.. _sec-bundledplugins-tracking-sourcecode:
|
||||
|
||||
Source Code
|
||||
-----------
|
||||
|
||||
The source of the Anonymous Usage Tracking plugin is bundled with OctoPrint and can be
|
||||
found in its source repository under ``src/octoprint/plugins/tracking``.
|
||||
@@ -9,6 +9,9 @@ import logging
|
||||
|
||||
from octoprint.util.version import get_octoprint_version_string, is_released_octoprint_version
|
||||
|
||||
from flask import jsonify
|
||||
from flask_babel import gettext
|
||||
|
||||
SENTRY_URL_SERVER = "https://827d1f11ccda4b31b924f29aaacab493@sentry.io/1373987"
|
||||
SENTRY_URL_COREUI = "https://30bdc39d2248444c8bc01484f38c9444@sentry.io/1374096"
|
||||
|
||||
@@ -21,10 +24,15 @@ SETTINGS_DEFAULTS = dict(enabled=False,
|
||||
|
||||
class ErrorTrackingPlugin(octoprint.plugin.SettingsPlugin,
|
||||
octoprint.plugin.AssetPlugin,
|
||||
octoprint.plugin.TemplatePlugin):
|
||||
octoprint.plugin.TemplatePlugin,
|
||||
octoprint.plugin.SimpleApiPlugin):
|
||||
|
||||
def get_template_configs(self):
|
||||
return [
|
||||
dict(type="settings",
|
||||
name=gettext("Error Tracking"),
|
||||
template="errortracking_settings.jinja2",
|
||||
custom_bindings=False),
|
||||
dict(type="generic", template="errortracking_javascripts.jinja2")
|
||||
]
|
||||
|
||||
@@ -32,22 +40,42 @@ class ErrorTrackingPlugin(octoprint.plugin.SettingsPlugin,
|
||||
enabled = self._settings.get_boolean(["enabled"])
|
||||
enabled_unreleased = self._settings.get_boolean(["enabled_unreleased"])
|
||||
|
||||
return dict(enabled=enabled and (enabled_unreleased or is_released_octoprint_version()),
|
||||
return dict(enabled=_is_enabled(enabled, enabled_unreleased),
|
||||
unique_id=self._settings.get(["unique_id"]),
|
||||
url_coreui=self._settings.get(["url_coreui"]))
|
||||
|
||||
def get_assets(self):
|
||||
return dict(js=["js/sentry.min.js",])
|
||||
return dict(js=["js/sentry.min.js", "js/errortracking.js"])
|
||||
|
||||
def get_settings_defaults(self):
|
||||
return SETTINGS_DEFAULTS
|
||||
|
||||
def on_settings_save(self, data):
|
||||
old_enabled = _is_enabled(self._settings.get_boolean(["enabled"]),
|
||||
self._settings.get_boolean(["enabled_unreleased"]))
|
||||
|
||||
def __plugin_enable__():
|
||||
octoprint.plugin.SettingsPlugin.on_settings_save(self, data)
|
||||
|
||||
enabled = _is_enabled(self._settings.get_boolean(["enabled"]),
|
||||
self._settings.get_boolean(["enabled_unreleased"]))
|
||||
|
||||
if old_enabled != enabled:
|
||||
_enable_errortracking()
|
||||
|
||||
def on_api_get(self, request):
|
||||
return jsonify(**self.get_template_vars())
|
||||
|
||||
|
||||
_enabled = False
|
||||
def _enable_errortracking():
|
||||
# this is a bit hackish, but we want to enable error tracking as early in the platform lifecycle as possible
|
||||
# and hence can't wait until our implementation is initialized and injected with settings
|
||||
|
||||
from octoprint.settings import settings
|
||||
global _enabled
|
||||
|
||||
if _enabled:
|
||||
return
|
||||
|
||||
version = get_octoprint_version_string()
|
||||
|
||||
@@ -64,7 +92,7 @@ def __plugin_enable__():
|
||||
s.set(["plugins", "errortracking", "unique_id"], unique_id, defaults=plugin_defaults)
|
||||
s.save()
|
||||
|
||||
if enabled and (enabled_unreleased or is_released_octoprint_version()):
|
||||
if _is_enabled(enabled, enabled_unreleased):
|
||||
import sentry_sdk
|
||||
sentry_sdk.init(url_server,
|
||||
release=version)
|
||||
@@ -73,6 +101,16 @@ def __plugin_enable__():
|
||||
scope.user = dict(id=unique_id)
|
||||
|
||||
logging.getLogger("octoprint.plugin.errortracking").info("Initialized error tracking")
|
||||
_enabled = True
|
||||
|
||||
|
||||
def _is_enabled(enabled, enabled_unreleased):
|
||||
return enabled and (enabled_unreleased or is_released_octoprint_version())
|
||||
|
||||
|
||||
def __plugin_enable__():
|
||||
_enable_errortracking()
|
||||
|
||||
|
||||
__plugin_name__ = "Error Tracking"
|
||||
__plugin_author__ = "Gina Häußge"
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
$(function() {
|
||||
function ErrorTrackingViewModel(parameters) {
|
||||
var self = this;
|
||||
|
||||
self.settings = parameters[0];
|
||||
self.loginState = parameters[1];
|
||||
|
||||
var notification = undefined;
|
||||
var performCheck = function() {
|
||||
if (!self.loginState.isAdmin()) return;
|
||||
|
||||
// already enabled?
|
||||
if (self.settings.settings.plugins.errortracking.enabled()) return;
|
||||
|
||||
// RC release channel?
|
||||
var releaseChannel = self.settings.settings.plugins.softwareupdate.octoprint_release_channel();
|
||||
if (releaseChannel === "rc/maintenance" || releaseChannel === "rc/devel") {
|
||||
if (notification !== undefined) return;
|
||||
|
||||
// ignored?
|
||||
try {
|
||||
var ignoredString = localStorage["plugin.errortracking.notification_ignored"];
|
||||
var ignored = false;
|
||||
|
||||
if (ignoredString) {
|
||||
ignored = JSON.parse(ignoredString);
|
||||
}
|
||||
|
||||
if (ignored) return;
|
||||
} catch (ex) {
|
||||
log.error("Error while reading plugin.errortracking.notification_ignored from local storage");
|
||||
}
|
||||
|
||||
// show notification
|
||||
notification = new PNotify({
|
||||
title: gettext("Enable error reporting?"),
|
||||
text: gettext("<p>It looks like you are tracking an OctoPrint RC release channel. It " +
|
||||
"would be great if you would enable error reporting so that any kind of errors that occur " +
|
||||
"with an RC can be looked into more easily. Thank you!</p>" +
|
||||
"<p><small>You can find more information on error reporting " +
|
||||
"under Settings > Error Tracking</small></p>"),
|
||||
hide: false,
|
||||
confirm: {
|
||||
confirm: true,
|
||||
buttons: [{
|
||||
text: gettext("Ignore"),
|
||||
click: function() {
|
||||
notification.remove();
|
||||
notification = undefined;
|
||||
new PNotify({
|
||||
text: gettext("You can still enable error tracking via \"Settings\" > \"Error Tracking\"")
|
||||
});
|
||||
|
||||
if (Modernizr.localstorage) {
|
||||
localStorage["plugin.errortracking.notification_ignored"] = JSON.stringify(true);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
text: gettext("Enable"),
|
||||
addClass: "btn-primary",
|
||||
click: function() {
|
||||
self.settings.saveData({
|
||||
plugins: {
|
||||
errortracking: {
|
||||
enabled: true
|
||||
}
|
||||
}
|
||||
}).done(function() {
|
||||
notification.remove();
|
||||
notification = undefined;
|
||||
location.reload(true);
|
||||
});
|
||||
}
|
||||
}]
|
||||
},
|
||||
buttons: {
|
||||
closer: false,
|
||||
sticker: false
|
||||
}
|
||||
});
|
||||
|
||||
// not an RC release channel, close notification
|
||||
} else if (notification !== undefined) {
|
||||
notification.remove();
|
||||
notification = undefined;
|
||||
}
|
||||
};
|
||||
|
||||
var subbed = false;
|
||||
self.onStartup = self.onUserLoggedIn = self.onUserLoggedOut = function() {
|
||||
performCheck();
|
||||
if (self.settings && self.settings.settings && self.settings.settings.plugins && self.settings.settings.plugins.softwareupdate && !subbed) {
|
||||
subbed = true;
|
||||
self.settings.settings.plugins.softwareupdate.octoprint_release_channel.subscribe(performCheck);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
OCTOPRINT_VIEWMODELS.push({
|
||||
construct: ErrorTrackingViewModel,
|
||||
dependencies: ["settingsViewModel", "loginStateViewModel"]
|
||||
});
|
||||
});
|
||||
@@ -1,21 +1,24 @@
|
||||
<script type="text/javascript">
|
||||
var ERRORTRACKING_ENABLED = {% if plugin_errortracking_enabled -%} true; {% else %} false; {%- endif %}
|
||||
|
||||
$(function() {
|
||||
var ERRORTRACKING_ENABLE = function() {
|
||||
var errortracking_url_coreui = "{{ plugin_errortracking_url_coreui }}";
|
||||
var errortracking_unique_id = "{{ plugin_errortracking_unique_id }}";
|
||||
|
||||
if (ERRORTRACKING_ENABLED) {
|
||||
Sentry.init({
|
||||
dsn: errortracking_url_coreui,
|
||||
release: VERSION
|
||||
});
|
||||
Sentry.configureScope(function (scope) {
|
||||
scope.setUser({"id": errortracking_unique_id});
|
||||
});
|
||||
log.info("Initialized error tracking");
|
||||
Sentry.init({
|
||||
dsn: errortracking_url_coreui,
|
||||
release: VERSION
|
||||
});
|
||||
Sentry.configureScope(function (scope) {
|
||||
scope.setUser({"id": errortracking_unique_id});
|
||||
});
|
||||
ERRORTRACKING_ENABLED = true;
|
||||
log.info("Initialized error tracking");
|
||||
};
|
||||
|
||||
throw Error("Omg!");
|
||||
$(function() {
|
||||
if (ERRORTRACKING_ENABLED) {
|
||||
ERRORTRACKING_ENABLE();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,42 @@
|
||||
<h3>{{ _('Error Tracking') }}</h3>
|
||||
|
||||
{% trans %}
|
||||
<p>
|
||||
Error tracking will cause any logged exceptions in the server and the browser interface to be sent
|
||||
to OctoPrint's <a href="https://sentry.io/" target="_blank" rel="noopener noreferer">Sentry instance</a>.
|
||||
</p>
|
||||
<p>
|
||||
By enabling it you help to gather detailed information on the cause of bugs or other issues. This is especially valuable
|
||||
on release candidates, which is why this plugin will also prompt you to enable error tracking if it detects that
|
||||
you are subscribed to an RC release channel.
|
||||
</p>
|
||||
<p>
|
||||
Please enable this if you are running a release candidate, or are prompted to do so while debugging an issue that you reported.
|
||||
</p>
|
||||
{% endtrans %}
|
||||
|
||||
<form class="form-horizontal">
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: settings.plugins.errortracking.enabled"> {{ _('Enable error tracking') }}
|
||||
</label>
|
||||
<span class="help-block">{{ _('Please reload the page after enabling/disabling & saving') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" title="{{ _('Random unique instance ID') }}">{{ _('Instance ID') }}</label>
|
||||
<div class="controls">
|
||||
<span style="padding-top: 5px; margin-bottom: 5px; display: inline-block" data-bind="text: settings.plugins.errortracking.unique_id() || 'N/A'"></span>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
{% trans %}
|
||||
<p>
|
||||
The Error Tracking plugin is using a Sentry instance kindly provided by
|
||||
<a href="https://sentry.io/" target="_blank" rel="noopener noreferer">sentry.io</a>. For information on their service
|
||||
please refer to their <a href="https://sentry.io/security/" target="_blank" rel="noopener noreferer">Security & Compliance documentation</a>
|
||||
and their <a href="https://sentry.io/privacy/" target="_blank" rel="noopener noreferer">Privacy Policy</a>.
|
||||
</p>
|
||||
{% endtrans %}
|
||||
@@ -196,7 +196,7 @@ def index():
|
||||
|
||||
default_additional_etag = [enable_accesscontrol,
|
||||
enable_gcodeviewer,
|
||||
enable_timelapse]
|
||||
enable_timelapse] + sorted(["{}:{}".format(k, v) for k, v in _plugin_vars.items()])
|
||||
|
||||
def get_preemptively_cached_view(key, view, data=None, additional_request_data=None, additional_unless=None):
|
||||
if (data is None and additional_request_data is None) or g.locale is None:
|
||||
|
||||
@@ -298,7 +298,8 @@ default_settings = {
|
||||
"section_printer", "serial", "printerprofiles", "temperatures", "terminalfilters", "gcodescripts",
|
||||
"section_features", "features", "webcam", "accesscontrol", "gcodevisualizer", "api", "plugin_appkeys",
|
||||
"section_octoprint", "server", "folders", "appearance", "plugin_logging", "plugin_pluginmanager",
|
||||
"plugin_softwareupdate", "plugin_announcements", "plugin_backup", "plugin_tracking", "plugin_pi_support"
|
||||
"plugin_softwareupdate", "plugin_announcements", "plugin_backup", "plugin_tracking", "plugin_errortracking",
|
||||
"plugin_pi_support"
|
||||
],
|
||||
"usersettings": ["access", "interface"],
|
||||
"wizard": ["access"],
|
||||
|
||||
Reference in new issue
Block a user