Page MenuHomePhabricator

Add import/export functionality for events
Open, Needs TriagePublic

Description

When we want to diagnose an issue in production (or staging for that matter), we will often want to reproduce it on our local for easier debugging. This is tedious to do if there are a lot of participants, for example. You'd need to copy/paste them one by one. We should add some import/export functionality.

The import part should probably only work in local environments. We discussed this in an engineering meeting a while back and the idea came about to provide a URL to the target event. So you'd manually browse to the import URL, something like:

http://localhost:8000/events/import?url=https://eventmetrics.wmflabs.org/events/export/123

where /import only works in a development environment. /export would return a JSON blob.

The /export endpoint doubles as a partial solution to T192738: Add an API to get/create/update programs and events, covering the GET aspect. Clients can interpret the result however they wish. They of course will need to be logged in for it to work.

I do not think we need to do the same for programs, but we could.

The key to making this work I believe is with the Symfony Serializer Component.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Almost got this finished. It will make debugging all those other bug reports much easier!

This turned into a rabbit hole. Exporting an event was super easy, and importing *would* be fine except the development server isn't logged in to production, so it can't access the event you give it. We'd need to use JavaScript or something so that it uses your login cookie.

WIP at https://github.com/wikimedia/eventmetrics/compare/import-export-events?expand=1

As a workaround, you can open up the JS console while viewing an event summary page, and use the following code to copy the participants to the clipboard:

copy($('.event__participants input').toArray().map(e => e.value).join('\n'));

Then you can paste it into the participant form on your local. Other things like the event settings and categories are much easier to copy manually.