Skip to content

Commit 4e45255

Browse files
authored
Add historical_migration option to toplevel Client (#117)
1 parent bc37351 commit 4e45255

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

posthog/client.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def __init__(
4949
project_api_key=None,
5050
disabled=False,
5151
disable_geoip=True,
52+
historical_migration=False,
5253
):
5354
self.queue = queue.Queue(max_queue_size)
5455

@@ -73,6 +74,7 @@ def __init__(
7374
self.distinct_ids_feature_flags_reported = SizeLimitedDict(MAX_DICT_SIZE, set)
7475
self.disabled = disabled
7576
self.disable_geoip = disable_geoip
77+
self.historical_migration = historical_migration
7678

7779
# personal_api_key: This should be a generated Personal API Key, private
7880
self.personal_api_key = personal_api_key
@@ -107,6 +109,7 @@ def __init__(
107109
gzip=gzip,
108110
retries=max_retries,
109111
timeout=timeout,
112+
historical_migration=historical_migration,
110113
)
111114
self.consumers.append(consumer)
112115

@@ -374,7 +377,14 @@ def _enqueue(self, msg, disable_geoip):
374377

375378
if self.sync_mode:
376379
self.log.debug("enqueued with blocking %s.", msg["event"])
377-
batch_post(self.api_key, self.host, gzip=self.gzip, timeout=self.timeout, batch=[msg])
380+
batch_post(
381+
self.api_key,
382+
self.host,
383+
gzip=self.gzip,
384+
timeout=self.timeout,
385+
batch=[msg],
386+
historical_migration=self.historical_migration,
387+
)
378388

379389
return True, msg
380390

posthog/consumer.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def __init__(
3636
gzip=False,
3737
retries=10,
3838
timeout=15,
39+
historical_migration=False,
3940
):
4041
"""Create a consumer thread."""
4142
Thread.__init__(self)
@@ -55,6 +56,7 @@ def __init__(
5556
self.running = True
5657
self.retries = retries
5758
self.timeout = timeout
59+
self.historical_migration = historical_migration
5860

5961
def run(self):
6062
"""Runs the consumer."""
@@ -134,6 +136,13 @@ def fatal_exception(exc):
134136

135137
@backoff.on_exception(backoff.expo, Exception, max_tries=self.retries + 1, giveup=fatal_exception)
136138
def send_request():
137-
batch_post(self.api_key, self.host, gzip=self.gzip, timeout=self.timeout, batch=batch)
139+
batch_post(
140+
self.api_key,
141+
self.host,
142+
gzip=self.gzip,
143+
timeout=self.timeout,
144+
batch=batch,
145+
historical_migration=self.historical_migration,
146+
)
138147

139148
send_request()

0 commit comments

Comments
 (0)