Onboard docs site (docs.gitlab.com) to Product Analytics
What does this MR do and why?
Dogfooding product analytics into gitlab docs. This will collect Page views.
Screenshots, screen recordings, or links to review app
How to set up and validate locally
We will be validating page views are being captured in product analytics or not.
- Configure a local GitLab Docs environment: https://gitlab.com/gitlab-org/gitlab-docs/-/blob/main/doc/setup.md.
- Update CSP's connect-src to allow
http
else there will be a content security policy error. - 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
- Run
docker compose up -d
- Verify all the containers are running fine.
docker ps -a
- 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"}
- 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
- Run
make view
again in gitlab docs. - There should be an page view events fired as shown in screenshot above.
- We can also verify in the Clickhouse database by visiting http://localhost:8123/play?user=test#c2VsZWN0ICogZnJvbSBteXByb2plY3Quc25vd3Bsb3dfZXZlbnRzOw==
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.
-
I have evaluated the MR acceptance checklist for this merge request.
Edited by Ankit Panchal