Skip to main content

Documentation Index

Fetch the complete documentation index at: https://launchdarkly-preview.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

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: 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.

Java

Script
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:
      const client = LDClient.initialize(
        'example-client-side-id',
        context,
        options: {
          inspectors: [
            {
              type: 'flag-used',
              name: 'example-flag-used',
              method: (flagKey, flagDetail) => {
                console.log(flagKey)
                console.log(flagDetail)
              }
            }
          ]
        }
      );

      try {
        await client.waitForInitialization(5);
        proceedWithSuccessfullyInitializedClient();
      } catch(err) {
        // Client failed to initialized or timed out
        // variation() calls return fallback values until initialization completes
      }

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.