Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
d79cac1
WIP highligth sdk
Vadman97 Apr 24, 2025
ce3d6ae
WIP launchdarkly peerDependency
Vadman97 Apr 25, 2025
77010dd
plugin interface
Vadman97 Apr 28, 2025
2f33d0b
rename
Vadman97 Apr 29, 2025
a78430c
progress?
Vadman97 Apr 30, 2025
34a014b
fixup! progress?
Vadman97 Apr 30, 2025
cbb8abe
prepare record plugin
Vadman97 Apr 30, 2025
f5b0001
plugins setup
Vadman97 Apr 30, 2025
465827a
observability record plugins
Vadman97 Apr 30, 2025
af64323
sdk theoretically working
Vadman97 Apr 30, 2025
27ccba8
setup e2e test of launchdarkly packages
Vadman97 May 1, 2025
88895c7
fixup! setup e2e test of launchdarkly packages
Vadman97 May 1, 2025
33ed9b9
build tweaks
Vadman97 May 1, 2025
b219e0d
lockfile
Vadman97 May 1, 2025
edd8bca
wip
Vadman97 May 1, 2025
7d08772
fix testing
Vadman97 May 2, 2025
5f08da4
buffering logic working
Vadman97 May 5, 2025
030936d
new sdk interface
Vadman97 May 6, 2025
68fb6ca
separate session replay and observability bundles
Vadman97 May 6, 2025
dda9c70
fixup! separate session replay and observability bundles
Vadman97 May 6, 2025
b021ded
emit metrics correctly and share LD singletons
Vadman97 May 6, 2025
d874915
refactor tests
Vadman97 May 6, 2025
9b8a7cc
docs(changeset): refactors highlight.run SDK into plugins consumed by…
Vadman97 May 6, 2025
13d8454
refactor options
Vadman97 May 6, 2025
649d9be
add trace-based log impl
Vadman97 May 6, 2025
bd4234f
move log / error logic to observe using native otel
Vadman97 May 6, 2025
7c4f33b
buffering for ld client
Vadman97 May 6, 2025
081d252
remove more todos
Vadman97 May 6, 2025
1482f87
support afterTrack
Vadman97 May 6, 2025
5237b8f
fix highlight-node build
Vadman97 May 6, 2025
0e18d07
testing with other sdk
Vadman97 May 7, 2025
718827f
fix hook loop
Vadman97 May 7, 2025
e193d24
fix test
Vadman97 May 7, 2025
2204769
add new unit tests
Vadman97 May 7, 2025
b8eb22f
update changelog
Vadman97 May 7, 2025
e5886c3
improvve publish script
Vadman97 May 7, 2025
1e29cfc
update READMEs
Vadman97 May 7, 2025
55b8326
report filtered context attributes
Vadman97 May 7, 2025
4f70b45
fixup! report filtered context attributes
Vadman97 May 7, 2025
07691e8
feedback
Vadman97 May 8, 2025
d65f7ca
update integration types
Vadman97 May 9, 2025
6b34d12
extract log span name
Vadman97 May 9, 2025
67dc8c4
fixup! update integration types
Vadman97 May 9, 2025
7c891cf
fix type
Vadman97 May 9, 2025
dd86bab
enforce max size for call buffer
Vadman97 May 9, 2025
a213da8
types dep
Vadman97 May 9, 2025
90a442e
remove fake tests
Vadman97 May 9, 2025
93385aa
fix changesets adding skip ci
Vadman97 May 9, 2025
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
2 changes: 1 addition & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": true,
"commit": ["@changesets/cli/commit", { "skipCI": false }],
"fixed": [],
"linked": [],
"access": "public",
Expand Down
7 changes: 7 additions & 0 deletions .changeset/fruity-parents-float.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@launchdarkly/session-replay': minor
'@launchdarkly/observability': minor
'highlight.run': minor
---

