Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ref(node): Move non-handler code out of
handlers
module (#5190)
Currently, the `handlers` module includes not just our middleware handlers but also a bunch of code for extracting context data and applying it to events. That latter code is indeed used in the handlers, but it's also used in a number of other places in the repo. This pulls that code into its own module in `@sentry/utils`, to make it possible to use in a platform-agnostic context. Key changes: - A new `requestData` module in `@sentry/utils` to hold the data extraction code (and a new test file for its tests). - Wrapper functions in the `handlers` module for backwards compatibility. (IOW, calling `Handlers.someFunc()` still works, but it's now just a passthrough to `someFunc` from the new module.) - Deprecation notices in the docstrings of the wrappers, and TODOs so we remember to make the switch in v8. - Wrapper `describe`s in the tests, to run the tests against both the real functions and their wrappers, to make sure the wrappers work identically to the real functions. (This means that for the moment, the test file needs to live in `@sentry/node`, since it depends on the wrappers as well as the real functions. Once the wrappers are removed, the test file can be moved to `@sentry/utils`.) - `parseRequest` has been renamed `addRequestDataToEvent` for greater accuracy and clarity for the reader. (The corresponding options type has also been renamed.) - Two pieces of context data which have until now been set by `parseRequest`, but which have nothing to do with the request and are Node-only (namely `runtime` and `server_name`) are now set by the Node client. As a result, they no longer need to be set separately in the serverless package. (The exception is `server_name` in the AWS integration, because it pulls from a non-standard location.) Note: The original impetus for this change is the need to call `parseRequest`/`addRequestDataToEvent` in the nextjs SDK, in code which can run either in Node or the browser, which means it can't be exported from `@sentry/node`.
- Loading branch information