Skip to content

Commit

Permalink
Merge branch 'add-sentry' of github.com:mitchellposk/property-manager…
Browse files Browse the repository at this point in the history
…-helper into add-sentry
  • Loading branch information
jcsavage2 committed Nov 14, 2023
2 parents e99b434 + e394139 commit 7bfa5b7
Show file tree
Hide file tree
Showing 9 changed files with 410 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ next-env.d.ts

.env
.vscode

# Sentry Auth Token
.sentryclirc
37 changes: 37 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,40 @@ const nextConfig = {
};

module.exports = nextConfig;

// Injected content via Sentry wizard below

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

module.exports = withSentryConfig(
module.exports,
{
// For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options

// Suppresses source map uploading logs during build
silent: true,
org: 'pillar-technologies-llc',
project: 'javascript-nextjs',
authToken: process.env.NEXT_PUBLIC_SENTRY_AUTH_TOKEN,
},
{
// For all available options, see:
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/

// Upload a larger set of source maps for prettier stack traces (increases build time)
widenClientFileUpload: true,

// Transpiles SDK to be compatible with IE11 (increases bundle size)
transpileClientSDK: true,

// Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers (increases server load)
tunnelRoute: '/monitoring',

// Hides source maps from generated client bundles
hideSourceMaps: true,

// Automatically tree-shake Sentry logger statements to reduce bundle size
disableLogger: true,
}
);
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@hookform/resolvers": "^3.3.1",
"@next-auth/dynamodb-adapter": "^3.0.2",
"@sendgrid/mail": "^7.7.0",
"@sentry/nextjs": "^7.80.0",
"@types/node": "18.14.6",
"@types/react": "18.0.28",
"@types/react-dom": "18.0.11",
Expand Down
30 changes: 30 additions & 0 deletions sentry.client.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// This file configures the initialization of Sentry on the client.
// The config you add here will be used whenever a users loads a page in their browser.
// https://docs.sentry.io/platforms/javascript/guides/nextjs/

import * as Sentry from "@sentry/nextjs";

Sentry.init({
dsn: "https://296a944ee979fb2cbb84b24658b83ac5@o4505949331390464.ingest.sentry.io/4505949333094400",

// Adjust this value in production, or use tracesSampler for greater control
tracesSampleRate: 1,

// Setting this option to true will print useful information to the console while you're setting up Sentry.
debug: false,

replaysOnErrorSampleRate: 1.0,

// This sets the sample rate to be 10%. You may want this to be 100% while
// in development and sample at a lower rate in production
replaysSessionSampleRate: 0.1,

// You can remove this option if you're not planning to use the Sentry Session Replay feature:
integrations: [
new Sentry.Replay({
// Additional Replay configuration goes in here, for example:
maskAllText: true,
blockAllMedia: true,
}),
],
});
16 changes: 16 additions & 0 deletions sentry.edge.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// This file configures the initialization of Sentry for edge features (middleware, edge routes, and so on).
// The config you add here will be used whenever one of the edge features is loaded.
// Note that this config is unrelated to the Vercel Edge Runtime and is also required when running locally.
// https://docs.sentry.io/platforms/javascript/guides/nextjs/

import * as Sentry from "@sentry/nextjs";

Sentry.init({
dsn: "https://296a944ee979fb2cbb84b24658b83ac5@o4505949331390464.ingest.sentry.io/4505949333094400",

// Adjust this value in production, or use tracesSampler for greater control
tracesSampleRate: 1,

// Setting this option to true will print useful information to the console while you're setting up Sentry.
debug: false,
});
15 changes: 15 additions & 0 deletions sentry.server.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// This file configures the initialization of Sentry on the server.
// The config you add here will be used whenever the server handles a request.
// https://docs.sentry.io/platforms/javascript/guides/nextjs/

import * as Sentry from "@sentry/nextjs";

Sentry.init({
dsn: "https://296a944ee979fb2cbb84b24658b83ac5@o4505949331390464.ingest.sentry.io/4505949333094400",

// Adjust this value in production, or use tracesSampler for greater control
tracesSampleRate: 1,

// Setting this option to true will print useful information to the console while you're setting up Sentry.
debug: false,
});
6 changes: 3 additions & 3 deletions src/pages/api/get-all-work-orders-for-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
});
const workOrders = response.workOrders
? response.workOrders.sort((a: IWorkOrder, b: IWorkOrder) => {
//@ts-ignore
return new Date(b.created) - new Date(a.created);
})
//@ts-ignore
return new Date(b.created) - new Date(a.created);
})
: [];

return res
Expand Down
8 changes: 6 additions & 2 deletions src/pages/work-orders/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { StatusOption, WoStatus } from '@/types';
import WorkOrdersCards from '@/components/work-orders-cards';
import WorkOrdersTable from '@/components/work-orders-table';
import { GetAllWorkOrdersForUserSchema, UpdateWorkOrderSchema } from '@/types/customschemas';
import { toast } from 'react-toastify';

export type HandleUpdateStatusProps = {
val: SingleValue<StatusOption>;
Expand Down Expand Up @@ -122,8 +123,11 @@ const WorkOrders = () => {
if (orders.length) {
sessionStorage.setItem('WORK_ORDERS', JSON.stringify({ orders, time: Date.now() }));
}
} catch (e: any) {
console.log(e);
} catch (error) {
toast.error(
(error as any)?.response?.data?.response ?? 'Failed to get work orders for user',
{ position: toast.POSITION.TOP_CENTER }
);
}
setIsFetching(false);
},
Expand Down
Loading

0 comments on commit 7bfa5b7

Please sign in to comment.