Skip to content

Commit

Permalink
Merge pull request #101 from goodeats/100-vite-sentry-setup
Browse files Browse the repository at this point in the history
vite sentry setup
  • Loading branch information
goodeats authored May 22, 2024
2 parents e0a597e + 13adc56 commit 98d6868
Show file tree
Hide file tree
Showing 19 changed files with 310 additions and 70 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,5 +178,6 @@ jobs:
# if: ${{ github.ref == 'refs/heads/main' }}
# run:
# flyctl deploy --remote-only --build-arg COMMIT_SHA=${{ github.sha }}
# --build-secret SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}
# env:
# FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
12 changes: 9 additions & 3 deletions app/entry.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
} from '@remix-run/node'
import { RemixServer } from '@remix-run/react'
import * as Sentry from '@sentry/remix'
import chalk from 'chalk'
import isbot from 'isbot'
import { renderToPipeableStream } from 'react-dom/server'
import { getEnv, init } from './utils/env.server.ts'
Expand Down Expand Up @@ -70,10 +71,8 @@ export default async function handleRequest(...args: DocRequestArgs) {
onShellError: (err: unknown) => {
reject(err)
},
onError: (error: unknown) => {
onError: () => {
didError = true

console.error(error)
},
nonce,
},
Expand All @@ -97,9 +96,16 @@ export function handleError(
error: unknown,
{ request }: LoaderFunctionArgs | ActionFunctionArgs,
): void {
// Skip capturing if the request is aborted as Remix docs suggest
// Ref: https://remix.run/docs/en/main/file-conventions/entry.server#handleerror
if (request.signal.aborted) {
return
}
if (error instanceof Error) {
console.error(chalk.red(error.stack))
Sentry.captureRemixServerException(error, 'remix.server', request)
} else {
console.error(chalk.red(error))
Sentry.captureException(error)
}
}
2 changes: 1 addition & 1 deletion app/models/user/user.server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type User } from '@sentry/remix'
import { type User } from '@prisma/client'
import { type DateOrString } from '#app/definitions/prisma-helper'

