| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [View Raw Code] [Original HTTPS Page] |
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 learn about some general SDK development principles check out the SDK Development Guide in the Sentry Developer Documentation.
We use Volta to ensure we use consistent versions of node, yarn and pnpm.
Make sure to also enable pnpm support in Volta if you want to run the E2E tests locally.
sentry-javascript is a monorepo containing several packages, and we use lerna to manage them. To get started, install all dependencies, and then perform an initial build, so TypeScript can read all of the linked type definitions.
$ yarn $ 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:
Note: Due to package incompatibilities between Python versions, building native binaries currently requires a Python version <3.12.
You can also run a production build via yarn build, which will build everything except for the tarballs for publishing to NPM. You can use this if you want to bundle Sentry yourself. The build output can be found in the packages build/ folder, e.g. packages/browser/build. Bundled files can be found in packages/browser/build/bundles. Note that there are no guarantees about the produced file names etc., so make sure to double check which files are generated after upgrading.
To test local versions of SDK packages, for instance in test projects, you have a couple of options:
Any nontrivial fixes/features should include tests. You'll find a test folder in each package.
For browser related changes, you may also add tests in dev-packages/browser-integration-tests. Similarly, for node integration tests can be added in dev-packages/node-integration-tests. Finally, we also have E2E test apps in dev-packages/e2e-tests.
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 like jest 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 a __DEBUG_BUILD__ constant. This flag serves two purposes:
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.
We highly appreciate external contributions to the SDK. If you want to contribute something, you can just open a PR against develop.
The SDK team will check out your PR shortly!
When contributing to the codebase, please note:
See Commit, Issue & PR guidelines.
See PR Reviews.
These steps are only relevant to Sentry employees when preparing and publishing a new SDK release.
| Back | FazBrowse Home | New Git URL |