Add extra required data to the track_event call when creating a school#899
Conversation
Test coverage92.05% line coverage reported by SimpleCov. |
| 'School - Created', | ||
| school_id: @school.id, | ||
| first_landing_page: params[:first_landing_page], | ||
| marketing_parameters: marketing_parameters |
There was a problem hiding this comment.
I'm wondering if it would be easier to query in the data warehouse if all of the event properties were at the same level. It might just be harder to document and query if some are nested inside other attributes. This means we could query on events.properties['utm_source'] rather than events.properties['marketing_params']['utm_source'].
You should be able to do this by spatting the marketing parameters:
track_event('School - Created', **marketing_parameters, @school.id:, first_landing_page: params[:first_landing_page])
zetter-rpf
left a comment
There was a problem hiding this comment.
Great. added a suggestion - let me know if you think it's worth doing.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 390cb3a. Configure here.
There was a problem hiding this comment.
Pull request overview
This PR updates the school creation analytics event so additional attribution metadata is included when a school is created via the REST API.
Changes:
- Expands the
School - Createdtrack_eventcall to includefirst_landing_pageand flattened marketing parameters. - Adds a request spec asserting that
marketing_parameterskeys become top-level event properties (and the nested hash is not stored).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| spec/features/school/creating_a_school_spec.rb | Adds coverage ensuring marketing parameters are recorded as top-level event properties. |
| app/controllers/api/schools_controller.rb | Extends School - Created event tracking to include marketing attribution fields. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
zetter-rpf
left a comment
There was a problem hiding this comment.
The track_event call looks good
I saw the comments from cursor and copilot - do you think they could be problems?
| marketing_parameters.merge( | ||
| school_id: @school.id, | ||
| first_landing_page: params[:first_landing_page] | ||
| ) |
| track_event( | ||
| 'School - Created', | ||
| marketing_parameters.merge( | ||
| school_id: @school.id, | ||
| first_landing_page: params[:first_landing_page] | ||
| ) | ||
| ) |
|
|
||
| properties = Event.last.properties |

Status
Description of what's been done
first_landing_pageandmarketing_preferencedata when saving the School - Created event