⬆️ Upgrade sentry and improve its reliability
This commit is contained in:
@ -54,20 +54,32 @@ const nextConfig = {
|
||||
},
|
||||
}
|
||||
|
||||
const sentryWebpackPluginOptions = {
|
||||
export default withSentryConfig(
|
||||
nextConfig,
|
||||
{
|
||||
// For all available options, see:
|
||||
// https://github.com/getsentry/sentry-webpack-plugin#options
|
||||
|
||||
// Suppresses source map uploading logs during build
|
||||
silent: true,
|
||||
release: process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA + '-builder',
|
||||
}
|
||||
|
||||
export default process.env.NEXT_PUBLIC_SENTRY_DSN
|
||||
? withSentryConfig(
|
||||
org: process.env.SENTRY_ORG,
|
||||
project: process.env.SENTRY_PROJECT,
|
||||
},
|
||||
{
|
||||
...nextConfig,
|
||||
sentry: {
|
||||
hideSourceMaps: true,
|
||||
// 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,
|
||||
},
|
||||
},
|
||||
sentryWebpackPluginOptions
|
||||
)
|
||||
: nextConfig
|
||||
|
||||
// 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,
|
||||
}
|
||||
)
|
||||
|
@ -26,13 +26,13 @@
|
||||
"@giphy/react-components": "7.1.0",
|
||||
"@googleapis/drive": "8.0.0",
|
||||
"@paralleldrive/cuid2": "2.2.1",
|
||||
"@sentry/nextjs": "7.66.0",
|
||||
"@sentry/nextjs": "7.73.0",
|
||||
"@tanstack/react-query": "^4.29.19",
|
||||
"@tanstack/react-table": "8.9.3",
|
||||
"@trpc/client": "10.34.0",
|
||||
"@trpc/next": "10.34.0",
|
||||
"@trpc/react-query": "10.34.0",
|
||||
"@trpc/server": "10.34.0",
|
||||
"@trpc/client": "10.40.0",
|
||||
"@trpc/next": "10.40.0",
|
||||
"@trpc/react-query": "10.40.0",
|
||||
"@trpc/server": "10.40.0",
|
||||
"@typebot.io/bot-engine": "workspace:*",
|
||||
"@typebot.io/emails": "workspace:*",
|
||||
"@typebot.io/env": "workspace:*",
|
||||
|
@ -1,6 +1,12 @@
|
||||
import * as Sentry from '@sentry/nextjs'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
|
||||
Sentry.init({
|
||||
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
|
||||
release: process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA + '-builder',
|
||||
integrations: [
|
||||
new Sentry.Integrations.Prisma({
|
||||
client: prisma,
|
||||
}),
|
||||
],
|
||||
})
|
@ -1,6 +1,6 @@
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authOptions } from '@/pages/api/auth/[...nextauth]'
|
||||
import { setUser } from '@sentry/nextjs'
|
||||
import * as Sentry from '@sentry/nextjs'
|
||||
import { User } from '@typebot.io/prisma'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { getServerSession } from 'next-auth'
|
||||
@ -19,7 +19,7 @@ export const getAuthenticatedUser = async (
|
||||
| User
|
||||
| undefined)
|
||||
if (!user || !('id' in user)) return
|
||||
setUser({ id: user.id })
|
||||
Sentry.setUser({ id: user.id })
|
||||
return user
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ const authenticateByToken = async (
|
||||
const user = (await prisma.user.findFirst({
|
||||
where: { apiTokens: { some: { token: apiToken } } },
|
||||
})) as User
|
||||
setUser({ id: user.id })
|
||||
Sentry.setUser({ id: user.id })
|
||||
return user
|
||||
}
|
||||
|
||||
|
@ -2,11 +2,18 @@ import { TRPCError, initTRPC } from '@trpc/server'
|
||||
import { Context } from './context'
|
||||
import { OpenApiMeta } from 'trpc-openapi'
|
||||
import superjson from 'superjson'
|
||||
import * as Sentry from '@sentry/nextjs'
|
||||
|
||||
const t = initTRPC.context<Context>().meta<OpenApiMeta>().create({
|
||||
transformer: superjson,
|
||||
})
|
||||
|
||||
const sentryMiddleware = t.middleware(
|
||||
Sentry.Handlers.trpcMiddleware({
|
||||
attachRpcInput: true,
|
||||
})
|
||||
)
|
||||
|
||||
const isAuthed = t.middleware(({ next, ctx }) => {
|
||||
if (!ctx.user?.id) {
|
||||
throw new TRPCError({
|
||||
@ -20,10 +27,12 @@ const isAuthed = t.middleware(({ next, ctx }) => {
|
||||
})
|
||||
})
|
||||
|
||||
const finalMiddleware = sentryMiddleware.unstable_pipe(isAuthed)
|
||||
|
||||
export const middleware = t.middleware
|
||||
|
||||
export const router = t.router
|
||||
|
||||
export const publicProcedure = t.procedure
|
||||
export const publicProcedure = t.procedure.use(sentryMiddleware)
|
||||
|
||||
export const authenticatedProcedure = t.procedure.use(isAuthed)
|
||||
export const authenticatedProcedure = t.procedure.use(finalMiddleware)
|
||||
|
@ -18,6 +18,7 @@ import { Ratelimit } from '@upstash/ratelimit'
|
||||
import { Redis } from '@upstash/redis/nodejs'
|
||||
import got from 'got'
|
||||
import { env } from '@typebot.io/env'
|
||||
import * as Sentry from '@sentry/nextjs'
|
||||
|
||||
const providers: Provider[] = []
|
||||
|
||||
@ -134,6 +135,14 @@ export const authOptions: AuthOptions = {
|
||||
signIn: '/signin',
|
||||
newUser: env.NEXT_PUBLIC_ONBOARDING_TYPEBOT_ID ? '/onboarding' : undefined,
|
||||
},
|
||||
events: {
|
||||
signIn({ user }) {
|
||||
Sentry.setUser({ id: user.id })
|
||||
},
|
||||
signOut() {
|
||||
Sentry.setUser(null)
|
||||
},
|
||||
},
|
||||
callbacks: {
|
||||
session: async ({ session, user }) => {
|
||||
const userFromDb = user as User
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { createContext } from '@/helpers/server/context'
|
||||
import { trpcRouter } from '@/helpers/server/routers/v1/trpcRouter'
|
||||
import { captureException } from '@sentry/nextjs'
|
||||
import * as Sentry from '@sentry/nextjs'
|
||||
import { createNextApiHandler } from '@trpc/server/adapters/next'
|
||||
|
||||
export default createNextApiHandler({
|
||||
@ -8,7 +8,7 @@ export default createNextApiHandler({
|
||||
createContext,
|
||||
onError({ error }) {
|
||||
if (error.code === 'INTERNAL_SERVER_ERROR') {
|
||||
captureException(error)
|
||||
Sentry.captureException(error)
|
||||
console.error('Something went wrong', error)
|
||||
}
|
||||
return error
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { createContext } from '@/helpers/server/context'
|
||||
import { trpcRouter } from '@/helpers/server/routers/v1/trpcRouter'
|
||||
import { captureException } from '@sentry/nextjs'
|
||||
import * as Sentry from '@sentry/nextjs'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { createOpenApiNextHandler } from 'trpc-openapi'
|
||||
import cors from 'nextjs-cors'
|
||||
@ -15,7 +15,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
createContext,
|
||||
onError({ error }) {
|
||||
if (error.code === 'INTERNAL_SERVER_ERROR') {
|
||||
captureException(error)
|
||||
Sentry.captureException(error)
|
||||
console.error('Something went wrong', error)
|
||||
}
|
||||
},
|
||||
|
@ -134,20 +134,32 @@ const nextConfig = {
|
||||
},
|
||||
}
|
||||
|
||||
const sentryWebpackPluginOptions = {
|
||||
export default withSentryConfig(
|
||||
nextConfig,
|
||||
{
|
||||
// For all available options, see:
|
||||
// https://github.com/getsentry/sentry-webpack-plugin#options
|
||||
|
||||
// Suppresses source map uploading logs during build
|
||||
silent: true,
|
||||
release: process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA + '-viewer',
|
||||
}
|
||||
|
||||
export default process.env.NEXT_PUBLIC_SENTRY_DSN
|
||||
? withSentryConfig(
|
||||
org: process.env.SENTRY_ORG,
|
||||
project: process.env.SENTRY_PROJECT,
|
||||
},
|
||||
{
|
||||
...nextConfig,
|
||||
sentry: {
|
||||
hideSourceMaps: true,
|
||||
// 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,
|
||||
},
|
||||
},
|
||||
sentryWebpackPluginOptions
|
||||
)
|
||||
: nextConfig
|
||||
|
||||
// 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,
|
||||
}
|
||||
)
|
||||
|
@ -12,8 +12,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@planetscale/database": "^1.8.0",
|
||||
"@sentry/nextjs": "7.66.0",
|
||||
"@trpc/server": "10.34.0",
|
||||
"@sentry/nextjs": "7.73.0",
|
||||
"@trpc/server": "10.40.0",
|
||||
"@typebot.io/bot-engine": "workspace:*",
|
||||
"@typebot.io/nextjs": "workspace:*",
|
||||
"@typebot.io/prisma": "workspace:*",
|
||||
|
@ -1,6 +1,12 @@
|
||||
import * as Sentry from '@sentry/nextjs'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
|
||||
Sentry.init({
|
||||
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
|
||||
release: process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA + '-viewer',
|
||||
integrations: [
|
||||
new Sentry.Integrations.Prisma({
|
||||
client: prisma,
|
||||
}),
|
||||
],
|
||||
})
|
@ -2,11 +2,18 @@ import { initTRPC } from '@trpc/server'
|
||||
import { OpenApiMeta } from 'trpc-openapi'
|
||||
import superjson from 'superjson'
|
||||
import { Context } from './context'
|
||||
import * as Sentry from '@sentry/nextjs'
|
||||
|
||||
const t = initTRPC.context<Context>().meta<OpenApiMeta>().create({
|
||||
transformer: superjson,
|
||||
})
|
||||
|
||||
const sentryMiddleware = t.middleware(
|
||||
Sentry.Handlers.trpcMiddleware({
|
||||
attachRpcInput: true,
|
||||
})
|
||||
)
|
||||
|
||||
const injectUser = t.middleware(({ next, ctx }) => {
|
||||
return next({
|
||||
ctx: {
|
||||
@ -15,8 +22,10 @@ const injectUser = t.middleware(({ next, ctx }) => {
|
||||
})
|
||||
})
|
||||
|
||||
const finalMiddleware = sentryMiddleware.unstable_pipe(injectUser)
|
||||
|
||||
export const middleware = t.middleware
|
||||
|
||||
export const router = t.router
|
||||
|
||||
export const publicProcedure = t.procedure.use(injectUser)
|
||||
export const publicProcedure = t.procedure.use(finalMiddleware)
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { appRouter } from '@/helpers/server/routers/appRouterV1'
|
||||
import { captureException } from '@sentry/nextjs'
|
||||
import * as Sentry from '@sentry/nextjs'
|
||||
import { createOpenApiNextHandler } from 'trpc-openapi'
|
||||
import cors from 'nextjs-cors'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
@ -13,7 +13,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
createContext,
|
||||
onError({ error }) {
|
||||
if (error.code === 'INTERNAL_SERVER_ERROR') {
|
||||
captureException(error)
|
||||
Sentry.captureException(error)
|
||||
console.error('Something went wrong', error)
|
||||
}
|
||||
},
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { appRouter } from '@/helpers/server/routers/appRouterV2'
|
||||
import { captureException } from '@sentry/nextjs'
|
||||
import * as Sentry from '@sentry/nextjs'
|
||||
import { createOpenApiNextHandler } from 'trpc-openapi'
|
||||
import cors from 'nextjs-cors'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
@ -13,7 +13,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
createContext,
|
||||
onError({ error }) {
|
||||
if (error.code === 'INTERNAL_SERVER_ERROR') {
|
||||
captureException(error)
|
||||
Sentry.captureException(error)
|
||||
console.error('Something went wrong', error)
|
||||
}
|
||||
},
|
||||
|
@ -3,9 +3,7 @@
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": [
|
||||
"src/*"
|
||||
]
|
||||
"@/*": ["src/*"]
|
||||
},
|
||||
"plugins": [
|
||||
{
|
||||
@ -14,10 +12,5 @@
|
||||
],
|
||||
"strictNullChecks": true
|
||||
},
|
||||
"include": [
|
||||
"next-env.d.ts",
|
||||
"**/*.ts",
|
||||
"**/*.tsx",
|
||||
".next/types/**/*.ts"
|
||||
]
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"]
|
||||
}
|
||||
|
@ -8,8 +8,8 @@
|
||||
"dependencies": {
|
||||
"@paralleldrive/cuid2": "2.2.1",
|
||||
"@planetscale/database": "^1.8.0",
|
||||
"@sentry/nextjs": "7.66.0",
|
||||
"@trpc/server": "10.34.0",
|
||||
"@sentry/nextjs": "7.73.0",
|
||||
"@trpc/server": "10.40.0",
|
||||
"@typebot.io/emails": "workspace:*",
|
||||
"@typebot.io/env": "workspace:*",
|
||||
"@typebot.io/lib": "workspace:*",
|
||||
|
@ -10,7 +10,7 @@ import {
|
||||
} from '@typebot.io/schemas/features/whatsapp'
|
||||
import { convertMessageToWhatsAppMessage } from './convertMessageToWhatsAppMessage'
|
||||
import { sendWhatsAppMessage } from './sendWhatsAppMessage'
|
||||
import { captureException } from '@sentry/nextjs'
|
||||
import * as Sentry from '@sentry/nextjs'
|
||||
import { HTTPError } from 'got'
|
||||
import { convertInputToWhatsAppMessages } from './convertInputToWhatsAppMessage'
|
||||
import { isNotDefined } from '@typebot.io/lib/utils'
|
||||
@ -108,7 +108,7 @@ export const sendChatReplyToWhatsApp = async ({
|
||||
})
|
||||
}
|
||||
} catch (err) {
|
||||
captureException(err, { extra: { message } })
|
||||
Sentry.captureException(err, { extra: { message } })
|
||||
console.log('Failed to send message:', JSON.stringify(message, null, 2))
|
||||
if (err instanceof HTTPError)
|
||||
console.log('HTTPError', err.response.statusCode, err.response.body)
|
||||
@ -139,7 +139,7 @@ export const sendChatReplyToWhatsApp = async ({
|
||||
credentials,
|
||||
})
|
||||
} catch (err) {
|
||||
captureException(err, { extra: { message } })
|
||||
Sentry.captureException(err, { extra: { message } })
|
||||
console.log('Failed to send message:', JSON.stringify(message, null, 2))
|
||||
if (err instanceof HTTPError)
|
||||
console.log('HTTPError', err.response.statusCode, err.response.body)
|
||||
@ -209,7 +209,7 @@ const executeClientSideAction =
|
||||
credentials: context.credentials,
|
||||
})
|
||||
} catch (err) {
|
||||
captureException(err, { extra: { message } })
|
||||
Sentry.captureException(err, { extra: { message } })
|
||||
console.log('Failed to send message:', JSON.stringify(message, null, 2))
|
||||
if (err instanceof HTTPError)
|
||||
console.log('HTTPError', err.response.statusCode, err.response.body)
|
||||
|
@ -58,7 +58,8 @@ export const startWhatsAppSession = async ({
|
||||
|
||||
const publicTypebotWithMatchedCondition = botsWithWhatsAppEnabled.find(
|
||||
(publicTypebot) =>
|
||||
publicTypebot.settings.whatsApp?.startCondition &&
|
||||
(publicTypebot.settings.whatsApp?.startCondition?.comparisons.length ??
|
||||
0) > 0 &&
|
||||
messageMatchStartCondition(
|
||||
incomingMessage ?? '',
|
||||
publicTypebot.settings.whatsApp?.startCondition
|
||||
|
@ -22,8 +22,8 @@
|
||||
"nodemailer": "6.7.8"
|
||||
},
|
||||
"dependencies": {
|
||||
"@sentry/nextjs": "7.66.0",
|
||||
"@trpc/server": "10.34.0",
|
||||
"@sentry/nextjs": "7.73.0",
|
||||
"@trpc/server": "10.40.0",
|
||||
"@udecode/plate-common": "^21.1.5",
|
||||
"got": "12.6.0",
|
||||
"minio": "7.1.3",
|
||||
|
3458
pnpm-lock.yaml
generated
3458
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user