From 9c0aaa71915fdc4b3277373d4d82ac5d82e1e4eb Mon Sep 17 00:00:00 2001 From: Rodolfo Carvalho Date: Fri, 15 May 2020 11:25:34 +0200 Subject: [PATCH] feat: Require use of flag to send envelopes This gives us an easy kill-switch if we decide to revert back to the store endpoint. Sending envelopes becomes opt-in. Usage: Sentry.init({ dsn: '...', integrations: [new Sentry.Integrations.Tracing()], tracesSampleRate: 1, _experiments: { useEnvelope: true }, }); --- packages/core/src/request.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/core/src/request.ts b/packages/core/src/request.ts index 3e13462a37c0..2665073ac929 100644 --- a/packages/core/src/request.ts +++ b/packages/core/src/request.ts @@ -1,3 +1,4 @@ +import { getCurrentHub } from '@sentry/hub'; import { Event } from '@sentry/types'; import { API } from './api'; @@ -15,7 +16,9 @@ interface SentryRequest { /** Creates a SentryRequest from an event. */ export function eventToSentryRequest(event: Event, api: API): SentryRequest { - const useEnvelope = event.type === 'transaction'; + const client = getCurrentHub().getClient(); + const experimentsOptions = (client && client.getOptions()._experiments) || {}; + const useEnvelope = event.type === 'transaction' && experimentsOptions.useEnvelope; const req: SentryRequest = { body: JSON.stringify(event),