Skip to content

Commit bcbcbee

Browse files
LaunchDarklyReleaseBotLaunchDarklyCIeli-darklyhroederldrobertjneal
authored
prepare 8.2.0 release (#225)
## [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>
1 parent d7488bd commit bcbcbee

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

ldclient/client.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import hmac
1111
import threading
1212
import traceback
13+
import warnings
1314

1415
from ldclient.config import Config
1516
from ldclient.context import Context
@@ -204,13 +205,16 @@ def track(self, event_name: str, context: Union[dict, Context], data: Optional[A
204205
the SDK will convert the user to a Context. There is some overhead to this conversion,
205206
so it is more efficient to pass a Context.
206207
208+
DEPRECATED: This method will no longer accept a dictionary for the context parameter starting in 9.0.0
209+
207210
:param event_name: the name of the event
208211
:param context: the evaluation context or user associated with the event
209212
:param data: optional additional data associated with the event
210213
:param metric_value: a numeric value used by the LaunchDarkly experimentation feature in
211214
numeric custom metrics; can be omitted if this event is used by only non-numeric metrics
212215
"""
213216
if not isinstance(context, Context):
217+
warnings.warn("track will require a Context instance in 9.0.0", DeprecationWarning)
214218
context = Context.from_dict(context)
215219
if not context.valid:
216220
log.warning("Invalid context for track (%s)" % context.error)
@@ -233,9 +237,12 @@ def identify(self, context: Union[Context, dict]):
233237
the SDK will convert the user to a Context. There is some overhead to this conversion,
234238
so it is more efficient to pass a Context.
235239
240+
DEPRECATED: This method will no longer accept a dictionary for the context parameter starting in 9.0.0
241+
236242
:param context: the context to register
237243
"""
238244
if not isinstance(context, Context):
245+
warnings.warn("identify will require a Context instance in 9.0.0", DeprecationWarning)
239246
context = Context.from_dict(context)
240247
if not context.valid:
241248
log.warning("Invalid context for identify (%s)" % context.error)
@@ -280,6 +287,8 @@ def variation(self, key: str, context: Union[Context, dict], default: Any) -> An
280287
the SDK will convert the user to a Context. There is some overhead to this conversion,
281288
so it is more efficient to pass a Context.
282289
290+
DEPRECATED: This method will no longer accept a dictionary for the context parameter starting in 9.0.0
291+
283292
:param key: the unique key for the feature flag
284293
:param context: the evaluation context or user
285294
:param default: the default value of the flag, to be used if the value is not
@@ -299,6 +308,8 @@ def variation_detail(self, key: str, context: Union[Context, dict], default: Any
299308
the SDK will convert the user to a Context. There is some overhead to this conversion,
300309
so it is more efficient to pass a Context.
301310
311+
DEPRECATED: This method will no longer accept a dictionary for the context parameter starting in 9.0.0
312+
302313
:param key: the unique key for the feature flag
303314
:param context: the evaluation context or user
304315
:param default: the default value of the flag, to be used if the value is not
@@ -325,6 +336,7 @@ def _evaluate_internal(self, key: str, context: Union[Context, dict], default: A
325336
return EvaluationDetail(default, None, reason)
326337

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

398412
if not isinstance(context, Context):
413+
warnings.warn("all_flags_state will require a Context instance in 9.0.0", DeprecationWarning)
399414
context = Context.from_dict(context)
400415
if not context.valid:
401416
log.warning("Context was invalid for all_flags_state (%s); returning default value" % context.error)
@@ -445,11 +460,14 @@ def secure_mode_hash(self, context: Union[Context, dict]) -> str:
445460
446461
For more information, see the documentation on
447462
`Secure mode <https://docs.launchdarkly.com/sdk/features/secure-mode#configuring-secure-mode-in-the-javascript-client-side-sdk>`_.
448-
463+
464+
DEPRECATED: This method will no longer accept a dictionary for the context parameter starting in 9.0.0
465+
449466
:param context: the evaluation context or user
450467
:return: the hash string
451468
"""
452469
if not isinstance(context, Context):
470+
warnings.warn("secure_mode_hash will require a Context instance in 9.0.0", DeprecationWarning)
453471
context = Context.from_dict(context)
454472
if not context.valid:
455473
log.warning("Context was invalid for secure_mode_hash (%s); returning empty hash" % context.error)

ldclient/context.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from collections.abc import Iterable
77
import json
88
import re
9+
import warnings
910
from typing import Any, Dict, Optional, Union
1011

1112

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

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

0 commit comments

Comments
 (0)