Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Organic Sessions widget #22073

Merged
merged 38 commits into from
Mar 5, 2025
Merged

Conversation

igorschoester
Copy link
Member

@igorschoester igorschoester commented Feb 25, 2025

Context

  • Implement the organic sessions widget. Which has two parts: comparison with trend and a daily chart.

Summary

This PR can be summarized in the following changelog entry:

  • Adds the Organic Sessions widget to the dashboard.

Relevant technical choices:

  • The trend has some edge cases:
    • No current/previous sessions => fall back to NaN
    • Formatting sessions => fall back to 0, so the current sessions number will not have an ugly NaN on screen
    • For the difference/trend:
      • Any falsy (except number zero) => NaN
      • Same value => 0 (0%, but we hide this in the component)
      • Previous number zero (divide by 0 case) => 1 (100%)

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

  • Make sure you have an environment with site kit configured with analytics.
  • Make sure site kit is not connected to yoast.
  • Connect to site kit and check you see the organic sessions widget with data.
  • Check the space between the ticks and the chart match the design.
  • Check the font weight and sizes are matching the design.
  • Check the error message is not duplicated if it's the same for both change and daily data. You can do that by opening the network tab in the devtools and change connection to offline. Change the tab to Alert center and go back to the Dashboard.
  • Check the widget title is "Organic sessions"
  • Check the tooltip has the text: "The number of organic sessions that began on your website. "
  • Check the learn more link is "https://yoa.st/dashboard-organic-sessions-learn-more" with link params.
  • Check the info icon is aligned to the title.
  • Check the tooltip arrow is aligned to the i icon.
  • Check the chart has gradient color.
  • Mock no data by changing the respone to empty array in src/dashboard/user-interface/time-based-seo-metrics/time-based-seo-metrics-route.php, line 207:
return new WP_REST_Response(
			[],
			200
		);
  • Check you get only once the message "No data to display: Your site hasn't received any visitors yet."

Relevant test scenarios

  • Changes should be tested with the browser console open
  • Changes should be tested on different posts/pages/taxonomies/custom post types/custom taxonomies
  • Changes should be tested on different editors (Default Block/Gutenberg/Classic/Elementor/other)
  • Changes should be tested on different browsers
  • Changes should be tested on multisite

Test instructions for QA when the code is in the RC

  • QA should use the same steps as above.

QA can test this PR by following these steps:

Impact check

This PR affects the following parts of the plugin, which may require extra testing:

UI changes

  • This PR changes the UI in the plugin. I have added the 'UI change' label to this PR.

Other environments

  • This PR also affects Shopify. I have added a changelog entry starting with [shopify-seo], added test instructions for Shopify and attached the Shopify label to this PR.

Documentation

  • I have written documentation for this change. For example, comments in the Relevant technical choices, comments in the code, documentation on Confluence / shared Google Drive / Yoast developer portal, or other.

Quality assurance

  • I have tested this code to the best of my abilities.
  • During testing, I had activated all plugins that Yoast SEO provides integrations for.
  • I have added unit tests to verify the code works as intended.
  • If any part of the code is behind a feature flag, my test instructions also cover cases where the feature flag is switched off.
  • I have written this PR in accordance with my team's definition of done.
  • I have checked that the base branch is correctly set.

Innovation

  • No innovation project is applicable for this PR.
  • This PR falls under an innovation project. I have attached the innovation label.
  • I have added my hours to the WBSO document.

Fixes https://github.com/Yoast/reserved-tasks/issues/411

@igorschoester igorschoester added the changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog label Feb 25, 2025
@coveralls
Copy link

coveralls commented Feb 25, 2025

Pull Request Test Coverage Report for Build 62731220764544d87392c8a83cf17b2eb8246908

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 80 of 88 (90.91%) changed or added relevant lines in 12 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall first build on 411-implement-organic-sessions-graph at 42.446%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/dashboard/infrastructure/integrations/site-kit.php 0 1 0.0%
packages/js/src/dashboard/widgets/organic-sessions/daily.js 24 31 77.42%
Totals Coverage Status
Change from base Build e635160065c497009be3f728b1284626af5a327c: 42.4%
Covered Lines: 21046
Relevant Lines: 46555

💛 - Coveralls

Copy link

A merge conflict has been detected for the proposed code changes in this PR. Please resolve the conflict by either rebasing the PR or merging in changes from the base branch.

@vraja-pro vraja-pro marked this pull request as ready for review February 26, 2025 16:38
Copy link
Contributor

@thijsoo thijsoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CR 🚧 some questions and feedback

*/
const getOrganicSessionsDaily = useCallback( ( options ) => {
return remoteDataProvider.fetchJson(
dataProvider.getEndpoint( "timeBasedSeoMetrics" ),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to also define all endpoints as a constant somewhere since we have quite a few random strings all over the place

Copy link
Member Author

@igorschoester igorschoester Mar 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will leave this be for now. Mostly because I'm not sure where this should live (static method in data provider? constant file? 🤷 ).
The options are documented through the Endpoint type.

Copy link

github-actions bot commented Mar 4, 2025

A merge conflict has been detected for the proposed code changes in this PR. Please resolve the conflict by either rebasing the PR or merging in changes from the base branch.

Add more internal documentation
…ment-organic-sessions-graph

# Conflicts:
#	packages/js/src/dashboard/index.js
#	packages/js/src/dashboard/services/widget-factory.js
#	packages/js/src/general/initialize.js
#	packages/js/tests/dashboard/__mocks__/data-provider.js
#	packages/js/tests/dashboard/services/widget-factory.test.js
…ment-organic-sessions-graph

# Conflicts:
#	packages/js/src/dashboard/widgets/top-queries-widget.js
@vraja-pro
Copy link
Contributor

ACC 🚧 : 2k?
Screenshot 2025-03-05 at 11 56 57

@vraja-pro vraja-pro added this to the 24.8 milestone Mar 5, 2025
@vraja-pro
Copy link
Contributor

CR & AC ✅

@vraja-pro vraja-pro merged commit 9399097 into trunk Mar 5, 2025
37 checks passed
@vraja-pro vraja-pro deleted the 411-implement-organic-sessions-graph branch March 5, 2025 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants