|
7 | 7 | from typing import Optional, Callable, List, Any, Set |
8 | 8 |
|
9 | 9 | from ldclient.feature_store import InMemoryFeatureStore |
10 | | -from ldclient.util import log |
| 10 | +from ldclient.util import log, validate_application_info |
11 | 11 | from ldclient.interfaces import BigSegmentStore, EventProcessor, FeatureStore, UpdateProcessor, FeatureRequester |
12 | 12 |
|
13 | 13 | GET_LATEST_FEATURES_PATH = '/sdk/latest-flags' |
@@ -173,7 +173,8 @@ def __init__(self, |
173 | 173 | wrapper_name: Optional[str]=None, |
174 | 174 | wrapper_version: Optional[str]=None, |
175 | 175 | http: HTTPConfig=HTTPConfig(), |
176 | | - big_segments: Optional[BigSegmentsConfig]=None): |
| 176 | + big_segments: Optional[BigSegmentsConfig]=None, |
| 177 | + application: Optional[dict]=None): |
177 | 178 | """ |
178 | 179 | :param sdk_key: The SDK key for your LaunchDarkly account. This is always required. |
179 | 180 | :param base_uri: The base URL for the LaunchDarkly server. Most users should use the default |
@@ -239,6 +240,7 @@ def __init__(self, |
239 | 240 | servers. |
240 | 241 | :param http: Optional properties for customizing the client's HTTP/HTTPS behavior. See |
241 | 242 | :class:`HTTPConfig`. |
| 243 | + :param application: Optional properties for setting application metadata. See :py:attr:`~application` |
242 | 244 | """ |
243 | 245 | self.__sdk_key = sdk_key |
244 | 246 |
|
@@ -271,6 +273,7 @@ def __init__(self, |
271 | 273 | self.__wrapper_version = wrapper_version |
272 | 274 | self.__http = http |
273 | 275 | self.__big_segments = BigSegmentsConfig() if not big_segments else big_segments |
| 276 | + self.__application = validate_application_info(application or {}, log) |
274 | 277 |
|
275 | 278 | def copy_with_new_sdk_key(self, new_sdk_key: str) -> 'Config': |
276 | 279 | """Returns a new ``Config`` instance that is the same as this one, except for having a different SDK key. |
@@ -441,3 +444,16 @@ def big_segments(self) -> BigSegmentsConfig: |
441 | 444 | def _validate(self): |
442 | 445 | if self.offline is False and self.sdk_key is None or self.sdk_key == '': |
443 | 446 | log.warning("Missing or blank sdk_key.") |
| 447 | + |
| 448 | + @property |
| 449 | + def application(self) -> dict: |
| 450 | + """ |
| 451 | + An object that allows configuration of application metadata. |
| 452 | +
|
| 453 | + Application metadata may be used in LaunchDarkly analytics or other |
| 454 | + product features, but does not affect feature flag evaluations. |
| 455 | +
|
| 456 | + If you want to set non-default values for any of these fields, provide |
| 457 | + the appropriately configured dict to the {Config} object. |
| 458 | + """ |
| 459 | + return self.__application |
0 commit comments