• Home
  • Integrations
  • SDKs
  • Guides
  • API docs
    No results for ""
    EXPAND ALL

    EDIT ON GITHUB

    Inspectors

    Read time: 1 minute
    Last edited: Feb 09, 2023

    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:

    const client = LDClient.initialize(
    'client-side-id-123abc',
    context,
    options = {
    inspectors: [
    {
    type: 'flag-used',
    name: 'example-flag-used',
    method: (flagKey, flagDetail) => {
    console.log(flagKey)
    console.log(flagDetail)
    }
    }
    ]
    }
    };

    React Native

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

    React Web

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