Skip to content

fix(nextjs): Export showReportDialog from NextJS SDK #5242

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

Merged
merged 2 commits into from
Jun 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/nextjs/src/index.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export * from '@sentry/node';

// Here we want to make sure to only include what doesn't have browser specifics
// because or SSR of next.js we can only use this.
export { ErrorBoundary, withErrorBoundary } from '@sentry/react';
export { ErrorBoundary, showReportDialog, withErrorBoundary } from '@sentry/react';

type GlobalWithDistDir = typeof global & { __rewriteFramesDistDir__: string };
const domain = domainModule as typeof domainModule & { active: (domainModule.Domain & Carrier) | null };
Expand Down
13 changes: 13 additions & 0 deletions packages/nextjs/test/integration/pages/reportDialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { showReportDialog } from '@sentry/nextjs';

const ReportDialogPage = (): JSX.Element => (
<button
onClick={() => {
showReportDialog();
}}
>
Open Report Dialog
</button>
);

export default ReportDialogPage;
14 changes: 14 additions & 0 deletions packages/nextjs/test/integration/test/client/reportDialog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const assert = require('assert');

module.exports = async ({ page, url }) => {
await page.goto(`${url}/reportDialog`);

await page.click('button');

const dialogScriptSelector = 'head > script[src^="https://dsn.ingest.sentry.io/api/embed/error-page"]';

const dialogScript = await page.waitForSelector(dialogScriptSelector, { state: 'attached' });
const dialogScriptSrc = await (await dialogScript.getProperty('src')).jsonValue();

assert(dialogScriptSrc.startsWith('https://dsn.ingest.sentry.io/api/embed/error-page/?'));
};