We welcome suggested improvements and bug fixes to the @sentry/*
family of packages, in the form of pull requests on GitHub
. The guide below will help you get started, but if you have further questions, please feel free to reach out on Discord.
To run the test suite and our code linter, node.js and yarn are required.
sentry-javascript
is a monorepo containing several packages, and we use lerna
to manage them. To get started, install all dependencies, use lerna
to bootstrap the workspace, and then perform an initial build, so TypeScript can read all of the linked type definitions.
$ yarn
$ yarn lerna bootstrap
$ yarn build
With that, the repo is fully set up and you are ready to run all commands.
Since we are using TypeScript
, you need to transpile the code to JavaScript to be able to use it. From the top level of the repo, there are three commands available:
yarn build:dev
, which runs a one-time build of ES5 and ES6 versions of every packageyarn build:dev:filter <name of npm package>
, which runsyarn build:dev
only in projects relevant to the given package (so, for example, runningyarn build:dev:filter @sentry/react
will build thereact
package, all of its dependencies (utils
,core
,browser
, etc), and all packages which depend on it (currentlygatsby
andnextjs
))yarn build:dev:watch
, which runsyarn build:dev
in watch mode (recommended)
Any nontrivial fixes/features should include tests. You'll find a test
folder in each package.
Note that for the browser
package only, if you add a new file to the integration test suite, you also need to add it to the list in shell.js
as well. Adding tests to existing files will work out of the box in all packages.
Running tests works the same way as building - running yarn test
at the project root will run tests for all packages, and running yarn test
in a specific package will run tests for that package. There are also commands to run subsets of the tests in each location. Check out the scripts
entry of the corresponding package.json
for details.
Note: you must run yarn build
before yarn test
will work.
If you run into trouble writing tests and need to debug one of them, you can do so using VSCode's debugger.
-
If you don't already have it installed, install the Tasks Shell Input extension, which you'll find in the Extensions tab in the sidebar as one of the recommended workspace extensions.
-
Place breakpoints or
debugger
statements in the test or the underlying code wherever you'd likejest
to pause. -
Open the file containing the test in question, and make sure its tab is active (so you can see the file's contents).
-
Switch to the debugger in the sidebar and choose
Debug unit tests - just open file
from the dropdown. -
Click the green "play" button to run the tests in the open file in watch mode.
Pro tip: If any of your breakpoints are in code run by multiple tests, and you run the whole test file, you'll land on those breakpoints over and over again, in the middle of tests you don't care about. To avoid this, replace the test's initial it
or test
with it.only
or test.only
. That way, when you hit a breakpoint, you'll know you got there are part of the buggy test.
Throughout the codebase, you will find the __DEBUG_BUILD__
flag guarding various code sections. This flag serves two purposes:
- It enables us to remove debug code from our minified CDN bundles during build, by replacing the flag with
false
before tree-shaking occurs. - It enables users to remove Sentry debug code from their production bundles during their own build. When we build our npm packages, we replace the flag with
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__)
. If the user does nothing, this evaluates totrue
and logging is included. But if the user runs their own replacement during build (again replacing the flag withfalse
), the build will tree-shake the logging away, just as our bundle builds do.
Note that the replacement flag, __SENTRY_DEBUG__
, is different from the original flag . This is necessary because the replacement plugin runs twice, at two different stages of the build, and we don't want to run a replacement on our replacement (as would happen if we reused __DEBUG_BUILD__
).
Similar to building and testing, linting can be done in the project root or in individual packages by calling yarn lint
.
Note: you must run yarn build
before yarn lint
will work.
When contributing to the codebase, please note:
- Make sure to follow the Commit, Issue & PR guidelines
- Non-trivial PRs will not be accepted without tests (see above).
- Please do not bump version numbers yourself.
raven-js
andraven-node
are deprecated, and only bug and security fix PRs will be accepted targeting the 3.x branch. Any new features and improvements should be to our new SDKs (browser
,node
, and framework-specific packages likereact
andnextjs
) and the packages which support them (core
,utils
,integrations
, and the like).
For feedback in PRs, we use the LOGAF scale to specify how important a comment is:
l
: low - nitpick. You may address this comment, but you don't have to.m
: medium - normal comment. Worth addressing and fixing.h
: high - Very important. We must not merge this PR without addressing this issue.
You only need one approval from a maintainer to be able to merge. For some PRs, asking specific or multiple people for review might be adequate.
Our different types of reviews:
- LGTM without any comments. You can merge immediately.
- LGTM with low and medium comments. The reviewer trusts you to resolve these comments yourself, and you don't need to wait for another approval.
- Only comments. You must address all the comments and need another review until you merge.
- Request changes. Only use if something critical is in the PR that absolutely must be addressed. We usually use
h
comments for that. When someone requests changes, the same person must approve the changes to allow merging. Use this sparingly.
For commit messages, we use the format:
<type>(<scope>): <subject> (<github-id>)
For example: feat(core): Set custom transaction source for event processors (#5722)
.
See commit message format for details.
The Github-ID can be left out until the PR is merged.
Issues should at least be categorized by package, for example package: Node
.
Additional labels for categorization can be added, and the Sentry SDK team may also add further labels as needed.
PRs are merged via Squash and merge
.
This means that all commits on the branch will be squashed into a single commit, and commited as such onto master.
- The PR name can generally follow the commit name (e.g.
feat(core): Set custom transaction source for event processors
) - Make sure to rebase the branch on
master
before squashing it - Make sure to update the commit message of the squashed branch to follow the commit guidelines - including the PR number
These steps are only relevant to Sentry employees when preparing and publishing a new SDK release.
If you want to release a new SDK for the first time, be sure to follow the New SDK Release Checklist
- Determine what version will be released (we use semver).
- Update
CHANGELOG.md
to add an entry for the next release number and a list of changes since the last release. (See details below.) - Run the Prepare Release workflow.
- A new issue should appear in https://github.com/getsentry/publish/issues.
- Ask a member of the @getsentry/releases team to approve the release.
- Create a new branch.
- Run
git log --format="- %s"
and copy everything since the last release. - Create a new section in the changelog, deciding based on the changes whether it should be a minor bump or a patch release.
- Paste in the logs you copied earlier.
- Delete any which aren't user-facing changes.
- Alphabetize the rest.
- If any of the PRs are from external contributors, include underneath the commits
Work in this release contributed by <list of external contributors' GitHub usernames>. Thank you for your contributions!
. If there's only one external PR, don't forget to remove the finals
. If there are three or more, use an Oxford comma. (It's in the Sentry styleguide!) - Commit, push, and open a PR with the title
meta: Update changelog for <fill in relevant version here>
.