Skip to content

Commit

Permalink
prepare 8.2.0 release (#225)
Browse files Browse the repository at this point in the history
## [8.2.0] - 2023-10-17
### Deprecated:
- Creating an `LDContext` using the legacy user format has been
deprecated and will be removed in the next major release. To learn more,
read the [Contexts
documentation](https://docs.launchdarkly.com/guides/flags/intro-contexts).
- Providing client methods `track`, `identify`, `variation`,
`variation_detail`, `all_flags_state`, and `secure_mode_hash` with a
context dictionary is deprecated. In the next major release, a `Context`
will be required.

---------

Co-authored-by: LaunchDarklyCI <dev@launchdarkly.com>
Co-authored-by: Eli Bishop <eli@launchdarkly.com>
Co-authored-by: hroederld <hroeder@launchdarkly.com>
Co-authored-by: Robert J. Neal <rneal@launchdarkly.com>
Co-authored-by: Robert J. Neal <robertjneal@users.noreply.github.com>
Co-authored-by: Ben Woskow <48036130+bwoskow-ld@users.noreply.github.com>
Co-authored-by: Ember Stevens <ember.stevens@launchdarkly.com>
Co-authored-by: ember-stevens <79482775+ember-stevens@users.noreply.github.com>
Co-authored-by: Matthew M. Keeler <keelerm84@gmail.com>
Co-authored-by: charukiewicz <charukiewicz@protonmail.com>
Co-authored-by: LaunchDarklyReleaseBot <launchdarklyreleasebot@launchdarkly.com>
Co-authored-by: Christian Charukiewicz <christian@foxhound.systems>
Co-authored-by: Matthew M. Keeler <mkeeler@launchdarkly.com>
Co-authored-by: Ben Woskow <bwoskow@launchdarkly.com>
Co-authored-by: Gavin Whelan <gwhelan@launchdarkly.com>
Co-authored-by: Elliot <35050275+Apache-HB@users.noreply.github.com>
Co-authored-by: Gabor Angeli <gabor@squareup.com>
Co-authored-by: Elliot <apachehaisley@gmail.com>
Co-authored-by: LaunchDarklyCI <LaunchDarklyCI@users.noreply.github.com>
Co-authored-by: Louis Chan <lchan@launchdarkly.com>
Co-authored-by: prpnmac <95777763+prpnmac@users.noreply.github.com>
Co-authored-by: Louis Chan <91093020+louis-launchdarkly@users.noreply.github.com>
Co-authored-by: Daniel Fritz <dfritz@indigoag.com>
  • Loading branch information
24 people authored Oct 17, 2023
1 parent d7488bd commit bcbcbee
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
20 changes: 19 additions & 1 deletion ldclient/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import hmac
import threading
import traceback
import warnings

from ldclient.config import Config
from ldclient.context import Context
Expand Down Expand Up @@ -204,13 +205,16 @@ def track(self, event_name: str, context: Union[dict, Context], data: Optional[A
the SDK will convert the user to a Context. There is some overhead to this conversion,
so it is more efficient to pass a Context.
DEPRECATED: This method will no longer accept a dictionary for the context parameter starting in 9.0.0
:param event_name: the name of the event
:param context: the evaluation context or user associated with the event
:param data: optional additional data associated with the event
:param metric_value: a numeric value used by the LaunchDarkly experimentation feature in
numeric custom metrics; can be omitted if this event is used by only non-numeric metrics
"""
if not isinstance(context, Context):
warnings.warn("track will require a Context instance in 9.0.0", DeprecationWarning)
context = Context.from_dict(context)
if not context.valid:
log.warning("Invalid context for track (%s)" % context.error)
Expand All @@ -233,9 +237,12 @@ def identify(self, context: Union[Context, dict]):
the SDK will convert the user to a Context. There is some overhead to this conversion,
so it is more efficient to pass a Context.
DEPRECATED: This method will no longer accept a dictionary for the context parameter starting in 9.0.0
:param context: the context to register
"""
if not isinstance(context, Context):
warnings.warn("identify will require a Context instance in 9.0.0", DeprecationWarning)
context = Context.from_dict(context)
if not context.valid:
log.warning("Invalid context for identify (%s)" % context.error)
Expand Down Expand Up @@ -280,6 +287,8 @@ def variation(self, key: str, context: Union[Context, dict], default: Any) -> An
the SDK will convert the user to a Context. There is some overhead to this conversion,
so it is more efficient to pass a Context.
DEPRECATED: This method will no longer accept a dictionary for the context parameter starting in 9.0.0
:param key: the unique key for the feature flag
:param context: the evaluation context or user
:param default: the default value of the flag, to be used if the value is not
Expand All @@ -299,6 +308,8 @@ def variation_detail(self, key: str, context: Union[Context, dict], default: Any
the SDK will convert the user to a Context. There is some overhead to this conversion,
so it is more efficient to pass a Context.
DEPRECATED: This method will no longer accept a dictionary for the context parameter starting in 9.0.0
:param key: the unique key for the feature flag
:param context: the evaluation context or user
:param default: the default value of the flag, to be used if the value is not
Expand All @@ -325,6 +336,7 @@ def _evaluate_internal(self, key: str, context: Union[Context, dict], default: A
return EvaluationDetail(default, None, reason)

if not isinstance(context, Context):
warnings.warn("variation methods will require a Context instance in 9.0.0", DeprecationWarning)
context = Context.from_dict(context)
if not context.valid:
log.warning("Context was invalid for flag evaluation (%s); returning default value" % context.error)
Expand Down Expand Up @@ -367,6 +379,8 @@ def all_flags_state(self, context: Union[Context, dict], **kwargs) -> FeatureFla
This method does not send analytics events back to LaunchDarkly.
DEPRECATED: This method will no longer accept a dictionary for the context parameter starting in 9.0.0
:param user: the end user requesting the feature flags
:param kwargs: optional parameters affecting how the state is computed - see below
Expand Down Expand Up @@ -396,6 +410,7 @@ def all_flags_state(self, context: Union[Context, dict], **kwargs) -> FeatureFla
return FeatureFlagsState(False)

if not isinstance(context, Context):
warnings.warn("all_flags_state will require a Context instance in 9.0.0", DeprecationWarning)
context = Context.from_dict(context)
if not context.valid:
log.warning("Context was invalid for all_flags_state (%s); returning default value" % context.error)
Expand Down Expand Up @@ -445,11 +460,14 @@ def secure_mode_hash(self, context: Union[Context, dict]) -> str:
For more information, see the documentation on
`Secure mode <https://docs.launchdarkly.com/sdk/features/secure-mode#configuring-secure-mode-in-the-javascript-client-side-sdk>`_.
DEPRECATED: This method will no longer accept a dictionary for the context parameter starting in 9.0.0
:param context: the evaluation context or user
:return: the hash string
"""
if not isinstance(context, Context):
warnings.warn("secure_mode_hash will require a Context instance in 9.0.0", DeprecationWarning)
context = Context.from_dict(context)
if not context.valid:
log.warning("Context was invalid for secure_mode_hash (%s); returning empty hash" % context.error)
Expand Down
4 changes: 4 additions & 0 deletions ldclient/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from collections.abc import Iterable
import json
import re
import warnings
from typing import Any, Dict, Optional, Union


Expand Down Expand Up @@ -189,6 +190,8 @@ def from_dict(cls, props: dict) -> Context:
is interpreted as a context with "user" kind using the somewhat different LaunchDarkly
JSON schema for users in older LaunchDarkly SDKs.
DEPRECATED: The legacy user format is deprecated and will be removed in 9.0.0
:param props: the context/user properties
:return: a context
"""
Expand Down Expand Up @@ -601,6 +604,7 @@ def __from_dict_single(self, props: dict, kind: Optional[str]) -> Context:

@classmethod
def __from_dict_old_user(self, props: dict) -> Context:
warnings.warn("legacy user format will be removed in 9.0.0", DeprecationWarning)
b = ContextBuilder('').kind('user')
has_key = False
for k, v in props.items():
Expand Down

0 comments on commit bcbcbee

Please sign in to comment.