Skip to content

Commit 70c310a

Browse files
authored
refactor: restructure into turbo monorepo (#1143)
1 parent 9af816d commit 70c310a

File tree

466 files changed

+2964
-3984
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

466 files changed

+2964
-3984
lines changed

.claude/CLAUDE.md

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,20 @@ Observability SDK for web applications built on OpenTelemetry. Captures Spans (t
1717

1818
```bash
1919
# Build
20-
npm run sdk:compile # Build SDK (ESM/CJS/IIFE)
21-
npm run cli:compile # Build CLI tool
20+
npm run build # Build all packages (turbo)
2221

2322
# Test
24-
npm run test # Run unit tests
25-
npm run sdk:test:coverage # With coverage
26-
npm run sdk:test:integration # Integration tests (requires sdk:compile first)
23+
npm run test # Run unit tests (turbo)
24+
npm run test:integration # Integration tests (requires build first)
2725

2826
# Lint & Check
29-
npm run lint # Auto-fix with Biome
30-
npm run validate # All checks (tsc + eslint baseline)
27+
npm run lint # Auto-fix with Biome
28+
npm run validate # All checks (tsc + eslint baseline)
3129
```
3230

3331
## Architecture
3432

35-
### Source Layout (`src/`)
33+
### Source Layout (`packages/web-sdk/src/`)
3634

3735
```
3836
api-*/ Public APIs with no-op defaults (traces, logs, sessions, users, page)
@@ -89,19 +87,19 @@ transport/ HTTP transport with retry logic
8987
Framework: @web/test-runner + Playwright + Mocha + Chai
9088

9189
```bash
92-
npm run sdk:test # Headless
93-
npm run sdk:test:manual # Browser with DevTools
94-
npm run sdk:test:watch # Watch mode
90+
npm run test # Headless (from packages/web-sdk/)
91+
npm run test:manual # Browser with DevTools
92+
npm run test:watch # Watch mode
9593
```
9694

9795
### Integration Tests
9896

9997
Test SDK against bundlers (Webpack 4/5, Vite 7, Next.js):
10098

10199
```bash
102-
npm run sdk:compile # Build first
103-
npm run sdk:test:integration # Run tests
104-
npm run sdk:test:integration:update-golden # Update golden files
100+
npm run build # Build first
101+
npm run test:integration # Run tests
102+
npm run test:integration:update-golden # Update golden files
105103
```
106104

107105
## Constraints
@@ -132,16 +130,16 @@ npm run sdk:test:integration:update-golden # Update golden files
132130

133131
### Adding an Instrumentation
134132

135-
1. Create in `src/instrumentations/<name>/`
133+
1. Create in `packages/web-sdk/src/instrumentations/<name>/`
136134
2. Extend `EmbraceInstrumentationBase`
137-
3. Export from `src/instrumentations/index.ts`
135+
3. Export from `packages/web-sdk/src/instrumentations/index.ts`
138136
4. Register in `setupDefaultInstrumentations.ts` if auto-enabled
139137

140138
### Adding a Processor
141139

142-
1. Create in `src/processors/<Name>Processor/`
140+
1. Create in `packages/web-sdk/src/processors/<Name>Processor/`
143141
2. Implement `SpanProcessor` or `LogRecordProcessor`
144-
3. Export from `src/processors/index.ts`
142+
3. Export from `packages/web-sdk/src/processors/index.ts`
145143
4. Wire into processor chain in `initSDK.ts`
146144

147145
## Git Workflow
@@ -194,5 +192,5 @@ npm run sdk:test:integration:update-golden # Update golden files
194192

195193
### Tests Flaky
196194

197-
- Ensure `npm run sdk:compile` before integration tests
198-
- Use `sdk:test:manual` for debugging
195+
- Ensure `npm run build` before integration tests
196+
- Use `npm run test:manual` for debugging (from `packages/web-sdk/`)

.github/workflows/ci-nodejs.yml

Lines changed: 24 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,13 @@ jobs:
112112
# playwright to install everything for us.
113113
- name: Install Playwright browsers with dependencies
114114
if: ${{ env.TEST_PREVIOUSLY_PASSED != 'true' && steps.playwright-cache.outputs.cache-hit != 'true' }}
115-
run: npm run playwright -- install --with-deps
115+
run: npx playwright install --with-deps
116116

117117
# If the Playwright browser binaries were restored, we tell
118118
# playwright to install just system deps.
119119
- name: Install Playwright's dependencies
120120
if: ${{ env.TEST_PREVIOUSLY_PASSED != 'true' && steps.playwright-cache.outputs.cache-hit == 'true' }}
121-
run: npm run playwright -- install-deps
121+
run: npx playwright install-deps
122122

123123
- name: Test with coverage
124124
if: ${{ env.TEST_PREVIOUSLY_PASSED != 'true' }}
@@ -130,7 +130,7 @@ jobs:
130130
argsCoverage='--config=web-test-runner.coverage.config.js'
131131
echo 'TEST_COLLECTED_COVERAGE=true' >> $GITHUB_ENV
132132
fi
133-
npm run sdk:test -- $argsCoverage
133+
npx turbo run test --filter=@embrace-io/web-sdk -- $argsCoverage
134134
env:
135135
GITHUB_EVENT_ACTION: ${{ github.event.action }}
136136

@@ -222,18 +222,18 @@ jobs:
222222
# playwright to install everything for us.
223223
- name: Install Playwright browsers with dependencies
224224
if: ${{ env.TEST_PREVIOUSLY_PASSED != 'true' && steps.playwright-cache.outputs.cache-hit != 'true' }}
225-
run: npm run playwright -- install --with-deps
225+
run: npx playwright install --with-deps
226226

227227
# If the Playwright browser binaries were restored, we tell
228228
# playwright to install just system deps.
229229
- name: Install Playwright's dependencies
230230
if: ${{ env.TEST_PREVIOUSLY_PASSED != 'true' && steps.playwright-cache.outputs.cache-hit == 'true' }}
231-
run: npm run playwright -- install-deps
231+
run: npx playwright install-deps
232232

233233
- name: Test SDK multiple browsers
234234
if: ${{ env.TEST_PREVIOUSLY_PASSED != 'true' }}
235235
run: |
236-
npm run sdk:test:multiBrowsers
236+
npm run test:multiBrowsers
237237
238238
- name: Cache successful test results
239239
if: ${{ success() }}
@@ -325,24 +325,18 @@ jobs:
325325
# playwright to install everything for us.
326326
- name: Install Playwright browsers with dependencies
327327
if: ${{ env.TEST_PREVIOUSLY_PASSED != 'true' && steps.playwright-cache.outputs.cache-hit != 'true' }}
328-
run: npm run playwright -- install --with-deps
328+
run: npx playwright install --with-deps
329329

330330
# If the Playwright browser binaries were restored, we tell
331331
# playwright to install just system deps.
332332
- name: Install Playwright's dependencies
333333
if: ${{ env.TEST_PREVIOUSLY_PASSED != 'true' && steps.playwright-cache.outputs.cache-hit == 'true' }}
334-
run: npm run playwright -- install-deps
335-
336-
# We need the SDK to be built, so we can use it during performance tests
337-
- name: Build SDK
338-
if: ${{ env.TEST_PREVIOUSLY_PASSED != 'true' }}
339-
run: |
340-
npm run sdk:compile
334+
run: npx playwright install-deps
341335

342336
- name: Test performance
343337
if: ${{ env.TEST_PREVIOUSLY_PASSED != 'true' }}
344338
run: |
345-
npm run sdk:test:performance
339+
npm run test:performance
346340
347341
- name: Cache successful test results
348342
if: ${{ success() }}
@@ -458,7 +452,7 @@ jobs:
458452
- name: Test CLI
459453
if: ${{ env.TEST_PREVIOUSLY_PASSED != 'true' }}
460454
run: |
461-
npm run test --prefix cli
455+
npx turbo run test --filter=@embrace-io/web-cli
462456
463457
- name: Cache successful test results
464458
if: ${{ success() }}
@@ -542,26 +536,20 @@ jobs:
542536
# playwright to install everything for us.
543537
- name: Install Playwright browsers with dependencies
544538
if: ${{ env.TEST_PREVIOUSLY_PASSED != 'true' && steps.playwright-cache.outputs.cache-hit != 'true' }}
545-
run: npm run playwright -- install --with-deps
539+
run: npx playwright install --with-deps
546540

547541
# If the Playwright browser binaries were restored, we tell
548542
# playwright to install just system deps.
549543
- name: Install Playwright's dependencies
550544
if: ${{ env.TEST_PREVIOUSLY_PASSED != 'true' && steps.playwright-cache.outputs.cache-hit == 'true' }}
551-
run: npm run playwright -- install-deps
552-
553-
# We need the SDK and CLI to be built, so we can use them in the sample apps
554-
- name: Build SDK and CLI
555-
if: ${{ env.TEST_PREVIOUSLY_PASSED != 'true' }}
556-
run: |
557-
npm run compile
545+
run: npx playwright install-deps
558546

559547
- name: Test Integration
560548
if: ${{ env.TEST_PREVIOUSLY_PASSED != 'true' }}
561549
# Build needs to run first so e2e tests can use the built apps and not build again
562550
# Run the e2e tests in a virtual display, since Playwright needs a display to run
563551
run: |
564-
npm run sdk:test:integration
552+
npm run test:integration
565553
566554
- name: Cache successful test results
567555
if: ${{ success() }}
@@ -695,7 +683,7 @@ jobs:
695683
- name: Lint
696684
if: ${{ env.LINT_PREVIOUSLY_PASSED != 'true' }}
697685
run: |
698-
npm run sdk:lint
686+
npm run lint
699687
700688
- name: Cache successful lint results
701689
if: ${{ success() }}
@@ -748,7 +736,7 @@ jobs:
748736
- name: Type check
749737
if: ${{ env.TYPE_CHECK_PREVIOUSLY_PASSED != 'true' }}
750738
run: |
751-
npm run sdk:check
739+
npm run check
752740
753741
- name: Cache successful type check results
754742
if: ${{ success() }}
@@ -800,30 +788,15 @@ jobs:
800788
run: |
801789
npm ci
802790
803-
- name: Build SDK
804-
if: ${{ env.VALIDATE_PREVIOUSLY_PASSED != 'true' }}
805-
run: |
806-
npm run sdk:compile
807-
808-
- name: Validate SDK
809-
if: ${{ env.VALIDATE_PREVIOUSLY_PASSED != 'true' }}
810-
run: |
811-
npm run sdk:validate
812-
813-
- name: Build CLI
814-
if: ${{ env.VALIDATE_PREVIOUSLY_PASSED != 'true' }}
815-
run: |
816-
npm run cli:compile
817-
818-
- name: Validate CLI
791+
- name: Build All Packages
819792
if: ${{ env.VALIDATE_PREVIOUSLY_PASSED != 'true' }}
820793
run: |
821-
npm run cli:validate
794+
npm run build
822795
823-
- name: Build Demo
796+
- name: Validate Packages
824797
if: ${{ env.VALIDATE_PREVIOUSLY_PASSED != 'true' }}
825798
run: |
826-
npm run build --prefix demo/frontend
799+
npm run validate
827800
828801
- name: Cache successful validate results
829802
if: ${{ success() }}
@@ -868,15 +841,16 @@ jobs:
868841
869842
- name: Build SDK and CLI
870843
run: |
871-
npm run compile
844+
npm run build
872845
873846
- name: Publish SDK
874847
run: |
848+
cd packages/web-sdk
875849
npm publish --provenance --access public
876850
877851
- name: Publish CLI
878852
run: |
879-
cd cli
853+
cd packages/web-cli
880854
npm publish --provenance --access public
881855
882856
# Publishes preview packages to pkg.pr.new after CI passes on main.
@@ -910,10 +884,10 @@ jobs:
910884
run: npm ci
911885

912886
- name: Build SDK and CLI
913-
run: npm run compile
887+
run: npm run build
914888

915889
- name: Publish preview packages
916-
run: npx --yes pkg-pr-new publish --compact '.' './cli'
890+
run: npx --yes pkg-pr-new publish --compact './packages/web-sdk' './packages/web-cli'
917891

918892
# not used yet, there are no "production" releases
919893
report-release-slack:

.github/workflows/pkg-pr-new.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
run: npm ci
3030

3131
- name: Build SDK and CLI
32-
run: npm run compile
32+
run: npm run build
3333

3434
- name: Publish preview packages
35-
run: npx --yes pkg-pr-new publish --compact '.' './cli'
35+
run: npx --yes pkg-pr-new publish --compact './packages/web-sdk' './packages/web-cli'

.github/workflows/publish-demo.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
paths:
77
- demo/**
88
- package*.json
9-
- src/**
9+
- packages/web-sdk/src/**
1010
- .nvmrc
1111
workflow_dispatch:
1212

@@ -38,9 +38,7 @@ jobs:
3838
- run: npm ci
3939

4040
- name: Build demo
41-
run: npm run build --prefix demo/frontend
42-
env:
43-
VITE_BASE_URL: /embrace-web-sdk/
41+
run: npx turbo run build --filter=embrace-web-sdk-react-demo
4442

4543
- name: Verify build output
4644
run: |

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
# commit the changes
6464
git config --global user.name 'embrace-ci'
6565
git config --global user.email 'embrace-ci@users.noreply.github.com'
66-
git add package.json package-lock.json cli/package.json src/resources/constants/index.ts cli/src/constants.ts tests/integration/tests/__golden__
66+
git add packages/web-sdk/package.json package-lock.json packages/web-cli/package.json packages/web-sdk/src/resources/constants/index.ts packages/web-cli/src/constants.ts tests/integration/tests/__golden__
6767
git commit -m "release: update version to $NEXT_VERSION"
6868
git push origin "release-$NEXT_VERSION"
6969
# create a PR with the next version

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ dist
1313
.tmp*/
1414
test-results
1515
build-test-results
16+
.turbo/

DEVELOPING.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ This command will:
2424

2525
## Repo Layout
2626

27-
The code within `src/` is divided as follows:
27+
The code within `packages/web-sdk/src/` is divided as follows:
2828

2929
- `api-*/`
3030
- High-level APIs that expose the SDK's functionality. By default these
@@ -63,36 +63,39 @@ together).
6363
Run tests with:
6464

6565
```sh
66-
npm run sdk:test
66+
npm run test
6767
```
6868

6969
For debugging, you can run tests in a browser to set breakpoints, open the dev
7070
console, etc. with:
7171

7272
```sh
73-
npm run sdk:test:manual
73+
npm run test:manual
7474
```
7575

7676
Manual mode as well as other debugging options can also be reached from watch
7777
mode:
7878

7979
```sh
80-
npm run sdk:test:watch
80+
npm run test:watch
8181
```
8282

83+
> Note: These commands should be run from `packages/web-sdk/`. From the repo
84+
> root, `npm run test` runs tests across all packages via Turbo.
85+
8386
## Integration Testing
8487

8588
Run the integration tests and build all prerequisites with:
8689

8790
```bash
88-
npm run sdk:compile
89-
npm run sdk:test:integration
91+
npm run build
92+
npm run test:integration
9093
```
9194

9295
To update golden files replace the last command with:
9396

9497
```bash
95-
npm run sdk:test:integration:update-golden
98+
npm run test:integration:update-golden
9699
```
97100

98101
## Dependency Versioning

0 commit comments

Comments
 (0)