[@sentry/browser] How to get last event for applyToEvent(lastEvent)

I would like to use scope.applyToEvent(event) to not manually configure the showReportDialog() options, like the user.

I figured out with Sentry.lastEventId(); you can get the last event id.
However applyToEvent requires an Event.

In theory:

Sentry.captureMessage(msg, Severity.Critical);

// I should have an eventId now, right?

const eventId = Sentry.lastEventId(); // I can do this but this doesn't help a lot

// Add scope to event (in theory).
Sentry.withScope(scope => {
    scope.applyToEvent($sentryEvent); // How to get this event?

// User report modal.
    eventId: eventId,
    // user: {
    //     email: 'something',
    //     name: 'something'
    // }
    // I don't want to set these again

I only found this test, but the event is build manually there.

How to get the last Event Object?

Did I miss any documentation or is there a different solution? :sweat_smile:

I figured out that you can assign the event to an variable with beforeSend(), although i don’t think that is the best idea.

    dsn: 'yourdns',
    beforeSend(event) {
        return event;

export class DemoClass implements ErrorHandler {

    private lastSentryEvent: Sentry.Event;


    beforeSend(event) {
        this.lastSentryEvent = event;


But this does not seem to work.