Skip to content

Commit

Permalink
Chore/change faro metadata (#1592)
Browse files Browse the repository at this point in the history
* feat change faro env and namespace values

* fix dynamically setup csp for faro
  • Loading branch information
mfshao authored Aug 29, 2024
1 parent 7c3c784 commit 17f5ee4
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 16 deletions.
2 changes: 1 addition & 1 deletion docs/portal_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Below is an example, with inline comments describing what each JSON block config
"ddSampleRate": 100, // optional; numeric; the Datadog RUM option specifying the percentage of sessions to track: 100 for all, 0 for none. Default to 100 if omitted
"grafanaFaroConfig": {
"grafanaFaroEnable": true, // optional; flag to turn on Grafana Faro RUM, default to false
"grafanaFaroEnv": "DEV", // optional; the Grafana Faro RUM option specifying the application’s environment, for example: prod, pre-prod, staging, etc. Can be determined automatically if omitted. But it is highly recommended to customize it to include project information, such as 'healprod'
"grafanaFaroNamespace": "DEV", // optional; the Grafana Faro RUM option specifying the application’s namespace, for example: prod, pre-prod, staging, etc. Can be determined automatically if omitted. But it is highly recommended to customize it to include project information, such as 'healprod'
"grafanaFaroUrl": "", // optional: the Grafana Faro collector url. Defaults to https://faro.planx-pla.net/collect
"grafanaFaroSampleRate": 1, // optional; numeric; the Grafana Faro option specifying the percentage of sessions to track: 1 for all, 0 for none. Default to 1 if omitted
},
Expand Down
5 changes: 3 additions & 2 deletions src/covid19Index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import {
basename, gaTrackingId, workspaceUrl, workspaceErrorUrl,
indexPublic, explorerPublic, enableResourceBrowser, resourceBrowserPublic, enableDAPTracker,
discoveryConfig, ddApplicationId, ddClientToken, ddEnv, ddUrl, ddSampleRate, knownBotRegex,
userAccessToSite, grafanaFaroConfig,
userAccessToSite, grafanaFaroConfig, hostnameWithSubdomain,
} from './localconf';
import { portalVersion } from './versions';
import { components } from './params';
Expand Down Expand Up @@ -115,7 +115,8 @@ async function init() {
app: {
name: 'portal',
version: portalVersion,
environment: grafanaFaroConfig.grafanaFaroEnv,
namespace: grafanaFaroConfig.grafanaFaroNamespace,
environment: hostnameWithSubdomain,
},
instrumentations: [
...getWebInstrumentations(),
Expand Down
5 changes: 3 additions & 2 deletions src/ecosystemIndex.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import {
basename, gaTrackingId, workspaceUrl, workspaceErrorUrl, Error403Url,
explorerPublic, enableResourceBrowser, resourceBrowserPublic, enableDAPTracker,
discoveryConfig, ddApplicationId, ddClientToken, ddEnv, ddUrl, ddSampleRate, knownBotRegex,
userAccessToSite, grafanaFaroConfig,
userAccessToSite, grafanaFaroConfig, hostnameWithSubdomain,
} from './localconf';
import { portalVersion } from './versions';
import Analysis from './Analysis/Analysis';
Expand Down Expand Up @@ -118,7 +118,8 @@ async function init() {
app: {
name: 'portal',
version: portalVersion,
environment: grafanaFaroConfig.grafanaFaroEnv,
namespace: grafanaFaroConfig.grafanaFaroNamespace,
environment: hostnameWithSubdomain,
},
instrumentations: [
...getWebInstrumentations(),
Expand Down
2 changes: 1 addition & 1 deletion src/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
- https://dap.digitalgov.gov will be inserted by htmlWebpackPlugin if env is configured with DAPTrackingURL. This hostname is needed for fetching and executing the DAP tracking script
- https://*.quicksight.aws.amazon.com for loading AWS Quicksight dashboards into COVID-19 Home page
-->
<meta http-equiv="Content-Security-Policy" content="default-src 'self' https://login.bionimbus.org https://wayf.incommonfederation.org; child-src blob:; img-src 'self' <%= htmlWebpackPlugin.options.imgSrc %> https://opendata.datacommons.io https://static.planx-pla.net data: https://*.s3.amazonaws.com blob:; script-src 'self' 'unsafe-eval' <%= htmlWebpackPlugin.options.scriptSrc %>; worker-src 'self' blob:; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; object-src 'none'; font-src 'self' data: https://fonts.googleapis.com https://fonts.gstatic.com; connect-src 'self' https://login.bionimbus.org https://wayf.incommonfederation.org https://opendata.datacommons.io https://static.planx-pla.net https://*.zendesk.com https://faro.planx-pla.net <%= htmlWebpackPlugin.options.connectSrc %>; frame-src <%= htmlWebpackPlugin.options.connectSrc %> 'self' https://auspice.planx-pla.net https://auspice.pandemicresponsecommons.org https://*.quicksight.aws.amazon.com;">
<meta http-equiv="Content-Security-Policy" content="default-src 'self' https://login.bionimbus.org https://wayf.incommonfederation.org; child-src blob:; img-src 'self' <%= htmlWebpackPlugin.options.imgSrc %> https://opendata.datacommons.io https://static.planx-pla.net data: https://*.s3.amazonaws.com blob:; script-src 'self' 'unsafe-eval' <%= htmlWebpackPlugin.options.scriptSrc %>; worker-src 'self' blob:; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; object-src 'none'; font-src 'self' data: https://fonts.googleapis.com https://fonts.gstatic.com; connect-src 'self' https://login.bionimbus.org https://wayf.incommonfederation.org https://opendata.datacommons.io https://static.planx-pla.net https://*.zendesk.com <%= htmlWebpackPlugin.options.connectSrc %>; frame-src <%= htmlWebpackPlugin.options.connectSrc %> 'self' https://auspice.planx-pla.net https://auspice.pandemicresponsecommons.org https://*.quicksight.aws.amazon.com;">
<meta name="viewport" content="width=device-width" />
<link href="https://fonts.googleapis.com/icon?family=Source+Sans+Pro" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,400;0,700;1,400;1,700&display=swap" rel="stylesheet">
Expand Down
5 changes: 3 additions & 2 deletions src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import {
basename, gaTrackingId, workspaceUrl, workspaceErrorUrl, Error403Url,
indexPublic, explorerPublic, enableResourceBrowser, resourceBrowserPublic, enableDAPTracker,
discoveryConfig, commonsWideAltText, ddApplicationId, ddClientToken, ddEnv, ddUrl, ddSampleRate, knownBotRegex,
userAccessToSite, grafanaFaroConfig,
userAccessToSite, grafanaFaroConfig, hostnameWithSubdomain,
} from './localconf';
import { portalVersion } from './versions';
import Analysis from './Analysis/Analysis';
Expand Down Expand Up @@ -118,7 +118,8 @@ async function init() {
app: {
name: 'portal',
version: portalVersion,
environment: grafanaFaroConfig.grafanaFaroEnv,
namespace: grafanaFaroConfig.grafanaFaroNamespace,
environment: hostnameWithSubdomain,
},
instrumentations: [
...getWebInstrumentations(),
Expand Down
8 changes: 4 additions & 4 deletions src/localconf.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,12 @@ function buildConfig(opts) {
if (!grafanaFaroConfig.grafanaFaroUrl) {
grafanaFaroConfig.grafanaFaroUrl = 'https://faro.planx-pla.net/collect';
}
if (!grafanaFaroConfig.grafanaFaroEnv) {
grafanaFaroConfig.grafanaFaroEnv = 'PROD';
if (!grafanaFaroConfig.grafanaFaroNamespace) {
grafanaFaroConfig.grafanaFaroNamespace = 'PROD';
if (hostnameOnly.includes('qa-')) {
grafanaFaroConfig.grafanaFaroEnv = 'QA';
grafanaFaroConfig.grafanaFaroNamespace = 'QA';
} else if (hostnameOnly.endsWith('.planx-pla.net')) {
grafanaFaroConfig.grafanaFaroEnv = 'DEV';
grafanaFaroConfig.grafanaFaroNamespace = 'DEV';
}
}
if (!grafanaFaroConfig.grafanaFaroSampleRate) {
Expand Down
5 changes: 3 additions & 2 deletions src/nctIndex.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ import {
basename, gaTrackingId, workspaceUrl, workspaceErrorUrl,
indexPublic, explorerPublic, enableResourceBrowser, resourceBrowserPublic, enableDAPTracker,
discoveryConfig, ddApplicationId, ddClientToken, ddEnv, ddUrl, ddSampleRate, knownBotRegex,
userAccessToSite, grafanaFaroConfig,
userAccessToSite, grafanaFaroConfig, hostnameWithSubdomain,
} from './localconf';
import { portalVersion } from './versions';
import Analysis from './Analysis/Analysis';
Expand Down Expand Up @@ -131,7 +131,8 @@ async function init() {
app: {
name: 'portal',
version: portalVersion,
environment: grafanaFaroConfig.grafanaFaroEnv,
namespace: grafanaFaroConfig.grafanaFaroNamespace,
environment: hostnameWithSubdomain,
},
instrumentations: [
...getWebInstrumentations(),
Expand Down
5 changes: 3 additions & 2 deletions src/workspaceIndex.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { ReduxNavBar, ReduxTopBar, ReduxFooter } from './Layout/reduxer';
import {
basename, gaTrackingId, workspaceUrl, workspaceErrorUrl, enableDAPTracker,
ddApplicationId, ddClientToken, ddEnv, ddUrl, ddSampleRate, knownBotRegex,
grafanaFaroConfig,
grafanaFaroConfig, hostnameWithSubdomain,
} from './localconf';
import { portalVersion } from './versions';
import { components } from './params';
Expand Down Expand Up @@ -92,7 +92,8 @@ async function init() {
app: {
name: 'portal',
version: portalVersion,
environment: grafanaFaroConfig.grafanaFaroEnv,
namespace: grafanaFaroConfig.grafanaFaroNamespace,
environment: hostnameWithSubdomain,
},
instrumentations: [
...getWebInstrumentations(),
Expand Down
7 changes: 7 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ if (process.env.DATADOG_APPLICATION_ID && process.env.DATADOG_CLIENT_TOKEN) {
connectSrcURLs.push('https://*.logs.datadoghq.com');
connectSrcURLs.push('https://*.browser-intake-ddog-gov.com');
}
if (configFile.grafanaFaroConfig?.grafanaFaroEnable) {
if (configFile.grafanaFaroConfig?.grafanaFaroUrl) {
connectSrcURLs.push(configFile.grafanaFaroConfig.grafanaFaroUrl);
} else {
connectSrcURLs.push('https://faro.planx-pla.net');
}
}
if (process.env.MAPBOX_API_TOKEN) {
connectSrcURLs.push('https://*.tiles.mapbox.com');
connectSrcURLs.push('https://api.mapbox.com');
Expand Down

0 comments on commit 17f5ee4

Please sign in to comment.