Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sentry doesn't log on nextjs13 frontend side #6763

Closed
3 tasks done
fernandops26 opened this issue Jan 13, 2023 · 5 comments
Closed
3 tasks done

Sentry doesn't log on nextjs13 frontend side #6763

fernandops26 opened this issue Jan 13, 2023 · 5 comments

Comments

@fernandops26
Copy link

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which package are you using?

@sentry/nextjs

SDK Version

7.30.0

Framework Version

"next": "13.1.1"

Link to Sentry event

No response

Steps to Reproduce

My next.config.js

const path = require('path');
/** @type {import('next').NextConfig} */
const { withSentryConfig } = require('@sentry/nextjs');

const nextConfig = {
  reactStrictMode: false,
  swcMinify: true,
  output: 'standalone',
  experimental: {
    appDir: true,
    serverComponentsExternalPackages: ['prisma', '@prisma/client'],
  },
  sentry: {
    hideSourceMaps: false,
  },
};

module.exports = withSentryConfig(nextConfig);

sentry.client.config.js

import * as Sentry from '@sentry/nextjs';

const SENTRY_DSN = process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN;

Sentry.init({
  dsn: SENTRY_DSN,
  tracesSampleRate: 1.0,
});

sentry.server.config.js

import * as Sentry from '@sentry/nextjs';

const SENTRY_DSN = process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN;

Sentry.init({
  dsn: SENTRY_DSN,
  tracesSampleRate: 1.0,
});

sentry.properties

defaults.url=https://sentry.io/
defaults.org=my-org
defaults.project=my-project-name
cli.executable=node_modules/@sentry/cli/bin/sentry-cli

.sentryclirc

[auth]
token=SENTRY_AUTH_TOKEN

app/error.tsx

'use client';
import { useEffect } from 'react';
import * as Sentry from '@sentry/nextjs';

export default function Error({
  error,
  reset,
}: {
  error: Error;
  reset: () => void;
}) {
  const reportSentry = async (error: Error) => {
    console.log('🚀🚀🚀 ~ reportSentry ~ error', error);
    await Sentry.captureException(error);
  };

  useEffect(() => {
    // Log the error to an error reporting service
    console.error('TOP LEVEL ERROR', error);
    reportSentry(error);
  }, [error]);

  return (
    <div>
            <h1>
              Something wrong happened.
            </h1>
    </div>
  );
}

Finally app/test/page.tsx

'use client';
export default function Page() {
  return (
    <>
      <h1>Hello, Test page</h1>
      <button
        onClick={() => {
          throw Error('From test'); // error in console but not in Sentry
        }}
      >
        Throw error
      </button>
    </>
  );
}

I already have setted my env varsNEXT_PUBLIC_SENTRY_DSN, SENTRY_AUTH_TOKEN, SENTRY_ORG, SENTRY_PROJECT but doesn't work.

Expected Result

Logged error on sentry

Actual Result

No logged nothing on sentry.

@Lms24
Copy link
Member

Lms24 commented Jan 13, 2023

Hi @fernandops26, thanks for writing in! We're already working on supporting Next 13's new app directory. In fact, the issue tracking this is already pinned on top of our issues list (#6726).

@Lms24
Copy link
Member

Lms24 commented Jan 13, 2023

Gonna close this issue as we're already tracking app dir support.

@fernandops26
Copy link
Author

Hi @fernandops26, thanks for writing in! We're already working on supporting Next 13's new app directory. In fact, the issue tracking this is already pinned on top of our issues list (#6726).

Ok good to know, thanks!

@danil-stealthgpt
Copy link

I still have this error

@Lms24
Copy link
Member

Lms24 commented Jun 4, 2024

@danil-stealthgpt would you mind opening a new bug report issue with all details? This issue is quite old and probably out of date by now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants