- ID
- 2b71882b-f34c-48e6-9b75-8167b1683ec8
BE-7134 Create constants for Segment event names used in pre-checkout training
- source :: https://hungryroot.atlassian.net/browse/BE-7134
- tags :: Hungryroot API Project
- epic :: EP-411 Eng Parking Lot
- sprint :: HR BE Sprint 104
- status :: Status - To Do
Description
Currently, Segment event names are passed as raw strings throughout the codebase
wherever enqueue_segment_precheckout_trk, enqueue_segment_ecommerce_track,
track_segment_event, and enqueue_segment_track are called. This is error-prone
(typos go undetected) and makes it hard to audit which events we send or rename
them consistently.
Proposed Change:
Add a constants class (e.g., SegmentEventName) in app/const.py — following the
same pattern as DataDogMetrics — that defines all Segment event names as class
attributes. Then replace all raw string usages across the codebase with the
corresponding constant.
Example event names to capture (from current usage):
Via enqueue_segment_precheckout_trk:
"Signed In" — login (Facebook, Google, Apple, email)
"Completed Registration" — signup (Facebook, Google, Apple, email)
"Order Completed" — checkout in app/views/api.py
"Reactivation" — plan reactivation in app/services/api/plan.py
"Checkout Started" — checkout start in app/services/api/analytics.py
Via track_segment_event:
"Cart Viewed" — cart view in app/views/api.py
"Product Added" — add to cart in app/rest/cart.py
Via enqueue_segment_ecommerce_track:
"Product List Filtered" — product/pairing list filtering in
app/services/api/product.py, app/services/api/pairing.py,
app/rest/shared/segment_service.py
Via enqueue_segment_track:
"Get Cancel Winback" — cancel winback in app/services/cancel_winback.py
"Accept Cancel Winback" — accept winback in app/services/cancel_winback.py
"submitted_delivery_rating" — delivery feedback in
app/services/shared/order_feedback_question.py
Credit-related event name (dynamic) in app/services/pricing/credit_manager.py
Acceptance Criteria:
All Segment event name strings used across the codebase are replaced with
constants from SegmentEventName
No raw string event names remain in production code (test assertions may
reference the constants)
Existing tests pass with no behavior change
The Literal type overloads in segment_tracking.py are updated to use the
constant values