IN-CORE / incore-ui

IN-CORE Web Tools: a component of IN-CORE. It consists of data viewer, hazard viewer, and fragility viewer.
https://incore.ncsa.illinois.edu
Mozilla Public License 2.0
4 stars 0 forks source link

Google analytics header env dynamic #199

Closed ywkim312 closed 3 months ago

ywkim312 commented 3 months ago

@longshuicy I've merged your PR but had a question so I recreated a PR again using your branch. Here's my question. You said that you were trying to mount this config.json using helm's config map, right? But isn't this config.json needed for during the building process. If it is working with config map in the deployment stage, then where should be the mounting point of the frontend container to mount this GA KEY json file? I mean, where should I mount the config map generated json file in the container that will be created after the building process. Or maybe I don't understand it correctly

longshuicy commented 3 months ago

@longshuicy I've merged your PR but had a question so I recreated a PR again using your branch. Here's my question. You said that you were trying to mount this config.json using helm's config map, right? But isn't this config.json needed for during the building process. If it is working with config map in the deployment stage, then where should be the mounting point of the frontend container to mount this GA KEY json file? I mean, where should I mount the config map generated json file in the container that will be created after the building process. Or maybe I don't understand it correctly

Note: I would need to change config.json to be the javascript script and mount/execute the javascript upon fetching


  1. Yes the config.json is a placeholder neede during the building process
  2. I haven't had time to create the config map PR in the incore-helm yet
  3. It should be mount at the exact location of config.json in the nginx folder, serving as an overwrite. Detail location can be found in the dockerfile
ywkim312 commented 3 months ago

@longshuicy I've merged your PR but had a question so I recreated a PR again using your branch. Here's my question. You said that you were trying to mount this config.json using helm's config map, right? But isn't this config.json needed for during the building process. If it is working with config map in the deployment stage, then where should be the mounting point of the frontend container to mount this GA KEY json file? I mean, where should I mount the config map generated json file in the container that will be created after the building process. Or maybe I don't understand it correctly

Note: I would need to change config.json to be the javascript script and mount/execute the javascript upon fetching

  1. Yes the config.json is a placeholder neede during the building process
  2. I haven't had time to create the config map PR in the incore-helm yet
  3. It should be mount at the exact location of config.json in the nginx folder, serving as an overwrite. Detail location can be found in the dockerfile

I have a PR for configmap in incore-helm so you don't need to worry. Okay, I will test with the nginx's config folder. So that is where you need to mount. What if there is config.json already in there, it will lose the information if there is any because it will override

longshuicy commented 3 months ago

I actually dont know what to with the "react-ga" library. Not sure I can put those logic as a javascript, so I just left it as it is.

longshuicy commented 3 months ago

@longshuicy I've merged your PR but had a question so I recreated a PR again using your branch. Here's my question. You said that you were trying to mount this config.json using helm's config map, right? But isn't this config.json needed for during the building process. If it is working with config map in the deployment stage, then where should be the mounting point of the frontend container to mount this GA KEY json file? I mean, where should I mount the config map generated json file in the container that will be created after the building process. Or maybe I don't understand it correctly

Note: I would need to change config.json to be the javascript script and mount/execute the javascript upon fetching

  1. Yes the config.json is a placeholder neede during the building process
  2. I haven't had time to create the config map PR in the incore-helm yet
  3. It should be mount at the exact location of config.json in the nginx folder, serving as an overwrite. Detail location can be found in the dockerfile

I have a PR for configmap in incore-helm so you don't need to worry. Okay, I will test with the nginx's config folder. So that is where you need to mount. What if there is config.json already in there, it will lose the information if there is any because it will override

Thanks!

Yes, if there is config.json already exist, the config will be override when deploying. We won't place any real value in the default "config.json". Isn't that the desired behavior?

ywkim312 commented 3 months ago

@longshuicy I've merged your PR but had a question so I recreated a PR again using your branch. Here's my question. You said that you were trying to mount this config.json using helm's config map, right? But isn't this config.json needed for during the building process. If it is working with config map in the deployment stage, then where should be the mounting point of the frontend container to mount this GA KEY json file? I mean, where should I mount the config map generated json file in the container that will be created after the building process. Or maybe I don't understand it correctly

