Skip to content

Commit 648ad26

Browse files
authored
feat: disable client-side LD metric forwarding (#286)
## Summary After launchdarkly/observability#320 is shipped, we can switch to server-emitted metrics for the Web SDK. ## How did you test this change? CI ## Are there any deployment considerations? need to make sure server metrics are flowing <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Stops forwarding metrics and errors from the LaunchDarkly client; metrics now handled on ingest while init and track events remain. > > - **Integrations – `sdk/highlight-run/src/integrations/launchdarkly/index.ts`** > - Disable client-side forwarding: > - `recordGauge` and `error` now no-ops (metrics handled on ingest). > - Remove metric/error events and filtering logic (`LD_METRIC_EVENT`, `LD_ERROR_EVENT`, `MetricCategory`). > - Retain session init and custom tracking: > - Still emits `LD_INITIALIZE_EVENT` and `LD_TRACK_EVENT` via `track()`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 2febce0. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent c4185a6 commit 648ad26

File tree

1 file changed

+3
-38
lines changed
  • sdk/highlight-run/src/integrations/launchdarkly

1 file changed

+3
-38
lines changed

sdk/highlight-run/src/integrations/launchdarkly/index.ts

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type HighlightPublicInterface, MetricCategory } from '../../client'
1+
import { type HighlightPublicInterface } from '../../client'
22
import type { ErrorMessage, Source } from '../../client/types/shared-types'
33
import type { IntegrationClient } from '../index'
44
import type { LDClientMin as LDClient } from './types/LDClient'
@@ -46,9 +46,7 @@ export const FEATURE_FLAG_APP_ID_ATTR = `${LD_SCOPE}.application.id`
4646
export const FEATURE_FLAG_APP_VERSION_ATTR = `${LD_SCOPE}.application.version`
4747

4848
export const LD_INITIALIZE_EVENT = '$ld:telemetry:session:init'
49-
export const LD_ERROR_EVENT = '$ld:telemetry:error'
5049
export const LD_TRACK_EVENT = '$ld:telemetry:track'
51-
export const LD_METRIC_EVENT = '$ld:telemetry:metric'
5250

5351
export const LD_METRIC_NAME_DOCUMENT_LOAD = 'document_load'
5452

@@ -211,29 +209,7 @@ export class LaunchDarklyIntegrationSDK implements IntegrationClient {
211209
}
212210

213211
recordGauge(sessionSecureID: string, metric: RecordMetric) {
214-
// only record web vitals
215-
if (
216-
metric.category !== MetricCategory.WebVital &&
217-
metric.name !== LD_METRIC_NAME_DOCUMENT_LOAD
218-
) {
219-
return
220-
}
221-
// ignore Jank metric, sent on interaction
222-
if (metric.name === 'Jank') {
223-
return
224-
}
225-
this.client.track(
226-
`${LD_METRIC_EVENT}:${metric.name.toLowerCase()}`,
227-
{
228-
...metric.tags
229-
?.map((t) => ({ [t.name]: t.value }))
230-
.reduce((a, b) => ({ ...a, ...b }), {}),
231-
category: metric.category,
232-
group: metric.group,
233-
sessionID: sessionSecureID,
234-
},
235-
metric.value,
236-
)
212+
// noop - metric forwarding is handled upon data ingest
237213
}
238214

239215
identify(
@@ -246,18 +222,7 @@ export class LaunchDarklyIntegrationSDK implements IntegrationClient {
246222
}
247223

248224
error(sessionSecureID: string, error: ErrorMessage) {
249-
let payload: { [key: string]: string } = {}
250-
try {
251-
if (error.payload) {
252-
payload = JSON.parse(error.payload)
253-
}
254-
} catch (e) {}
255-
const { payload: _, ...errorWithoutPayload } = error
256-
this.client.track(LD_ERROR_EVENT, {
257-
...errorWithoutPayload,
258-
sessionID: sessionSecureID,
259-
...payload,
260-
})
225+
// noop - metric forwarding is handled upon data ingest
261226
}
262227

263228
track(sessionSecureID: string, metadata: object) {

0 commit comments

Comments
 (0)