本文整理汇总了Python中mixpanel.tasks.EventTracker.delay方法的典型用法代码示例。如果您正苦于以下问题:Python EventTracker.delay方法的具体用法?Python EventTracker.delay怎么用?Python EventTracker.delay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mixpanel.tasks.EventTracker
的用法示例。
在下文中一共展示了EventTracker.delay方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_failed_request
# 需要导入模块: from mixpanel.tasks import EventTracker [as 别名]
# 或者: from mixpanel.tasks.EventTracker import delay [as 别名]
def test_failed_request(self):
EventTracker.endpoint = 'brokenurl'
with eager_tasks():
result = EventTracker.delay('event_foo')
self.assertNotEqual(result.traceback, None)
示例2: test_failed_socket_request
# 需要导入模块: from mixpanel.tasks import EventTracker [as 别名]
# 或者: from mixpanel.tasks.EventTracker import delay [as 别名]
def test_failed_socket_request(self):
def new_read(*args, **kwargs):
raise socket.error('BOOM')
self.response.read = new_read
with eager_tasks():
result = EventTracker.delay('event_foo')
self.assertNotEqual(result.traceback, None)
示例3: send_mixpanel_event
# 需要导入模块: from mixpanel.tasks import EventTracker [as 别名]
# 或者: from mixpanel.tasks.EventTracker import delay [as 别名]
def send_mixpanel_event(event_name, user, event_dict=None):
"""
Helper function that takes from various views an event name, an event_dict and an user and populates the event dict with
a) distinct_id of the user with key 'distinct_id'
b) 'username' = user.firstname + user.lastname
c) 'age' = in years, today - DOB
d) 'gender' = user.gender
e) total em
f) redeemable em
g) time on earthmiles = today - joining date
and then calls EventTracker.delay() with the modified dictionary
"""
from dateutil.relativedelta import relativedelta
from datetime import datetime, date
if event_dict == None:
event_dict = {}
try:
age = relativedelta(datetime.today(), user.age, ).years
days_on_em = (datetime.today() - user.date_joined.replace(tzinfo=None)).days
event_dict.update(
{
'distinct_id': user.id,
'Username': user.__str__(),
'Age': age,
'Gender': user.gender,
'Days on Earthmiles': days_on_em,
'Total Earthmiles': user.total_earthmiles,
'Redeemable Earthmiles': user.redeemable_earthmiles,
}
)
except AttributeError as e:
event_dict.update(
{
'distinct_id': user.id,
}
)
#Try to send event to mixpanel. If there is an error, it could be because we're testing on localhost, in which case, pass, else raise the error
try:
EventTracker.delay(event_name, event_dict)
except ConnectionError as e:
if 'localhost' not in str(e):
raise
示例4: test_failed_socket_request
# 需要导入模块: from mixpanel.tasks import EventTracker [as 别名]
# 或者: from mixpanel.tasks.EventTracker import delay [as 别名]
def test_failed_socket_request(self):
mp_settings.MIXPANEL_API_SERVER = '127.0.0.1:60000'
with eager_tasks():
result = EventTracker.delay('event_foo')
self.assertNotEqual(result.traceback, None)
示例5: test_failed_request
# 需要导入模块: from mixpanel.tasks import EventTracker [as 别名]
# 或者: from mixpanel.tasks.EventTracker import delay [as 别名]
def test_failed_request(self):
self.response.status = 400
with eager_tasks():
result = EventTracker.delay('event_foo')
self.assertNotEqual(result.traceback, None)
示例6: test_failed_socket_request
# 需要导入模块: from mixpanel.tasks import EventTracker [as 别名]
# 或者: from mixpanel.tasks.EventTracker import delay [as 别名]
def test_failed_socket_request(self):
self.response.read = Mock(side_effect=socket.error('BOOM'))
with eager_tasks():
result = EventTracker.delay('event_foo')
self.assertNotEqual(result.traceback, None)
示例7: send_event
# 需要导入模块: from mixpanel.tasks import EventTracker [as 别名]
# 或者: from mixpanel.tasks.EventTracker import delay [as 别名]
def send_event(event_name, **kwargs):
if not event_name: raise ValueError("event name is required")
EventTracker.delay(event_name, **kwargs)