Skip to content

Commit

Permalink
Do not start Feature Flag polling if no API Key (#15)
Browse files Browse the repository at this point in the history
* jetbrains idea .gitignore

* do not start the poller if no personal api key
  • Loading branch information
mariusandra authored Nov 23, 2020
1 parent 98d2d4c commit 221d7f0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ env
flake8.out
pylint.out
posthog-analytics
.idea

10 changes: 5 additions & 5 deletions posthog/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,6 @@ def shutdown(self):
self.join()

def _load_feature_flags(self):
if not self.personal_api_key:
self.log.warning('[FEATURE FLAGS] You have to specify a personal_api_key to use feature flags.')
self.feature_flags = []
return

try:
self.feature_flags = get(self.personal_api_key, '/api/feature_flag/', self.host)['results']
except APIError as e:
Expand All @@ -250,6 +245,11 @@ def _load_feature_flags(self):
self._last_feature_flag_poll = datetime.utcnow().replace(tzinfo=tzutc())

def load_feature_flags(self):
if not self.personal_api_key:
self.log.warning('[FEATURE FLAGS] You have to specify a personal_api_key to use feature flags.')
self.feature_flags = []
return

self._load_feature_flags()
poller = Poller(interval=timedelta(seconds=self.poll_interval), execute=self._load_feature_flags)
poller.start()
Expand Down

0 comments on commit 221d7f0

Please sign in to comment.