Skip to content

Commit

Permalink
Revert "Merge pull request #79 from ThangHuuVu/fix/disable-sentry"
Browse files Browse the repository at this point in the history
This reverts commit 8f4f07e, reversing
changes made to 1cdf730.
  • Loading branch information
ThangHuuVu committed Oct 28, 2021
1 parent e896d87 commit 7e2f655
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 8 deletions.
10 changes: 9 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ const withBundleAnalyzer = require("@next/bundle-analyzer")({
const withPWA = require("next-pwa");
const runtimeCaching = require("next-pwa/cache");

const { withSentryConfig } = require("@sentry/nextjs");

const SentryWebpackPluginOptions = {
silent: true,
};

const isDevelopment = process.env.NODE_ENV === "development";

// @ts-check
Expand Down Expand Up @@ -68,4 +74,6 @@ const nextConfig = {
},
};

module.exports = isDevelopment ? nextConfig : withPWA(withBundleAnalyzer(nextConfig));
module.exports = isDevelopment
? nextConfig
: withSentryConfig(withPWA(withBundleAnalyzer(nextConfig)), SentryWebpackPluginOptions);
3 changes: 2 additions & 1 deletion pages/api/analytics.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { withSentry } from "@sentry/nextjs";
import { google } from "googleapis";
import type { NextApiRequest, NextApiResponse } from "next";

Expand Down Expand Up @@ -33,4 +34,4 @@ const handlers = async (_: NextApiRequest, res: NextApiResponse<Analytic>) => {
});
};

export default handlers;
export default withSentry(handlers);
3 changes: 2 additions & 1 deletion pages/api/endorsement.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import prisma from "@/lib/prisma";
import { withSentry } from "@sentry/nextjs";
import type { NextApiRequest, NextApiResponse } from "next";
import { getSession } from "next-auth/react";

Expand All @@ -18,4 +19,4 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
return res.send("Method not allowed.");
}

export default handler;
export default withSentry(handler);
3 changes: 2 additions & 1 deletion pages/api/guestbook/[id].ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getSession } from "next-auth/react";
import { withSentry } from "@sentry/nextjs";
import type { NextApiRequest, NextApiResponse } from "next";
import prisma from "@/lib/prisma";
import { GuestBookEntry } from "@/lib/types/guestbook";
Expand Down Expand Up @@ -58,4 +59,4 @@ const guestbookEntries = async (
return res.send("Method not allowed.");
};

export default guestbookEntries;
export default withSentry(guestbookEntries);
3 changes: 2 additions & 1 deletion pages/api/guestbook/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getSession } from "next-auth/react";
import { withSentry } from "@sentry/nextjs";
import type { NextApiRequest, NextApiResponse } from "next";
import prisma from "@/lib/prisma";
import { GuestBookEntry } from "@/lib/types/guestbook";
Expand Down Expand Up @@ -57,4 +58,4 @@ const handler = async (
return res.send("Method not allowed.");
};

export default handler;
export default withSentry(handler);
3 changes: 2 additions & 1 deletion pages/api/now-playing.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getNowPlaying } from "@/lib/spotify";
import { withSentry } from "@sentry/nextjs";
import type { NextApiRequest, NextApiResponse } from "next";

export interface NowPlayingSong {
Expand Down Expand Up @@ -40,4 +41,4 @@ async function handler(_: NextApiRequest, res: NextApiResponse<NowPlayingSong>)
}
}

export default handler;
export default withSentry(handler);
3 changes: 2 additions & 1 deletion pages/api/skill-category.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { getAllSkillsByCategory } from "@/lib/db";
import { SkillCategory } from "@/lib/types/skill";
import { withSentry } from "@sentry/nextjs";
import type { NextApiRequest, NextApiResponse } from "next";

async function handler(req: NextApiRequest, res: NextApiResponse<SkillCategory[] | string>) {
Expand All @@ -10,4 +11,4 @@ async function handler(req: NextApiRequest, res: NextApiResponse<SkillCategory[]
return res.send("Method not allowed.");
}

export default handler;
export default withSentry(handler);
3 changes: 2 additions & 1 deletion pages/api/skill.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import prisma from "@/lib/prisma";
import { Skill } from "@/lib/types/skill";
import { withSentry } from "@sentry/nextjs";
import type { NextApiRequest, NextApiResponse } from "next";

async function handler(req: NextApiRequest, res: NextApiResponse<Skill[] | string>) {
Expand Down Expand Up @@ -33,4 +34,4 @@ async function handler(req: NextApiRequest, res: NextApiResponse<Skill[] | strin
return res.send("Method not allowed.");
}

export default handler;
export default withSentry(handler);
8 changes: 8 additions & 0 deletions sentry.client.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import * as Sentry from "@sentry/nextjs";

const SENTRY_DSN = process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN;

Sentry.init({
dsn: SENTRY_DSN || "https://[email protected]/5951862",
tracesSampleRate: 0.2,
});
4 changes: 4 additions & 0 deletions sentry.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
defaults.url=https://sentry.io/
defaults.org=thvu
defaults.project=thvu-blog
# cli.executable=../../../.npm/_npx/a8388072043b4cbc/node_modules/@sentry/cli/bin/sentry-cli
8 changes: 8 additions & 0 deletions sentry.server.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import * as Sentry from "@sentry/nextjs";

const SENTRY_DSN = process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN;

Sentry.init({
dsn: SENTRY_DSN || "https://[email protected]/5951862",
tracesSampleRate: 0.2,
});

0 comments on commit 7e2f655

Please sign in to comment.