Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ jobs:
- bundle_min
- bundle_replay
- bundle_tracing
- bundle_tracing_logs_metrics
- bundle_tracing_replay
- bundle_tracing_replay_feedback
- bundle_tracing_replay_feedback_min
Expand Down
13 changes: 13 additions & 0 deletions .size-limit.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,12 @@ module.exports = [
gzip: true,
limit: '43 KB',
},
{
name: 'CDN Bundle (incl. Tracing, Logs, Metrics)',
path: createCDNPath('bundle.tracing.logs.metrics.min.js'),
gzip: true,
limit: '44 KB',
},
{
name: 'CDN Bundle (incl. Tracing, Replay)',
path: createCDNPath('bundle.tracing.replay.min.js'),
Expand Down Expand Up @@ -213,6 +219,13 @@ module.exports = [
brotli: false,
limit: '127 KB',
},
{
name: 'CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed',
path: createCDNPath('bundle.tracing.logs.metrics.min.js'),
gzip: false,
brotli: false,
limit: '130 KB',
},
{
name: 'CDN Bundle (incl. Tracing, Replay) - uncompressed',
path: createCDNPath('bundle.tracing.replay.min.js'),
Expand Down
5 changes: 3 additions & 2 deletions dev-packages/browser-integration-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ To filter tests by their title:

You can refer to [Playwright documentation](https://playwright.dev/docs/test-cli) for other CLI options.

You can set env variable `PW_BUNDLE` to set specific build or bundle to test against. Available options: `esm`, `cjs`,
`bundle`, `bundle_min`
You can set env variable `PW_BUNDLE` to set specific build or bundle to test against. Available options include: `esm`, `cjs`,
`bundle`, `bundle_min`, `bundle_tracing`, `bundle_tracing_logs_metrics`, `bundle_replay`, `bundle_tracing_replay_feedback`, and more.
See `package.json` scripts for the full list of `test:bundle:*` commands.

### Troubleshooting

Expand Down
3 changes: 3 additions & 0 deletions dev-packages/browser-integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
"test:bundle:replay:min": "PW_BUNDLE=bundle_replay_min yarn test",
"test:bundle:tracing": "PW_BUNDLE=bundle_tracing yarn test",
"test:bundle:tracing:min": "PW_BUNDLE=bundle_tracing_min yarn test",
"test:bundle:tracing_logs_metrics": "PW_BUNDLE=bundle_tracing_logs_metrics yarn test",
"test:bundle:tracing_logs_metrics:min": "PW_BUNDLE=bundle_tracing_logs_metrics_min yarn test",
"test:bundle:tracing_logs_metrics:debug_min": "PW_BUNDLE=bundle_tracing_logs_metrics_debug_min yarn test",
"test:bundle:full": "PW_BUNDLE=bundle_tracing_replay_feedback yarn test",
"test:bundle:full:min": "PW_BUNDLE=bundle_tracing_replay_feedback_min yarn test",
"test:cjs": "PW_BUNDLE=cjs yarn test",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { sentryTest } from '../../../../utils/fixtures';
import {
getFirstSentryEnvelopeRequest,
properFullEnvelopeRequestParser,
testingCdnBundle,
shouldSkipLogsTest,
} from '../../../../utils/helpers';

sentryTest('should capture console object calls', async ({ getLocalTestUrl, page }) => {
// Only run this for npm package exports
sentryTest.skip(testingCdnBundle());
// Only run this for npm package exports and CDN bundles with logs
sentryTest.skip(shouldSkipLogsTest());

const url = await getLocalTestUrl({ testDir: __dirname });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { sentryTest } from '../../../../utils/fixtures';
import {
getFirstSentryEnvelopeRequest,
properFullEnvelopeRequestParser,
testingCdnBundle,
shouldSkipLogsTest,
} from '../../../../utils/helpers';

sentryTest('captures logs with scope attributes', async ({ getLocalTestUrl, page }) => {
sentryTest.skip(testingCdnBundle());
sentryTest.skip(shouldSkipLogsTest());

const url = await getLocalTestUrl({ testDir: __dirname });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { sentryTest } from '../../../../utils/fixtures';
import {
getFirstSentryEnvelopeRequest,
properFullEnvelopeRequestParser,
testingCdnBundle,
shouldSkipLogsTest,
} from '../../../../utils/helpers';

sentryTest('should capture all logging methods', async ({ getLocalTestUrl, page }) => {
// Only run this for npm package exports
sentryTest.skip(testingCdnBundle());
// Only run this for npm package exports and CDN bundles with logs
sentryTest.skip(shouldSkipLogsTest());

const url = await getLocalTestUrl({ testDir: __dirname });

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { expect } from '@playwright/test';
import { sentryTest } from '../../../../utils/fixtures';
import { shouldSkipMetricsTest } from '../../../../utils/helpers';

sentryTest(
'should emit afterCaptureMetric event with processed metric from beforeSendMetric',
async ({ getLocalTestUrl, page }) => {
const bundle = process.env.PW_BUNDLE || '';
if (bundle.startsWith('bundle') || bundle.startsWith('loader')) {
// Only run this for npm package exports and CDN bundles with metrics
if (shouldSkipMetricsTest()) {
sentryTest.skip();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { expect } from '@playwright/test';
import type { MetricEnvelope } from '@sentry/core';
import { sentryTest } from '../../../../utils/fixtures';
import { getFirstSentryEnvelopeRequest, properFullEnvelopeRequestParser } from '../../../../utils/helpers';
import {
getFirstSentryEnvelopeRequest,
properFullEnvelopeRequestParser,
shouldSkipMetricsTest,
} from '../../../../utils/helpers';

sentryTest('should capture all metric types', async ({ getLocalTestUrl, page }) => {
const bundle = process.env.PW_BUNDLE || '';
if (bundle.startsWith('bundle') || bundle.startsWith('loader')) {
// Only run this for npm package exports and CDN bundles with metrics
if (shouldSkipMetricsTest()) {
sentryTest.skip();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ const BUNDLE_PATHS: Record<string, Record<string, string>> = {
bundle_replay_min: 'build/bundles/bundle.replay.min.js',
bundle_tracing: 'build/bundles/bundle.tracing.js',
bundle_tracing_min: 'build/bundles/bundle.tracing.min.js',
bundle_tracing_logs_metrics: 'build/bundles/bundle.tracing.logs.metrics.js',
bundle_tracing_logs_metrics_min: 'build/bundles/bundle.tracing.logs.metrics.min.js',
bundle_tracing_logs_metrics_debug_min: 'build/bundles/bundle.tracing.logs.metrics.debug.min.js',
bundle_tracing_replay: 'build/bundles/bundle.tracing.replay.js',
bundle_tracing_replay_min: 'build/bundles/bundle.tracing.replay.min.js',
bundle_tracing_replay_feedback: 'build/bundles/bundle.tracing.replay.feedback.js',
Expand Down Expand Up @@ -245,7 +248,9 @@ class SentryScenarioGenerationPlugin {
.replace('loader_', 'bundle_')
.replace('_replay', '')
.replace('_tracing', '')
.replace('_feedback', '');
.replace('_feedback', '')
.replace('_logs', '')
.replace('_metrics', '');

// For feedback bundle, make sure to add modal & screenshot integrations
if (bundleKey.includes('_feedback')) {
Expand Down
24 changes: 24 additions & 0 deletions dev-packages/browser-integration-tests/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,30 @@ export function shouldSkipTracingTest(): boolean {
return bundle != null && !bundle.includes('tracing') && !bundle.includes('esm') && !bundle.includes('cjs');
}

/**
* We can only test metrics tests in certain bundles/packages:
* - NPM (ESM, CJS)
* - CDN bundles that contain metrics
*
* @returns `true` if we should skip the metrics test
*/
export function shouldSkipMetricsTest(): boolean {
const bundle = process.env.PW_BUNDLE;
return bundle != null && !bundle.includes('metrics') && !bundle.includes('esm') && !bundle.includes('cjs');
}

/**
* We can only test logs tests in certain bundles/packages:
* - NPM (ESM, CJS)
* - CDN bundles that contain logs
*
* @returns `true` if we should skip the logs test
*/
export function shouldSkipLogsTest(): boolean {
const bundle = process.env.PW_BUNDLE;
return bundle != null && !bundle.includes('logs') && !bundle.includes('esm') && !bundle.includes('cjs');
}

/**
* @returns `true` if we are testing a CDN bundle
*/
Expand Down
8 changes: 8 additions & 0 deletions packages/browser/rollup.bundle.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ const tracingReplayFeedbackBaseBundleConfig = makeBaseBundleConfig({
outputFileBase: () => 'bundles/bundle.tracing.replay.feedback',
});

const tracingLogsMetricsBaseBundleConfig = makeBaseBundleConfig({
bundleType: 'standalone',
entrypoints: ['src/index.bundle.tracing.logs.metrics.ts'],
licenseTitle: '@sentry/browser (Performance Monitoring, Logs, and Metrics)',
outputFileBase: () => 'bundles/bundle.tracing.logs.metrics',
});

builds.push(
...makeBundleConfigVariants(baseBundleConfig),
...makeBundleConfigVariants(tracingBaseBundleConfig),
Expand All @@ -112,6 +119,7 @@ builds.push(
...makeBundleConfigVariants(tracingReplayBaseBundleConfig),
...makeBundleConfigVariants(replayFeedbackBaseBundleConfig),
...makeBundleConfigVariants(tracingReplayFeedbackBaseBundleConfig),
...makeBundleConfigVariants(tracingLogsMetricsBaseBundleConfig),
);

export default builds;
35 changes: 35 additions & 0 deletions packages/browser/src/index.bundle.tracing.logs.metrics.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { registerSpanErrorInstrumentation } from '@sentry/core';
import { feedbackIntegrationShim, replayIntegrationShim } from '@sentry-internal/integration-shims';

registerSpanErrorInstrumentation();

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

// TODO(v11): Export metrics here once we remove it from the base bundle.
export { logger, consoleLoggingIntegration } from '@sentry/core';

export {
getActiveSpan,
getRootSpan,
getSpanDescendants,
setMeasurement,
startInactiveSpan,
startNewTrace,
startSpan,
startSpanManual,
withActiveSpan,
} from '@sentry/core';

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

export {
feedbackIntegrationShim as feedbackAsyncIntegration,
feedbackIntegrationShim as feedbackIntegration,
replayIntegrationShim as replayIntegration,
};
17 changes: 17 additions & 0 deletions packages/browser/test/index.bundle.tracing.logs.metrics.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { logger as coreLogger, metrics as coreMetrics } from '@sentry/core';
import { feedbackIntegrationShim, replayIntegrationShim } from '@sentry-internal/integration-shims';
import { describe, expect, it } from 'vitest';
import { browserTracingIntegration } from '../src';
import * as TracingLogsMetricsBundle from '../src/index.bundle.tracing.logs.metrics';

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

expect(TracingLogsMetricsBundle.logger).toBe(coreLogger);
expect(TracingLogsMetricsBundle.metrics).toBe(coreMetrics);
});
});
Loading