Skip to content

makeBrowserOfflineTransport no longer adds types to transportOptions #3

Open
@hiroshinishio

Description

@hiroshinishio

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/vue

SDK Version

8.33.1

Framework Version

Vue 3.5.4

Link to Sentry event

No response

Reproduction Example/SDK Setup

import * as Sentry from '@sentry/vue';
import { Capacitor } from '@capacitor/core';
import type { App } from 'vue';

export default function setupSentry(app: App) {
	Sentry.init({
		app,
		dsn: __SENTRY_DSN__,
		enabled: true,
		release: __APP_VERSION__,
		dist: __APP_VERSION__ + (Capacitor.isNativePlatform() ? '-native' : '-web'),
		transport: Sentry.makeBrowserOfflineTransport(Sentry.makeFetchTransport),
		transportOptions: {
			flushAtStartup: true,
		},
		logErrors: true,
		tracesSampleRate: 0,
		autoSessionTracking: false,
		sendClientReports: false,
	});
}

Steps to Reproduce

After upgrading to 8.33.1 from 7.60.0 I am getting a TypeScript error

Expected Result

Sentry.init is valid TypeScript

Actual Result

TypeScript Error:
Object literal may only specify known properties, and 'flushAtStartup' does not exist in type 'Partial<BrowserTransportOptions>'.

Current dirty workaround is to manually type transportOptions

import * as Sentry from '@sentry/vue';
import type { BrowserOfflineTransportOptions } from '@sentry/browser/build/npm/types/transports/offline';
import { Capacitor } from '@capacitor/core';
import type { App } from 'vue';

export default function setupSentry(app: App) {
	Sentry.init({
		app,
		dsn: __SENTRY_DSN__,
		enabled: true,
		release: __APP_VERSION__,
		dist: __APP_VERSION__ + (Capacitor.isNativePlatform() ? '-native' : '-web'),
		transport: Sentry.makeBrowserOfflineTransport(Sentry.makeFetchTransport),
		transportOptions: {
			flushAtStartup: true,
		} as BrowserOfflineTransportOptions,
		logErrors: true,
		tracesSampleRate: 0,
		autoSessionTracking: false,
		sendClientReports: false,
	});
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions