You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs(transports): Update Migration document with custom Transport changes (#5012)
add the Transport changes to MIGRATION.md.
show the difference between old and new transports and give example how to migrate a custom v6 transport to v7.
Co-authored-by: Abhijeet Prasad <aprasad@sentry.io>
The `Transport` API was simplified and some functionality (e.g. APIDetails and client reports) was refactored and moved
108
+
to the Client. To send data to Sentry, we switched from the previously used [Store endpoint](https://develop.sentry.dev/sdk/store/) to the [Envelopes endpoint](https://develop.sentry.dev/sdk/envelopes/).
109
+
110
+
This example shows the new v7 and the v6 Transport API:
111
+
112
+
```js
113
+
// New in v7:
114
+
exportinterfaceTransport {
115
+
/* Sends an envelope to the Envelope endpoint in Sentry */
116
+
send(request: Envelope): PromiseLike<void>;
117
+
/* Waits for all events to be sent or the timeout to expire, whichever comes first */
118
+
flush(timeout?: number): PromiseLike<boolean>;
119
+
}
120
+
121
+
// Before:
122
+
exportinterfaceTransport {
123
+
/* Sends the event to the Store endpoint in Sentry */
124
+
sendEvent(event: Event): PromiseLike<Response>;
125
+
/* Sends the session to the Envelope endpoint in Sentry */
transport: MyCustomTransport, // the constructor was called when the client was initialized
197
+
...
198
+
})
199
+
```
200
+
201
+
Overall, the new way of transport creation allows you to create your custom sending implementation
202
+
without having to deal with the conversion of events or sessions to envelopes.
203
+
We recommend calling using the `createTransport` function from `@sentry/core` as demonstrated in the example above which, besides creating the `Transport`
204
+
object with your custom logic, will also take care of rate limiting and flushing.
205
+
206
+
For a complete v7 transport implementation, take a look at our [browser fetch transport](https://github.com/getsentry/sentry-javascript/blob/ebc938a03d6efe7d0c4bbcb47714e84c9a566a9c/packages/browser/src/transports/fetch.ts#L1-L34).
207
+
208
+
## Enum Changes
106
209
107
210
Given that enums have a high bundle-size impact, our long term goal is to eventually remove all enums from the SDK in
0 commit comments