diff --git a/package-lock.json b/package-lock.json index d67d2ae..f181e09 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "tomatoro", - "version": "3.0.180", + "version": "3.0.181", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "tomatoro", - "version": "3.0.180", + "version": "3.0.181", "dependencies": { "@emotion/react": "11.11.4", "@emotion/styled": "11.11.5", diff --git a/package.json b/package.json index e45e102..41f142c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tomatoro", - "version": "3.0.180", + "version": "3.0.181", "private": true, "scripts": { "dev": "next dev", diff --git a/pages/404.tsx b/pages/404.tsx index 77ba7be..0d9e6b2 100644 --- a/pages/404.tsx +++ b/pages/404.tsx @@ -1,3 +1,4 @@ +import * as Sentry from '@sentry/nextjs' import { GetStaticProps } from 'next' import Image from 'next/image' import React from 'react' @@ -14,8 +15,7 @@ const fallbackPage: BasicPage = { id: 'fallback', attributes: { title: 'Oops! 🍅 Time\'s Up!', - // eslint-disable-next-line max-len - content: 'We couldn\'t find the page you\'re looking for.\n\nLet\'s get you back on track!\n\n[Return to Tomatoro Home](/)', + content: 'We couldn\'t find the page you\'re looking for.\n\nLet\'s get you back on track!\n', createdAt: '2023-04-29T00:35:43.151Z', updatedAt: '2023-04-29T00:40:25.617Z', publishedAt: '2023-04-29T00:40:25.617Z', @@ -31,14 +31,19 @@ export const getStaticProps: GetStaticProps< { page: BasicPage }, {} > = async ({ locale }) => { - const fieldParameters = ['seo', 'seo.metaImage', 'hero'].join('&populate[]=') - let page = await getSingleType('error-404', fieldParameters, locale) + try { + const fieldParameters = ['seo', 'seo.metaImage', 'hero'].join('&populate[]=') + let page = await getSingleType('error-404', fieldParameters, locale) - if (!page) { - page = fallbackPage - } + if (!page) { + page = fallbackPage + } - return { props: { page } } + return { props: { page } } + } catch (e) { + Sentry.captureException(e) + return { props: { page: fallbackPage } } + } } export default function Custom404 ({ page }: { page: Post }) { diff --git a/pages/[slug].tsx b/pages/[slug].tsx index b9ce598..8581ce5 100644 --- a/pages/[slug].tsx +++ b/pages/[slug].tsx @@ -1,3 +1,4 @@ +import * as Sentry from '@sentry/nextjs' import { GetStaticProps } from 'next' import React from 'react' import { Grid, Heading } from 'theme-ui' @@ -39,6 +40,7 @@ export const getStaticProps: GetStaticProps< return { props: { post, banners } } } catch (e) { + Sentry.captureException(e) return { notFound: true } } } diff --git a/pages/blog/[slug].tsx b/pages/blog/[slug].tsx index 4b0d507..4e2285c 100644 --- a/pages/blog/[slug].tsx +++ b/pages/blog/[slug].tsx @@ -1,3 +1,4 @@ +import * as Sentry from '@sentry/nextjs' import { GetServerSideProps } from 'next' import React from 'react' import { Grid, Heading } from 'theme-ui' @@ -22,6 +23,7 @@ export const getServerSideProps: GetServerSideProps< return { props: { post } } } catch (e) { + Sentry.captureException(e) return { notFound: true } } } diff --git a/pages/blog/index.tsx b/pages/blog/index.tsx index c65f7ac..485a023 100644 --- a/pages/blog/index.tsx +++ b/pages/blog/index.tsx @@ -1,3 +1,4 @@ +import * as Sentry from '@sentry/nextjs' import { GetServerSideProps } from 'next' import React from 'react' import { Grid, Heading } from 'theme-ui' @@ -12,7 +13,8 @@ export const getServerSideProps: GetServerSideProps<{}> = async ({ locale = 'en' const posts = await getAllPosts(locale as Locale) return { props: { posts } } } catch (e) { - throw new Error('[getServerSideProps] getAllPosts') + Sentry.captureException(e) + return { props: { posts: [] } } } } diff --git a/pages/faq.tsx b/pages/faq.tsx index 64ba9b1..584735d 100644 --- a/pages/faq.tsx +++ b/pages/faq.tsx @@ -1,3 +1,4 @@ +import * as Sentry from '@sentry/nextjs' import { GetServerSideProps } from 'next' import React from 'react' import { Grid, Heading } from 'theme-ui' @@ -20,11 +21,17 @@ export const getServerSideProps: GetServerSideProps<{}> = async ({ locale }) => ]) return { props: { questions, page } } } catch (e) { - throw new Error('[getServerSideProps] getUpdates') + Sentry.captureException(e) + return { props: { questions: [], page: null } } } } -export default function Faq ({ page, questions }: { page: BasicPage, questions: Question[] }) { +interface RouteProps { + questions: Question[] + page: BasicPage | null +} + +export default function Faq ({ page, questions }: RouteProps) { if (!page) { return null } diff --git a/pages/index.tsx b/pages/index.tsx index 9fbe009..b03d894 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,3 +1,4 @@ +import * as Sentry from '@sentry/nextjs' import { GetServerSideProps } from 'next' import React from 'react' import { Box, Divider } from 'theme-ui' @@ -18,7 +19,8 @@ export const getServerSideProps: GetServerSideProps<{}> = async () => { const banners = await getBanners('home') return { props: { banners } } } catch (e) { - throw new Error('[getServerSideProps] getBanners') + Sentry.captureException(e) + return { props: { banners: [] } } } } diff --git a/pages/news.tsx b/pages/news.tsx index 4750816..342f7f8 100644 --- a/pages/news.tsx +++ b/pages/news.tsx @@ -1,3 +1,4 @@ +import * as Sentry from '@sentry/nextjs' import { GetServerSideProps } from 'next' import useTranslation from 'next-translate/useTranslation' import React from 'react' @@ -15,7 +16,8 @@ export const getServerSideProps: GetServerSideProps<{}> = async ({ locale }) => const sortedUpdates = updates.sort((a, b) => b.attributes.date.localeCompare(a.attributes.date)) return { props: { updates: sortedUpdates } } } catch (e) { - throw new Error('[getServerSideProps] getUpdates') + Sentry.captureException(e) + return { props: { updates: [] } } } } diff --git a/pages/preguntas-frecuentes.tsx b/pages/preguntas-frecuentes.tsx index 64ba9b1..584735d 100644 --- a/pages/preguntas-frecuentes.tsx +++ b/pages/preguntas-frecuentes.tsx @@ -1,3 +1,4 @@ +import * as Sentry from '@sentry/nextjs' import { GetServerSideProps } from 'next' import React from 'react' import { Grid, Heading } from 'theme-ui' @@ -20,11 +21,17 @@ export const getServerSideProps: GetServerSideProps<{}> = async ({ locale }) => ]) return { props: { questions, page } } } catch (e) { - throw new Error('[getServerSideProps] getUpdates') + Sentry.captureException(e) + return { props: { questions: [], page: null } } } } -export default function Faq ({ page, questions }: { page: BasicPage, questions: Question[] }) { +interface RouteProps { + questions: Question[] + page: BasicPage | null +} + +export default function Faq ({ page, questions }: RouteProps) { if (!page) { return null } diff --git a/pages/sitemap.tsx b/pages/sitemap.tsx index e53ec5b..bef177f 100644 --- a/pages/sitemap.tsx +++ b/pages/sitemap.tsx @@ -1,3 +1,4 @@ +import * as Sentry from '@sentry/nextjs' import { GetServerSideProps } from 'next' import { getAllPosts } from '~/utils/cms.api' @@ -54,7 +55,7 @@ export const getServerSideProps: GetServerSideProps<{}> = async ({ res }) => { getAllPosts('es'), ]) const sitemap = generateSiteMap({ - posts: { en: postsEn, es: postsEs } , + posts: { en: postsEn, es: postsEs }, domain: 'https://tomatoro.com', staticPages, }) @@ -67,7 +68,8 @@ export const getServerSideProps: GetServerSideProps<{}> = async ({ res }) => { props: {}, } } catch (e) { - throw new Error('[getServerSideProps] sitemap') + Sentry.captureException(e) + return { props: {} } } }