Skip to content

Store jitsu js code on project after initialization

Max Woolf requested to merge mw/store-jitsu-js-code-on-project into master

What does this MR do and why?

  • In Add interface to create analytics stack for pro... (!95999 - merged) we created an interface by which a GitLab project can initialize the required Jitsu configuration via a service object.
  • However, in that MR we didn't pass the generated JS token back to GitLab which will need to be displayed to the user.
  • This MR adds a new database column to Project and stores the value there.

How to set up and validate locally

  1. Set up the devkit and start it running. docker-compose up

  2. In this branch, run rails c to open the rails console

  3. Enable the feature flag

    Feature.enable(:cube_api_proxy)
  4. Set the required application settings:

    The Jitsu attributes are set up when first configuring your jitsu instance.

    ApplicationSetting.current.update(jitsu_project_xid: 'XXXXXXXXXX', jitsu_host: 'http://localhost:8000', clickhouse_connection_string: 'http://test:test@clickhouse:8123', jitsu_administrator_email: 'XXXXXXX', jitsu_administrator_password: 'XXXXXXX')
    reload!
  5. Find a project on the console: project = Project.find(PROJECT_ID)

  6. Run ProductAnalytics::InitializeStackService.new(container: project).execute

  7. Ensure that a sidekiq job was enqueued.

  8. Check the project and make sure that the Jitsu key has been stored: project.project_setting.jitsu_key

  9. In the Jitsu configurator, ensure that a new API key (with the project ID) has been created, along with a new associated connection to a clickhouse destination. 👇

Screenshot_2022-08-23_at_14.39.47

MR acceptance checklist

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

/related #371206 (closed)

Edited by Dennis Tang

Merge request reports