-
Notifications
You must be signed in to change notification settings - Fork 3
refactor highlight.run SDK into plugins #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
d79cac1
WIP highligth sdk
Vadman97 ce3d6ae
WIP launchdarkly peerDependency
Vadman97 77010dd
plugin interface
Vadman97 2f33d0b
rename
Vadman97 a78430c
progress?
Vadman97 34a014b
fixup! progress?
Vadman97 cbb8abe
prepare record plugin
Vadman97 f5b0001
plugins setup
Vadman97 465827a
observability record plugins
Vadman97 af64323
sdk theoretically working
Vadman97 27ccba8
setup e2e test of launchdarkly packages
Vadman97 88895c7
fixup! setup e2e test of launchdarkly packages
Vadman97 33ed9b9
build tweaks
Vadman97 b219e0d
lockfile
Vadman97 edd8bca
wip
Vadman97 7d08772
fix testing
Vadman97 5f08da4
buffering logic working
Vadman97 030936d
new sdk interface
Vadman97 68fb6ca
separate session replay and observability bundles
Vadman97 dda9c70
fixup! separate session replay and observability bundles
Vadman97 b021ded
emit metrics correctly and share LD singletons
Vadman97 d874915
refactor tests
Vadman97 9b8a7cc
docs(changeset): refactors highlight.run SDK into plugins consumed by…
Vadman97 13d8454
refactor options
Vadman97 649d9be
add trace-based log impl
Vadman97 bd4234f
move log / error logic to observe using native otel
Vadman97 7c4f33b
buffering for ld client
Vadman97 081d252
remove more todos
Vadman97 1482f87
support afterTrack
Vadman97 5237b8f
fix highlight-node build
Vadman97 0e18d07
testing with other sdk
Vadman97 718827f
fix hook loop
Vadman97 e193d24
fix test
Vadman97 2204769
add new unit tests
Vadman97 b8eb22f
update changelog
Vadman97 e5886c3
improvve publish script
Vadman97 1e29cfc
update READMEs
Vadman97 55b8326
report filtered context attributes
Vadman97 4f70b45
fixup! report filtered context attributes
Vadman97 07691e8
feedback
Vadman97 d65f7ca
update integration types
Vadman97 6b34d12
extract log span name
Vadman97 67dc8c4
fixup! update integration types
Vadman97 7c891cf
fix type
Vadman97 dd86bab
enforce max size for call buffer
Vadman97 a213da8
types dep
Vadman97 90a442e
remove fake tests
Vadman97 93385aa
fix changesets adding skip ci
Vadman97 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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", | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> | ||
| ) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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] | ||
|
|
||
| # ⛔️⛔️⛔️⛔️ | ||
|
|
||
|
|
@@ -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 | ||
|
|
||
|
|
@@ -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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| // vite.config.ts | ||
Vadman97 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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, | ||
| }), | ||
| ] | ||
| : [], | ||
| } | ||
| }) | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.