fix(js-client-sdk): better undefined handling#1303
Conversation
|
@cursor review |
|
@launchdarkly/js-sdk-common size report |
|
@launchdarkly/browser size report |
|
@launchdarkly/js-client-sdk-common size report |
|
@launchdarkly/js-client-sdk size report |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 23fc8f9. Configure here.
23fc8f9 to
3cee041
Compare
🤖 I have created a release *beep* *boop* --- <details><summary>browser: 0.1.16</summary> ## [0.1.16](browser-v0.1.15...browser-v0.1.16) (2026-04-21) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/js-client-sdk bumped from 4.6.0 to 4.6.1 </details> <details><summary>browser-telemetry: 1.0.32</summary> ## [1.0.32](browser-telemetry-v1.0.31...browser-telemetry-v1.0.32) (2026-04-21) ### Bug Fixes * correct typeof comparisons in browser SDK ([#1301](#1301)) ([f4bd636](f4bd636)) * **js-client-sdk:** better `undefined` handling ([#1303](#1303)) ([4818678](4818678)) ### Dependencies * The following workspace dependencies were updated * devDependencies * @launchdarkly/js-client-sdk bumped from 4.6.0 to 4.6.1 </details> <details><summary>js-client-sdk: 4.6.1</summary> ## [4.6.1](js-client-sdk-v4.6.0...js-client-sdk-v4.6.1) (2026-04-21) ### Bug Fixes * correct typeof comparisons in browser SDK ([#1301](#1301)) ([f4bd636](f4bd636)) * **js-client-sdk:** better `undefined` handling ([#1303](#1303)) ([4818678](4818678)) </details> <details><summary>react-sdk: 0.2.2</summary> ## [0.2.2](react-sdk-v0.2.1...react-sdk-v0.2.2) (2026-04-21) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/js-client-sdk bumped from ^4.6.0 to ^4.6.1 </details> <details><summary>server-sdk-ai: 0.17.0</summary> ## [0.17.0](server-sdk-ai-v0.16.8...server-sdk-ai-v0.17.0) (2026-04-21) ### ⚠ BREAKING CHANGES * Flatten JudgeResponse and EvalScore into new LDJudgeResult ([#1284](#1284)) * Add per-execution runId, at-most-once tracking, and cross-process tracker resumption ([#1270](#1270)) ### Features * Add per-execution runId, at-most-once tracking, and cross-process tracker resumption ([#1270](#1270)) ([fc25ab7](fc25ab7)) * Flatten JudgeResponse and EvalScore into new LDJudgeResult ([#1284](#1284)) ([aba1221](aba1221)) * Implement agent graph definitions ([#1282](#1282)) ([e7d08e5](e7d08e5)) * simplify evaluation schema to flat score/reasoning shape ([#1286](#1286)) ([c132e9f](c132e9f)) ### Bug Fixes * Add support for graph metric tracking ([#1269](#1269)) ([034a89d](034a89d)) </details> <details><summary>server-sdk-ai-langchain: 0.5.5</summary> ## [0.5.5](server-sdk-ai-langchain-v0.5.4...server-sdk-ai-langchain-v0.5.5) (2026-04-21) ### Dependencies * The following workspace dependencies were updated * devDependencies * @launchdarkly/server-sdk-ai bumped from ^0.16.8 to ^0.17.0 * peerDependencies * @launchdarkly/server-sdk-ai bumped from ^0.15.0 || ^0.16.0 to ^0.17.0 </details> <details><summary>server-sdk-ai-openai: 0.5.5</summary> ## [0.5.5](server-sdk-ai-openai-v0.5.4...server-sdk-ai-openai-v0.5.5) (2026-04-21) ### Dependencies * The following workspace dependencies were updated * devDependencies * @launchdarkly/server-sdk-ai bumped from ^0.16.8 to ^0.17.0 * peerDependencies * @launchdarkly/server-sdk-ai bumped from ^0.15.0 || ^0.16.0 to ^0.17.0 </details> <details><summary>server-sdk-ai-vercel: 0.5.5</summary> ## [0.5.5](server-sdk-ai-vercel-v0.5.4...server-sdk-ai-vercel-v0.5.5) (2026-04-21) ### Dependencies * The following workspace dependencies were updated * devDependencies * @launchdarkly/server-sdk-ai bumped from ^0.16.8 to ^0.17.0 * peerDependencies * @launchdarkly/server-sdk-ai bumped from ^0.15.0 || ^0.16.0 to ^0.17.0 </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Primarily a version/changelog bump, but it publishes `@launchdarkly/server-sdk-ai` `0.17.0` with documented breaking API changes that can impact downstream consumers and provider peer dependency resolution. > > **Overview** > Bumps release versions across the monorepo via `.release-please-manifest.json`, updating `@launchdarkly/server-sdk-ai` to `0.17.0`, `@launchdarkly/js-client-sdk` to `4.6.1`, and related packages (`@launchdarkly/browser`, `@launchdarkly/react-sdk`, `@launchdarkly/browser-telemetry`, and AI provider packages) accordingly. > > Updates package metadata, changelogs, examples, and embedded SDK/wrapper version strings (e.g., `BrowserInfo` and `LDReactClient`) to reflect the new releases, including `server-sdk-ai`’s `0.17.0` breaking-change notes and provider peer dependency bumps to `^0.17.0`. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit e7f8c09. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: jsonbailey <jbailey@launchdarkly.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This PR addresses
SDK-2235
SDK-2236
changes:
isDocumenttoisWindowbecause that is more semanitcally correct (we are usingwindowin the conditional block)crypto->typeof crypto !== 'undefined') so that the code doesn't throw due tocryptonot existing (this should never happen unless running on some bad obscure browser)Note
Low Risk
Low risk: small guard-condition fixes around
windowandcryptopresence to avoid runtime errors in non-browser/limited environments. Behavior changes only when these globals are missing, where the previous code could throw or incorrectly skip listener registration.Overview
Fixes environment detection in the browser SDK by gating
addWindowEventListeneronisWindow()(matching the actualwindowusage) and updating the no-op comment accordingly.Hardens UUID v4 generation in both the SDK and browser-telemetry packages by replacing the unsafe
cryptotruthiness check withtypeof crypto !== 'undefined'before callingcrypto.getRandomValues, preventing ReferenceErrors whencryptois absent.Reviewed by Cursor Bugbot for commit 3cee041. Bugbot is set up for automated code reviews on this repo. Configure here.