Skip to content

Commit

Permalink
fix faro reporting errors from local env (#4621)
Browse files Browse the repository at this point in the history
# What this PR does
fix faro reporting errors from local env


<!--
*Note*: if you have more than one GitHub issue that this PR closes, be
sure to preface
each issue link with a [closing
keyword](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests#linking-a-pull-request-to-an-issue).
This ensures that the issue(s) are auto-closed once the PR has been
merged.
-->

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
  • Loading branch information
brojd authored Jul 8, 2024
1 parent 038d627 commit 361a298
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions grafana-plugin/src/utils/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,24 @@ export const ONCALL_PROD = 'https://oncall-prod-us-central-0.grafana.net/oncall'
export const ONCALL_OPS = 'https://oncall-ops-us-east-0.grafana.net/oncall';
export const ONCALL_DEV = 'https://oncall-dev-us-central-0.grafana.net/oncall';

export const getProcessEnvVarSafely = (name: string) => {
export const getIsDevelopmentEnv = () => {
try {
return process.env[name];
return process.env.NODE_ENV === 'development';
} catch (error) {
console.error(error);
return undefined;
return false;
}
};

export const getIsDevelopmentEnv = () => getProcessEnvVarSafely['NODE_ENV'] === 'development';

// Single source of truth on the frontend for OnCall API URL
export const getOnCallApiUrl = (meta?: OnCallAppPluginMeta) => {
if (meta?.jsonData?.onCallApiUrl) {
return meta?.jsonData?.onCallApiUrl;
} else if (typeof window === 'undefined') {
return getProcessEnvVarSafely('ONCALL_API_URL');
try {
return process.env.ONCALL_API_URL;
} catch (error) {
return undefined;
}
}
return undefined;
};
Expand Down

0 comments on commit 361a298

Please sign in to comment.