Skip to content

Conversation

@Vadman97
Copy link
Contributor

@Vadman97 Vadman97 commented Apr 25, 2025

Summary

Refactors the highlight.run SDK into plugins that can be connected to the 3.x and 4.x LaunchDarkly SDKs.

import { initialize } from '@launchdarkly/js-client-sdk'
import Observability, { LDObserve } from '@launchdarkly/observability'
import SessionReplay, { LDRecord } from '@launchdarkly/session-replay'

const client = initialize('client-side-id-123abc', {
	plugins: [
		new Observability('highlight-project-id', {
			networkRecording: {
				enabled: true,
				recordHeadersAndBody: true,
			},
			otlpEndpoint: 'https://otel.observability.ld-stg.launchdarkly.com',
		}),
		new SessionReplay('highlight-project-id', {
			networkRecording: {
				enabled: true,
				recordHeadersAndBody: true,
			},
			backendUrl: 'https://pub.observability.ld-stg.launchdarkly.com',
		}),
	],
})

How did you test this change?

local testing with react-router app, new unit tests

validating bundling working as expected (@launchdarkly/observability does not bundle rrweb, @launchdarkly/session-replay bundles observability features since it uses them and rrweb)
Screenshot 2025-05-05 at 22 17 37
Screenshot 2025-05-05 at 22 17 47

Are there any deployment considerations?

0.x versions of @launchdarkly packages released.
changeset for highlight.run

Does this work require review from our design team?

no

@Vadman97 Vadman97 force-pushed the vadim/ob-75 branch 2 times, most recently from 8299474 to d815094 Compare May 1, 2025 03:14
@kinyoklion
Copy link
Member

Things should work with launchdarkly-js-client-sdk 3.x as well, correct? Or did you find something lacking in the interfaces?

@Vadman97 Vadman97 marked this pull request as ready for review May 7, 2025 00:25
@Vadman97 Vadman97 requested a review from kinyoklion May 7, 2025 00:25
@Vadman97
Copy link
Contributor Author

Vadman97 commented May 7, 2025

Things should work with launchdarkly-js-client-sdk 3.x as well, correct? Or did you find something lacking in the interfaces?

tested with 3.x: helped find a bug because the 0.6.0 @launchdarkly/js-client-sdk sdk version didn't have the afterTrack implementation

Copy link
Contributor

@ccschmitz-launchdarkly ccschmitz-launchdarkly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool! Left a couple thoughts, but will leave the real review to @kinyoklion.

I mainly looked over the observe plugin. I'm sure we don't want to diverge too much from the existing implementation, but was wondering if we wanted to take the opportunity to clean up some of the rough edges, mainly deprecated or poorly chosen config options.

@Vadman97 Vadman97 requested review from a team and ccschmitz-launchdarkly May 8, 2025 23:24
@Vadman97 Vadman97 merged commit 26cc5f1 into main May 9, 2025
16 checks passed
@Vadman97 Vadman97 deleted the vadim/ob-75 branch May 9, 2025 20:21
Comment on lines +73 to +74
[FEATURE_FLAG_CLIENT_SIDE_ID_ATTR]: metadata.clientSideId,
[FEATURE_FLAG_ENV_ATTR]: metadata.application?.id,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Vadman97 Please forgive the comment without context - is application.id the right thing to pass here? I'm not sure if this is just a terminology thing (in LD terms "application" is a separate concept from "environment", but I'm not sure about the Highlight terminology), or if we've arranged for the plugins to pass the LD environment id in the application id field, etc.

Also, fun fact, the LD client-side id is actually identical to the LD environment id, so we might not need to pass both. (The client-side id is also used as a credential - albeit a weird one that's not treated as secret - so it might be better not to include it per se in the telemetry unless we have a good use case for it?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet