Repository navigation
fix(rokt): read form email only once committed and unfocused, and require two-letter TLD - #1778
crisryantan wants to merge 8 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## v3-development #1778 +/- ##
=================================================
Coverage ? 64.20%
=================================================
Files ? 79
Lines ? 10722
Branches ? 3109
=================================================
Hits ? 6884
Misses ? 3514
Partials ? 324
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
… email field Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ield Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… a blur A trusted blur can follow a script that set the field silently, so restoring a committed field on blur could read the script's value. The field now waits for the next trusted change, without the listener reading any value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mattbodle
left a comment
There was a problem hiding this comment.
Automated agent review; not an independent human approval.
Head e3bfb36. Moving focus after a script sets the value fires a trusted blur and no change, in Chrome, Firefox, and WebKit, and that blur still sends that value. Not an approval.
Kit Tests: Amplitude 8 is failing. Safari was not driven. The full kit suite was not run locally.
…commit A blur on a field committed before it had focus flushed pending pre-selection dispatches too, reading a value a script may have set silently since. Only the blur that ends a change heard while the field had focus retries now, once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A script could keep the blur that ended a focused commit and dispatch it again after rewriting the field. A replayed event is untrusted, so it never retries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mattbodle
left a comment
There was a problem hiding this comment.
Automated agent review; not an independent human approval.
Head 028da73.
A change while a field has focus, then a script sets another value, then blur, still sends that value. The previous code does not flush on that blur. BrowserStack Test fails an identity custom-device assertion on Firefox 51. Safari was not driven.
Any blur can follow a script that set the field silently, and the listener reads no values to tell the two apart. A field committed while focused now waits for the next trigger or checkout commit intent, as before blur was heard. Blur still drops a field no change committed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mattbodle
left a comment
There was a problem hiding this comment.
Automated agent review; not an independent human approval.
Head c10bc8f.
A focused commit does not flush, but the change fired when focus later leaves still sends a value written after that commit. The base sends the focused commit. Not an approval.
| // Notes which fields the shopper types into or autofills, reading no value, and retries on a committed | ||
| // change. The form's own gates run before the changed field's value is read. | ||
| // change. A blur only drops a field no change committed. The form's own gates run before the changed | ||
| // field's value is read. |
There was a problem hiding this comment.
A change that fires after focus leaves still flushes the field's current value. A commit while the field is focused does not. A value written between them is what this change sends, where the base sends the focused commit.
Why
When pre-selection scans a form while a shopper is still typing an email address, keystroke
inputevents can capture a partial address that differs from the completed email sent on the confirmation page, causing a cache key mismatch on the email attribute. Reading the field only after a trustedchangeevent when the field is no longer focused (or on a checkout commit intent), and requiring a multi-character top-level domain, avoids capturing partial emails mid-typing.Programme
Standalone change, no programme.
What changes
recordShopperInputrecords an email candidate inshopperInputson a trustedchangeevent, removes it if a laterinputor other event fires before the nextchange, and removes an uncommitted candidate fromtouchedInputsonblur. Ablurnever marks a field finished, since a script can set the value silently first; only a trustedchangedoes, and the listener still reads no value.Rokt-Kitlistens for captureblurevents alongsideinputandchangeonly so a blur drops a field nochangecommitted. A blur never flushes pending dispatches, since a script can set the value silently before it; a field committed while focused waits for the next trigger or checkout commit intent.isEmailInputskipsdocument.activeElement, andscanFormEmailsskipsdocument.activeElementon background reads while reading a focused committed field on a checkout intent signal, counting an unsettled touched field toward the two-email rule when it istype="email", hasautocomplete="email", is mid-edit after a committedchange, or holds@(testing a text field's value only for@), and reportinguncommitted_fillindescribeMissingEmail.EMAIL_PATTERNrequires a top-level domain of two or more ASCII letters, a punycodexn--label, or two or more non-whitespace, non-separator Unicode characters.inputevents, re-editing a completed field and blurring without achange(including after a silent script write), focused inputs never flushing onblur(including after a silent script write) and firing oncommitintent, unsettled second fields in the ambiguity check, anduncommitted_fill.Linked work
Rollout
No flag. Rollback is a revert.
Risks
changefires and the field is not focused, or while focused when checkout commit intent fires. A trustedchangeon an unfocused email field flushes pending pre-selection dispatches; ablurnever does.Who
Written by: an automated coding agent.
Checked: CI runs the kit's Vitest suite (
mparticle-web-kit-tests) on this change. It was not run on the authoring machine.Size
Hand-written: 4 files, 466 lines added and 71 removed.