Repository navigation
Commit b6d95f2
authored
SEO: Record a Tracks event when Google one-click verify saves the code (#53798)
* SEO: Record a Tracks event when Google one-click verify saves the code
Google auto-verify saved the verification code through its own request,
so it never fired jetpack_seo_setting_updated, and only mirrored the code
into unsaved form state. The next verification save then re-sent the code
and recorded it late.
The settings form now saves the code for it (saveVerification), records
it like a form save (only when the code changed, or the failure event if
the save fails), and adopts it as saved in the form and the settings store.
* SEO: Keep the auto-verified Google code when a form save finishes later
saveValues adopted its whole start-of-save snapshot as the new baseline
and store state. A Google code saveVerification adopted while that save
was in flight was rolled back, so the code looked unsaved again and the
next verification save recorded it a second time. Adopt only the fields
the save sent.
Also cover the hook's save-then-verify order and its stop on a failed
save, and correct wording that claimed later saves don't re-send the
code: the section save still sends the full map; it no longer counts
the code as a change.
* SEO: Send only changed verification codes and patch the latest store snapshot
A verification-section save sent the whole code map and adopted it as
saved, so finishing after a Google auto-verify could overwrite the new
code on the server and roll it back in the form. The server merges
submitted codes over the stored ones, so send and adopt only the codes
that changed.
Every write to the settings store now patches its latest snapshot
instead of replacing it with the writing form's own baseline, so a form
left on another tab mid-save can't roll back what a newer one saved.
* SEO: Serialize Google auto-verify with form saves
The server merges verification codes without a lock, so a form save
overlapping saveVerification could drop the new code, and a form save's
post-save re-read arriving after it could roll the code back in the form
and store.
saveVerification now waits for the save in flight, re-read included, and
holds isSaving during its own request so the form's controls stay locked.
A re-read also applies only the codes its save changed, which covers a
form left on another tab, where the two don't share a queue.
* SEO: Queue form saves behind Google auto-verify too
The isSaving lock saveVerification takes disables a focused code field,
and in Chrome that fires blur, which starts a section save while the
Google save is still running. saveValues didn't wait for it, and either
save's finally could clear isSaving while the other still ran.
Form saves now queue behind the save in flight as well (their payload is
still computed when called, and applied only to the codes they changed),
and isSaving holds until the last queued save settles.
* SEO: Lock the manual Google code field during auto-verify
A code typed into the manual Google field while auto-verify was running
got saved by the blur the form lock fires, queued right after the token,
and replaced it, so Google could not find the token it was asked to
verify. Disable that field while auto-verify runs; clicking Verify
already blurs it, so a code typed before the click saves first.
* SEO: Lock the manual Google field only once the popup returns
Locking it for the whole auto-verify left it disabled until reload when
the browser blocked the popup, which never returns, taking away the
manual fallback. Lock it from the moment the popup returns a keyring
instead: a code typed while the popup was open is then saved by the
lock's blur before the token save is queued, so the token still wins.
* SEO: Word the Google field lock comment without relying on blur
Whether disabling a focused field fires blur differs by browser, so state only what the lock guarantees.1 parent 6d11b2b commit b6d95f2
14 files changed
Lines changed: 644 additions & 72 deletions
File tree
- projects/packages/seo
- _inc
- data
- test
- screens/settings
- test
- changelog
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
48 | 47 | | |
49 | 48 | | |
50 | 49 | | |
51 | 50 | | |
52 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
53 | 70 | | |
54 | 71 | | |
55 | 72 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
96 | 90 | | |
97 | | - | |
| 91 | + | |
98 | 92 | | |
99 | 93 | | |
100 | 94 | | |
| |||
107 | 101 | | |
108 | 102 | | |
109 | 103 | | |
110 | | - | |
| 104 | + | |
111 | 105 | | |
112 | 106 | | |
113 | 107 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
0 commit comments