Add analytics support #145
Merged
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.
This... is a large PR and includes a few refactorings to make the code more accessible and easier to plug the analytics into.
All analytics are published by the interface backend. However, the metadata it needs comes from a variety of sources.
At startup, the configurator now starts a new container using its own image and mounts the Docker Desktop backend socket to obtain the user IDs of the logged in user and the current setting for the "allow usage analytics" setting. This, as well as a variety of other fields are stored in a
metadata.jsonfile in thelabspace-supportvolume that is also mounted into the interface service.It is recognized that the
idfield can easily be spoofed by other authors, but so can any of the analytic events at this point. We may consider creating a custom GitHub Action that is used to publish Labspaces, where some sort of validation could be applied. But again, that's easily worked around (by not using the action). Longer term, we may look at signing of the images and creating rules around identifiers in relation to the signing authority/subjects. But that's a conversation for another day.Notably, if a user has disabled usage tracking in Docker Desktop at the time the Labspace starts or is running in a non-Docker Desktop environment, no event tracking will be performed. The user must explicitly have usage tracking enabled.
Development environment changes
This PR also adds a
merlin-mockservice. This service is added to the development Compose stack and the interface backend is configured to send events to it. This mock interface provides a frontend to display the events that were published.Update to the
labspace.yamlschemaThis change also forces an update to the
labspace.yamlschema. The newmetadatablock provides additional metadata needed for analytics. When the fields aren't set, the analytics will default their value tounknown. We can determine in the future whether we skip events on unknown labs or not.