Skip to content

Commit

Permalink
Boost: Fix sending multiple tracks when speed score changes (#40700)
Browse files Browse the repository at this point in the history
* Fix sending multiple tracks when speed score changes

* Fix sending speed score changed tracks when popup was dismissed

* add changelog

---------

Co-authored-by: Adnan Haque <[email protected]>
  • Loading branch information
dilirity and haqadn authored Dec 20, 2024
1 parent e564fe0 commit 8109ade
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { animated, useSpring } from '@react-spring/web';
import CloseButton from '$features/ui/close-button/close-button';
import styles from './pop-out.module.scss';
import { __ } from '@wordpress/i18n';
import { ReactNode, useState } from 'react';
import { ReactNode, useState, useEffect } from 'react';
import { Button } from '@wordpress/components';
import { useDismissibleAlertState } from '$features/performance-history/lib/hooks';
import { getRedirectUrl } from '@automattic/jetpack-components';
Expand Down Expand Up @@ -77,11 +77,13 @@ function PopOut( { scoreChange }: Props ) {

const hideAlert = () => setClose( true );

if ( hasScoreChanged ) {
recordBoostEvent( 'speed_score_alert_shown', {
score_direction: scoreChange > 0 ? 'up' : 'down',
} );
}
useEffect( () => {
if ( hasScoreChanged && ! isDismissed && ! isClosed ) {
recordBoostEvent( 'speed_score_alert_shown', {
score_direction: scoreChange > 0 ? 'up' : 'down',
} );
}
}, [ hasScoreChanged, scoreChange, isDismissed, isClosed ] );

const animationStyles = useSpring( {
from: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fixed
Comment: Fix for an unreleased change.


0 comments on commit 8109ade

Please sign in to comment.