For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Sign inTry it free
DocsGuidesSDKsIntegrationsAPI docsTutorialsFlagship blog
DocsGuidesSDKsIntegrationsAPI docsTutorialsFlagship blog
  • SDKs
    • SDK concepts
    • SDK features
      • Aliasing users
      • Anonymous contexts and users
      • Automatic environment attributes
      • Big segments
      • Bootstrapping
      • Configuration
      • Context configuration
      • Customizing AgentControl
      • Data saving mode
      • Evaluating flags
      • Flag evaluation reasons
      • Flushing events
      • Getting all flags
      • Hooks
      • Identifying and changing contexts
      • Inspectors
      • Logging configuration
      • Migrations
      • Monitoring SDK status
      • Multiple environments
      • Offline mode
      • OpenTelemetry in server-side SDKs
      • Private attributes
      • User feedback
      • Reading flags from a file
      • Relay Proxy configuration
      • Secure mode
      • Sending custom events
      • Shutting down
      • Storing data
      • Subscribing to flag changes
      • Test data sources
      • Tracking AI metrics
      • Web proxy configuration
    • Client-side SDKs
    • Server-side SDKs
    • AI SDKs
    • Edge SDKs
    • OpenFeature providers
    • Observability SDKs
    • Relay Proxy
Sign inTry it free
LogoLogo
On this page
  • Overview
  • Inspector types
  • JavaScript
  • React Native
  • React Web
SDKsSDK features

Inspectors

Was this page helpful?
Previous

Logging configuration

Next
Built with

Overview

This topic explains how to configure inspectors for client-side JavaScript LaunchDarkly SDKs.

Inspector types

There are different types of inspectors you can provide when configuring the JavaScript SDK. They are intended for monitoring, analytics, or debugging purposes. The application should not use these interfaces to access flags for the purpose of controlling application flow.

These are the inspector types:

  • Flag Used
  • Flag Details Changed
  • Flag Detail Changed

Details about each SDK’s configuration are available in the SDK-specific sections below:

  • JavaScript
  • React Native: The React Native SDK relies on the JavaScript SDK for user-related functionality.
  • React Web: The React Web SDK relies on the JavaScript SDK for user-related functionality.

JavaScript

Expand JavaScript code sample

The inspector type defines when in the SDK lifecycle it calls the method callback, and with what arguments.

To configure a Flag Used inspector, set type to flag-used and pass in a method that matches the expected signature:

JavaScript
1const client = LDClient.initialize(
2 'example-client-side-id',
3 context,
4 options: {
5 inspectors: [
6 {
7 type: 'flag-used',
8 name: 'example-flag-used',
9 method: (flagKey, flagDetail) => {
10 console.log(flagKey)
11 console.log(flagDetail)
12 }
13 }
14 ]
15 }
16);
17
18try {
19 await client.waitForInitialization(5);
20 proceedWithSuccessfullyInitializedClient();
21} catch(err) {
22 // Client failed to initialized or timed out
23 // variation() calls return fallback values until initialization completes
24}

React Native

Inspector-related functionality provided by the JavaScript SDK is available but deprecated in version 10 of the React Native SDK. We recommend that you use hooks instead.

React Web

All inspector-related functionality provided by the JavaScript SDK is also available in the React Web SDK.