GithubHelp home page GithubHelp logo

Comments (5)

Hyperkid123 avatar Hyperkid123 commented on August 10, 2024

The reason for this is that the route change and thus page event is fired before the JS module is loaded and can customize the page load event.

We have an option to leverage the module first page vent via the module definition in cloud service config (and frontend operator). The issue with this approach is that the module will not have total freedom in what data we pass to the page event. Anything static is good. But any dynamic data has to be restricted.

Do we know the nature of the data we want to send via the page event? Is this something dynamic? (requires async request etc.)

from insights-chrome.

jschuler avatar jschuler commented on August 10, 2024

Generally, once the route is mounted in OCM we send some additional metadata like:

ocm_resource_type: 'all' | 'moa' | 'ocp' | 'ocptrial' | and more based on product
path: some paths are overwritten, like cluster details paths (to strip out the unique IDs in the path name
// next 2 fields are sent from cluster details
ocm_cluster_id: cluster ID
resource_id: external cluster ID

This information is available after a route change. Using react-router-dom we send additional information like this:

const { pathname } = useLocation();
const { setPageMetadata } = useAnalytics();
useEffect(() => {
    setPageMetadata({
      // additional metadata here
    });
}, [pathname]);

No async call is needed as of now, as the redux store is updated with the information we need before the route mounts

from insights-chrome.

Hyperkid123 avatar Hyperkid123 commented on August 10, 2024

Do you think it would be possible to create a route-based static specification of the data? Something like

{
  "eventConfig": {
    "routes": {
      "/foo/bar": {
       "ocm_resource_type": "something",
       ...
      },
      ...
    }
  }
}

from insights-chrome.

jschuler avatar jschuler commented on August 10, 2024

That could work for the ocm_resource_type field if wildcards are supported as well. You can see the implementation on gitlab here (VPN required)

from insights-chrome.

Hyperkid123 avatar Hyperkid123 commented on August 10, 2024

We can use the router match notation to get the correct value.

from insights-chrome.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.