Skip to content

Commit 3e90673

Browse files
authored
feat: publish umd for broser environments (#334)
## Summary Creates a umd build for unpkg and other browser script installations. ## How did you test this change? ```html <html> <head> <script type="text/javascript" src="https://unpkg.com/[email protected]"></script> <script type="text/javascript" src="https://unpkg.com/@launchdarkly/[email protected]"></script> <script type="text/javascript" src="https://unpkg.com/@launchdarkly/[email protected]"></script> <script> const context = { type: 'user', key: '[email protected]' }; window.ld = window.LDClient.initialize('YOUR_LD_CLIENT_ID', context, { plugins: [ new window.Observability.default({ tracingOrigins: true, networkRecording: { enabled: true, recordHeadersAndBody: true } }), new window.SessionReplay.default({ privacySetting: 'none', }) ] }); </script> </head> <body> yooo </body> </html> ``` https://github.com/launchdarkly/observability-sdk/actions/runs/20444345338 <img width="1793" height="442" alt="Screenshot 2025-12-22 at 13 21 07" src="https://github.com/user-attachments/assets/648aae06-2d3f-4f7d-8383-41f4499acd9b" /> ## Are there any deployment considerations? <!-- Backend - Do we need to consider migrations or backfilling data? --> <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Enables browser/CDN script usage by publishing UMD bundles alongside ES builds for both `@launchdarkly/observability` and `@launchdarkly/session-replay`. > > - Build: Vite now outputs `umd` and `es` formats with named globals (`Observability`, `SessionReplay`) and consistent filenames (`index.js`, `index.umd.js`) > - Packaging: `package.json` switches `main`/`module` to `./dist/index.js` and adds `unpkg`/`jsdelivr` pointing to `./dist/index.umd.js` > - Version: bump both packages to `0.4.12-alpha.1` > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit c921ab0. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent bf70e18 commit 3e90673

File tree

4 files changed

+38
-14
lines changed

4 files changed

+38
-14
lines changed

sdk/@launchdarkly/observability/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@launchdarkly/observability",
3-
"version": "0.4.11",
3+
"version": "0.4.12-alpha.1",
44
"description": "Browser observability for your web app. Capture frontend metrics, errors, logs and traces.",
55
"keywords": [
66
"launchdarkly",
@@ -37,8 +37,10 @@
3737
"vitest": "^3.1.2"
3838
},
3939
"type": "module",
40-
"main": "./dist/observability.js",
41-
"module": "./dist/observability.js",
40+
"main": "./dist/index.js",
41+
"module": "./dist/index.js",
42+
"unpkg": "./dist/index.umd.js",
43+
"jsdelivr": "./dist/index.umd.js",
4244
"types": "./dist/index.d.ts",
4345
"files": [
4446
"dist"

sdk/@launchdarkly/observability/vite.config.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,27 @@ export default defineConfig(({}) => {
88
build: {
99
target: 'esnext',
1010
lib: {
11-
formats: ['es'],
11+
name: 'Observability',
12+
formats: ['umd', 'es'],
1213
entry: resolvePath(__dirname, 'src/index.ts'),
14+
fileName: (format, entryName) =>
15+
format === 'es'
16+
? `${entryName}.js`
17+
: `${entryName}.${format}.js`,
1318
},
1419
minify: true,
1520
sourcemap: true,
1621
emptyOutDir: false,
1722
rollupOptions: {
1823
treeshake: 'smallest',
19-
output: {
20-
exports: 'named',
21-
},
24+
output: [
25+
{ format: 'es', exports: 'named' },
26+
{
27+
format: 'umd',
28+
name: 'Observability',
29+
exports: 'named',
30+
},
31+
],
2232
cache: false,
2333
},
2434
},

sdk/@launchdarkly/session-replay/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@launchdarkly/session-replay",
3-
"version": "0.4.11",
3+
"version": "0.4.12-alpha.1",
44
"description": "Browser observability for your web app. Record session replays to visualize usage patterns.",
55
"keywords": [
66
"launchdarkly",
@@ -34,8 +34,10 @@
3434
"vitest": "^3.1.2"
3535
},
3636
"type": "module",
37-
"main": "./dist/session-replay.js",
38-
"module": "./dist/session-replay.js",
37+
"main": "./dist/index.js",
38+
"module": "./dist/index.js",
39+
"unpkg": "./dist/index.umd.js",
40+
"jsdelivr": "./dist/index.umd.js",
3941
"types": "./dist/index.d.ts",
4042
"files": [
4143
"dist"

sdk/@launchdarkly/session-replay/vite.config.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,27 @@ export default defineConfig(({}) => {
88
build: {
99
target: 'esnext',
1010
lib: {
11-
formats: ['es'],
11+
name: 'SessionReplay',
12+
formats: ['umd', 'es'],
1213
entry: resolvePath(__dirname, 'src/index.ts'),
14+
fileName: (format, entryName) =>
15+
format === 'es'
16+
? `${entryName}.js`
17+
: `${entryName}.${format}.js`,
1318
},
1419
minify: true,
1520
sourcemap: true,
1621
emptyOutDir: false,
1722
rollupOptions: {
1823
treeshake: 'smallest',
19-
output: {
20-
exports: 'named',
21-
},
24+
output: [
25+
{ format: 'es', exports: 'named' },
26+
{
27+
format: 'umd',
28+
name: 'SessionReplay',
29+
exports: 'named',
30+
},
31+
],
2232
cache: false,
2333
},
2434
},

0 commit comments

Comments
 (0)