Add and enforce analytics naming convention#9318
Conversation
zachmargolis
left a comment
There was a problem hiding this comment.
LGTM! 🚀
(Assuming the existing exceptions will be added before merging?)
docs/backend.md
Outdated
There was a problem hiding this comment.
They're there, but the changes are extensive so GitHub's changes preview collapses the file. |
changelog: Internal, Analytics, Add new naming convention for analytics events
70947c9 to
5bfcff1
Compare
matthinz
left a comment
There was a problem hiding this comment.
Question: Would track_event(__method__) be acceptable or is that too opaque? (For the record, I am 👍 with this PR as-is)
Hmm, interesting idea! I don't personally mind it. It does come close to being "clever" programming, but I can't really imagine a scenario where I'd probably lean toward keeping this as-is, but I don't feel strongly at all; mostly just care about having it be consistent. |
soniaconnolly
left a comment
There was a problem hiding this comment.
LGTM. Thanks for doing this!
I can imagine that in the future we might want to require the method name as the first part of the analytics name and allow additional words afterward, but we can always add that later if we find we want it.
I'd be curious what this would look like, since my instinct would be that if it should be included in the event name, it could / should also be reflected in the method name? |
|
Thanks all for the feedback! As mentioned in Slack, I'll plan to merge this and we can see how it works out. I'll also try to search for open pull requests that might fall victim to this if merged to main without accounting for the new linter. |
🛠 Summary of changes
Adds a new custom Rubocop linter to enforce a naming convention for analytics, expecting that the first argument to
track_eventshould be a symbol with the same name as the method.Good:
Bad:
This was discussed in Engineering Huddle 2023-10-05 (see notes).
The proposal here would not retroactively update existing analytics, but would enforce against all new analytics events moving forward. This is done by adding inline Rubocop disabling for existing events.
📜 Testing Plan