Skip to content

Commit 3044dec

Browse files
committed
better types
1 parent 579781c commit 3044dec

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

packages/feedback/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
"@sentry/types": "7.100.0",
3434
"@sentry/utils": "7.100.0"
3535
},
36+
"devDependencies": {
37+
"@sentry/replay": "7.100.0"
38+
},
3639
"scripts": {
3740
"build": "run-p build:transpile build:types build:bundle",
3841
"build:transpile": "rollup -c rollup.npm.config.mjs",

packages/feedback/src/integration.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { type replayIntegration } from '@sentry/replay';
12
import type { BaseTransportOptions, Client, ClientOptions, Integration, IntegrationFn } from '@sentry/types';
23
import { isBrowser, logger } from '@sentry/utils';
34

@@ -197,15 +198,13 @@ export class Feedback implements Integration {
197198
return;
198199
}
199200

200-
const replay = client.getIntegrationByName!('Replay');
201+
const replay = client.getIntegrationByName<ReturnType<typeof replayIntegration>>('Replay');
201202

202203
if (!replay) {
203204
return;
204205
}
205206

206207
try {
207-
// @ts-expect-error Not sure how best to type this w/o
208-
// making @sentry/replay a dep
209208
replay.startBuffering();
210209
} catch (err) {
211210
DEBUG_BUILD && logger.error(err);

packages/feedback/src/widget/createWidget.ts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { getClient, getCurrentScope } from '@sentry/core';
2+
import { type replayIntegration } from '@sentry/replay';
23
import { logger } from '@sentry/utils';
34

45
import type { FeedbackFormData, FeedbackInternalOptions, FeedbackWidget } from '../types';
@@ -129,22 +130,20 @@ export function createWidget({
129130
/**
130131
* Internal handler when dialog is opened
131132
*/
132-
function handleOpenDialog({ includeReplay }: { includeReplay?: boolean } = {}) {
133-
// Flush replay if it exists
134-
if (includeReplay) {
135-
const client = getClient();
136-
const replay = client && client.getIntegrationByName!('Replay');
137-
if (!replay) {
138-
return;
139-
}
140-
try {
141-
// @ts-expect-error Not sure how best to type this w/o
142-
// making @sentry/replay a dep
143-
void replay.flush();
144-
} catch (err) {
145-
DEBUG_BUILD && logger.error(err);
146-
}
133+
function handleOpenDialog({ includeReplay }: { includeReplay?: boolean } = {}): void {
134+
if (!includeReplay) {
135+
return;
136+
}
137+
138+
// Flush replay if integration exists
139+
const client = getClient();
140+
const replay = client && client.getIntegrationByName<ReturnType<typeof replayIntegration>>('Replay');
141+
if (!replay) {
142+
return;
147143
}
144+
replay.flush().catch(err => {
145+
DEBUG_BUILD && logger.error(err);
146+
});
148147
}
149148

150149
/**

0 commit comments

Comments
 (0)