Skip to content

Commit

Permalink
Hashed SDK Keys to Target Apps (#208)
Browse files Browse the repository at this point in the history
* Hashed SDK Keys to Target Apps

* update
  • Loading branch information
sroyal-statsig authored and kenny-statsig committed Nov 15, 2023
1 parent 6bbbde0 commit cee5db8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions statsig/spec_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from concurrent.futures import ThreadPoolExecutor, wait
from typing import Optional

from .utils import djb2_hash

from .evaluation_details import EvaluationReason
from .statsig_error_boundary import _StatsigErrorBoundary
from .statsig_errors import StatsigValueError, StatsigNameError
Expand Down Expand Up @@ -52,6 +54,7 @@ def __init__(self, network: _StatsigNetwork, options: StatsigOptions, statsig_me
self._layers = {}
self._experiment_to_layer = {}
self._sdk_keys_to_app_ids = {}
self._hashed_sdk_keys_to_app_ids = {}

self._id_lists = {}

Expand Down Expand Up @@ -120,6 +123,9 @@ def get_all_id_lists(self):
def get_target_app_for_sdk_key(self, sdk_key=None):
if sdk_key is None:
return None
target_app_id = self._hashed_sdk_keys_to_app_ids.get(djb2_hash(sdk_key))
if target_app_id is not None:
return target_app_id
return self._sdk_keys_to_app_ids.get(sdk_key)

def _initialize_specs(self):
Expand Down Expand Up @@ -165,6 +171,7 @@ def get_parsed_specs(key: str):
new_experiment_to_layer[experiment_name] = layer_name

self._sdk_keys_to_app_ids = specs_json.get("sdk_keys_to_app_ids", {})
self._hashed_sdk_keys_to_app_ids = specs_json.get("hashed_sdk_keys_to_app_ids", {})
self._gates = new_gates
self._configs = new_configs
self._layers = new_layers
Expand Down
2 changes: 1 addition & 1 deletion statsig/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.21.2'
__version__ = '0.22.1'

0 comments on commit cee5db8

Please sign in to comment.