Skip to content

Commit

Permalink
fix: password reset & review add (#743)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeKarow authored Aug 28, 2023
2 parents 30a0515 + 6a0d3d1 commit 1f7af7b
Show file tree
Hide file tree
Showing 31 changed files with 472 additions and 588 deletions.
1 change: 0 additions & 1 deletion apps/app/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable import/no-unused-modules */
module.exports = {
plugins: ['i18next'],
extends: ['@weareinreach/eslint-config/next'],
Expand Down
1 change: 0 additions & 1 deletion apps/app/instrumentation.node.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable turbo/no-undeclared-env-vars */
/* eslint-disable node/no-process-env */
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http'
import { Resource } from '@opentelemetry/resources'
Expand Down
22 changes: 5 additions & 17 deletions apps/app/next-i18next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable turbo/no-undeclared-env-vars */
/* eslint-disable node/no-process-env */
// @ts-check
import LanguageDetector from 'i18next-browser-languagedetector'
Expand All @@ -10,20 +9,9 @@ import MultiBackend from 'i18next-multiload-backend-adapter'

import path from 'path'

export const namespaces = [
'attribute',
'common',
'country',
'gov-dist',
// 'org-data',
// 'org-description',
// 'org-service',
'phone-type',
'services',
'user',
]
const isBrowser = typeof window !== 'undefined'

const isDev = process.env.NODE_ENV !== 'production'
const isVerbose = !!process.env.NEXT_VERBOSE
// const Keys = z.record(z.string())

/**
Expand Down Expand Up @@ -60,8 +48,8 @@ const config = {
defaultNS: 'common',
localePath: path.resolve('./public/locales'),
fallbackLng: ['en'],
reloadOnPrerender: process.env.NODE_ENV !== 'production',
debug: process.env.NODE_ENV !== 'production' && isBrowser && !!process.env.NEXT_VERBOSE,
reloadOnPrerender: isDev,
debug: isDev && isBrowser && isVerbose,
partialBundledLanguages: true,
nonExplicitSupportedLngs: true,
cleanCode: true,
Expand Down Expand Up @@ -91,7 +79,7 @@ const config = {
interpolation: {
skipOnVariables: false,
alwaysFormat: true,
format: (value, format, lng, edit) => {
format: (value, format) => {
switch (format) {
case 'lowercase': {
if (typeof value === 'string') return value.toLowerCase()
Expand Down
46 changes: 37 additions & 9 deletions apps/app/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import bundleAnalyze from '@next/bundle-analyzer'
import { PrismaPlugin } from '@prisma/nextjs-monorepo-workaround-plugin'
import { withSentryConfig } from '@sentry/nextjs'
import withRoutes from 'nextjs-routes/config'
import routes from 'nextjs-routes/config'
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'

import path from 'path'
import { fileURLToPath } from 'url'
Expand All @@ -14,18 +15,28 @@ const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)

const isVercelActiveDev = process.env.VERCEL_ENV === 'preview' && process.env.VERCEL_GIT_COMMIT_REF !== 'dev'
const isVercelProd = process.env.VERCEL_ENV === 'production'
const isLocalDev =
process.env.NODE_ENV === 'development' && !['preview', 'production'].includes(process.env.VERCEL_ENV)
const shouldAnalyze = process.env.ANALYZE === 'true'

const withBundleAnalyzer = bundleAnalyze({ enabled: process.env.ANALYZE === 'true' })
const withRoutes = routes({ outDir: './src/types' })
const withBundleAnalyzer = bundleAnalyze({ enabled: shouldAnalyze, openAnalyzer: false })
/** @type {import('next').NextConfig} */
const nextConfig = {
i18n: i18nConfig.i18n,
reactStrictMode: true,
swcMinify: true,
transpilePackages: ['@weareinreach/ui', '@weareinreach/db', '@weareinreach/auth', '@weareinreach/api'],
transpilePackages: [
'@weareinreach/api',
'@weareinreach/auth',
'@weareinreach/db',
'@weareinreach/env',
'@weareinreach/ui',
'@weareinreach/util',
],
compiler: {
...(process.env.VERCEL_ENV === 'production' ? { removeConsole: { exclude: ['error'] } } : {}),
...(isVercelProd ? { removeConsole: { exclude: ['error'] } } : {}),
},
experimental: {
outputFileTracingExcludes: {
Expand All @@ -35,25 +46,42 @@ const nextConfig = {
instrumentationHook: true,
},
eslint: {
ignoreDuringBuilds: isVercelActiveDev,
ignoreDuringBuilds: !isVercelProd,
},
images: {
remotePatterns: [{ protocol: 'https', hostname: '**.4sqi.net' }],
},
rewrites: async () => [{ source: '/search', destination: '/' }],

typescript: {
ignoreBuildErrors: isVercelActiveDev,
ignoreBuildErrors: !isVercelProd,
},
webpack: (config, { isServer, webpack }) => {
if (isServer) {
config.plugins = [...config.plugins, new PrismaPlugin()]
}
if (process.env.VERCEL_ENV === 'production') {
if (!isLocalDev) {
config.plugins.push(new webpack.DefinePlugin({ __SENTRY_DEBUG__: false }))
if (shouldAnalyze) {
config.plugins.push(
new BundleAnalyzerPlugin({ analyzerMode: 'static', generateStatsFile: true, openAnalyzer: false })
)
}
}
return config
},
async headers() {
return [
{
source: '/(.*)',
headers: [
{ key: 'Access-Control-Allow-Headers', value: 'sentry-trace' },
{ key: 'Access-Control-Allow-Headers', value: 'baggage' },
{ key: 'Document-Policy', value: 'js-profiling' },
],
},
]
},
}

/**
Expand All @@ -64,7 +92,7 @@ const nextConfig = {
* @returns {T}
*/
function defineNextConfig(config) {
return withBundleAnalyzer(withRoutes({ outDir: './src/types' })(config))
return withBundleAnalyzer(withRoutes(config))
}
/**
* Wraps NextJS config with the Sentry config.
Expand Down Expand Up @@ -102,7 +130,7 @@ const defineSentryConfig = (nextConfig) =>
hideSourceMaps: false,

// Automatically tree-shake Sentry logger statements to reduce bundle size
disableLogger: true,
disableLogger: isVercelProd,
}
)

Expand Down
23 changes: 9 additions & 14 deletions apps/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"version": "0.100.0",
"private": true,
"license": "GPL-3.0-only",
"sideEffects": false,
"scripts": {
"analyze": "ANALYZE=true next build",
"build": "next build",
"build:prebuild": "SKIP_ENV_VALIDATION=true tsx ./lib/prebuild.ts",
"clean:node": "rm -rf ./node_modules/ || true && rm -rf ./.next || true",
Expand All @@ -22,13 +24,11 @@
"with-env": "dotenv -e ../../.env --"
},
"dependencies": {
"@aws-crypto/sha256-js": "5.0.0",
"@aws-sdk/client-s3": "3.400.0",
"@aws-sdk/signature-v4": "3.370.0",
"@crowdin/crowdin-api-client": "1.24.0",
"@crowdin/ota-client": "1.0.0",
"@emotion/react": "11.11.1",
"@emotion/server": "11.11.0",
"@hookform/resolvers": "3.2.0",
"@iconify/react": "4.1.1",
"@mantine/carousel": "6.0.19",
"@mantine/core": "6.0.19",
Expand All @@ -47,9 +47,6 @@
"@next/bundle-analyzer": "13.4.19",
"@opentelemetry/api": "1.4.1",
"@opentelemetry/exporter-trace-otlp-http": "0.41.2",
"@opentelemetry/instrumentation": "0.41.2",
"@opentelemetry/instrumentation-fetch": "0.41.2",
"@opentelemetry/instrumentation-http": "0.41.2",
"@opentelemetry/resources": "1.15.2",
"@opentelemetry/sdk-node": "0.41.2",
"@opentelemetry/sdk-trace-base": "1.15.2",
Expand All @@ -58,6 +55,7 @@
"@prisma/instrumentation": "5.2.0",
"@sentry/nextjs": "7.64.0",
"@sentry/opentelemetry-node": "7.64.0",
"@sentry/profiling-node": "1.1.2",
"@tanstack/react-query": "4.33.0",
"@tanstack/react-table": "8.9.3",
"@tiptap/extension-link": "2.1.7",
Expand All @@ -76,12 +74,9 @@
"@weareinreach/env": "workspace:*",
"@weareinreach/ui": "workspace:*",
"@weareinreach/util": "workspace:*",
"axios": "1.5.0",
"cookies-next": "2.1.2",
"core-js": "3.32.1",
"dayjs": "1.11.9",
"deepmerge": "4.3.1",
"duration-fns": "3.0.2",
"embla-carousel-autoplay": "7.1.0",
"embla-carousel-react": "7.1.0",
"flat": "5.0.2",
Expand All @@ -90,9 +85,7 @@
"i18next-chained-backend": "4.4.0",
"i18next-http-backend": "2.2.1",
"i18next-intervalplural-postprocessor": "3.0.0",
"i18next-localstorage-backend": "4.1.1",
"i18next-multiload-backend-adapter": "2.2.2",
"ioredis": "5.3.2",
"just-compact": "3.2.0",
"just-compare": "2.3.0",
"luxon": "3.4.2",
Expand All @@ -107,11 +100,13 @@
"react": "18.2.0",
"react-dom": "18.2.0",
"react-error-boundary": "4.0.11",
"react-hook-form": "7.45.4",
"react-hook-form-mantine": "2.0.0",
"react-i18next": "13.2.0",
"tslog": "4.9.2",
"zod": "3.22.2"
},
"devDependencies": {
"@hookform/devtools": "4.3.1",
"@playwright/test": "1.37.1",
"@prisma/nextjs-monorepo-workaround-plugin": "5.2.0",
"@tanstack/react-query-devtools": "4.33.0",
Expand All @@ -133,14 +128,14 @@
"dotenv": "16.3.1",
"eslint": "8.48.0",
"eslint-plugin-i18next": "6.0.3",
"i18next-resources-for-ts": "1.3.0",
"listr2": "6.6.1",
"prettier": "3.0.2",
"trpc-client-devtools-link": "0.2.1-next",
"trpc-panel": "1.3.4",
"trpc-playground": "1.0.4",
"type-fest": "4.3.1",
"typescript": "5.2.2"
"typescript": "5.2.2",
"webpack-bundle-analyzer": "4.9.0"
},
"ct3aMetadata": {
"initVersion": "5.10.1"
Expand Down
32 changes: 17 additions & 15 deletions apps/app/sentry.client.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,20 @@
// 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 { BrowserProfilingIntegration, BrowserTracing, init, Replay } from '@sentry/nextjs'

Sentry.init({
// Sentry.init({
init({
dsn: 'https://[email protected]/6751163',

integrations: [
new Replay({
// Additional Replay configuration goes in here, for example:
maskAllText: true,
blockAllMedia: true,
}),
new BrowserTracing(),
new BrowserProfilingIntegration(),
],
// Adjust this value in production, or use tracesSampler for greater control
tracesSampleRate: 1,

Expand All @@ -18,19 +27,12 @@ Sentry.init({
// 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,
profilesSampleRate: 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,
}),
new Sentry.BrowserTracing(),
],
tracePropagationTargets: [
'https://app.inreach.org',
'https://*-weareinreach.vercel.app',
'http://localhost',
/^https?:\/\/app\.inreach\.org(?:\/.*)?/i,
/^https?:\/\/.*-weareinreach\.vercel\.app(?:\/.*)?/i,
/^https?:\/\/localhost(?::\d+)?(?:\/.*)?/i,
/^\//i,
],
})
3 changes: 3 additions & 0 deletions apps/app/sentry.server.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
// https://docs.sentry.io/platforms/javascript/guides/nextjs/

import * as Sentry from '@sentry/nextjs'
import { ProfilingIntegration } from '@sentry/profiling-node'

Sentry.init({
dsn: 'https://[email protected]/6751163',

// Adjust this value in production, or use tracesSampler for greater control
tracesSampleRate: 1,
profilesSampleRate: 1,

// Setting this option to true will print useful information to the console while you're setting up Sentry.
debug: false,
instrumenter: 'otel',
integrations: [new ProfilingIntegration()],
})
3 changes: 1 addition & 2 deletions apps/app/src/pages/401.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { useTranslation } from 'next-i18next'
import { type Route } from 'nextjs-routes'
import { z } from 'zod'

import { LoginBody } from '@weareinreach/ui/modals/Login'
import { getServerSideTranslations } from '~app/utils/i18n'
import { LoginBody } from '~ui/modals/Login'

const RouteSchema = z.object({
pathname: z.string(),
Expand All @@ -30,7 +30,6 @@ const Unauthorized = () => {
spacing={32}
>
<Stack spacing={0} align='center'>
{/* eslint-disable-next-line i18next/no-literal-string */}
<Title order={1}>🔐</Title>
<Title order={1}>{t('errors.401-title')}</Title>
</Stack>
Expand Down
Loading

0 comments on commit 1f7af7b

Please sign in to comment.