Skip to content

Onboard docs site (docs.gitlab.com) to Product Analytics

Ankit Panchal requested to merge ankit.panchal/add-pa-docs into main

What does this MR do and why?

Dogfooding product analytics into gitlab docs. This will collect Page views.

gitlab#418252 (closed)

Screenshots, screen recordings, or links to review app

Screenshot_2023-10-16_at_4.30.34_PM

How to set up and validate locally

We will be validating page views are being captured in product analytics or not.

  1. Configure a local GitLab Docs environment: https://gitlab.com/gitlab-org/gitlab-docs/-/blob/main/doc/setup.md.
  2. Update CSP's connect-src to allow http else there will be a content security policy error.
  3. Clone the devkit. You need docker desktop or any other docker client installed in local.
git clone git@gitlab.com:gitlab-org/analytics-section/product-analytics/devkit.git && cd devkit && cp cube/.env.sample cube/.env 
  1. Run docker compose up -d
  2. Verify all the containers are running fine.
docker ps -a
  1. Run below API calls. This will setup project locally where events will be collected.
curl -X POST http://localhost:4567/setup-clickhouse -u test:test
curl -X POST http://localhost:4567/setup-project/myproject -u test:test

Output will be something like below

{"app_id":"a2b2959d-5776-4ddf-8392-3e08239aa61f","project_id":"myproject"}
  1. copy the app id and go to gitlab docs directory and export this env variables
export GITLAB_ANALYTICS_HOST=http://localhost:9091
export GITLAB_ANALYTICS_ID=a2b2959d-5776-4ddf-8392-3e08239aa61f
  1. Run make view again in gitlab docs.
  2. There should be an page view events fired as shown in screenshot above.
  3. We can also verify in the Clickhouse database by visiting http://localhost:8123/play?user=test#c2VsZWN0ICogZnJvbSBteXByb2plY3Quc25vd3Bsb3dfZXZlbnRzOw==

Screenshot_2023-10-16_at_4.39.09_PM

Password is test for local setup.

Merge request 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 Ankit Panchal

Merge request reports