Skip to content

🚧 Guided import metrics 🚧 #1172

Draft
laritakr wants to merge 12 commits into
mainfrom
guided-import-metrics
Draft

🚧 Guided import metrics 🚧 #1172
laritakr wants to merge 12 commits into
mainfrom
guided-import-metrics

Conversation

@laritakr

@laritakr laritakr commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

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.

Screenshot 2026-04-10 at 2 05 24 PM Screenshot 2026-04-10 at 2 05 38 PM Screenshot 2026-04-10 at 2 24 39 PM

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.

It finds all import_outcome metrics where payload.is_first_attempt is true, then checks how many of those importers currently have status_message = 'Complete' in the bulkrax_importers table.

So: successes / total first-attempt imports × 100

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.

laritakr and others added 12 commits April 3, 2026 16:37
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

minor-ver for release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant