Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/browser/src/feedback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
} from '@sentry-internal/feedback';
import { lazyLoadIntegration } from './utils/lazyLoadIntegration';

// The full feedback widget, with everything pre-loaded
/** Add a widget to capture user feedback to your application. */
export const feedbackIntegration = buildFeedbackIntegration({
lazyLoadIntegration,
getModalIntegration: () => feedbackModalIntegration,
Expand Down
5 changes: 5 additions & 0 deletions packages/feedback/src/core/getFeedback.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,10 @@ describe('getFeedback', () => {
const actual = getFeedback();
expect(actual).toBeDefined();
expect(actual === configuredIntegration).toBe(true);

// has correct type
expect(typeof actual?.attachTo).toBe('function');
expect(typeof actual?.createWidget).toBe('function');
expect(typeof actual?.remove).toBe('function');
});
});
2 changes: 1 addition & 1 deletion packages/feedback/src/core/getFeedback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ type FeedbackIntegration = ReturnType<typeof buildFeedbackIntegration>;
*/
export function getFeedback(): ReturnType<FeedbackIntegration> | undefined {
const client = getClient();
return client && client.getIntegrationByName('Feedback');
return client && client.getIntegrationByName<ReturnType<FeedbackIntegration>>('Feedback');
}
9 changes: 8 additions & 1 deletion packages/feedback/src/core/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,18 @@ interface BuilderOptions {
getModalIntegration?: null | (() => IntegrationFn);
getScreenshotIntegration?: null | (() => IntegrationFn);
}

export const buildFeedbackIntegration = ({
lazyLoadIntegration,
getModalIntegration,
getScreenshotIntegration,
}: BuilderOptions): IntegrationFn => {
}: BuilderOptions): IntegrationFn<
Integration & {
attachTo(el: Element | string, optionOverrides: OverrideFeedbackConfiguration): Unsubscribe;
createWidget(optionOverrides: OverrideFeedbackConfiguration): Promise<FeedbackDialog>;
remove(): void;
}
> => {
const feedbackIntegration = (({
// FeedbackGeneralConfiguration
id = 'sentry-feedback',
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ export interface Integration {
* An integration in function form.
* This is expected to return an integration.
*/
export type IntegrationFn = (...rest: any[]) => Integration;
export type IntegrationFn<IntegrationType = Integration> = (...rest: any[]) => IntegrationType;