Skip to content

Commit

Permalink
fix(app): Datadog error logs cleanup (passportxyz#209)
Browse files Browse the repository at this point in the history
* fix(app): updates datadog error logging messages

* fix(app): adds env variable to sample env
  • Loading branch information
farque65 authored Jun 15, 2022
1 parent b8c8c0a commit d336783
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 7 deletions.
3 changes: 2 additions & 1 deletion app/.env-example.env
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ NEXT_PUBLIC_DPOPP_IAM_URL=http://localhost:80/api/
NEXT_PUBLIC_DPOPP_IAM_ISSUER_DID=did:key:z6MkghvGHLobLEdj1bgRLhS4LPGJAvbMA1tn2zcRyqmYU5LC
NEXT_PUBLIC_DPOPP_PROCEDURE_URL=http://localhost:80/procedure/

NEXT_PUBLIC_DPOPP_INFURA_KEY=YOUR_INFURA_KEY
NEXT_PUBLIC_DPOPP_MAINNET_RPC_URL=YOUR_RPC_URL
NEXT_PUBLIC_CERAMIC_CLIENT_URL=https://ceramic-clay.3boxlabs.com

NEXT_PUBLIC_DATADOG_APPLICATION_ID=some-uid-id
NEXT_PUBLIC_DATADOG_CLIENT_TOKEN=somepubclienttoken
NEXT_PUBLIC_DATADOG_ENV=someenvname
3 changes: 3 additions & 0 deletions app/components/ProviderCards/BrightidCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export default function BrightIdCard(): JSX.Element {
});
})
.catch((e: any): void => {
datadogLogs.logger.error("Verification Error", { error: e, provider: providerId });
datadogRum.addError(`Error ${e}`, { provider: providerId });
})
.finally((): void => {
Expand Down Expand Up @@ -125,6 +126,7 @@ export default function BrightIdCard(): JSX.Element {
duration: 9000,
isClosable: true,
});
datadogLogs.logger.error("Error sponsoring user", { provider: providerId });
datadogRum.addError(data?.response?.error || "Failed to sponsor user on BrightId", { provider: providerId });
}
setCredentialResponseIsLoading(false);
Expand Down Expand Up @@ -155,6 +157,7 @@ export default function BrightIdCard(): JSX.Element {
handleAddStamp(credentialResponse!)
.then(() => datadogLogs.logger.info("Successfully saved Stamp", { provider: providerId }))
.catch((e): void => {
datadogLogs.logger.error("Error Saving Stamp", { error: e, provider: providerId });
datadogRum.addError(e, { provider: providerId });
throw e;
})
Expand Down
4 changes: 2 additions & 2 deletions app/components/ProviderCards/EnsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ export default function EnsCard(): JSX.Element {
});
})
.catch((e: any): void => {
datadogLogs.logger.error("1) error providing verification", { error: e, provider: providerId });
console.error("2) error providing verification");
datadogLogs.logger.error("Verification Error", { error: e, provider: providerId });
datadogRum.addError(e, { provider: providerId });
})
.finally((): void => {
Expand All @@ -72,6 +71,7 @@ export default function EnsCard(): JSX.Element {
handleAddStamp(credentialResponse!)
.then(() => datadogLogs.logger.info("Successfully saved Stamp", { provider: providerId }))
.catch((e: any): void => {
datadogLogs.logger.error("Error Saving Stamp", { error: e, provider: providerId });
datadogRum.addError(e, { provider: providerId });
})
.finally(() => {
Expand Down
1 change: 1 addition & 0 deletions app/components/ProviderCards/FacebookCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export default function FacebookCard(): JSX.Element {
});
})
.catch((e): void => {
datadogLogs.logger.error("Verification Error", { error: e, provider: providerId });
datadogRum.addError(e, { provider: providerId });
})
.finally(() => {
Expand Down
4 changes: 4 additions & 0 deletions app/components/ProviderCards/GithubCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ export default function GithubCard(): JSX.Element {
});
datadogLogs.logger.info("Successfully saved Stamp", { provider: "Github" });
})
.catch((e) => {
datadogLogs.logger.error("Verification Error", { error: e, provider: providerId });
throw e;
})
.finally(() => {
setLoading(false);
});
Expand Down
3 changes: 1 addition & 2 deletions app/components/ProviderCards/GoogleCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ export default function GoogleCard(): JSX.Element {
});
})
.catch((e): void => {
datadogLogs.logger.error("1) error providing verification", { error: e, provider: providerId });
console.error("2) error providing verification");
datadogLogs.logger.error("Verification Error", { error: e, provider: providerId });
datadogRum.addError(e, { provider: providerId });
})
.finally(() => {
Expand Down
1 change: 1 addition & 0 deletions app/components/ProviderCards/PoapCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export default function PoapCard(): JSX.Element {
});
})
.catch((e: any): void => {
datadogLogs.logger.error("Verification Error", { error: e, provider: providerId });
datadogRum.addError(e, { provider: providerId });
})
.finally((): void => {
Expand Down
4 changes: 3 additions & 1 deletion app/components/ProviderCards/PohCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function PohCard(): JSX.Element {
const toast = useToast();

const handleFetchCredential = (): void => {
datadogLogs.logger.info("Saving Stamp", { provider: providerId });
datadogLogs.logger.info("Starting verification", { provider: providerId });
setCredentialResponseIsLoading(true);
fetchVerifiableCredential(
iamUrl,
Expand All @@ -57,6 +57,7 @@ export default function PohCard(): JSX.Element {
});
})
.catch((e: any): void => {
datadogLogs.logger.error("Verification Error", { error: e, provider: providerId });
datadogRum.addError(e, { provider: providerId });
})
.finally((): void => {
Expand All @@ -68,6 +69,7 @@ export default function PohCard(): JSX.Element {
handleAddStamp(credentialResponse!)
.then(() => datadogLogs.logger.info("Successfully saved Stamp", { provider: providerId }))
.catch((e) => {
datadogLogs.logger.error("Error Saving Stamp", { error: e, provider: providerId });
datadogRum.addError(e, { provider: providerId });
})
.finally(() => {
Expand Down
2 changes: 1 addition & 1 deletion app/components/ProviderCards/TwitterCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export default function TwitterCard(): JSX.Element {
});
})
.catch((e) => {
datadogRum.addError(e, { provider: providerId });
datadogLogs.logger.error("Verification Error", { error: e, provider: providerId });
throw e;
})
.finally(() => {
Expand Down

0 comments on commit d336783

Please sign in to comment.