Skip to content
This repository has been archived by the owner on Apr 5, 2024. It is now read-only.

Commit

Permalink
feat: add sentry example triggers (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Bouquillon authored Sep 29, 2022
1 parent 8842797 commit 439f13d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .env.development
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NEXT_PUBLIC_SENTRY_DSN=""
NEXT_PUBLIC_SENTRY_ENV=""
NEXT_PUBLIC_SENTRY_DSN="https://[email protected]/68"
NEXT_PUBLIC_SENTRY_ENV="dev"
NEXT_PUBLIC_MATOMO_URL=""
NEXT_PUBLIC_MATOMO_SITE_ID=""
NEXT_PUBLIC_APP_REPOSITORY_URL="https://github.com/SocialGouv/template"
Expand Down
2 changes: 1 addition & 1 deletion .talismanrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
fileignoreconfig:
- filename: .env.development
checksum: 01c8bd12e80600594a21713d543700ea033eeeee3ed3cad9f5d6e3ea31de094e
checksum: 9487b9d63713290be841abcb50e6fb4101f2e4bc73815fd376d307926d711fe9
- filename: .env.production
checksum: 85afa96cd9ada6392aa39804231e743505a1b3e648429ceffc27cbc7538f5075
- filename: .env.staging
Expand Down
9 changes: 9 additions & 0 deletions src/pages/api/error.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// This is an example of how to read a JSON Web Token from an API route
import { NextApiRequest, NextApiResponse } from "next";
import { withSentry } from "@sentry/nextjs";

const triggerError = async (req: NextApiRequest, res: NextApiResponse) => {
throw new Error("Server error :/");
};

export default withSentry(triggerError);
12 changes: 11 additions & 1 deletion src/pages/pageA.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
import { Alert } from "@dataesr/react-dsfr";
import { Alert, Button } from "@dataesr/react-dsfr";
import type { NextPage } from "next";
import React from "react";

const PageA: NextPage = () => {
const onClick1 = () => {
throw new Error("Hello, sentry");
};
const onClick2 = () => {
fetch("/api/error");
};
return (
<div className="fr-container fr-my-6w">
<h1>Lien A</h1>
<Alert title="Cette page doit être mise à jour. " type="info" />
<br />
<Button onClick={onClick1}>test sentry client-side error</Button>
&nbsp;
<Button onClick={onClick2}>test sentry server-side error</Button>
</div>
);
};
Expand Down

0 comments on commit 439f13d

Please sign in to comment.