-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Server-side SDK for integrating with LaunchDarkly -- -- Please see the README on GitHub at -- https://github.com/launchdarkly/haskell-server-sdk#readme @package launchdarkly-server-sdk @version 3.0.2 module LaunchDarkly.AesonCompat type KeyMap = KeyMap emptyObject :: KeyMap v singleton :: Text -> v -> KeyMap v fromList :: [(Text, v)] -> KeyMap v toList :: KeyMap v -> [(Text, v)] deleteKey :: Text -> KeyMap v -> KeyMap v lookupKey :: Text -> KeyMap v -> Maybe v objectKeys :: KeyMap v -> [Text] objectValues :: KeyMap v -> [v] keyToText :: Key -> Text insertKey :: Text -> v -> KeyMap v -> KeyMap v filterKeys :: (Key -> Bool) -> KeyMap a -> KeyMap a filterObject :: (v -> Bool) -> KeyMap v -> KeyMap v adjustKey :: (v -> v) -> Key -> KeyMap v -> KeyMap v mapValues :: (v1 -> v2) -> KeyMap v1 -> KeyMap v2 mapWithKey :: (Text -> v1 -> v2) -> KeyMap v1 -> KeyMap v2 mapMaybeValues :: (v1 -> Maybe v2) -> KeyMap v1 -> KeyMap v2 keyMapUnion :: KeyMap v -> KeyMap v -> KeyMap v -- | This module contains details for external store implementations. module LaunchDarkly.Server.Store -- | The result type for every StoreInterface function. Instead of -- throwing an exception, any store related error should return -- Left. Exceptions unrelated to the store should not be caught. type StoreResult a = IO (Either Text a) -- | Represents the key for a given feature. type FeatureKey = Text -- | Represents a namespace such as flags or segments type FeatureNamespace = Text -- | The interface implemented by external stores for use by the SDK. data StoreInterface StoreInterface :: !FeatureNamespace -> StoreResult (KeyMap RawFeature) -> !FeatureNamespace -> FeatureKey -> StoreResult RawFeature -> !FeatureNamespace -> FeatureKey -> RawFeature -> StoreResult Bool -> !StoreResult Bool -> !KeyMap (KeyMap RawFeature) -> StoreResult () -> StoreInterface -- | A map of all features in a given namespace including deleted. [$sel:storeInterfaceAllFeatures:StoreInterface] :: StoreInterface -> !FeatureNamespace -> StoreResult (KeyMap RawFeature) -- | Return the value of a key in a namespace. [$sel:storeInterfaceGetFeature:StoreInterface] :: StoreInterface -> !FeatureNamespace -> FeatureKey -> StoreResult RawFeature -- | Upsert a given feature. Versions should be compared before upsert. The -- result should indicate if the feature was replaced or not. [$sel:storeInterfaceUpsertFeature:StoreInterface] :: StoreInterface -> !FeatureNamespace -> FeatureKey -> RawFeature -> StoreResult Bool -- | Checks if the external store has been initialized, which may have been -- done by another instance of the SDK. [$sel:storeInterfaceIsInitialized:StoreInterface] :: StoreInterface -> !StoreResult Bool -- | A map of namespaces, and items in namespaces. The entire store state -- should be replaced with these values. [$sel:storeInterfaceInitialize:StoreInterface] :: StoreInterface -> !KeyMap (KeyMap RawFeature) -> StoreResult () -- | An abstract representation of a store object. data RawFeature RawFeature :: !Maybe ByteString -> !Natural -> RawFeature -- | A serialized item. If the item is deleted or does not exist this -- should be Nothing. [$sel:rawFeatureBuffer:RawFeature] :: RawFeature -> !Maybe ByteString -- | The version of a given item. If the item does not exist this should be -- zero. [$sel:rawFeatureVersion:RawFeature] :: RawFeature -> !Natural -- | A mechanism for providing dynamically updatable feature flag state in -- a simplified form to an SDK client in test scenarios. -- -- Unlike LaunchDarkly.Server.Integrations.FileData, this -- mechanism does not use any external resources. It provides only the -- data that the application has put into it using the update -- function. -- --
-- td <- TestData.newTestData -- update td =<< (flag td "flag-key-1" -- <&> booleanFlag -- <&> variationForAllUsers True) -- -- let config = makeConfig "sdkKey" -- & configSetDataSourceFactory (dataSourceFactory td) -- client <- makeClient config -- -- -- flags can be updated at any time: -- update td =<< -- (flag td "flag-key-2" -- <&> variationForUser "some-user-key" True -- <&> fallthroughVariation False) ---- -- The above example uses a simple boolean flag, but more complex -- configurations are possible using the methods of the -- FlagBuilder that is returned by flag. FlagBuilder -- supports many of the ways a flag can be configured on the LaunchDarkly -- dashboard, but does not currently support: -- --
-- testData -- & flag "flag" -- & ifMatch "name" [toJSON "Patsy", toJSON "Edina"] -- & thenReturn True --ifMatch :: UserAttribute -> [Value] -> FlagBuilder -> FlagRuleBuilder -- | Starts defining a flag rule, using the "is not one of" operator. -- -- For example, this creates a rule that returns True if the -- name is neither "Saffron" nor "Bubble" -- --
-- testData -- & flag "flag" -- & ifNotMatch "name" [toJSON "Saffron", toJSON "Bubble"] -- & thenReturn True --ifNotMatch :: UserAttribute -> [Value] -> FlagBuilder -> FlagRuleBuilder type VariationIndex = Integer -- | A builder for feature flag rules to be used with FlagBuilder. -- -- In the LaunchDarkly model, a flag can have any number of rules, and a -- rule can have any number of clauses. A clause is an individual test -- such as "name is 'X'". A rule matches a user if all of the rule's -- clauses match the user. -- -- To start defining a rule, use one of the matching functions such as -- ifMatch or ifNotMatch. This defines the first clause for -- the rule. Optionally, you may add more clauses with the rule builder -- functions such as andMatch and andNotMatch. Finally, -- call thenReturn to finish defining the rule. data FlagRuleBuilder -- | Adds another clause, using the "is one of" operator. -- -- For example, this creates a rule that returns True if the -- name is "Patsy" and the country is "gb": -- --
-- testData -- & flag "flag" -- & ifMatch "name" [toJSON "Patsy"] -- & andMatch "country" [toJSON "gb"] -- & thenReturn True --andMatch :: UserAttribute -> [Value] -> FlagRuleBuilder -> FlagRuleBuilder -- | Adds another clause, using the "is not one of" operator. -- -- For example, this creates a rule that returns True if the -- name is "Patsy" and the country is not "gb": -- --
-- testData -- & flag "flag" -- & ifMatch "name" [toJSON "Patsy"] -- & andNotMatch "country" [toJSON "gb"] -- & thenReturn True --andNotMatch :: UserAttribute -> [Value] -> FlagRuleBuilder -> FlagRuleBuilder -- | Finishes defining the rule, specifying the result as either a boolean -- or a variation index. -- -- If the flag was previously configured with other variations and the -- variation specified is a boolean, this also changes it to a boolean -- flag. thenReturn :: Variation val => val -> FlagRuleBuilder -> FlagBuilder -- | Integration between the LaunchDarkly SDK and file data. -- -- The file data source allows you to use local files as a source of -- feature flag state. This would typically be used in a test -- environment, to operate using a predetermined feature flag state -- without an actual LaunchDarkly connection. See -- dataSourceFactory for details. module LaunchDarkly.Server.Integrations.FileData -- | Creates a DataSourceFactory which uses the configured the -- file data sources. This allows you to use local files as a source of -- feature flag state, instead of using an actual LaunchDarkly -- connection. -- -- To use the file dataSource you can add it to the Config using -- configSetDataSourceFactory -- --
-- let config = configSetDataSourceFactory (FileData.dataSourceFactory [".testDataflags.json"]) $ -- makeConfig "sdk-key" -- client <- makeClient config ---- -- This will cause the client not to connect to LaunchDarkly to -- get feature flags. The client may still make network connections to -- send analytics events, unless you have disabled this with -- configSetSendEvents to False. IMPORTANT: Do not -- set configSetOffline to True; doing so would not just -- put the SDK "offline" with regard to LaunchDarkly, but will completely -- turn off all flag data sources to the SDK including the file data -- source. -- -- Flag data files can be either JSON or YAML. They contain an object -- with three possible properties: -- --
-- curl -H "Authorization: {your sdk key}" https://app.launchdarkly.com/sdk/latest-all
--
--
-- The output will look something like this (but with many more
-- properties):
--
--
-- {
-- "flags": {
-- "flag-key-1": {
-- "key": "flag-key-1",
-- "on": true,
-- "variations": [ "a", "b" ]
-- },
-- "flag-key-2": {
-- "key": "flag-key-2",
-- "on": true,
-- "variations": [ "c", "d" ]
-- }
-- },
-- "segments": {
-- "segment-key-1": {
-- "key": "segment-key-1",
-- "includes": [ "user-key-1" ]
-- }
-- }
-- }
--
--
-- Data in this format allows the SDK to exactly duplicate all the kinds
-- of flag behavior supported by LaunchDarkly. However, in many cases you
-- will not need this complexity, but will just want to set specific flag
-- keys to specific values. For that, you can use a much simpler format:
--
--
-- {
-- "flagValues": {
-- "my-string-flag-key": "value-1",
-- "my-boolean-flag-key": true,
-- "my-integer-flag-key": 3
-- }
-- }
--
--
-- Or, in YAML:
--
-- -- flagValues: -- my-string-flag-key: "value-1" -- my-boolean-flag-key: true ---- -- It is also possible to specify both flags and -- flagValues, if you want some flags to have simple values and -- others to have complex behavior. However, it is an error to use the -- same flag key or segment key more than once, either in a single file -- or across multiple files. -- -- If the data source encounters any error in any file(malformed content, -- a missing file) it will not load flags from that file. If the data -- source encounters a duplicate key it will ignore that duplicate entry. dataSourceFactory :: [FilePath] -> DataSourceFactory instance GHC.Classes.Eq LaunchDarkly.Server.Integrations.FileData.FileFlag instance GHC.Show.Show LaunchDarkly.Server.Integrations.FileData.FileFlag instance Data.Aeson.Types.FromJSON.FromJSON LaunchDarkly.Server.Integrations.FileData.FileFlag instance GHC.Generics.Generic LaunchDarkly.Server.Integrations.FileData.FileFlag instance GHC.Classes.Eq LaunchDarkly.Server.Integrations.FileData.FileSegment instance GHC.Show.Show LaunchDarkly.Server.Integrations.FileData.FileSegment instance Data.Aeson.Types.FromJSON.FromJSON LaunchDarkly.Server.Integrations.FileData.FileSegment instance GHC.Generics.Generic LaunchDarkly.Server.Integrations.FileData.FileSegment instance Data.Aeson.Types.FromJSON.FromJSON LaunchDarkly.Server.Integrations.FileData.FileBody instance GHC.Show.Show LaunchDarkly.Server.Integrations.FileData.FileBody instance GHC.Generics.Generic LaunchDarkly.Server.Integrations.FileData.FileBody instance GHC.Base.Semigroup LaunchDarkly.Server.Integrations.FileData.FileBody instance GHC.Base.Monoid LaunchDarkly.Server.Integrations.FileData.FileBody -- | This module is for configuration of the SDK. module LaunchDarkly.Server.Config -- | Config allows advanced configuration of the LaunchDarkly client. data Config -- | Create a default configuration from a given SDK key. makeConfig :: Text -> Config -- | Set the SDK key used to authenticate with LaunchDarkly. configSetKey :: Text -> Config -> Config -- | The base URI of the main LaunchDarkly service. This should not -- normally be changed except for testing. configSetBaseURI :: Text -> Config -> Config -- | The base URI of the LaunchDarkly streaming service. This should not -- normally be changed except for testing. configSetStreamURI :: Text -> Config -> Config -- | The base URI of the LaunchDarkly service that accepts analytics -- events. This should not normally be changed except for testing. configSetEventsURI :: Text -> Config -> Config -- | Sets whether streaming mode should be enabled. By default, streaming -- is enabled. It should only be disabled on the advice of LaunchDarkly -- support. configSetStreaming :: Bool -> Config -> Config -- | Sets whether or not all user attributes (other than the key) should be -- hidden from LaunchDarkly. If this is true, all user attribute values -- will be private, not just the attributes specified in -- PrivateAttributeNames. configSetAllAttributesPrivate :: Bool -> Config -> Config -- | Marks a set of user attribute names private. Any users sent to -- LaunchDarkly with this configuration active will have attributes with -- these names removed. configSetPrivateAttributeNames :: Set Text -> Config -> Config -- | The time between flushes of the event buffer. Decreasing the flush -- interval means that the event buffer is less likely to reach capacity. configSetFlushIntervalSeconds :: Natural -> Config -> Config -- | The polling interval (when streaming is disabled). configSetPollIntervalSeconds :: Natural -> Config -> Config -- | The number of user keys that the event processor can remember at any -- one time, so that duplicate user details will not be sent in analytics -- events. configSetUserKeyLRUCapacity :: Natural -> Config -> Config -- | Set to true if you need to see the full user details in every -- analytics event. configSetInlineUsersInEvents :: Bool -> Config -> Config -- | The capacity of the events buffer. The client buffers up to this many -- events in memory before flushing. If the capacity is exceeded before -- the buffer is flushed, events will be discarded. configSetEventsCapacity :: Natural -> Config -> Config -- | Set the logger to be used by the client. configSetLogger :: (LoggingT IO () -> IO ()) -> Config -> Config -- | Sets the Manager to use with the client. If not set explicitly -- a new Manager will be created when creating the client. configSetManager :: Manager -> Config -> Config -- | Sets whether to send analytics events back to LaunchDarkly. By -- default, the client will send events. This differs from Offline in -- that it only affects sending events, not streaming or polling for -- events from the server. configSetSendEvents :: Bool -> Config -> Config -- | Sets whether this client is offline. An offline client will not make -- any network connections to LaunchDarkly, and will return default -- values for all feature flags. configSetOffline :: Bool -> Config -> Config -- | Sets how long an the HTTP client should wait before a response is -- returned. configSetRequestTimeoutSeconds :: Natural -> Config -> Config -- | Configures a handle to an external store such as Redis. configSetStoreBackend :: Maybe StoreInterface -> Config -> Config -- | When a store backend is configured, control how long values should be -- cached in memory before going back to the backend. configSetStoreTTL :: Natural -> Config -> Config -- | Sets whether this client should use the LaunchDarkly Relay Proxy in -- daemon mode. In this mode, the client does not subscribe to the -- streaming or polling API, but reads data only from the feature store. -- See: https://docs.launchdarkly.com/home/relay-proxy configSetUseLdd :: Bool -> Config -> Config -- | Sets a data source to use instead of the default network based data -- source see LaunchDarkly.Server.Integrations.FileData configSetDataSourceFactory :: Maybe DataSourceFactory -> Config -> Config -- | This module is for configuration of the user object. module LaunchDarkly.Server.User -- | User contains specific attributes of a user of your application -- -- The only mandatory property is the Key, which must uniquely identify -- each user. For authenticated users, this may be a username or e-mail -- address. For anonymous users, this could be an IP address or session -- ID. data User -- | Creates a new user identified by the given key. makeUser :: Text -> User -- | Set the primary key for a user. userSetKey :: Text -> User -> User -- | Set the secondary key for a user. userSetSecondary :: Maybe Text -> User -> User -- | Set the IP for a user. userSetIP :: Maybe Text -> User -> User -- | Set the country for a user. userSetCountry :: Maybe Text -> User -> User -- | Set the email for a user. userSetEmail :: Maybe Text -> User -> User -- | Set the first name for a user. userSetFirstName :: Maybe Text -> User -> User -- | Set the last name for a user. userSetLastName :: Maybe Text -> User -> User -- | Set the avatar for a user. userSetAvatar :: Maybe Text -> User -> User -- | Set the name for a user. userSetName :: Maybe Text -> User -> User -- | Set if the user is anonymous or not. userSetAnonymous :: Bool -> User -> User -- | Set custom fields for a user. userSetCustom :: HashMap Text Value -> User -> User -- | This contains list of attributes to keep private, whether they appear -- at the top-level or Custom The attribute "key" is always sent -- regardless of whether it is in this list, and "custom" cannot be used -- to eliminate all custom attributes userSetPrivateAttributeNames :: Set Text -> User -> User -- | This module contains the core functionality of the SDK. module LaunchDarkly.Server.Client -- | Client is the LaunchDarkly client. Client instances are thread-safe. -- Applications should instantiate a single instance for the lifetime of -- their application. data Client -- | Create a new instance of the LaunchDarkly client. makeClient :: Config -> IO Client -- | The version string for this library. clientVersion :: Text -- | Evaluate a Boolean typed flag. boolVariation :: Client -> Text -> User -> Bool -> IO Bool -- | Evaluate a Boolean typed flag, and return an explanation. boolVariationDetail :: Client -> Text -> User -> Bool -> IO (EvaluationDetail Bool) -- | Evaluate a String typed flag. stringVariation :: Client -> Text -> User -> Text -> IO Text -- | Evaluate a String typed flag, and return an explanation. stringVariationDetail :: Client -> Text -> User -> Text -> IO (EvaluationDetail Text) -- | Evaluate a Number typed flag, and truncate the result. intVariation :: Client -> Text -> User -> Int -> IO Int -- | Evaluate a Number typed flag, truncate the result, and return an -- explanation. intVariationDetail :: Client -> Text -> User -> Int -> IO (EvaluationDetail Int) -- | Evaluate a Number typed flag. doubleVariation :: Client -> Text -> User -> Double -> IO Double -- | Evaluate a Number typed flag, and return an explanation. doubleVariationDetail :: Client -> Text -> User -> Double -> IO (EvaluationDetail Double) -- | Evaluate a JSON typed flag. jsonVariation :: Client -> Text -> User -> Value -> IO Value -- | Evaluate a JSON typed flag, and return an explanation. jsonVariationDetail :: Client -> Text -> User -> Value -> IO (EvaluationDetail Value) -- | Combines the result of a flag evaluation with an explanation of how it -- was calculated. data EvaluationDetail value EvaluationDetail :: !value -> !Maybe Integer -> !EvaluationReason -> EvaluationDetail value -- | The result of the flag evaluation. This will be either one of the -- flag's variations or the default value passed by the application. [$sel:value:EvaluationDetail] :: EvaluationDetail value -> !value -- | The index of the returned value within the flag's list of variations, -- e.g. 0 for the first variation - or Nothing if the default value was -- returned. [$sel:variationIndex:EvaluationDetail] :: EvaluationDetail value -> !Maybe Integer -- | Describes the main factor that influenced the flag evaluation value. [$sel:reason:EvaluationDetail] :: EvaluationDetail value -> !EvaluationReason -- | Defines the possible values of the Kind property of EvaluationReason. data EvaluationReason -- | Indicates that the flag was off and therefore returned its configured -- off value. EvaluationReasonOff :: EvaluationReason -- | indicates that the user key was specifically targeted for this flag. EvaluationReasonTargetMatch :: EvaluationReason EvaluationReasonRuleMatch :: !Natural -> !Text -> !Bool -> EvaluationReason -- | The index of the rule that was matched (0 being the first). [$sel:ruleIndex:EvaluationReasonOff] :: EvaluationReason -> !Natural -- | The unique identifier of the rule that was matched. [$sel:ruleId:EvaluationReasonOff] :: EvaluationReason -> !Text -- | Whether the evaluation was part of an experiment. Is true if the -- evaluation resulted in an experiment rollout *and* served one of the -- variations in the experiment. Otherwise false. [$sel:inExperiment:EvaluationReasonOff] :: EvaluationReason -> !Bool EvaluationReasonPrerequisiteFailed :: !Text -> EvaluationReason -- | The flag key of the prerequisite that failed. [$sel:prerequisiteKey:EvaluationReasonOff] :: EvaluationReason -> !Text EvaluationReasonFallthrough :: !Bool -> EvaluationReason -- | Whether the evaluation was part of an experiment. Is true if the -- evaluation resulted in an experiment rollout *and* served one of the -- variations in the experiment. Otherwise false. [$sel:inExperiment:EvaluationReasonOff] :: EvaluationReason -> !Bool EvaluationReasonError :: !EvalErrorKind -> EvaluationReason -- | Describes the type of error. [$sel:errorKind:EvaluationReasonOff] :: EvaluationReason -> !EvalErrorKind -- | Defines the possible values of the errorKind property of -- EvaluationReason. data EvalErrorKind -- | Indicates that there was an internal inconsistency in the flag data, -- e.g. a rule specified a nonexistent variation. EvalErrorKindMalformedFlag :: EvalErrorKind -- | Indicates that the caller provided a flag key that did not match any -- known flag. EvalErrorFlagNotFound :: EvalErrorKind -- | Indicates that the result value was not of the requested type, e.g. -- you called boolVariationDetail but the value was an integer. EvalErrorWrongType :: EvalErrorKind -- | Indicates that the caller tried to evaluate a flag before the client -- had successfully initialized. EvalErrorClientNotReady :: EvalErrorKind -- | Indicates that some error was returned by the external feature store. EvalErrorExternalStore :: !Text -> EvalErrorKind -- | Returns a map from feature flag keys to values for a given user. If -- the result of the flag's evaluation would result in the default value, -- Null will be returned. This method does not send analytics -- events back to LaunchDarkly. allFlags :: Client -> User -> IO (KeyMap Value) -- | Returns an object that encapsulates the state of all feature flags for -- a given user. This includes the flag values, and also metadata that -- can be used on the front end. -- -- The most common use case for this method is to bootstrap a set of -- client-side feature flags from a back-end service. -- -- The first parameter will limit to only flags that are marked for use -- with the client-side SDK (by default, all flags are included). -- -- The second parameter will include evaluation reasons in the state. -- -- The third parameter will omit any metadata that is normally only used -- for event generation, such as flag versions and evaluation reasons, -- unless the flag has event tracking or debugging turned on -- -- For more information, see the Reference Guide: -- https://docs.launchdarkly.com/sdk/features/all-flags#haskell allFlagsState :: Client -> User -> Bool -> Bool -> Bool -> IO AllFlagsState -- | AllFlagsState captures the state of all feature flag keys as evaluated -- for a specific user. This includes their values, as well as other -- metadata. data AllFlagsState -- | Close shuts down the LaunchDarkly client. After calling this, the -- LaunchDarkly client should no longer be used. The method will block -- until all pending analytics events have been sent. close :: Client -> IO () -- | Flush tells the client that all pending analytics events (if any) -- should be delivered as soon as possible. Flushing is asynchronous, so -- this method will return before it is complete. flushEvents :: Client -> IO () -- | Identify reports details about a user. identify :: Client -> User -> IO () -- | Track reports that a user has performed an event. Custom data can be -- attached to the event, and / or a numeric value. -- -- The numeric value is used by the LaunchDarkly experimentation feature -- in numeric custom metrics, and will also be returned as part of the -- custom event for Data Export. track :: Client -> User -> Text -> Maybe Value -> Maybe Double -> IO () -- | Alias associates two users for analytics purposes with an alias event. -- -- The first parameter should be the new version of the user, the second -- parameter should be the old version. alias :: Client -> User -> User -> IO () -- | The status of the client initialization. data Status -- | The client has not yet finished connecting to LaunchDarkly. Uninitialized :: Status -- | The client attempted to connect to LaunchDarkly and was denied. Unauthorized :: Status -- | The client has successfuly connected to LaunchDarkly. Initialized :: Status -- | The client is being terminated ShuttingDown :: Status -- | Return the initialization status of the Client getStatus :: Client -> IO Status instance GHC.Generics.Generic LaunchDarkly.Server.Client.FlagState instance GHC.Show.Show LaunchDarkly.Server.Client.FlagState instance GHC.Generics.Generic LaunchDarkly.Server.Client.AllFlagsState instance GHC.Show.Show LaunchDarkly.Server.Client.AllFlagsState instance Data.Aeson.Types.ToJSON.ToJSON LaunchDarkly.Server.Client.AllFlagsState instance Data.Aeson.Types.ToJSON.ToJSON LaunchDarkly.Server.Client.FlagState -- | This module re-exports the User, Client, and Config modules. module LaunchDarkly.Server -- | Config allows advanced configuration of the LaunchDarkly client. data Config -- | Create a default configuration from a given SDK key. makeConfig :: Text -> Config -- | Set the SDK key used to authenticate with LaunchDarkly. configSetKey :: Text -> Config -> Config -- | The base URI of the main LaunchDarkly service. This should not -- normally be changed except for testing. configSetBaseURI :: Text -> Config -> Config -- | The base URI of the LaunchDarkly streaming service. This should not -- normally be changed except for testing. configSetStreamURI :: Text -> Config -> Config -- | The base URI of the LaunchDarkly service that accepts analytics -- events. This should not normally be changed except for testing. configSetEventsURI :: Text -> Config -> Config -- | Sets whether streaming mode should be enabled. By default, streaming -- is enabled. It should only be disabled on the advice of LaunchDarkly -- support. configSetStreaming :: Bool -> Config -> Config -- | Sets whether or not all user attributes (other than the key) should be -- hidden from LaunchDarkly. If this is true, all user attribute values -- will be private, not just the attributes specified in -- PrivateAttributeNames. configSetAllAttributesPrivate :: Bool -> Config -> Config -- | Marks a set of user attribute names private. Any users sent to -- LaunchDarkly with this configuration active will have attributes with -- these names removed. configSetPrivateAttributeNames :: Set Text -> Config -> Config -- | The time between flushes of the event buffer. Decreasing the flush -- interval means that the event buffer is less likely to reach capacity. configSetFlushIntervalSeconds :: Natural -> Config -> Config -- | The polling interval (when streaming is disabled). configSetPollIntervalSeconds :: Natural -> Config -> Config -- | The number of user keys that the event processor can remember at any -- one time, so that duplicate user details will not be sent in analytics -- events. configSetUserKeyLRUCapacity :: Natural -> Config -> Config -- | Set to true if you need to see the full user details in every -- analytics event. configSetInlineUsersInEvents :: Bool -> Config -> Config -- | The capacity of the events buffer. The client buffers up to this many -- events in memory before flushing. If the capacity is exceeded before -- the buffer is flushed, events will be discarded. configSetEventsCapacity :: Natural -> Config -> Config -- | Set the logger to be used by the client. configSetLogger :: (LoggingT IO () -> IO ()) -> Config -> Config -- | Sets the Manager to use with the client. If not set explicitly -- a new Manager will be created when creating the client. configSetManager :: Manager -> Config -> Config -- | Sets whether to send analytics events back to LaunchDarkly. By -- default, the client will send events. This differs from Offline in -- that it only affects sending events, not streaming or polling for -- events from the server. configSetSendEvents :: Bool -> Config -> Config -- | Sets whether this client is offline. An offline client will not make -- any network connections to LaunchDarkly, and will return default -- values for all feature flags. configSetOffline :: Bool -> Config -> Config -- | Sets how long an the HTTP client should wait before a response is -- returned. configSetRequestTimeoutSeconds :: Natural -> Config -> Config -- | Configures a handle to an external store such as Redis. configSetStoreBackend :: Maybe StoreInterface -> Config -> Config -- | When a store backend is configured, control how long values should be -- cached in memory before going back to the backend. configSetStoreTTL :: Natural -> Config -> Config -- | Sets whether this client should use the LaunchDarkly Relay Proxy in -- daemon mode. In this mode, the client does not subscribe to the -- streaming or polling API, but reads data only from the feature store. -- See: https://docs.launchdarkly.com/home/relay-proxy configSetUseLdd :: Bool -> Config -> Config -- | Sets a data source to use instead of the default network based data -- source see LaunchDarkly.Server.Integrations.FileData configSetDataSourceFactory :: Maybe DataSourceFactory -> Config -> Config -- | User contains specific attributes of a user of your application -- -- The only mandatory property is the Key, which must uniquely identify -- each user. For authenticated users, this may be a username or e-mail -- address. For anonymous users, this could be an IP address or session -- ID. data User -- | Creates a new user identified by the given key. makeUser :: Text -> User -- | Set the primary key for a user. userSetKey :: Text -> User -> User -- | Set the secondary key for a user. userSetSecondary :: Maybe Text -> User -> User -- | Set the IP for a user. userSetIP :: Maybe Text -> User -> User -- | Set the country for a user. userSetCountry :: Maybe Text -> User -> User -- | Set the email for a user. userSetEmail :: Maybe Text -> User -> User -- | Set the first name for a user. userSetFirstName :: Maybe Text -> User -> User -- | Set the last name for a user. userSetLastName :: Maybe Text -> User -> User -- | Set the avatar for a user. userSetAvatar :: Maybe Text -> User -> User -- | Set the name for a user. userSetName :: Maybe Text -> User -> User -- | Set if the user is anonymous or not. userSetAnonymous :: Bool -> User -> User -- | Set custom fields for a user. userSetCustom :: HashMap Text Value -> User -> User -- | This contains list of attributes to keep private, whether they appear -- at the top-level or Custom The attribute "key" is always sent -- regardless of whether it is in this list, and "custom" cannot be used -- to eliminate all custom attributes userSetPrivateAttributeNames :: Set Text -> User -> User -- | Client is the LaunchDarkly client. Client instances are thread-safe. -- Applications should instantiate a single instance for the lifetime of -- their application. data Client -- | Create a new instance of the LaunchDarkly client. makeClient :: Config -> IO Client -- | The version string for this library. clientVersion :: Text -- | Evaluate a Boolean typed flag. boolVariation :: Client -> Text -> User -> Bool -> IO Bool -- | Evaluate a Boolean typed flag, and return an explanation. boolVariationDetail :: Client -> Text -> User -> Bool -> IO (EvaluationDetail Bool) -- | Evaluate a String typed flag. stringVariation :: Client -> Text -> User -> Text -> IO Text -- | Evaluate a String typed flag, and return an explanation. stringVariationDetail :: Client -> Text -> User -> Text -> IO (EvaluationDetail Text) -- | Evaluate a Number typed flag, and truncate the result. intVariation :: Client -> Text -> User -> Int -> IO Int -- | Evaluate a Number typed flag, truncate the result, and return an -- explanation. intVariationDetail :: Client -> Text -> User -> Int -> IO (EvaluationDetail Int) -- | Evaluate a Number typed flag. doubleVariation :: Client -> Text -> User -> Double -> IO Double -- | Evaluate a Number typed flag, and return an explanation. doubleVariationDetail :: Client -> Text -> User -> Double -> IO (EvaluationDetail Double) -- | Evaluate a JSON typed flag. jsonVariation :: Client -> Text -> User -> Value -> IO Value -- | Evaluate a JSON typed flag, and return an explanation. jsonVariationDetail :: Client -> Text -> User -> Value -> IO (EvaluationDetail Value) -- | Combines the result of a flag evaluation with an explanation of how it -- was calculated. data EvaluationDetail value EvaluationDetail :: !value -> !Maybe Integer -> !EvaluationReason -> EvaluationDetail value -- | The result of the flag evaluation. This will be either one of the -- flag's variations or the default value passed by the application. [$sel:value:EvaluationDetail] :: EvaluationDetail value -> !value -- | The index of the returned value within the flag's list of variations, -- e.g. 0 for the first variation - or Nothing if the default value was -- returned. [$sel:variationIndex:EvaluationDetail] :: EvaluationDetail value -> !Maybe Integer -- | Describes the main factor that influenced the flag evaluation value. [$sel:reason:EvaluationDetail] :: EvaluationDetail value -> !EvaluationReason -- | Defines the possible values of the Kind property of EvaluationReason. data EvaluationReason -- | Indicates that the flag was off and therefore returned its configured -- off value. EvaluationReasonOff :: EvaluationReason -- | indicates that the user key was specifically targeted for this flag. EvaluationReasonTargetMatch :: EvaluationReason EvaluationReasonRuleMatch :: !Natural -> !Text -> !Bool -> EvaluationReason -- | The index of the rule that was matched (0 being the first). [$sel:ruleIndex:EvaluationReasonOff] :: EvaluationReason -> !Natural -- | The unique identifier of the rule that was matched. [$sel:ruleId:EvaluationReasonOff] :: EvaluationReason -> !Text -- | Whether the evaluation was part of an experiment. Is true if the -- evaluation resulted in an experiment rollout *and* served one of the -- variations in the experiment. Otherwise false. [$sel:inExperiment:EvaluationReasonOff] :: EvaluationReason -> !Bool EvaluationReasonPrerequisiteFailed :: !Text -> EvaluationReason -- | The flag key of the prerequisite that failed. [$sel:prerequisiteKey:EvaluationReasonOff] :: EvaluationReason -> !Text EvaluationReasonFallthrough :: !Bool -> EvaluationReason -- | Whether the evaluation was part of an experiment. Is true if the -- evaluation resulted in an experiment rollout *and* served one of the -- variations in the experiment. Otherwise false. [$sel:inExperiment:EvaluationReasonOff] :: EvaluationReason -> !Bool EvaluationReasonError :: !EvalErrorKind -> EvaluationReason -- | Describes the type of error. [$sel:errorKind:EvaluationReasonOff] :: EvaluationReason -> !EvalErrorKind -- | Defines the possible values of the errorKind property of -- EvaluationReason. data EvalErrorKind -- | Indicates that there was an internal inconsistency in the flag data, -- e.g. a rule specified a nonexistent variation. EvalErrorKindMalformedFlag :: EvalErrorKind -- | Indicates that the caller provided a flag key that did not match any -- known flag. EvalErrorFlagNotFound :: EvalErrorKind -- | Indicates that the result value was not of the requested type, e.g. -- you called boolVariationDetail but the value was an integer. EvalErrorWrongType :: EvalErrorKind -- | Indicates that the caller tried to evaluate a flag before the client -- had successfully initialized. EvalErrorClientNotReady :: EvalErrorKind -- | Indicates that some error was returned by the external feature store. EvalErrorExternalStore :: !Text -> EvalErrorKind -- | Returns a map from feature flag keys to values for a given user. If -- the result of the flag's evaluation would result in the default value, -- Null will be returned. This method does not send analytics -- events back to LaunchDarkly. allFlags :: Client -> User -> IO (KeyMap Value) -- | Returns an object that encapsulates the state of all feature flags for -- a given user. This includes the flag values, and also metadata that -- can be used on the front end. -- -- The most common use case for this method is to bootstrap a set of -- client-side feature flags from a back-end service. -- -- The first parameter will limit to only flags that are marked for use -- with the client-side SDK (by default, all flags are included). -- -- The second parameter will include evaluation reasons in the state. -- -- The third parameter will omit any metadata that is normally only used -- for event generation, such as flag versions and evaluation reasons, -- unless the flag has event tracking or debugging turned on -- -- For more information, see the Reference Guide: -- https://docs.launchdarkly.com/sdk/features/all-flags#haskell allFlagsState :: Client -> User -> Bool -> Bool -> Bool -> IO AllFlagsState -- | AllFlagsState captures the state of all feature flag keys as evaluated -- for a specific user. This includes their values, as well as other -- metadata. data AllFlagsState -- | Close shuts down the LaunchDarkly client. After calling this, the -- LaunchDarkly client should no longer be used. The method will block -- until all pending analytics events have been sent. close :: Client -> IO () -- | Flush tells the client that all pending analytics events (if any) -- should be delivered as soon as possible. Flushing is asynchronous, so -- this method will return before it is complete. flushEvents :: Client -> IO () -- | Identify reports details about a user. identify :: Client -> User -> IO () -- | Track reports that a user has performed an event. Custom data can be -- attached to the event, and / or a numeric value. -- -- The numeric value is used by the LaunchDarkly experimentation feature -- in numeric custom metrics, and will also be returned as part of the -- custom event for Data Export. track :: Client -> User -> Text -> Maybe Value -> Maybe Double -> IO () -- | Alias associates two users for analytics purposes with an alias event. -- -- The first parameter should be the new version of the user, the second -- parameter should be the old version. alias :: Client -> User -> User -> IO () -- | The status of the client initialization. data Status -- | The client has not yet finished connecting to LaunchDarkly. Uninitialized :: Status -- | The client attempted to connect to LaunchDarkly and was denied. Unauthorized :: Status -- | The client has successfuly connected to LaunchDarkly. Initialized :: Status -- | The client is being terminated ShuttingDown :: Status -- | Return the initialization status of the Client getStatus :: Client -> IO Status