Repository navigation
fix: Send abandoned cart emails, keep product views and TikTok server events working - #862
Merged
Merged
Conversation
The carts were listed without items and subtotal, which the email template reads, so rendering failed for every cart. Failed carts were not flagged and came back on every exec. Only carts up to 7 days past the abandon delay are emailed now, so the backlog of unflagged carts doesn't get old recovery emails all at once. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01AzZmcNMuAAjtyPLYYbnJBX
…t IDs The product ID check was unanchored, so IDs with injection payloads appended were stored on ssrProductViews. The save views cron stopped on the API 406 for that doc on every exec, leaving all other views unsaved. The ID must now be exactly 24 hex chars, and the cron drops docs on any 4xx other than 429 instead of stopping. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01AzZmcNMuAAjtyPLYYbnJBX
The client tagged TikTok events as 'ttk' while the server groups them by 'ttq', so server-side TikTok events were never sent. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01AzZmcNMuAAjtyPLYYbnJBX
…re rejected Only drops view docs on 4xx that can't succeed later, 401 and 403 now stop the run like before so views aren't lost while credentials are fixed. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01AzZmcNMuAAjtyPLYYbnJBX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Three small fixes for errors found in the stores' Cloud Logging (last 7 days).
Abandoned cart emails were never sent
cron-cart-emails.tslisted carts withoutitemsandsubtotal, but theabandoned-carttemplate reads both (partials/cartitems.ejs→cart.items.forEach). Rendering failed for every cart since the feature shipped. Failed carts are not flagged, so the same 200 came back on every exec: ~47k log entries/day on demo and tiasonia, ~16k on barradoce.The cron now also limits carts to 7 days past the abandon delay (
updated_at>). Without that, the first exec after this fix would send recovery emails for months-old carts that piled up unflagged. Checked on the Store API thatupdated_at<+updated_at>filter as a range.Product views stuck on barradoce
The product ID check on
/_analyticswas unanchored (/[0-9a-f]{24}/), so bot IDs with SQL injection appended were stored onssrProductViews.cronSaveViewsgot a 406 on that doc andbreaks on any non-404 error, on every exec (169 errors/week), so no views were saved. The ID must now be exactly 24 hex chars, and the cron drops docs on any 4xx except 429 (which already removes the stuck doc).TikTok server events never sent
The client sent
type: 'ttk'while the server groups byttq(the declared type is already'ttq', hidden byas any). Only tiasonia hasTIKTOK_PIXEL_ID/TIKTOK_ACCESS_TOKENset. Sending failures are already caught byPromise.allSettled.Checks
tsc --noEmitonssrandapp-emails, eslint on the changed files.🤖 Generated with Claude Code
https://claude.ai/code/session_01AzZmcNMuAAjtyPLYYbnJBX