Skip to content

Commit

Permalink
fix: Handle hoisting
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Sep 20, 2023
1 parent 2926091 commit d0763b7
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions editor.planx.uk/src/airbrake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,29 @@ import { isLiveEnv } from "utils";

export const logger = getErrorLogger();

/**
* Checking a partial host can be unsafe, e.g.
* window.location.host.endsWith("gov.uk")
*/
const getEnvForAllowedHosts = (host: string) => {
switch (host) {
case "planningservices.newcastle.gov.uk":
case "planningservices.medway.gov.uk":
case "planningservices.doncaster.gov.uk":
case "planningservices.lambeth.gov.uk":
case "planningservices.southwark.gov.uk":
case "planningservices.buckinghamshire.gov.uk":
case "editor.planx.uk":
return "production"

case "editor.planx.dev":
return "staging"

default:
"pullrequest";
}
}

function log(...args: any[]) {
return process.env.SUPPRESS_LOGS
? () => {
Expand Down Expand Up @@ -38,26 +61,3 @@ function getErrorLogger(): ErrorLogger {
interface ErrorLogger {
notify: (args: unknown) => void;
}

/**
* Checking a partial host can be unsafe, e.g.
* window.location.host.endsWith("gov.uk")
*/
const getEnvForAllowedHosts = (host: string) => {
switch (host) {
case "planningservices.newcastle.gov.uk":
case "planningservices.medway.gov.uk":
case "planningservices.doncaster.gov.uk":
case "planningservices.lambeth.gov.uk":
case "planningservices.southwark.gov.uk":
case "planningservices.buckinghamshire.gov.uk":
case "editor.planx.uk":
return "production"

case "editor.planx.dev":
return "staging"

default:
"pullrequest";
}
}

0 comments on commit d0763b7

Please sign in to comment.