Skip to content

Commit

Permalink
Merge pull request #831 from haqq-network/fix/hqw-299-shell-sentry-er…
Browse files Browse the repository at this point in the history
…rors-a-lot-off

fix: dynamically load components to prevent hydrations errors
  • Loading branch information
olegshilov authored May 16, 2024
2 parents 0e53db8 + c1a6cae commit bb8cefe
Show file tree
Hide file tree
Showing 21 changed files with 1,648 additions and 705 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,6 @@ package-lock.json

# Sentry Config File
.sentryclirc

# Sentry Config File
.env.sentry-build-plugin
62 changes: 35 additions & 27 deletions apps/shell/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,40 +32,48 @@ const nextConfig = {
},
];
},
sentry: {
// 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,

// Transpiles SDK to be compatible with IE11 (increases bundle size)
transpileClientSDK: true,

// Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers. (increases server load)
// Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
// side errors will fail.
tunnelRoute: '/monitoring',

// Hides source maps from generated client bundles
hideSourceMaps: true,

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

// Enables automatic instrumentation of Vercel Cron Monitors.
// See the following for more information:
// https://docs.sentry.io/product/crons/
// https://vercel.com/docs/cron-jobs
automaticVercelMonitors: true,
experimental: {
instrumentationHook: true,
},
};

const sentryWebpackPluginOptions = {
silent: true,
// For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options

// Only print logs for uploading source maps in CI
silent: !process.env.CI,

org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
authToken: process.env.SENTRY_AUTH_TOKEN,

// 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,

// Transpiles SDK to be compatible with IE11 (increases bundle size)
transpileClientSDK: true,

// Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
// This can increase your server load as well as your hosting bill.
// Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
// side errors will fail.
tunnelRoute: '/api/monitoring',

// Hides source maps from generated client bundles
hideSourceMaps: true,

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

// Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)
// See the following for more information:
// https://docs.sentry.io/product/crons/
// https://vercel.com/docs/cron-jobs
automaticVercelMonitors: true,
};

const plugins = [
Expand Down
16 changes: 0 additions & 16 deletions apps/shell/sentry.edge.config.js

This file was deleted.

18 changes: 0 additions & 18 deletions apps/shell/sentry.server.config.js

This file was deleted.

17 changes: 13 additions & 4 deletions apps/shell/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { SpeedInsights } from '@vercel/speed-insights/next';
import clsx from 'clsx';
import type { Metadata, Viewport } from 'next';
import dynamic from 'next/dynamic';
import { headers } from 'next/headers';
import type { Config } from '@haqq/shell-shared';
import { AppWrapper } from '../components/app-wrapper';
import { PHProvider } from '../components/posthog';
Expand Down Expand Up @@ -46,12 +47,20 @@ const PostHogPageView = dynamic(
const { PostHogPageView } = await import('../components/posthog-page-view');
return { default: PostHogPageView };
},
{
ssr: false,
},
{ ssr: false },
);

export default function RootLayout({ children }: PropsWithChildren) {
const headersList = headers();
const userAgent = headersList.get('user-agent');
const isMobileUserAgent = userAgent
? Boolean(
userAgent.match(
/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile|WPDesktop/i,
),
)
: false;

return (
<html
lang="en"
Expand All @@ -63,7 +72,7 @@ export default function RootLayout({ children }: PropsWithChildren) {
<PostHogPageView />
<SpeedInsights />

<Providers config={shellConfig}>
<Providers config={shellConfig} isMobileUserAgent={isMobileUserAgent}>
<AppWrapper>{children}</AppWrapper>
</Providers>
</body>
Expand Down
Loading

0 comments on commit bb8cefe

Please sign in to comment.