当前位置: 首页>>代码示例>>Python>>正文


Python EventTracker.delay方法代码示例

本文整理汇总了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)
开发者ID:andela,项目名称:mixpanel-celery,代码行数:9,代码来源:test_tasks.py

示例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)
开发者ID:winhamwr,项目名称:mixpanel-celery,代码行数:10,代码来源:test_tasks.py

示例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
开发者ID:praveenjha527,项目名称:eatio-server,代码行数:47,代码来源:mixpanel_helper.py

示例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)
开发者ID:andela,项目名称:mixpanel-celery,代码行数:8,代码来源:test_tasks.py

示例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)
开发者ID:winhamwr,项目名称:mixpanel-celery,代码行数:7,代码来源:test_tasks.py

示例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)
开发者ID:datafyit,项目名称:mixpanel-celery,代码行数:7,代码来源:test_tasks.py

示例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)
开发者ID:huokedu,项目名称:dynamic-scrapy,代码行数:5,代码来源:analytics_service.py


注:本文中的mixpanel.tasks.EventTracker.delay方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。