Skip to content

Commit

Permalink
chore(sentry): remove duplicate sentry-logging (#1776)
Browse files Browse the repository at this point in the history
  • Loading branch information
SelmaBergstrand authored Jan 6, 2025
1 parent 4013804 commit 938676b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 65 deletions.
61 changes: 18 additions & 43 deletions tavla/pages/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,55 +10,30 @@ import { useRefresh } from 'hooks/useRefresh'
import { getBackendUrl } from 'utils/index'
import Head from 'next/head'
import { useEffect } from 'react'
import { GetServerSideProps } from 'next'
import * as Sentry from '@sentry/nextjs'

export const getServerSideProps: GetServerSideProps = async (context) => {
try {
const { params, req } = context
if (!params || !req) {
Sentry.captureMessage('Missing params or req in getServerSideProps')
return {
notFound: true,
}
}
const { id } = params as { id: string }

if (!id) {
Sentry.captureMessage('Missing board ID in getServerSideProps')
return {
notFound: true,
}
}

const board: TBoard | undefined = await getBoard(id)

if (!board) {
//Sentry.captureMessage('Board is undefined in getServerSideProps')
return {
notFound: true,
}
}

const organization = await getOrganizationWithBoard(id)
export async function getServerSideProps({
params,
}: {
params: { id: string }
}) {
const { id } = params
const board: TBoard | undefined = await getBoard(id)

return {
props: {
board,
organization,
backend_url: getBackendUrl(),
},
}
} catch (error) {
Sentry.captureException(error, {
extra: {
message: 'Unknown error occurred in getServerSideProps',
},
})
if (!board) {
return {
notFound: true,
}
}

const organization = await getOrganizationWithBoard(id)

return {
props: {
board,
organization,
backend_url: getBackendUrl(),
},
}
}

function BoardPage({
Expand Down
11 changes: 0 additions & 11 deletions tavla/src/Board/scenarios/QuayTile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
DataFetchingFailed,
FetchErrorTypes,
} from 'Board/components/DataFetchingFailed'
import * as Sentry from '@sentry/nextjs'

export function QuayTile({
placeId,
Expand Down Expand Up @@ -40,16 +39,6 @@ export function QuayTile({
}

if (error || !data || !data.quay) {
if (!error) {
Sentry.captureException(
new Error('Departure fetch for quay returned no data'),
{
extra: {
quayId: placeId,
},
},
)
}
return (
<Tile>
<DataFetchingFailed
Expand Down
11 changes: 0 additions & 11 deletions tavla/src/Board/scenarios/StopPlaceTile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
DataFetchingFailed,
FetchErrorTypes,
} from 'Board/components/DataFetchingFailed'
import * as Sentry from '@sentry/nextjs'

export function StopPlaceTile({
placeId,
Expand Down Expand Up @@ -39,16 +38,6 @@ export function StopPlaceTile({
}

if (error || !data || !data.stopPlace) {
if (!error) {
Sentry.captureException(
new Error('Departure fetch for stopPlace returned no data'),
{
extra: {
stopPlaceId: placeId,
},
},
)
}
return (
<Tile>
<DataFetchingFailed
Expand Down

0 comments on commit 938676b

Please sign in to comment.