diff --git a/docs/events/index.rst b/docs/events/index.rst index eeaac5869..2250d402f 100644 --- a/docs/events/index.rst +++ b/docs/events/index.rst @@ -588,6 +588,7 @@ SlicingStarted Payload: + * ``slicer``: the used slicer * ``stl``: the STL's filename * ``stl_location``: the STL's location * ``gcode``: the sliced GCODE's filename @@ -599,6 +600,7 @@ SlicingDone Payload: + * ``slicer``: the used slicer * ``stl``: the STL's filename * ``stl_location``: the STL's location * ``gcode``: the sliced GCODE's filename @@ -611,6 +613,7 @@ SlicingCancelled Payload: + * ``slicer``: the used slicer * ``stl``: the STL's filename * ``stl_location``: the STL's location * ``gcode``: the sliced GCODE's filename @@ -621,6 +624,7 @@ SlicingFailed Payload: + * ``slicer``: the used slicer * ``stl``: the STL's filename * ``stl_location``: the STL's location * ``gcode``: the sliced GCODE's filename diff --git a/src/octoprint/filemanager/__init__.py b/src/octoprint/filemanager/__init__.py index 2c7ff6161..6551d7090 100644 --- a/src/octoprint/filemanager/__init__.py +++ b/src/octoprint/filemanager/__init__.py @@ -329,16 +329,18 @@ class FileManager(object): printer_profile_id, callback, callback_args, _error=None, _cancelled=False, _analysis=None): try: if _error: - eventManager().fire(Events.SLICING_FAILED, dict(stl=source_path, - stl_location=source_location, - gcode=dest_path, - gcode_location=dest_location, - reason=_error)) + eventManager().fire(Events.SLICING_FAILED, dict(slicer=slicer_name, + stl=source_path, + stl_location=source_location, + gcode=dest_path, + gcode_location=dest_location, + reason=_error)) elif _cancelled: - eventManager().fire(Events.SLICING_CANCELLED, dict(stl=source_path, - stl_location=source_location, - gcode=dest_path, - gcode_location=dest_location)) + eventManager().fire(Events.SLICING_CANCELLED, dict(slicer=slicer_name, + stl=source_path, + stl_location=source_location, + gcode=dest_path, + gcode_location=dest_location)) else: source_meta = self.get_metadata(source_location, source_path) hash = source_meta.get("hash", "n/a") @@ -356,11 +358,12 @@ class FileManager(object): printer_profile=printer_profile, analysis=_analysis) end_time = octoprint.util.monotonic_time() - eventManager().fire(Events.SLICING_DONE, dict(stl=source_path, - stl_location=source_location, - gcode=dest_path, - gcode_location=dest_location, - time=end_time - start_time)) + eventManager().fire(Events.SLICING_DONE, dict(slicer=slicer_name, + stl=source_path, + stl_location=source_location, + gcode=dest_path, + gcode_location=dest_location, + time=end_time - start_time)) if callback is not None: if callback_args is None: @@ -381,7 +384,8 @@ class FileManager(object): slicer = self._slicing_manager.get_slicer(slicer_name) start_time = octoprint.util.monotonic_time() - eventManager().fire(Events.SLICING_STARTED, {"stl": source_path, + eventManager().fire(Events.SLICING_STARTED, {"slicer": slicer_name, + "stl": source_path, "stl_location": source_location, "gcode": dest_path, "gcode_location": dest_location, diff --git a/src/octoprint/plugins/tracking/__init__.py b/src/octoprint/plugins/tracking/__init__.py index 4a89a98ba..732ebefbe 100644 --- a/src/octoprint/plugins/tracking/__init__.py +++ b/src/octoprint/plugins/tracking/__init__.py @@ -67,7 +67,8 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin, update=True, printer=True, printer_safety_check=True, - throttled=True)) + throttled=True, + slicing=True)) def get_settings_restricted_paths(self): return dict(admin=[["enabled"], ["unique_id"], ["events"]], @@ -121,6 +122,9 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin, self._record_next_firmware_info = False self._track_printer_event(event, payload) + elif event in (Events.SLICING_STARTED,): + self._track_slicing_event(event, payload) + elif hasattr(Events, "PLUGIN_PLUGINMANAGER_INSTALL_PLUGIN") and \ event in (Events.PLUGIN_PLUGINMANAGER_INSTALL_PLUGIN, Events.PLUGIN_PLUGINMANAGER_UNINSTALL_PLUGIN, Events.PLUGIN_PLUGINMANAGER_ENABLE_PLUGIN, Events.PLUGIN_PLUGINMANAGER_DISABLE_PLUGIN): @@ -367,6 +371,13 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin, printer_safety_warning_type=payload.get(b"warning_type", "unknown"), printer_safety_check_name=payload.get(b"check_name", "unknown")) + def _track_slicing_event(self, event, payload): + if not self._settings.get_boolean(["events", "slicing"]): + return + + self._track("slicing_started", + slicer=payload.get(b"slicer", "unknown")) + def _track(self, event, **kwargs): if not self._settings.get_boolean([b"enabled"]): return diff --git a/src/octoprint/plugins/tracking/templates/tracking_settings.jinja2 b/src/octoprint/plugins/tracking/templates/tracking_settings.jinja2 index 570038309..9d1d572a9 100644 --- a/src/octoprint/plugins/tracking/templates/tracking_settings.jinja2 +++ b/src/octoprint/plugins/tracking/templates/tracking_settings.jinja2 @@ -46,6 +46,9 @@ +