Skip to content

Commit 1a7bc64

Browse files
authored
Improve the anonymous path check to support multiple languages (#106917)
1 parent cf29df8 commit 1a7bc64

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

client/lib/analytics/survicate.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,19 @@ export function mayWeLoadSurvicateScript() {
5555
* @returns {boolean} True if the user is on an anonymous path, false otherwise
5656
*/
5757
export function isUserOnAnonymousPaths() {
58-
return [
58+
const pathname = window.location.pathname;
59+
const anonymousPaths = [
5960
'/log-in',
6061
'/setup/onboarding/user',
6162
'/log-in/lostpassword',
6263
'/account/user-social',
6364
'/log-in/link',
6465
'/log-in/qr',
65-
].includes( window.location.pathname );
66+
];
67+
68+
return anonymousPaths.some(
69+
( path ) => pathname === path || pathname.startsWith( `${ path }/` )
70+
);
6671
}
6772

6873
export function addSurvicate() {

client/lib/analytics/test/survicate.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,11 @@ describe( 'survicate', () => {
137137
test.each( [
138138
// Anonymous paths should return true
139139
[ '/log-in', true ],
140-
[ '/setup/onboarding/user', true ],
141140
[ '/log-in/lostpassword', true ],
142141
[ '/account/user-social', true ],
142+
[ '/setup/onboarding/user', true ],
143+
[ '/setup/onboarding/user/pt-br', true ],
144+
[ '/log-in/two-factor', true ],
143145
// Non-anonymous paths should return false
144146
[ '/sites', false ],
145147
[ '/home', false ],

0 commit comments

Comments
 (0)