Skip to content

fix: Limit queued events in Local storage

Ankit Panchal requested to merge 40-limit-local-storage-queue into main

#40 (closed)

This MR limits number of events events queued up in local storage.

the snowplow option docs

Steps to verify:

Prerequisite: Install an ad blocker in your browser (I've tried it with uBlock).

Before changes from this MR :

  1. Run yarn examples:serve in Browser SDK. It should open test app in localhost:8080

  2. Accept cookie banner and click on Track Event and Track Error button multiple times.

  3. If adblocker is installed correctly, all the events API calls should be failing.

    Screenshot 2023-10-28 at 3.36.41 PM.png

  4. Go to Applications Tab and Check in the localStorage , For key snowplowOutQueue_gitlab_post2 verify that events are being queued. As per snowplow maximum limit of such queue is 1000

    Screenshot 2023-10-28 at 3.38.33 PM.png

  5. This raises an issue because currently in .com we have two versions of snowplow running and it can exhaust localStorage's maximum limit ~5MB very quickly.

  6. As a workaround, I have changed limit to 100 which should provide enough space for other data.

After This MR's Change:

  1. Just to verify that the limit on localStorage is working correctly, change the limit to 1 instead of 100

  2. Run yarn build and then yarn examples:serve again.

  3. Verify that in the snowplowOutQueue_gitlab_post2 key maximum one event is being present.

    Screenshot 2023-10-28 at 3.46.45 PM.png

Edited by Ankit Panchal

Merge request reports