Constructors

  • A Flagsmith client.

    Provides an interface for interacting with the Flagsmith http API. Basic Usage::

    import flagsmith from Flagsmith const flagsmith = new Flagsmith({environmentKey: ''}); const environmentFlags = flagsmith.getEnvironmentFlags(); const featureEnabled = environmentFlags.isFeatureEnabled('foo'); const identityFlags = flagsmith.getIdentityFlags('identifier', {'foo': 'bar'}); const featureEnabledForIdentity = identityFlags.isFeatureEnabled("foo")

    Parameters

    Returns Flagsmith

Methods

  • Get all the default for flags for the current environment.

    Returns Promise<Flags>

    Flags object holding all the flags for the current environment.

  • Get all the flags for the current environment for a given identity. Will also upsert all traits to the Flagsmith API for future evaluations. Providing a trait with a value of None will remove the trait from the identity if it exists.

    Parameters

    Returns Promise<Flags>

    Flags object holding all the flags for the given identity.

  • Get the segments for the current environment for a given identity. Will also upsert all traits to the Flagsmith API for future evaluations. Providing a trait with a value of None will remove the trait from the identity if it exists.

    Parameters

    • identifier: string

      a unique identifier for the identity in the current environment, e.g. email address, username, uuid

    • Optional traits: {
          [key: string]: any;
      }
      • [key: string]: any

    Returns Promise<SegmentModel[]>

    Segments that the given identity belongs to.

  • Updates the environment state for local flag evaluation. Sets a local promise to prevent race conditions in getIdentityFlags / getIdentitySegments. You only need to call this if you wish to bypass environmentRefreshIntervalSeconds.

    Returns Promise<void>

Properties

agent?: Dispatcher
analyticsProcessor?: any
analyticsUrl?: string
apiUrl?: string
cache?: any
customFetch: any
customHeaders?: {
    [key: string]: any;
}

Type declaration

  • [key: string]: any
defaultFlagHandler?: ((featureName) => DefaultFlag)

Type declaration

enableAnalytics: boolean
enableLocalEvaluation?: boolean
environment: EnvironmentModel
environmentDataPollingManager?: EnvironmentDataPollingManager
environmentFlagsUrl?: string
environmentKey?: string
environmentPromise: any

This promise ensures that the environment is retrieved before attempting to locally evaluate.

environmentRefreshIntervalSeconds: number
environmentUrl?: string
getEnvironmentFlagsFromApi: any
getEnvironmentFlagsFromDocument: any
getEnvironmentFromApi: any
getIdentityFlagsFromApi: any
getIdentityFlagsFromDocument: any
getIdentityModel: any
getJSONResponse: any
identitiesUrl?: string
identitiesWithOverridesByIdentifier?: Map<string, IdentityModel>
logger: any
offlineHandler?: BaseOfflineHandler
offlineMode: boolean
onEnvironmentChange?: any
requestTimeoutMs?: number
retries?: number