Skip to content

Commit

Permalink
feat(fedback): Convert CDN bundles to use async feedback for lower bu…
Browse files Browse the repository at this point in the history
…ndle sizes (#11791)

It's more aggressive to start with the async loading strategy in the CDN
bundle, but could be safer because if we want to change from async->sync
it would not really be a majr version change. Whereas going from
sync->async would be more of a big feature, riskier, and could demand a
version bump or something.
  • Loading branch information
ryan953 authored Apr 30, 2024
1 parent ffcdc5c commit 3c95ac9
Show file tree
Hide file tree
Showing 14 changed files with 55 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
import { lazyLoadIntegration } from './utils/lazyLoadIntegration';

/** Add a widget to capture user feedback to your application. */
export const feedbackIntegration = buildFeedbackIntegration({
export const feedbackSyncIntegration = buildFeedbackIntegration({
lazyLoadIntegration,
getModalIntegration: () => feedbackModalIntegration,
getScreenshotIntegration: () => feedbackScreenshotIntegration,
Expand Down
9 changes: 7 additions & 2 deletions packages/browser/src/index.bundle.feedback.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { browserTracingIntegrationShim, replayIntegrationShim } from '@sentry-internal/integration-shims';
import { feedbackAsyncIntegration } from './feedbackAsync';

export * from './index.bundle.base';

export { feedbackIntegration } from './feedback';
export { getFeedback } from '@sentry-internal/feedback';

export { browserTracingIntegrationShim as browserTracingIntegration, replayIntegrationShim as replayIntegration };
export {
browserTracingIntegrationShim as browserTracingIntegration,
feedbackAsyncIntegration as feedbackAsyncIntegration,
feedbackAsyncIntegration as feedbackIntegration,
replayIntegrationShim as replayIntegration,
};
6 changes: 5 additions & 1 deletion packages/browser/src/index.bundle.replay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ export * from './index.bundle.base';

export { replayIntegration } from '@sentry-internal/replay';

export { browserTracingIntegrationShim as browserTracingIntegration, feedbackIntegrationShim as feedbackIntegration };
export {
browserTracingIntegrationShim as browserTracingIntegration,
feedbackIntegrationShim as feedbackAsyncIntegration,
feedbackIntegrationShim as feedbackIntegration,
};
7 changes: 4 additions & 3 deletions packages/browser/src/index.bundle.tracing.replay.feedback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ export {
setMeasurement,
} from '@sentry/core';

export { feedbackIntegration } from './feedback';
export { getFeedback } from '@sentry-internal/feedback';

export {
browserTracingIntegration,
startBrowserTracingNavigationSpan,
startBrowserTracingPageLoadSpan,
} from './tracing/browserTracingIntegration';

import { feedbackAsyncIntegration } from './feedbackAsync';
export { getFeedback } from '@sentry-internal/feedback';
export { feedbackAsyncIntegration as feedbackAsyncIntegration, feedbackAsyncIntegration as feedbackIntegration };

export { replayIntegration } from '@sentry-internal/replay';
4 changes: 2 additions & 2 deletions packages/browser/src/index.bundle.tracing.replay.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { feedbackIntegrationShim } from '@sentry-internal/integration-shims';
import { registerSpanErrorInstrumentation } from '@sentry/core';

registerSpanErrorInstrumentation();
Expand All @@ -22,6 +21,7 @@ export {
startBrowserTracingPageLoadSpan,
} from './tracing/browserTracingIntegration';

export { feedbackIntegrationShim as feedbackIntegration };
import { feedbackIntegrationShim } from '@sentry-internal/integration-shims';
export { feedbackIntegrationShim as feedbackAsyncIntegration, feedbackIntegrationShim as feedbackIntegration };

export { replayIntegration } from '@sentry-internal/replay';
6 changes: 5 additions & 1 deletion packages/browser/src/index.bundle.tracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ export {
startBrowserTracingPageLoadSpan,
} from './tracing/browserTracingIntegration';

export { feedbackIntegrationShim as feedbackIntegration, replayIntegrationShim as replayIntegration };
export {
feedbackIntegrationShim as feedbackAsyncIntegration,
feedbackIntegrationShim as feedbackIntegration,
replayIntegrationShim as replayIntegration,
};
1 change: 1 addition & 0 deletions packages/browser/src/index.bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export * from './index.bundle.base';

export {
browserTracingIntegrationShim as browserTracingIntegration,
feedbackIntegrationShim as feedbackAsyncIntegration,
feedbackIntegrationShim as feedbackIntegration,
replayIntegrationShim as replayIntegration,
};
5 changes: 3 additions & 2 deletions packages/browser/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ export type {

export { replayCanvasIntegration } from '@sentry-internal/replay-canvas';

export { feedbackIntegration } from './feedback';
export { feedbackAsyncIntegration } from './feedbackAsync';
import { feedbackAsyncIntegration } from './feedbackAsync';
import { feedbackSyncIntegration } from './feedbackSync';
export { feedbackAsyncIntegration, feedbackSyncIntegration, feedbackSyncIntegration as feedbackIntegration };
export {
getFeedback,
sendFeedback,
Expand Down
5 changes: 3 additions & 2 deletions packages/browser/test/unit/index.bundle.feedback.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { browserTracingIntegrationShim, replayIntegrationShim } from '@sentry-internal/integration-shims';
import { feedbackIntegration } from '../../src';
import { feedbackAsyncIntegration } from '../../src';

import * as FeedbackBundle from '../../src/index.bundle.feedback';

describe('index.bundle.feedback', () => {
it('has correct exports', () => {
expect(FeedbackBundle.browserTracingIntegration).toBe(browserTracingIntegrationShim);
expect(FeedbackBundle.feedbackAsyncIntegration).toBe(feedbackAsyncIntegration);
expect(FeedbackBundle.feedbackIntegration).toBe(feedbackAsyncIntegration);
expect(FeedbackBundle.replayIntegration).toBe(replayIntegrationShim);
expect(FeedbackBundle.feedbackIntegration).toBe(feedbackIntegration);
});
});
8 changes: 5 additions & 3 deletions packages/browser/test/unit/index.bundle.replay.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { feedbackIntegrationShim } from '@sentry-internal/integration-shims';
import { replayIntegration } from '@sentry/browser';
import { browserTracingIntegrationShim, feedbackIntegrationShim } from '@sentry-internal/integration-shims';
import { replayIntegration } from '../../src';

import * as ReplayBundle from '../../src/index.bundle.replay';

describe('index.bundle.replay', () => {
it('has correct exports', () => {
expect(ReplayBundle.replayIntegration).toBe(replayIntegration);
expect(ReplayBundle.browserTracingIntegration).toBe(browserTracingIntegrationShim);
expect(ReplayBundle.feedbackAsyncIntegration).toBe(feedbackIntegrationShim);
expect(ReplayBundle.feedbackIntegration).toBe(feedbackIntegrationShim);
expect(ReplayBundle.replayIntegration).toBe(replayIntegration);
});
});
10 changes: 8 additions & 2 deletions packages/browser/test/unit/index.bundle.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import { feedbackIntegrationShim, replayIntegrationShim } from '@sentry-internal/integration-shims';
import {
browserTracingIntegrationShim,
feedbackIntegrationShim,
replayIntegrationShim,
} from '@sentry-internal/integration-shims';

import * as Bundle from '../../src/index.bundle';

describe('index.bundle', () => {
it('has correct exports', () => {
expect(Bundle.replayIntegration).toBe(replayIntegrationShim);
expect(Bundle.browserTracingIntegration).toBe(browserTracingIntegrationShim);
expect(Bundle.feedbackAsyncIntegration).toBe(feedbackIntegrationShim);
expect(Bundle.feedbackIntegration).toBe(feedbackIntegrationShim);
expect(Bundle.replayIntegration).toBe(replayIntegrationShim);
});
});
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { browserTracingIntegration, feedbackIntegration, replayIntegration } from '../../src';
import { browserTracingIntegration, feedbackAsyncIntegration, replayIntegration } from '../../src';

import * as TracingReplayFeedbackBundle from '../../src/index.bundle.tracing.replay.feedback';

describe('index.bundle.tracing.replay.feedback', () => {
it('has correct exports', () => {
expect(TracingReplayFeedbackBundle.replayIntegration).toBe(replayIntegration);
expect(TracingReplayFeedbackBundle.browserTracingIntegration).toBe(browserTracingIntegration);
expect(TracingReplayFeedbackBundle.feedbackIntegration).toBe(feedbackIntegration);
expect(TracingReplayFeedbackBundle.feedbackAsyncIntegration).toBe(feedbackAsyncIntegration);
expect(TracingReplayFeedbackBundle.feedbackIntegration).toBe(feedbackAsyncIntegration);
expect(TracingReplayFeedbackBundle.replayIntegration).toBe(replayIntegration);
});
});
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { feedbackIntegrationShim } from '@sentry-internal/integration-shims';

import { browserTracingIntegration, replayIntegration } from '../../src';

import * as TracingReplayBundle from '../../src/index.bundle.tracing.replay';

describe('index.bundle.tracing.replay', () => {
it('has correct exports', () => {
expect(TracingReplayBundle.replayIntegration).toBe(replayIntegration);

expect(TracingReplayBundle.browserTracingIntegration).toBe(browserTracingIntegration);

expect(TracingReplayBundle.feedbackAsyncIntegration).toBe(feedbackIntegrationShim);
expect(TracingReplayBundle.feedbackIntegration).toBe(feedbackIntegrationShim);
expect(TracingReplayBundle.replayIntegration).toBe(replayIntegration);
});
});
5 changes: 3 additions & 2 deletions packages/browser/test/unit/index.bundle.tracing.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { feedbackIntegrationShim, replayIntegrationShim } from '@sentry-internal/integration-shims';

import { browserTracingIntegration } from '../../src';

import * as TracingBundle from '../../src/index.bundle.tracing';

describe('index.bundle.tracing', () => {
it('has correct exports', () => {
expect(TracingBundle.replayIntegration).toBe(replayIntegrationShim);
expect(TracingBundle.browserTracingIntegration).toBe(browserTracingIntegration);
expect(TracingBundle.feedbackAsyncIntegration).toBe(feedbackIntegrationShim);
expect(TracingBundle.feedbackIntegration).toBe(feedbackIntegrationShim);
expect(TracingBundle.replayIntegration).toBe(replayIntegrationShim);
});
});

0 comments on commit 3c95ac9

Please sign in to comment.