Skip to content

Use namespace from project if none provided to track_event

Jonas Larsen requested to merge j_lar/use_namepspace_from_project into master

What does this MR do and why?

We would like to make it easier to send as much of the standard context (user, project, namespace) as possible when using Gitlab::InternalEvents.track_event.

In most cases the project belongs to the namespace.

This MR adds the convenience that you can now call

Gitlab::InternalEvents.track_event('my_event', user: user, project: project)

instead of

Gitlab::InternalEvents.track_event('my_event', user: user, project: project, namespace: project.namespace)

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Start the monitor by running rails runner scripts/internal_events/monitor.rb ci_template_included
  2. In another terminal run gdk rails console and trigger an event with Gitlab::InternalEvents.track_event('ci_template_included', project: Project.first, user: User.first)
  3. In the monitor, verify that the new Snowplow event has namespace filled out.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Jonas Larsen

Merge request reports