// Omitting 'createdAt' and 'updatedAt' from the User interface
Expand Down
8 changes: 4 additions & 4 deletions app/services/design-type/update-fill.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { type User } from '@sentry/remix'
import { type IDesign } from '#app/models/design/design.server'
import { type IFill } from '#app/models/design-type/fill/fill.server'
import {
Expand All @@ -7,14 +6,15 @@ import {
updateDesignTypeFillValue,
updateDesignTypeFillStyle,
} from '#app/models/design-type/fill/fill.update.server'
import { type IUser } from '#app/models/user/user.server'

export const updateDesignTypeFillValueService = async ({
userId,
id,
designId,
value,
}: {
userId: User['id']
userId: IUser['id']
id: IFill['id']
designId: IDesign['id']
value: number
Expand Down Expand Up @@ -44,7 +44,7 @@ export const updateDesignTypeFillBasisService = async ({
designId,
basis,
}: {
userId: User['id']
userId: IUser['id']
id: IFill['id']
designId: IDesign['id']
basis: string
Expand Down Expand Up @@ -74,7 +74,7 @@ export const updateDesignTypeFillStyleService = async ({
designId,
style,
}: {
userId: User['id']
userId: IUser['id']
id: IFill['id']
designId: IDesign['id']
style: string
Expand Down
10 changes: 5 additions & 5 deletions app/services/design-type/update-layout.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { type User } from '@sentry/remix'
import { type IDesign } from '#app/models/design/design.server'
import { type ILayout } from '#app/models/design-type/layout/layout.server'
import {
Expand All @@ -8,14 +7,15 @@ import {
updateDesignTypeLayoutColumns,
updateDesignTypeLayoutStyle,
} from '#app/models/design-type/layout/layout.update.server'
import { type IUser } from '#app/models/user/user.server'

export const updateDesignTypeLayoutCountService = async ({
userId,
id,
designId,
count,
}: {
userId: User['id']
userId: IUser['id']
id: ILayout['id']
designId: IDesign['id']
count: number
Expand Down Expand Up @@ -45,7 +45,7 @@ export const updateDesignTypeLayoutRowsService = async ({
designId,
rows,
}: {
userId: User['id']
userId: IUser['id']
id: ILayout['id']
designId: IDesign['id']
rows: number
Expand Down Expand Up @@ -75,7 +75,7 @@ export const updateDesignTypeLayoutColumnsService = async ({
designId,
columns,
}: {
userId: User['id']
userId: IUser['id']
id: ILayout['id']
designId: IDesign['id']
columns: number
Expand Down Expand Up @@ -105,7 +105,7 @@ export const updateDesignTypeLayoutStyleService = async ({
designId,
style,
}: {
userId: User['id']
userId: IUser['id']
id: ILayout['id']
designId: IDesign['id']
style: number
Expand Down
8 changes: 4 additions & 4 deletions app/services/design-type/update-line.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { type User } from '@sentry/remix'
import { type IDesign } from '#app/models/design/design.server'
import { type ILine } from '#app/models/design-type/line/line.server'
import {
Expand All @@ -7,14 +6,15 @@ import {
updateDesignTypeLineBasis,
updateDesignTypeLineFormat,
} from '#app/models/design-type/line/line.update.server'
import { type IUser } from '#app/models/user/user.server'

export const updateDesignTypeLineWidthService = async ({
userId,
id,
designId,
width,
}: {
userId: User['id']
userId: IUser['id']
id: ILine['id']
designId: IDesign['id']
width: number
Expand Down Expand Up @@ -44,7 +44,7 @@ export const updateDesignTypeLineBasisService = async ({
designId,
basis,
}: {
userId: User['id']
userId: IUser['id']
id: ILine['id']
designId: IDesign['id']
basis: string
Expand Down Expand Up @@ -74,7 +74,7 @@ export const updateDesignTypeLineFormatService = async ({
designId,
format,
}: {
userId: User['id']
userId: IUser['id']
id: ILine['id']
designId: IDesign['id']
format: string
Expand Down
4 changes: 2 additions & 2 deletions app/services/design-type/update-palette.service.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { type User } from '@sentry/remix'
import { type IDesign } from '#app/models/design/design.server'
import { type IPalette } from '#app/models/design-type/palette/palette.server'
import {
type IDesignTypePaletteUpdatedResponse,
updateDesignTypePaletteValue,
} from '#app/models/design-type/palette/palette.update.server'
import { type IUser } from '#app/models/user/user.server'

export const updateDesignTypePaletteValueService = async ({
userId,
id,
designId,
value,
}: {
userId: User['id']
userId: IUser['id']
id: IPalette['id']
designId: IDesign['id']
value: number
Expand Down
6 changes: 3 additions & 3 deletions app/services/design-type/update-rotate.service.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { type User } from '@sentry/remix'
import { type IDesign } from '#app/models/design/design.server'
import { type IRotate } from '#app/models/design-type/rotate/rotate.server'
import {
type IDesignTypeRotateUpdatedResponse,
updateDesignTypeRotateValue,
updateDesignTypeRotateBasis,
} from '#app/models/design-type/rotate/rotate.update.server'
import { type IUser } from '#app/models/user/user.server'

export const updateDesignTypeRotateValueService = async ({
userId,
id,
designId,
value,
}: {
userId: User['id']
userId: IUser['id']
id: IRotate['id']
designId: IDesign['id']
value: number
Expand Down Expand Up @@ -43,7 +43,7 @@ export const updateDesignTypeRotateBasisService = async ({
designId,
basis,
}: {
userId: User['id']
userId: IUser['id']
id: IRotate['id']
designId: IDesign['id']
basis: string
Expand Down
8 changes: 4 additions & 4 deletions app/services/design-type/update-size.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { type User } from '@sentry/remix'
import { type IDesign } from '#app/models/design/design.server'
import { type ISize } from '#app/models/design-type/size/size.server'
import {
Expand All @@ -7,14 +6,15 @@ import {
updateDesignTypeSizeBasis,
updateDesignTypeSizeFormat,
} from '#app/models/design-type/size/size.update.server'
import { type IUser } from '#app/models/user/user.server'

export const updateDesignTypeSizeValueService = async ({
userId,
id,
designId,
value,
}: {
userId: User['id']
userId: IUser['id']
id: ISize['id']
designId: IDesign['id']
value: number
Expand Down Expand Up @@ -44,7 +44,7 @@ export const updateDesignTypeSizeBasisService = async ({
designId,
basis,
}: {
userId: User['id']
userId: IUser['id']
id: ISize['id']
designId: IDesign['id']
basis: string
Expand Down Expand Up @@ -74,7 +74,7 @@ export const updateDesignTypeSizeFormatService = async ({
designId,
format,
}: {
userId: User['id']
userId: IUser['id']
id: ISize['id']
designId: IDesign['id']
format: string
Expand Down
8 changes: 4 additions & 4 deletions app/services/design-type/update-stroke.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { type User } from '@sentry/remix'
import { type IDesign } from '#app/models/design/design.server'
import { type IStroke } from '#app/models/design-type/stroke/stroke.server'
import {
Expand All @@ -7,14 +6,15 @@ import {
updateDesignTypeStrokeStyle,
updateDesignTypeStrokeValue,
} from '#app/models/design-type/stroke/stroke.update.server'
import { type IUser } from '#app/models/user/user.server'

export const updateDesignTypeStrokeValueService = async ({
userId,
id,
designId,
value,
}: {
userId: User['id']
userId: IUser['id']
id: IStroke['id']
designId: IDesign['id']
value: number
Expand Down Expand Up @@ -44,7 +44,7 @@ export const updateDesignTypeStrokeBasisService = async ({
designId,
basis,
}: {
userId: User['id']
userId: IUser['id']
id: IStroke['id']
designId: IDesign['id']
basis: string
Expand Down Expand Up @@ -74,7 +74,7 @@ export const updateDesignTypeStrokeStyleService = async ({
designId,
style,
}: {
userId: User['id']
userId: IUser['id']
id: IStroke['id']
designId: IDesign['id']
style: string
Expand Down
8 changes: 4 additions & 4 deletions app/services/design-type/update-template.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { type User } from '@sentry/remix'
import { type IDesign } from '#app/models/design/design.server'
import { type IFill } from '#app/models/design-type/fill/fill.server'
import {
Expand All @@ -7,14 +6,15 @@ import {
updateDesignTypeFillValue,
updateDesignTypeFillStyle,
} from '#app/models/design-type/fill/fill.update.server'
import { type IUser } from '#app/models/user/user.server'

export const updateDesignTypeFillValueService = async ({
userId,
id,
designId,
value,
}: {
userId: User['id']
userId: IUser['id']
id: IFill['id']
designId: IDesign['id']
value: number
Expand Down Expand Up @@ -44,7 +44,7 @@ export const updateDesignTypeFillBasisService = async ({
designId,
basis,
}: {
userId: User['id']
userId: IUser['id']
id: IFill['id']
designId: IDesign['id']
basis: string
Expand Down Expand Up @@ -74,7 +74,7 @@ export const updateDesignTypeFillStyleService = async ({
designId,
style,
}: {
userId: User['id']
userId: IUser['id']
id: IFill['id']
designId: IDesign['id']
style: string
Expand Down
13 changes: 13 additions & 0 deletions app/utils/monitoring.client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ export function init() {
Sentry.init({
dsn: ENV.SENTRY_DSN,
environment: ENV.MODE,
beforeSend(event) {
if (event.request?.url) {
const url = new URL(event.request.url)
if (
url.protocol === 'chrome-extension:' ||
url.protocol === 'moz-extension:'
) {
// This error is from a browser extension, ignore it
return null
}
}
return event
},
integrations: [
new Sentry.BrowserTracing({
routingInstrumentation: Sentry.remixRouterInstrumentation(
Expand Down
3 changes: 0 additions & 3 deletions fly.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ auto_rollback = true
source = "data"
destination = "/data"

[deploy]
release_command = "node ./other/sentry-create-release"

[[services]]
internal_port = 8080
processes = [ "app" ]
Expand Down
Loading

0 comments on commit 98d6868

Please sign in to comment.