Skip to content

Commit

Permalink
feat: Add @sentry-internal/browser-utils (getsentry#11381)
Browse files Browse the repository at this point in the history
This PR creates a `browser-utils` package that contains browser specific
utils that can be shared between the browser, replay, and feedback
packages.

Eventually we will move `browserTracingIntegration` outside of this
package, but the instrumentation handlers will remain here. We will also
move the browser related utils in `@sentry/utils` to this package.

Given this removes `@sentry-internal/tracing` entirely, it is a part of
getsentry#9885

ref getsentry#9832
  • Loading branch information
AbhiPrasad authored and cadesalaberry committed Apr 19, 2024
1 parent 1a1a699 commit 6bfd4ed
Show file tree
Hide file tree
Showing 74 changed files with 56 additions and 49 deletions.
6 changes: 3 additions & 3 deletions .craft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ targets:
- name: npm
id: '@sentry/core'
includeNames: /^sentry-core-\d.*\.tgz$/
## 1.4 Tracing package
## 1.4 Browser Utils package
- name: npm
id: '@sentry-internal/tracing'
includeNames: /^sentry-internal-tracing-\d.*\.tgz$/
id: '@sentry-internal/browser-utils'
includeNames: /^sentry-internal-browser-utils-\d.*\.tgz$/
## 1.5 Replay Internal package (browser only)
- name: npm
id: '@sentry-internal/replay'
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,12 @@ jobs:
- 'scripts/**'
- 'packages/core/**'
- 'packages/rollup-utils/**'
- 'packages/tracing/**'
- 'packages/tracing-internal/**'
- 'packages/utils/**'
- 'packages/types/**'
browser: &browser
- *shared
- 'packages/browser/**'
- 'packages/browser-utils/**'
- 'packages/replay/**'
- 'packages/replay-canvas/**'
- 'packages/feedback/**'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { addLcpInstrumentationHandler } from '@sentry-internal/tracing';
import { addLcpInstrumentationHandler } from '@sentry-internal/browser-utils';

addLcpInstrumentationHandler(({ metric }) => {
const entry = metric.entries[metric.entries.length - 1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@sentry-internal/event-proxy-server": "link:../../../event-proxy-server",
"@sentry-internal/feedback": "latest || *",
"@sentry-internal/replay-canvas": "latest || *",
"@sentry-internal/tracing": "latest || *",
"@sentry-internal/browser-utils": "latest || *",
"@sentry/browser": "latest || *",
"@sentry/core": "latest || *",
"@sentry/nextjs": "latest || *",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@sentry-internal/event-proxy-server": "link:../../../event-proxy-server",
"@sentry-internal/feedback": "latest || *",
"@sentry-internal/replay-canvas": "latest || *",
"@sentry-internal/tracing": "latest || *",
"@sentry-internal/browser-utils": "latest || *",
"@sentry/browser": "latest || *",
"@sentry/core": "latest || *",
"@sentry/nextjs": "latest || *",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"packages/astro",
"packages/aws-serverless",
"packages/browser",
"packages/browser-utils",
"packages/bun",
"packages/core",
"packages/deno",
Expand All @@ -69,7 +70,6 @@
"packages/replay-worker",
"packages/svelte",
"packages/sveltekit",
"packages/tracing-internal",
"packages/types",
"packages/typescript",
"packages/utils",
Expand Down
File renamed without changes.
File renamed without changes.
23 changes: 23 additions & 0 deletions packages/browser-utils/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<p align="center">
<a href="https://sentry.io/?utm_source=github&utm_medium=logo" target="_blank">
<img src="https://sentry-brand.storage.googleapis.com/sentry-wordmark-dark-280x84.png" alt="Sentry" width="280" height="84">
</a>
</p>

# Sentry JavaScript SDK Browser Utilities

[![npm version](https://img.shields.io/npm/v/@sentry-internal/browser-utils.svg)](https://www.npmjs.com/package/@sentry-internal/browser-utils)
[![npm dm](https://img.shields.io/npm/dm/@sentry-internal/browser-utils.svg)](https://www.npmjs.com/package/@sentry-internal/browser-utils)
[![npm dt](https://img.shields.io/npm/dt/@sentry-internal/browser-utils.svg)](https://www.npmjs.com/package/@sentry-internal/browser-utils)

## Links

- [Official SDK Docs](https://docs.sentry.io/quickstart/)
- [TypeDoc](http://getsentry.github.io/sentry-javascript/)

## General

Common utilities used by the Sentry JavaScript SDKs.

Note: This package is only meant to be used internally, and as such is not part of our public API contract and does not
follow semver.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "@sentry-internal/tracing",
"name": "@sentry-internal/browser-utils",
"version": "8.0.0-alpha.7",
"description": "Sentry Internal Tracing Package",
"description": "Browser Utilities for all Sentry JavaScript SDKs",
"repository": "git://github.com/getsentry/sentry-javascript.git",
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/tracing-internal",
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/browser-utils",
"author": "Sentry",
"license": "MIT",
"engines": {
Expand Down Expand Up @@ -46,9 +46,6 @@
"@sentry/types": "8.0.0-alpha.7",
"@sentry/utils": "8.0.0-alpha.7"
},
"devDependencies": {
"@types/express": "^4.17.14"
},
"scripts": {
"build": "run-p build:transpile build:types",
"build:dev": "yarn build",
Expand All @@ -61,7 +58,7 @@
"build:transpile:watch": "rollup -c rollup.npm.config.mjs --watch",
"build:types:watch": "tsc -p tsconfig.types.json --watch",
"build:tarball": "ts-node ../../scripts/prepack.ts && npm pack ./build",
"clean": "rimraf build coverage sentry-internal-tracing-*.tgz",
"clean": "rimraf build coverage sentry-internal-browser-utils-*.tgz",
"fix": "eslint . --format stylish --fix",
"lint": "eslint . --format stylish",
"test:unit": "jest",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"@sentry-internal/feedback": "8.0.0-alpha.7",
"@sentry-internal/replay": "8.0.0-alpha.7",
"@sentry-internal/replay-canvas": "8.0.0-alpha.7",
"@sentry-internal/tracing": "8.0.0-alpha.7",
"@sentry-internal/browser-utils": "8.0.0-alpha.7",
"@sentry/core": "8.0.0-alpha.7",
"@sentry/types": "8.0.0-alpha.7",
"@sentry/utils": "8.0.0-alpha.7"
Expand Down
6 changes: 3 additions & 3 deletions packages/browser/src/index.bundle.tracing.replay.feedback.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { feedbackIntegration, getFeedback } from '@sentry-internal/feedback';
import { replayIntegration } from '@sentry-internal/replay';
import {
browserTracingIntegration,
startBrowserTracingNavigationSpan,
startBrowserTracingPageLoadSpan,
} from '@sentry-internal/tracing';
} from '@sentry-internal/browser-utils';
import { feedbackIntegration, getFeedback } from '@sentry-internal/feedback';
import { replayIntegration } from '@sentry-internal/replay';
import { addTracingExtensions } from '@sentry/core';

// We are patching the global object with our hub extension methods
Expand Down
6 changes: 3 additions & 3 deletions packages/browser/src/index.bundle.tracing.replay.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { feedbackIntegrationShim } from '@sentry-internal/integration-shims';
import { replayIntegration } from '@sentry-internal/replay';
import {
browserTracingIntegration,
startBrowserTracingNavigationSpan,
startBrowserTracingPageLoadSpan,
} from '@sentry-internal/tracing';
} from '@sentry-internal/browser-utils';
import { feedbackIntegrationShim } from '@sentry-internal/integration-shims';
import { replayIntegration } from '@sentry-internal/replay';
import { addTracingExtensions } from '@sentry/core';

// We are patching the global object with our hub extension methods
Expand Down
6 changes: 3 additions & 3 deletions packages/browser/src/index.bundle.tracing.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// This is exported so the loader does not fail when switching off Replay
import { feedbackIntegrationShim, replayIntegrationShim } from '@sentry-internal/integration-shims';
import {
browserTracingIntegration,
startBrowserTracingNavigationSpan,
startBrowserTracingPageLoadSpan,
} from '@sentry-internal/tracing';
} from '@sentry-internal/browser-utils';
// This is exported so the loader does not fail when switching off Replay
import { feedbackIntegrationShim, replayIntegrationShim } from '@sentry-internal/integration-shims';
import { addTracingExtensions } from '@sentry/core';

// We are patching the global object with our hub extension methods
Expand Down
4 changes: 2 additions & 2 deletions packages/browser/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export {
browserTracingIntegration,
startBrowserTracingNavigationSpan,
startBrowserTracingPageLoadSpan,
} from '@sentry-internal/tracing';
export type { RequestInstrumentationOptions } from '@sentry-internal/tracing';
} from '@sentry-internal/browser-utils';
export type { RequestInstrumentationOptions } from '@sentry-internal/browser-utils';
export {
addTracingExtensions,
getActiveSpan,
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/src/profiling/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export function isProfiledTransactionEvent(event: Event): event is ProfiledEvent
}

/*
See packages/tracing-internal/src/browser/router.ts
See packages/browser-utils/src/browser/router.ts
*/
/**
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { browserTracingIntegration } from '@sentry-internal/tracing';
import { browserTracingIntegration } from '@sentry-internal/browser-utils';
import { feedbackIntegration, replayIntegration } from '@sentry/browser';

import * as TracingReplayFeedbackBundle from '../../src/index.bundle.tracing.replay.feedback';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { browserTracingIntegration } from '@sentry-internal/browser-utils';
import { feedbackIntegrationShim } from '@sentry-internal/integration-shims';
import { browserTracingIntegration } from '@sentry-internal/tracing';
import { replayIntegration } from '@sentry/browser';

import * as TracingReplayBundle from '../../src/index.bundle.tracing.replay';
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/test/unit/index.bundle.tracing.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { browserTracingIntegration } from '@sentry-internal/browser-utils';
import { feedbackIntegrationShim, replayIntegrationShim } from '@sentry-internal/integration-shims';
import { browserTracingIntegration } from '@sentry-internal/tracing';

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

Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/test/integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
"@sentry/node": "file:../../../node",
"@sentry/opentelemetry": "file:../../../opentelemetry",
"@sentry/react": "file:../../../react",
"@sentry-internal/browser-utils": "file:../../../browser-utils",
"@sentry-internal/replay": "file:../../../replay-internal",
"@sentry-internal/replay-canvas": "file:../../../replay-canvas",
"@sentry-internal/tracing": "file:../../../tracing-internal",
"@sentry-internal/feedback": "file:../../../feedback",
"@sentry/types": "file:../../../types",
"@sentry/utils": "file:../../../utils",
Expand Down
2 changes: 1 addition & 1 deletion packages/remix/test/integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
"@sentry/node": "file:../../../node",
"@sentry/opentelemetry": "file:../../../opentelemetry",
"@sentry/react": "file:../../../react",
"@sentry-internal/browser-utils": "file:../../../browser-utils",
"@sentry-internal/replay": "file:../../../replay-internal",
"@sentry-internal/replay-canvas": "file:../../../replay-canvas",
"@sentry-internal/tracing": "file:../../../tracing-internal",
"@sentry-internal/feedback": "file:../../../feedback",
"@sentry/types": "file:../../../types",
"@sentry/utils": "file:../../../utils",
Expand Down
2 changes: 1 addition & 1 deletion packages/replay-internal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"jsdom-worker": "^0.2.1"
},
"dependencies": {
"@sentry-internal/tracing": "8.0.0-alpha.7",
"@sentry-internal/browser-utils": "8.0.0-alpha.7",
"@sentry/core": "8.0.0-alpha.7",
"@sentry/types": "8.0.0-alpha.7",
"@sentry/utils": "8.0.0-alpha.7"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { addLcpInstrumentationHandler, addPerformanceInstrumentationHandler } from '@sentry-internal/tracing';
import { addLcpInstrumentationHandler, addPerformanceInstrumentationHandler } from '@sentry-internal/browser-utils';

import type { ReplayContainer } from '../types';
import { getLargestContentfulPaint } from '../util/createPerformanceEntries';
Expand Down
1 change: 0 additions & 1 deletion packages/sveltekit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"@sveltejs/kit": "1.x || 2.x"
},
"dependencies": {
"@sentry-internal/tracing": "8.0.0-alpha.7",
"@sentry/core": "8.0.0-alpha.7",
"@sentry/node": "8.0.0-alpha.7",
"@sentry/opentelemetry": "8.0.0-alpha.7",
Expand Down
12 changes: 0 additions & 12 deletions packages/tracing-internal/README.md

This file was deleted.

1 change: 1 addition & 0 deletions scripts/node-unit-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const DEFAULT_SKIP_TESTS_PACKAGES = [
'@sentry/angular',
'@sentry/svelte',
'@sentry/profiling-node',
'@sentry-internal/browser-utils',
'@sentry-internal/replay',
'@sentry-internal/replay-canvas',
'@sentry-internal/replay-worker',
Expand Down

0 comments on commit 6bfd4ed

Please sign in to comment.