🚧 Guided import metrics 🚧 #1172
Draft
laritakr wants to merge 12 commits into
Draft
Conversation
Creates the bulkrax_import_metrics table with JSONB payload and indexed on metric_type/event/created_at. Adds Bulkrax::ImportMetric model with fire-and-forget record class method and named scopes. Adds ImportMetricsController with a CSRF-exempt record_metric POST endpoint plus protected index/export actions. Wires up three routes: POST guided_import/metrics, GET metrics, GET metrics/export. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Records a validation metric (outcome, row count, error types, duration) in GuidedImportsController#validate after each CSV validation. Tags importers created via the guided flow with parser_fields['guided_import'] = true in #create. Records an import outcome metric (complete/partial/ failed, record counts, first-attempt flag) in Importer#record_status when each import run finishes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds a MetricsTracker module inside the stepper IIFE that manages a session ID, records per-step timestamps, and sends beacon payloads to the metrics endpoint. Wires hooks into initBulkImportStepper (init + step 1 funnel event), goToStep (funnel steps 2-3), validateFiles (validation start timestamp), handleValidationSuccess (validation outcome), and handleImportSubmit (timing summary). Reads the endpoint URL from data-metrics-url on the stepper container, set via guided_import_metrics_path in the view. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Converts handleImportSubmit from a full form post to an AJAX call so the success state can be shown inline without a page navigation. On success, hides the stepper header and form, reveals the .import-success-state div, then fades in the SEQ feedback section after 400ms. Adds SEQ interaction handlers (rating selection, comment reveal, submit, skip/dismiss) that call MetricsTracker.recordFeedback with the returned importer_id. Adds the SEQ HTML to new.html.erb and the _seq_feedback.scss partial (using only existing design tokens) imported in stepper.scss. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds MetricsAggregator service with aggregation queries for total imports, first-attempt success rate, avg validation duration, funnel drop-off, error type frequencies, SEQ distribution, recent comments, and imports-over-time trend data. Adds the dashboard view with a date filter bar, four summary cards, and five tabs: Trends (Flot.js line chart), Funnel (horizontal bar visualization), Errors (Flot.js bar chart + table), User Feedback (SEQ distribution chart + comments), and Recent Imports (DataTable). Loads Flot.js and DataTables from CDN. Handles the empty-state case when no metrics exist yet. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Moves anchor labels out of the flex row and into a separate row below the circles using an inline-flex wrapper. Labels now span exactly the width of the circles row with space-between, keeping "Very Difficult" under circle 1 and "Very Easy" under circle 7 at all viewport widths. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replaces "You'll be notified when it's complete" with "You can monitor progress in the Import Queue" in English and updates the equivalent message in de, es, fr, it, pt-BR, and zh locale files. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit adds a metric which links a guided import to import result. It also includes a configuration option to enable or disable the generation of metrics.
Adjustments to the metrics display and aggregation logic. Adds internatlization. Adds sidebar link & ability method to view. Changes the status message shown in metrics to match the message in the importer show page. Adds database helpers for spec support to handle postgres vs sqlite differences. Finetunes the metrics display.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This work-in-process branch introduces a metrics feature to the guided import process, recording usage, elapsed time, and the types of issues encountered.
A markdown file is included which documents the types of metrics and how to access them.
Use
A sidebar menu option appears to admins & superadmins when the Hyku feature flipper is enabled to capture metrics. This is enabled by a bulkrax config variable (that is on by default). The config variable is separate from the guided import as a whole.
Caveats
The logic is sort of a work in progress and possibly needs fine-tuning. Additional metrics may be needed to be connected, or the reporting calculations may need to be changed.
For example: the first attempt success calculation isn't totally helpful, because it uses the importer's current status message, so a subsequent run could succeed and distort the accuracy. Consider removing importers with multiple runs from the calculation.
Additional reporting may be desired to connect the validation result to the status message, to confirm the accuracy of the validation process.
Another possibility may be to connect the metrics into the original importer as well, so we can compare use and accuracy between the two import options.
Specs
The specs pass locally with ruby 3.3.0 but are failing here on github. That also will require additional work.