Uploaded image for project: 'Planet4'
  1. Planet4
  2. PLANET-7516

AnalyticsTrackingSidebar: Fix options data while testing Wordpress 6.5

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Merged
    • Icon: Must have Must have
    • None
    • 3
    • Analytics
    • saturn

      Summary

      While testing WordPress 6.5 the AnalyticsTrackingSidebar stopped working.

      I noticed that the problem comes after adding the analytics-values Entity but not sure exactly why this happens. Unfortunately, there is no recent updates of the addEntities function.

       

      You can also validate the issue on this demo page at the mars instance which using WordPress 6.5.2.

      About the issue

      Currently we add the analytics-values entity like this

      dispatch('core').addEntities([{
        baseURL: '/planet4/v1/analytics-values',
        kind: 'planet4/v1',
        name: 'analytics-values',
        label: 'Analytics and tracking values',
      }]);
      

      And getting the value

      const options = useSelect(select => {
          return select('core').getEntityRecords('planet4/v1', 'analytics-values', {id: postId});
       });
      

      Then,

      Finally, the endpoint GET http://www.planet4.test/wp-json/planet4/v1/analytics-values?id=:ID is returning the correct value BUT options is always set to an empty Array.

       After a big research and testing the issue in WordPress 6.4.* and 6.5.* I detected that the baseURLParams field should be also included when adding a new identity and match exactly against the endpoint.

      The other problem is that adding the Entity should be run in to the Scope of the component but never outside.

      You can also validate the issue on this demo page at the mars instance which using WordPress 6.5.2.

      Requirements

      • Run WordPress 6.5

      Resources

            dtovbein Dan Tovbein
            dtovbein Dan Tovbein
            Sagar Deshmukh Sagar Deshmukh
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: