Skip to content

Feat/promo tracking send email - #43

Merged
tranh0anghuan merged 2 commits into
testfrom
feat/promo-tracking-send-email
Aug 28, 2026
Merged

tranh0anghuan merged 2 commits into
testfrom
feat/promo-tracking-send-email

Conversation

@tranh0anghuan

Copy link
Copy Markdown
Collaborator

No description provided.

Drumee Dev and others added 2 commits August 27, 2026 14:49
initiate parks `dest` on oauth_state beside ref and utm_*; the callback reads it
back and appends it to the `home` URL it already builds. A signed-out visitor
who clicks a campaign CTA and signs in with Google or Apple now lands where the
link named instead of on a bare desk.

THE DESTINATION GOES ON THE URL, not into storage. The visitor may land on a
different deploy slot from the one they clicked (measured on stage: clicked
/-/huan/, landed /-/), and a fragment could never have reached this server
anyway. ui-team's billing-deep-link consume() already reads a destination off
the URL when storage has none — so nothing changes over there, which was worth
verifying rather than assuming.

ALL THREE SUCCESSFUL EXITS carry it: existing sign-in, new account (the welcome
card's CTA) and 2FA (through the OTP screen). Missing one would make the feature
work for some users and silently not for others.

_sanitiseDest IS A SHAPE CHECK THAT REBUILDS, not an escaping pass: one path,
four params, each matched against its own anchored regex, and the string
assembled again from what survived — so a value can only ever be one this
function could have written. An unknown param is REFUSED rather than dropped,
because honouring half a link written against a contract we do not have is how a
destination becomes a wrong one rather than an absent one. Run at both ends: the
row is data, and the code that builds a template's input is the code that has to
have checked it.

AND THE TEMPLATES NO LONGER INTERPOLATE THAT URL RAW. lib/loby.js renders with
lodash, whose equals-delimiter is the RAW one — the reverse of EJS — so
location.replace('<url>') put request-derived text straight into a JS string
literal on the page that runs immediately after authentication. Both landing
templates now emit it through JSON.stringify, and the new-account CTA through
the escaping delimiter. The sanitiser refusing quotes and the template escaping
are independent; either alone is one edit away from an XSS.

The initiate INSERT now degrades one column-group at a time (dest → utm → ref →
bare) rather than falling straight to the bare row: a database without `dest`
must still keep the campaign. Signing in never depends on any of it.

Two guards in the sanitiser — the character check and the 255 cap — cannot
currently decide anything, verified by mutation: with the path fixed and every
param bounded, the longest value it can emit is 125 chars. They are kept as
defence in depth, and the suite pins the PREMISE instead (every param regex is
anchored and quote-free), so adding a free-text param fails loudly at the moment
those guards start doing real work.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
_sanitiseDest refuses any param it does not recognise — deliberately, so a link
written against a contract this code does not have cannot be half-honoured. That
makes an omission here worse than elsewhere: a destination carrying the campaign
CTA's `for=<tag>` was rejected WHOLE, so the OAuth deep link stopped working
entirely rather than merely losing its marker.

Case-tolerant and normalised to lowercase on rebuild. The server only ever emits
lowercase and the dashboard compares case-insensitively, so refusing an
uppercased tag would kill an entire destination over something neither end cares
about.

An EMPTY `for=` reads as absent rather than malformed, like every other param:
stripping a value is no easier than stripping the whole param, and the marker is
a UX guard rather than a control either way. Stated as its own case because the
first version of that test asserted the opposite — my expectation was wrong, not
the code.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@tranh0anghuan
tranh0anghuan merged commit b40ff35 into test Aug 28, 2026
8 checks passed
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)
15.9% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@github-actions

github-actions Bot commented Aug 28, 2026 •

Copy link
Copy Markdown

Claude encountered an error after 0s —— View job


I'll analyze this and get back to you.

@tranh0anghuan
tranh0anghuan deleted the feat/promo-tracking-send-email branch August 28, 2026 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant