Add user_id to SDK on .com & Limit snowplow events in storage
What does this MR do and why?
Implements gitlab-org/analytics-section/product-analytics/gl-application-sdk-browser#40 (closed) / #425948 (closed) & #415556 (closed)
This MR sends user_id
field to Browser SDK. We have added pseudonymization in the previous MR
We are now limiting snowplow events stored in localStorage to 100 instead of 1000 (default) , I have already updated that limit for Browser SDK in MR
How to set up and validate locally
Here, We need to verify that user_id is being passed via Browser SDK. We have tested pseudonymization working in previous MR and snowplow is limited to 100 in local storage.
Validate user_id is being passed:
- Make sure snowplow micro is running along with GDK. here are the steps to run it. Make sure it is not running on 9091 as browser sdk collector is running on that port.
- Setup devkit in local.
- Enable feature flag
browsersdk_tracking
andgl_analytics_tracking
rails c
Feature.enable(:browsersdk_tracking)
Feature.enable(:gl_analytics_tracking)
-
This feature will only be supported for Gitlab.com, so make sure you make
Gitlab.com?
method to true inlib/gitlab.rb
and restart gdk.def self.com? true end
-
Create project in devkit with below curl and copy the app_id received.
curl -X POST http://localhost:4567/setup-project/[project_name] -u test:test
-
Setup below env variables in gdk terminal and restart gdk.
export GITLAB_ANALYTICS_URL=http://localhost:9091
export GITLAB_ANALYTICS_ID=<app_id received from step 5>
- On browser, reload any page. Check snowplow plugin tab, there will be user id being passed.
Validate local storage limit :
Prerequisite: Install an ad blocker in your browser (I've tried it with uBlock). This will block all the snowplow request and it will be pushed to local storage.
- Just to verify that the limit on localStorage is working correctly, change the limit to 1 instead of 100 here
- Verify that in the
snowplowOutQueue_gl_post2
key of localStorage maximum one event is being present even after multiple reloads.
MR 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 MR.
Related to #415556 (closed)