Skip to content

Commit

Permalink
RDV: Fix the performance issue on AT sites (#41248)
Browse files Browse the repository at this point in the history
* RDV: Fix the performance issue on AT sites

* Redo condition

* Linting

* Simplify condition

* Modified comment a bit

* We now use the constant instead of the option_name variable

---------

Co-authored-by: Richard Ortiz <[email protected]>

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/12951631814

Upstream-Ref: Automattic/jetpack@cbd6957
  • Loading branch information
rcrdortiz authored and matticbot committed Jan 24, 2025
1 parent 68f63c7 commit 8aa29b8
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 92 deletions.
60 changes: 30 additions & 30 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -451,16 +451,24 @@ function wpcom_is_duplicate_views_experiment_enabled() {

$data = json_decode( wp_remote_retrieve_body( $response ), true );

if ( isset( $data['variations'] ) && isset( $data['variations'][ $experiment_name ] ) ) {
if ( isset( $data['variations'][ $experiment_name ] ) ) {
$variation = $data['variations'][ $experiment_name ];
update_user_option( get_current_user_id(), RDV_EXPERIMENT_FORCE_ASSIGN_OPTION, $variation, true );

$is_enabled = 'treatment' === $variation;
return $is_enabled;
} elseif ( isset( $data['variations'] ) ) {
/**
* If the variations array is set but the variation value is null chances are this is an a11n (since ExPlat returns null for a12s).
*
* We set treatment for all a12s.
*/
update_user_option( get_current_user_id(), RDV_EXPERIMENT_FORCE_ASSIGN_OPTION, 'treatment', true );
$is_enabled = true;
} else {
$is_enabled = false;
return $is_enabled;
}

return $is_enabled;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion jetpack_vendor/i18n-map.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
),
'jetpack-mu-wpcom' => array(
'path' => 'jetpack_vendor/automattic/jetpack-mu-wpcom',
'ver' => '6.2.0-alpha1737704139',
'ver' => '6.2.0-alpha1737729110',
),
'jetpack-password-checker' => array(
'path' => 'jetpack_vendor/automattic/jetpack-password-checker',
Expand Down
Loading

0 comments on commit 8aa29b8

Please sign in to comment.