Note: I would need to change config.json to be the javascript script and mount/execute the javascript upon fetching

  1. Yes the config.json is a placeholder neede during the building process
  2. I haven't had time to create the config map PR in the incore-helm yet
  3. It should be mount at the exact location of config.json in the nginx folder, serving as an overwrite. Detail location can be found in the dockerfile

I have a PR for configmap in incore-helm so you don't need to worry. Okay, I will test with the nginx's config folder. So that is where you need to mount. What if there is config.json already in there, it will lose the information if there is any because it will override

Thanks!

Yes, if there is config.json already exist, the config will be override when deploying. We won't place any real value in the default "config.json". Isn't that the desired behavior?

No I don't think so, I was just curious what if there was the data already and how we handle in that situation

ywkim312 commented 3 months ago

@longshuicy Other question is that, if you want to whole javascript block, it will not be just a simple config.json, right? Or maybe we can put the javascript values in the json's value field with given key? Anyway, I will see how you handle this.

ywkim312 commented 3 months ago

@longshuicy This is the source of index.html. Does it look correct?


<body>
<!--StartFragment-->
  | <!doctype html><html lang="en"><head><script>fetch("/config/googleAnalytics.js").then((t=>t.text())).then((t=>{const e=document.createElement("script");e.textContent=t,document.head.appendChild(e)})).catch((t=>console.error("Failed to load analytics script:",t)))</script><meta charset="utf-8"/><title>IN-CORE</title><link rel="icon" href="favicon.ico"><script defer="defer" src="main.408a5fcdcffa7d07451c.js"></script><link href="main.edc7cdc5ee8e7fcb8778.css" rel="stylesheet"></head><body><div id="app"></div></body></html
-- | --

<!--EndFragment-->
</body>
</html><!doctype html><html lang="en"><head><script>fetch("/config/googleAnalytics.js").then((t=>t.text())).then((t=>{const e=document.createElement("script");e.textContent=t,document.head.appendChild(e)})).catch((t=>console.error("Failed to load analytics script:",t)))</script><meta http-equiv="X-UA-Compatible" content="no-cache"><meta charset="utf-8"/><title>IN-CORE</title><link rel="icon" href="[favicon.ico](https://incore-dev.ncsa.illinois.edu/favicon.ico)"><script defer="defer" src="[main.408a5fcdcffa7d07451c.js](https://incore-dev.ncsa.illinois.edu/main.408a5fcdcffa7d07451c.js)"></script><link href="[main.edc7cdc5ee8e7fcb8778.css](https://incore-dev.ncsa.illinois.edu/main.edc7cdc5ee8e7fcb8778.css)" rel="stylesheet"></head><body><div id="app"></div></body></html```
ywkim312 commented 3 months ago

@longshuicy This is the source of index.html. Does it look correct?

<body>
<!--StartFragment-->
  | <!doctype html><html lang="en"><head><script>fetch("/config/googleAnalytics.js").then((t=>t.text())).then((t=>{const e=document.createElement("script");e.textContent=t,document.head.appendChild(e)})).catch((t=>console.error("Failed to load analytics script:",t)))</script><meta charset="utf-8"/><title>IN-CORE</title><link rel="icon" href="favicon.ico"><script defer="defer" src="main.408a5fcdcffa7d07451c.js"></script><link href="main.edc7cdc5ee8e7fcb8778.css" rel="stylesheet"></head><body><div id="app"></div></body></html
-- | --

<!--EndFragment-->
</body>
</html><!doctype html><html lang="en"><head><script>fetch("/config/googleAnalytics.js").then((t=>t.text())).then((t=>{const e=document.createElement("script");e.textContent=t,document.head.appendChild(e)})).catch((t=>console.error("Failed to load analytics script:",t)))</script><meta http-equiv="X-UA-Compatible" content="no-cache"><meta charset="utf-8"/><title>IN-CORE</title><link rel="icon" href="[favicon.ico](https://incore-dev.ncsa.illinois.edu/favicon.ico)"><script defer="defer" src="[main.408a5fcdcffa7d07451c.js](https://incore-dev.ncsa.illinois.edu/main.408a5fcdcffa7d07451c.js)"></script><link href="[main.edc7cdc5ee8e7fcb8778.css](https://incore-dev.ncsa.illinois.edu/main.edc7cdc5ee8e7fcb8778.css)" rel="stylesheet"></head><body><div id="app"></div></body></html```

@longshuicy I checked the response and it has the value of config.json but I am not very sure if this works. I will keep checking.