Skip to content

Commit

Permalink
Finish sentry integration, hide sentry for dev env
Browse files Browse the repository at this point in the history
  • Loading branch information
jcsavage2 committed Nov 14, 2023
1 parent 7bfa5b7 commit 132e80a
Show file tree
Hide file tree
Showing 30 changed files with 97 additions and 37 deletions.
42 changes: 22 additions & 20 deletions sentry.client.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,31 @@
// 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";
import * as Sentry from '@sentry/nextjs';

Sentry.init({
dsn: "https://296a944ee979fb2cbb84b24658b83ac5@o4505949331390464.ingest.sentry.io/4505949333094400",
if (!process.env.NEXT_PUBLIC_IS_LOCAL) {
Sentry.init({
dsn: 'https://296a944ee979fb2cbb84b24658b83ac5@o4505949331390464.ingest.sentry.io/4505949333094400',

// Adjust this value in production, or use tracesSampler for greater control
tracesSampleRate: 1,
// 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,
// Setting this option to true will print useful information to the console while you're setting up Sentry.
debug: false,

replaysOnErrorSampleRate: 1.0,
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,
// 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,
}),
],
});
// 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,
}),
],
});
}
18 changes: 10 additions & 8 deletions sentry.edge.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
// 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";
import * as Sentry from '@sentry/nextjs';

Sentry.init({
dsn: "https://296a944ee979fb2cbb84b24658b83ac5@o4505949331390464.ingest.sentry.io/4505949333094400",
if (!process.env.NEXT_PUBLIC_IS_LOCAL) {
Sentry.init({
dsn: 'https://296a944ee979fb2cbb84b24658b83ac5@o4505949331390464.ingest.sentry.io/4505949333094400',

// Adjust this value in production, or use tracesSampler for greater control
tracesSampleRate: 1,
// 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,
});
// Setting this option to true will print useful information to the console while you're setting up Sentry.
debug: false,
});
}
18 changes: 10 additions & 8 deletions sentry.server.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
// 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";
import * as Sentry from '@sentry/nextjs';

Sentry.init({
dsn: "https://296a944ee979fb2cbb84b24658b83ac5@o4505949331390464.ingest.sentry.io/4505949333094400",
if (!process.env.NEXT_PUBLIC_IS_LOCAL) {
Sentry.init({
dsn: 'https://296a944ee979fb2cbb84b24658b83ac5@o4505949331390464.ingest.sentry.io/4505949333094400',

// Adjust this value in production, or use tracesSampler for greater control
tracesSampleRate: 1,
// 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,
});
// Setting this option to true will print useful information to the console while you're setting up Sentry.
debug: false,
});
}
2 changes: 2 additions & 0 deletions src/pages/api/add-images-to-work-order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ApiError, ApiResponse } from './_types';
import { errorToResponse } from './_utils';
import { UpdateImagesSchema } from '@/types/customschemas';
import { UpdateImages } from '@/types';
import * as Sentry from '@sentry/nextjs';

