Skip to content

Commit

Permalink
Lower serverity of missing Trustpilot settings
Browse files Browse the repository at this point in the history
<!--
PR title: GRW-123 / Feature / Awesome new thing
-->

## Describe your changes

Reduce noise from Trustpilot not being configured.  Warn in production, info otherwise

<!--
What changes are made?
If there are many changes, a list might be a good format.
If it makes sense, add screenshots and/or screen recordings here.
-->

## Justify why they are needed

Improve developer experience

## Checklist before requesting a review

- [ ] I have performed a self-review of my code
  • Loading branch information
alebedev committed Jul 18, 2023
1 parent 1625a4c commit 558408b
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions apps/store/src/services/trustpilot/trustpilot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,16 @@ export const fetchTrustpilotData = async () => {
try {
const hedvigBusinessUnitId = process.env.TRUSTPILOT_HEDVIG_BUSINESS_UNIT_ID
if (!hedvigBusinessUnitId) {
throw new Error('TRUSTPILOT_HEDVIG_BUSINESS_UNIT_ID is not configured')
logMissingSetting(
'TRUSTPILOT_HEDVIG_BUSINESS_UNIT_ID is not configured, skipping Trustpilot data',
)
return null
}

const trustpilotApiKey = process.env.TRUSTPILOT_API_KEY
if (!trustpilotApiKey) {
throw new Error('`TRUSTPILOT_API_KEY` is not configured')
logMissingSetting('TRUSTPILOT_API_KEY is not configured, skipping Trustpilot data')
return null
}

const response = await fetch(
Expand All @@ -57,3 +61,11 @@ export const fetchTrustpilotData = async () => {
return null
}
}

const logMissingSetting = (message: string) => {
if (process.env.NODE_ENV === 'production') {
console.warn(message)
} else {
console.log(message)
}
}

0 comments on commit 558408b

Please sign in to comment.