refactors highlight.run SDK into plugins consumed by new @launchdarkly packages
5 changes: 4 additions & 1 deletion e2e/react-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
},
"dependencies": {
"@highlight-run/react": "workspace:*",
"highlight.run": "workspace:*",
"@launchdarkly/js-client-sdk": "^0.6.0",
"@launchdarkly/observability": "workspace:*",
"@launchdarkly/session-replay": "workspace:*",
"launchdarkly-js-client-sdk": "^3.7.0-beta.1",
"localforage": "^1.10.0",
"match-sorter": "^6.3.1",
"react": "^19.0.0",
Expand Down
106 changes: 99 additions & 7 deletions e2e/react-router/src/routes/root.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,109 @@
import { H } from 'highlight.run'
// import { initialize as init4 } from '@launchdarkly/js-client-sdk'
import { initialize as init3 } from 'launchdarkly-js-client-sdk'
import Observability, { LDObserve } from '@launchdarkly/observability'
import SessionReplay, { LDRecord } from '@launchdarkly/session-replay'
import { useEffect, useRef, useState } from 'react'
// import { LD } from '@launchdarkly/browser'

H.init('1', {
// Get your project ID from https://app.highlight.io/setup
networkRecording: {
enabled: true,
recordHeadersAndBody: true,
const client = init3(
'66d9d3c255856f0fa8fd62d0',
{ key: 'unknown' },
{
// Not including plugins at all would be equivalent to the current LaunchDarkly SDK.
plugins: [
new Observability('1', {
networkRecording: {
enabled: true,
recordHeadersAndBody: true,
},
serviceName: 'ryan-test',
backendUrl: 'https://pub.observability.ld-stg.launchdarkly.com',
otlpEndpoint:
'https://otel.observability.ld-stg.launchdarkly.com',
}),
new SessionReplay('1', {
serviceName: 'ryan-test',
backendUrl: 'https://pub.observability.ld-stg.launchdarkly.com',
}), // Could be omitted for customers who cannot use session replay.
],
},
})
)

export default function Root() {
const fillColor = 'lightblue'
const canvasRef = useRef<HTMLCanvasElement>(null)
const [flags, setFlags] = useState<string>()

useEffect(() => {
const canvas = canvasRef.current
if (!canvas) return
const ctx = canvas.getContext('2d')!
// Fill the entire canvas with the specified color
ctx.fillStyle = fillColor
ctx.fillRect(0, 0, canvas.width, canvas.height)
}, [fillColor])

return (
<div id="sidebar">
<h1>Hello, world</h1>
<p>{flags}</p>
<canvas width="100" height="100" ref={canvasRef}></canvas>
<button
onClick={() => {
LDObserve.recordLog('hello', 'INFO')
}}
>
LDObserve.recordLog
</button>
<button
onClick={() => {
LDObserve.recordError(new Error('test error'))
}}
>
LDObserve.consumeError
</button>
<button
onClick={() => {
if (canvasRef.current) {
LDRecord.snapshot(canvasRef.current)
}
}}
>
LDRecord.snapshot
</button>
<button
onClick={async () => {
await client.identify({
kind: 'user',
key: '[email protected]',
})
setFlags(JSON.stringify(client.allFlags()))
}}
>
client.identify
</button>
<button
onClick={async () => {
await client.identify({
kind: 'multi',
org: {
key: 'my-org-key',
someAttribute: 'my-attribute-value',
},
user: {
key: 'my-user-key',
firstName: 'Bob',
lastName: 'Bobberson',
_meta: {
privateAttributes: ['firstName'],
},
},
})
setFlags(JSON.stringify(client.allFlags()))
}}
>
client.identify multi
</button>
</div>
)
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"lint": "yarn run turbo lint --filter=!rrweb --filter=!rrvideo --filter=!@rrweb/rrweb-plugin-console-record --filter=!@rrweb/_monorepo --filter=!@rrweb/all --filter=!@rrweb/record --filter=!@rrweb/replay --filter=!@rrweb/types --filter=!@rrweb/packer --filter=!@rrweb/utils --filter=!@rrweb/web-extension --filter=!rrweb-snapshot --filter=!rrweb-player --filter=!rrdom --filter=!rrdom-nodejs --filter=!e2e-react-native",
"prepare": "husky",
"preinstall": "git submodule update --init --recursive || true",
"publish": "yarn workspaces foreach -R --no-private --from '@launchdarkly/*' npm publish --access public --tolerate-republish",
"publish": "yarn workspaces foreach -A --include '@launchdarkly/*' --exclude '@launchdarkly/observability-sdk' npm publish --access public --tolerate-republish",
"publish:highlight": "yarn workspaces foreach -R --no-private --from '@highlight-run/*' npm publish --access public --tolerate-republish && yarn workspace highlight.run npm publish --access public --tolerate-republish",
"test": "yarn turbo run test --filter=!rrweb --filter=!rrvideo --filter=!@rrweb/rrweb-plugin-console-record --filter=!@rrweb/_monorepo --filter=!@rrweb/all --filter=!@rrweb/record --filter=!@rrweb/replay --filter=!@rrweb/types --filter=!@rrweb/packer --filter=!@rrweb/utils --filter=!@rrweb/web-extension --filter=!rrweb-snapshot --filter=!rrweb-player --filter=!rrdom --filter=!rrdom-nodejs --filter=!nextjs"
},
Expand Down
49 changes: 34 additions & 15 deletions sdk/@launchdarkly/observability/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# LaunchDarkly JavaScript Observability SDK for Browsers

[![NPM][browser-sdk-npm-badge]][browser-sdk-npm-link]
[![Actions Status][browser-sdk-ci-badge]][browser-sdk-ci]
[![Documentation][browser-sdk-ghp-badge]][browser-sdk-ghp-link]
[![NPM][browser-sdk-dm-badge]][browser-sdk-npm-link]
[![NPM][browser-sdk-dt-badge]][browser-sdk-npm-link]
[![NPM][o11y-sdk-npm-badge]][o11y-sdk-npm-link]
[![Actions Status][o11y-sdk-ci-badge]][o11y-sdk-ci]
[![NPM][o11y-sdk-dm-badge]][o11y-sdk-npm-link]
[![NPM][o11y-sdk-dt-badge]][o11y-sdk-npm-link]

# ⛔️⛔️⛔️⛔️

Expand All @@ -13,17 +12,39 @@

# ☝️☝️☝️☝️☝️☝️

<!--
## Install

Install the package
```shell
# npm
npm i @launchdarkly/observability

# yarn
yarn add @launchdarkly/observability
```
-->

Update your web app entrypoint.
```tsx
import { initialize } from 'launchdarkly-js-client-sdk'
import Observability, { LDObserve } from '@launchdarkly/observability'

const client = init3(
'<CLIENT_SIDE_ID>',
{ key: '[email protected]' },
{
// Not including plugins at all would be equivalent to the current LaunchDarkly SDK.
plugins: [
new Observability('<OBSERVABILITY_PROJECT_ID>', {
networkRecording: {
enabled: true,
recordHeadersAndBody: true,
},
}),
],
},
)

```

## Getting started

Expand All @@ -49,11 +70,9 @@ LaunchDarkly uses the [SLSA framework](https://slsa.dev/spec/v1.0/about) (Supply
- [apidocs.launchdarkly.com](https://apidocs.launchdarkly.com/ 'LaunchDarkly API Documentation') for our API documentation
- [blog.launchdarkly.com](https://blog.launchdarkly.com/ 'LaunchDarkly Blog Documentation') for the latest product updates

[browser-sdk-ci-badge]: https://github.com/launchdarkly/observability-sdk/actions/workflows/browser.yml/badge.svg
[browser-sdk-ci]: https://github.com/launchdarkly/observability-sdk/actions/workflows/browser.yml
[browser-sdk-npm-badge]: https://img.shields.io/npm/v/@launchdarkly/observability.svg?style=flat-square
[browser-sdk-npm-link]: https://www.npmjs.com/package/@launchdarkly/observability
[browser-sdk-ghp-badge]: https://img.shields.io/static/v1?label=GitHub+Pages&message=API+reference&color=00add8
[browser-sdk-ghp-link]: https://launchdarkly.github.io/js-core/packages/sdk/browser/docs/
[browser-sdk-dm-badge]: https://img.shields.io/npm/dm/@launchdarkly/observability.svg?style=flat-square
[browser-sdk-dt-badge]: https://img.shields.io/npm/dt/@launchdarkly/observability.svg?style=flat-square
[o11y-sdk-ci-badge]: https://github.com/launchdarkly/observability-sdk/actions/workflows/turbo.yml/badge.svg
[o11y-sdk-ci]: https://github.com/launchdarkly/observability-sdk/actions/workflows/turbo.yml
[o11y-sdk-npm-badge]: https://img.shields.io/npm/v/@launchdarkly/observability.svg?style=flat-square
[o11y-sdk-npm-link]: https://www.npmjs.com/package/@launchdarkly/observability
[o11y-sdk-dm-badge]: https://img.shields.io/npm/dm/@launchdarkly/observability.svg?style=flat-square
[o11y-sdk-dt-badge]: https://img.shields.io/npm/dt/@launchdarkly/observability.svg?style=flat-square
25 changes: 13 additions & 12 deletions sdk/@launchdarkly/observability/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,21 @@
"url": "https://github.com/launchdarkly/observability-sdk.git"
}
},
"scripts": {
"typegen": "tsc",
"build": "vite build"
},
"devDependencies": {
"highlight.run": "workspace:*",
"rollup-plugin-visualizer": "^5.14.0",
"typescript": "^5.8.3",
"vite": "^6.3.4",
"vitest": "^3.1.2"
},
"type": "module",
"main": "./dist/index.js",
"module": "./dist/index.js",
"unpkg": "./dist/index.umd.js",
"jsdelivr": "./dist/index.umd.js",
"main": "./dist/observability.js",
"module": "./dist/observability.js",
"types": "./dist/index.d.ts",
"exports": {
"types": "./dist/index.d.ts",
"unpkg": "./dist/index.umd.js",
"jsdelivr": "./dist/index.umd.js",
"import": "./dist/index.js",
"require": "./dist/index.js",
"default": "./dist/index.js"
},
"files": [
"dist"
],
Expand Down
2 changes: 2 additions & 0 deletions sdk/@launchdarkly/observability/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { Observe as default } from 'highlight.run/observe'
export { LDObserve } from 'highlight.run/ld/observe'
31 changes: 31 additions & 0 deletions sdk/@launchdarkly/observability/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"compilerOptions": {
"outDir": "dist",
"allowJs": true,
"allowSyntheticDefaultImports": true,
"baseUrl": "src",
"declaration": true,
"declarationDir": "dist",
"downlevelIteration": true,
"emitDeclarationOnly": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"jsx": "react",
"lib": ["dom", "dom.iterable", "esnext"],
"module": "NodeNext",
"moduleResolution": "NodeNext",
"resolveJsonModule": true,
"skipLibCheck": true,
"target": "ESNext",
"rootDir": "src",
"types": ["@types/chrome", "@types/node", "vitest/globals"],
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"],
"exclude": ["**/src/**/*.test.tsx"],
"files": ["package.json"]
}
37 changes: 37 additions & 0 deletions sdk/@launchdarkly/observability/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// vite.config.ts
import { resolve as resolvePath } from 'path'
import { defineConfig } from 'vite'
import { visualizer } from 'rollup-plugin-visualizer'

export default defineConfig(({}) => {
return {
build: {
target: 'esnext',
lib: {
formats: ['es'],
entry: resolvePath(__dirname, 'src/index.ts'),
},
minify: true,
sourcemap: true,
emptyOutDir: false,
rollupOptions: {
treeshake: 'smallest',
output: {
exports: 'named',
},
cache: false,
},
},
plugins:
process.env.VISUALIZE_BUNDLE === 'true'
? [
visualizer({
gzipSize: true,
brotliSize: true,
sourcemap: true,
open: true,
}),
]
: [],
}
})
Loading
Loading