-
Notifications
You must be signed in to change notification settings - Fork 46
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
Added Next.js example #83
Added Next.js example #83
Conversation
I know you've probably spent a lot of time on this, but if you're able to, I would really recommend switching to Sentry. Took me 5 minutes to set up and never had a problem. I've had dozens with Rollbar, which I'm stuck with because that's what my company uses. Thanks for this PR, though! I'll take a look and give it a shot. Hopefully it solves my source map woes at least! 😁 |
<html lang="en"> | ||
<Head> | ||
<script | ||
dangerouslySetInnerHTML={{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, it looks like this will only log client-side errors, right? I've set up my project for both client and server, though the source maps have continued to be an issue for me. I can post my config once I (hopefully) get this all working in my project!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. I figured for a minimal example that will help other get started in the right direction I would just use the browser SDK. Otherwise setting up Rollbar via their npm package starts to really get into the weeds with implementation details of Rollbar. Ultimately for those using the npm SDK it'd be a similar setup from a Rollbar initialization perspective:
import RollbarSdk from 'rollbar';
new RollbarSdk({
enabled: ${process.env.NODE_ENV === 'production'},
accessToken: `${process.env.ROLLBAR_ACCESS_TOKEN}`,
captureUncaught: true,
captureUnhandledRejections: true,
payload: {
environment: `${process.env.NODE_ENV || 'production'}`,
client: {
javascript: {
source_map_enabled: true,
code_version: `${process.env.NEXT_BUILD_ID}`,
guess_uncaught_frames: true,
},
},
},
})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that only cover browser side is good enough, to keep it simple as possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jamesmosier thank you so much for taking that time to do this! And @pjaws thanks for your feedback as well!
I just had suggestions for a couple README related tweaks. After those I will merge this.
examples/next-js/README.md
Outdated
|
||
This is a basic Next.js app (created via `npm init next-app`). | ||
|
||
The pertinent files in this PR: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you re-word this just a bit so it doesn't mention "PR"? Maybe just change to "example"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jamesmosier in the main README, there's a link to the react example. Would mind adding a link to the Next.js example too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! that was a copy/paste from the PR description 😄
updated them both!
Codecov Report
@@ Coverage Diff @@
## master #83 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 3 3
Lines 74 74
Branches 18 18
=========================================
Hits 74 74 Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again for this contribution @jamesmosier!
published in [email protected] |
# [1.1.0-beta.1](v1.0.2...v1.1.0-beta.1) (2020-10-16) ### Bug Fixes * **ci:** migrate to semantic-release ([d8ae222](d8ae222)) * **docs:** add devtool to usage example and document ([#78](#78)) ([1705a9b](1705a9b)) ### Features * **examples:** added Next.js example ([#83](#83)) ([5a6edd5](5a6edd5)) * **options:** add encodeFilename flag ([#163](#163)) ([4829ebe](4829ebe)), closes [#162](#162) * **publicPath:** public path as function ([#58](#58)) ([041d205](041d205)) * **webpack-api:** support webpack 4 hooks API ([#53](#53)) ([cc3b747](cc3b747))
This example shows how to use
rollbar-sourcemap-webpack-plugin
with Next.jsI am using the
nosources-source-map
webpack devtool in this example which is described in the webpack docs as:Pertinent files in this PR:
examples/next-js/next.config.js
examples/next-js/pages/_document.js
examples/next-js/README.md
Previously I tried using
hidden-source-map
but Rollbar reported that the sourcemap was found but because Next doesn't addmin.js
extensions to the actual source files, Rollbar said it assumed the files were not minified and therefore wouldn't associate the uploaded map files with the source files on the server. Thereforenosources-source-map
will allow the map files to be uploaded to Rollbar and also includes a comment at the end of each file with the destination of the sourcemap (which does not contain actual source code).Closes #67