Skip to content

Commit 048cf71

Browse files
committed
Add api_key argument as in Mixpanel package v4.3.2
The Mixpanel `BufferedConsumer.send` method now has a third argument `api_key`, that `AsyncBufferedConsumer` has to have too.
1 parent 8812984 commit 048cf71

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
## [Unreleased]
99

10+
### Added
11+
12+
* Argument `api_key` for `AsyncBufferedConsumer.send`, for compatibility with the version
13+
4.3.2 of the Mixpanel package.
14+
1015
### Changed
1116

1217
* Breaking change: Argument of `flush` renamed from `async` to `async_` for

mixpanel_async/async_buffered_consumer.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def _should_flush(self, endpoint=None):
133133
return False
134134

135135

136-
def send(self, endpoint, json_message):
136+
def send(self, endpoint, json_message, api_key=None):
137137
'''
138138
Record an event or a profile update. Calls to send() will store
139139
the given message in memory, and (when enough messages have been stored)
@@ -147,6 +147,8 @@ def send(self, endpoint, json_message):
147147
:type endpoint: str (one of 'events' or 'people')
148148
:param json_message: A json message formatted for the endpoint.
149149
:type json_message: str
150+
:param api_key: Your Mixpanel project's API key
151+
:type api_key: str
150152
:raises: MixpanelException
151153
'''
152154
if endpoint not in self._async_buffers:
@@ -155,6 +157,9 @@ def send(self, endpoint, json_message):
155157
buf = self._async_buffers[endpoint]
156158
buf.append(json_message)
157159

160+
if api_key is not None:
161+
self._api_key = api_key
162+
158163
should_flush = self._should_flush(endpoint)
159164

160165
if should_flush == self.ALL:

tests/async_buffered_consumer_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def test_does_not_drop_events(self):
148148

149149
self.wait_for_threads()
150150

151-
send_patch.assert_called_once_with(self.ENDPOINT, '[{"test": true}]')
151+
send_patch.assert_called_once_with(self.ENDPOINT, '[{"test": true}]', None)
152152
self.assertEqual(self.consumer._async_buffers[self.ENDPOINT], [self.JSON])
153153

154154
def test_raises_exception_with_bad_endpoint(self):

0 commit comments

Comments
 (0)