export default async function handler(req: NextApiRequest, res: NextApiResponse<ApiResponse>) {
try {
Expand All @@ -31,6 +32,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
return res.status(API_STATUS.SUCCESS).json({ response: 'Successfully added images' });
} catch (error: any) {
console.log({ error });
Sentry.captureException(error);
return res
.status(error?.statusCode || API_STATUS.INTERNAL_SERVER_ERROR)
.json(errorToResponse(error));
Expand Down
2 changes: 2 additions & 0 deletions src/pages/api/assign-technician.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { AssignTechnicianSchema } from '@/types/customschemas';
import { MISSING_ENV, errorToResponse, initializeSendgrid } from './_utils';
import { AssignTechnicianBody } from '@/types';
import { init, track } from '@amplitude/analytics-node';
import * as Sentry from '@sentry/nextjs';

export default async function handler(req: NextApiRequest, res: NextApiResponse<ApiResponse>) {
try {
Expand Down Expand Up @@ -200,6 +201,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
return res.status(API_STATUS.SUCCESS).json({ response: JSON.stringify(assignedTechnician) });
} catch (error: any) {
console.error(error);
Sentry.captureException(error);
return res
.status(error?.statusCode || API_STATUS.INTERNAL_SERVER_ERROR)
.json(errorToResponse(error));
Expand Down
2 changes: 2 additions & 0 deletions src/pages/api/create-comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ApiError, ApiResponse } from './_types';
import { errorToResponse } from './_utils';
import { CreateCommentSchema } from '@/types/customschemas';
import { CreateComment } from '@/types';
import * as Sentry from '@sentry/nextjs';

/**
*
Expand Down Expand Up @@ -43,6 +44,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
return res.status(API_STATUS.SUCCESS).json({ response: JSON.stringify(newComment) });
} catch (error: any) {
console.log({ error });
Sentry.captureException(error);
return res
.status(error?.statusCode || API_STATUS.INTERNAL_SERVER_ERROR)
.json(errorToResponse(error));
Expand Down
2 changes: 2 additions & 0 deletions src/pages/api/create-org.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { API_STATUS, USER_PERMISSION_ERROR } from '@/constants';
import { ApiError, ApiResponse } from './_types';
import { CreateOrgSchema } from '@/types/customschemas';
import { errorToResponse } from './_utils';
import * as Sentry from '@sentry/nextjs';

export default async function handler(req: NextApiRequest, res: NextApiResponse<ApiResponse>) {
try {
Expand All @@ -24,6 +25,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
return res.status(API_STATUS.SUCCESS).json({ response: JSON.stringify(newOrg) });
} catch (error: any) {
console.log({ error });
Sentry.captureException(error);
return res
.status(error?.statusCode || API_STATUS.INTERNAL_SERVER_ERROR)
.json(errorToResponse(error));
Expand Down
2 changes: 2 additions & 0 deletions src/pages/api/create-pm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { errorToResponse, initializeSendgrid } from './_utils';
import { ApiError, ApiResponse } from './_types';
import { CreatePMSchema } from '@/types/customschemas';
import { CreatePM } from '@/types';
import * as Sentry from '@sentry/nextjs';

/**
*
Expand Down Expand Up @@ -114,6 +115,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
return res.status(API_STATUS.SUCCESS).json({ response: JSON.stringify(newPM) });
} catch (error: any) {
console.log({ error });
Sentry.captureException(error);
return res
.status(error?.statusCode || API_STATUS.INTERNAL_SERVER_ERROR)
.json(errorToResponse(error));
Expand Down
2 changes: 2 additions & 0 deletions src/pages/api/create-property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { CreatePropertySchema } from '@/types/customschemas';
import { CreateProperty } from '@/types';
import { ApiError, ApiResponse } from './_types';
import { errorToResponse } from './_utils';
import * as Sentry from '@sentry/nextjs';

/**
*
Expand Down Expand Up @@ -79,6 +80,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
return res.status(API_STATUS.SUCCESS).json({ response: JSON.stringify(newProperty) });
} catch (error: any) {
console.log({ error });
Sentry.captureException(error);
return res
.status(error?.statusCode || API_STATUS.INTERNAL_SERVER_ERROR)
.json(errorToResponse(error));
Expand Down
2 changes: 2 additions & 0 deletions src/pages/api/create-technician.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ApiError, ApiResponse } from './_types';
import { CreateTechnician } from '@/types';
import { CreateTechnicianSchema } from '@/types/customschemas';
import { toTitleCase } from '@/utils';
import * as Sentry from '@sentry/nextjs';

/**
*
Expand Down Expand Up @@ -116,6 +117,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
return res.status(API_STATUS.SUCCESS).json({ response: JSON.stringify(newTechnician) });
} catch (error: any) {
console.log({ error });
Sentry.captureException(error);
return res
.status(error?.statusCode || API_STATUS.INTERNAL_SERVER_ERROR)
.json(errorToResponse(error));
Expand Down
2 changes: 2 additions & 0 deletions src/pages/api/create-tenant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { CreateTenantSchema } from '@/types/customschemas';
import { ApiError, ApiResponse } from './_types';
import { INVALID_PARAM_ERROR, errorToResponse, initializeSendgrid } from './_utils';
import { CreateTenant } from '@/types';
import * as Sentry from '@sentry/nextjs';

/**
*
Expand Down Expand Up @@ -105,6 +106,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
return res.status(API_STATUS.SUCCESS).json({ response: JSON.stringify(newTenant) });
} catch (error: any) {
console.log({ error });
Sentry.captureException(error);
return res
.status(error?.statusCode || API_STATUS.INTERNAL_SERVER_ERROR)
.json(errorToResponse(error));
Expand Down
2 changes: 2 additions & 0 deletions src/pages/api/create-work-order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { CreateWorkOrderSchema } from '@/types/customschemas';
import { ApiError, ApiResponse } from './_types';
import { errorToResponse, initializeSendgrid } from './_utils';
import { CreateWorkOrder } from '@/types';
import * as Sentry from '@sentry/nextjs';

export default async function handler(req: NextApiRequest, res: NextApiResponse<ApiResponse>) {
try {
Expand Down Expand Up @@ -303,6 +304,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
return res.status(API_STATUS.SUCCESS).json({ response: 'Successfully sent email' });
} catch (error: any) {
console.log({ error });
Sentry.captureException(error);
return res
.status(error?.statusCode || API_STATUS.INTERNAL_SERVER_ERROR)
.json(errorToResponse(error));
Expand Down
2 changes: 2 additions & 0 deletions src/pages/api/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { DeleteEntitySchema } from '@/types/customschemas';
import { DeleteEntity } from '@/types';
import { ApiError, ApiResponse } from './_types';
import { errorToResponse } from './_utils';
import * as Sentry from '@sentry/nextjs';

export default async function handler(req: NextApiRequest, res: NextApiResponse<ApiResponse>) {
try {
Expand Down Expand Up @@ -104,6 +105,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
return res.status(API_STATUS.SUCCESS).json({ response: 'Successfully deleted entity' });
} catch (error: any) {
console.log({ error });
Sentry.captureException(error);
return res
.status(error?.status || API_STATUS.INTERNAL_SERVER_ERROR)
.json(errorToResponse(error));
Expand Down
2 changes: 2 additions & 0 deletions src/pages/api/get-all-pms-for-org.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { GetPM } from '@/types';
import { GetPMSchema } from '@/types/customschemas';
import { ApiError, ApiResponse } from './_types';
import { errorToResponse } from './_utils';
import * as Sentry from '@sentry/nextjs';

export default async function handler(req: NextApiRequest, res: NextApiResponse<ApiResponse>) {
try {
Expand All @@ -26,6 +27,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
.json({ response: JSON.stringify({ pms: response.pms, startKey: response.startKey }) });
} catch (error: any) {
console.log({ error });
Sentry.captureException(error);
return res
.status(error?.statusCode || API_STATUS.INTERNAL_SERVER_ERROR)
.json(errorToResponse(error));
Expand Down
2 changes: 2 additions & 0 deletions src/pages/api/get-all-properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { GetProperties } from '@/types';
import { ApiError, ApiResponse } from './_types';
import { GetPropertiesSchema } from '@/types/customschemas';
import { errorToResponse } from './_utils';
import * as Sentry from '@sentry/nextjs';

export default async function handler(req: NextApiRequest, res: NextApiResponse<ApiResponse>) {
try {
Expand Down Expand Up @@ -44,6 +45,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
});
} catch (error: any) {
console.log({ error });
Sentry.captureException(error);
return res
.status(error?.statusCode || API_STATUS.INTERNAL_SERVER_ERROR)
.json(errorToResponse(error));
Expand Down
2 changes: 2 additions & 0 deletions src/pages/api/get-all-tenants-for-org.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { API_STATUS, USER_PERMISSION_ERROR } from '@/constants';
import { ApiError, ApiResponse } from './_types';
import { GetTenantsForOrgSchema } from '@/types/customschemas';
import { errorToResponse } from './_utils';
import * as Sentry from '@sentry/nextjs';

export default async function handler(req: NextApiRequest, res: NextApiResponse<ApiResponse>) {
try {
Expand All @@ -31,6 +32,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
});
} catch (error: any) {
console.log({ error });
Sentry.captureException(error);
return res
.status(error?.statusCode || API_STATUS.INTERNAL_SERVER_ERROR)
.json(errorToResponse(error));
Expand Down
2 changes: 2 additions & 0 deletions src/pages/api/get-all-work-orders-for-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { GetAllWorkOrdersForUserSchema } from '@/types/customschemas';
import { GetAllWorkOrdersForUser } from '@/types';
import { errorToResponse } from './_utils';
import { ApiError, ApiResponse } from './_types';
import * as Sentry from '@sentry/nextjs';

export default async function handler(req: NextApiRequest, res: NextApiResponse<ApiResponse>) {
try {
Expand Down Expand Up @@ -39,6 +40,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
.json({ response: JSON.stringify({ workOrders, startKey: response.startKey }) });
} catch (error: any) {
console.log({ error });
Sentry.captureException(error);
return res
.status(error?.statusCode || API_STATUS.INTERNAL_SERVER_ERROR)
.json(errorToResponse(error));
Expand Down
4 changes: 3 additions & 1 deletion src/pages/api/get-images.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { getServerSession } from 'next-auth/next';
import { options } from './auth/[...nextauth]';
import { API_STATUS, USER_PERMISSION_ERROR } from '@/constants';
import { ApiError } from './_types';
import * as Sentry from '@sentry/nextjs';

export default async function handler(req: NextApiRequest, res: NextApiResponse) {
try {
Expand Down Expand Up @@ -44,7 +45,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
})
);
res.status(API_STATUS.SUCCESS).json({ images });
} catch (error) {
} catch (error: any) {
Sentry.captureException(error);
// @ts-ignore
res.status(API_STATUS.INTERNAL_SERVER_ERROR).send('Failed to Upload Image');
}
Expand Down
2 changes: 2 additions & 0 deletions src/pages/api/get-s3bucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { API_STATUS, USER_PERMISSION_ERROR } from '@/constants';
import { GetS3BucketSchema } from '@/types/customschemas';
import { ApiError, ApiResponse } from './_types';
import { errorToResponse } from './_utils';
import * as Sentry from '@sentry/nextjs';

/*
* Retrieves the value for the given key from the given s3 bucket.
Expand All @@ -33,6 +34,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
return res.status(API_STATUS.SUCCESS).json({ response: url });
} catch (error: any) {
console.error(error);
Sentry.captureException(error);
return res
.status(error?.statusCode || API_STATUS.INTERNAL_SERVER_ERROR)
.json(errorToResponse(error));
Expand Down
2 changes: 2 additions & 0 deletions src/pages/api/get-techs-for-org.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { GetTechsForOrgSchema } from '@/types/customschemas';
import { ApiError, ApiResponse } from './_types';
import { errorToResponse } from './_utils';
import { GetTechsForOrg } from '@/types';
import * as Sentry from '@sentry/nextjs';

export default async function handler(req: NextApiRequest, res: NextApiResponse<ApiResponse>) {
try {
Expand All @@ -31,6 +32,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
.json({ response: JSON.stringify({ techs: response.techs, startKey: response.startKey }) });
} catch (error: any) {
console.log({ error });
Sentry.captureException(error);
return res
.status(error?.statusCode || API_STATUS.INTERNAL_SERVER_ERROR)
.json(errorToResponse(error));
Expand Down
2 changes: 2 additions & 0 deletions src/pages/api/get-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { GetUserSchema } from '@/types/customschemas';
import { GetUserBody } from '@/types';
import { ApiError, ApiResponse } from './_types';
import { errorToResponse } from './_utils';
import * as Sentry from '@sentry/nextjs';

export default async function handler(req: NextApiRequest, res: NextApiResponse<ApiResponse>) {
try {
Expand All @@ -24,6 +25,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
return res.status(API_STATUS.SUCCESS).json({ response: JSON.stringify(user) });
} catch (error: any) {
console.error(error);
Sentry.captureException(error);
return res
.status(error?.statusCode || API_STATUS.INTERNAL_SERVER_ERROR)
.json(errorToResponse(error));
Expand Down
Loading

0 comments on commit 132e80a

Please sign in to comment.