chore(metrics): Only track 'Loaded a Page' event to Amplitude when userId is known #9193
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Amplitude bills us on MTU (Monthly Tracking User). Last month our MTU is a little bit above the limit of 100K however our MAU is only at 60K. Upon investigation, I found that there were enough anonymous users triggering the page view events. For example, this user just visited parabol.co, this user run a demo, and this user reset the password. They were not registered or logged in. Amplitude count them as distinct users, causing our MTU spikes.
Eventually we would like to have the anonymous traffic in Amplitude too (majority being from www.parabol.co) so we can do full channel analysis but today is not the date yet (plus we can achieve similar functionality by GA).
This simple change just assure that only when the
userId
is known that we sentLoaded a Page
event to Amplitude. This way the MTU should be in line with our MAU so we have more buffer below the 100K threshold.Testing scenarios
Loaded a Page
event is sentFinal checklist
One Review Required
if the PR introduces only minor changes, does not contain any architectural changes or does not introduce any new patterns and I think one review is sufficient'