本文整理汇总了Python中mixpanel.tasks.EventTracker.run方法的典型用法代码示例。如果您正苦于以下问题:Python EventTracker.run方法的具体用法?Python EventTracker.run怎么用?Python EventTracker.run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mixpanel.tasks.EventTracker
的用法示例。
在下文中一共展示了EventTracker.run方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_old_run
# 需要导入模块: from mixpanel.tasks import EventTracker [as 别名]
# 或者: from mixpanel.tasks.EventTracker import run [as 别名]
def test_old_run(self):
"""non-recorded events should return False"""
et = EventTracker()
# Times older than 3 hours don't get recorded according to: http://mixpanel.com/api/docs/specification
# equests will be rejected that are 3 hours older than present time
result = et.run('event_foo', {'time': 1245613885})
self.assertFalse(result)
示例2: test_non_recorded
# 需要导入模块: from mixpanel.tasks import EventTracker [as 别名]
# 或者: from mixpanel.tasks.EventTracker import run [as 别名]
def test_non_recorded(self):
"""non-recorded events should return False"""
self.response.read.return_value = '0'
et = EventTracker()
# Times older than 3 hours don't get recorded according to:
# http://mixpanel.com/api/docs/specification
# requests will be rejected that are 3 hours older than present time
# (though actually this is returnin False because of mocking network)
result = et.run('event_foo', {'time': 1245613885})
self.assertFalse(result)
示例3: test_debug_logger
# 需要导入模块: from mixpanel.tasks import EventTracker [as 别名]
# 或者: from mixpanel.tasks.EventTracker import run [as 别名]
def test_debug_logger(self):
et = EventTracker()
result = et.run('event_foo', {}, loglevel=logging.DEBUG)
self.assertTrue(result)
示例4: test_run
# 需要导入模块: from mixpanel.tasks import EventTracker [as 别名]
# 或者: from mixpanel.tasks.EventTracker import run [as 别名]
def test_run(self):
# "correct" result obtained from: http://mixpanel.com/api/docs/console
et = EventTracker()
result = et.run('event_foo', {})
self.assertTrue(result)
示例5: EventTracker
# 需要导入模块: from mixpanel.tasks import EventTracker [as 别名]
# 或者: from mixpanel.tasks.EventTracker import run [as 别名]
from guelphapi.api.utils.log import get_data
from tastypie.resources import Resource, ModelResource
from mixpanel.tasks import EventTracker
tracker = EventTracker()
track_event = lambda *a, **kw: tracker.run(*a, **kw)
class LoggingResource(Resource):
def dispatch(self, request_type, request, **kwargs):
# Let the "real" dispatch do its thing.
# This includes checking a throttle, authentication, authorization, etc
response = super(LoggingResource, self).dispatch(request_type, request, **kwargs)
# Only log "good" requests for now
# We know once we're down here, that things are fine
data = get_data(request_type, request, kwargs)
track_event('request-%s' % request.META.get('REQUEST_METHOD', request_type), data)
return response
class LoggingModelResource(ModelResource):
def dispatch(self, request_type, request, **kwargs):
# Let the "real" dispatch do its thing.
# This includes checking a throttle, authentication, authorization, etc.
response = super(LoggingModelResource, self).dispatch(request_type, request, **kwargs)
# Only log "good" requests for now
# We know once we're down here, that things are fine
data = get_data(request_type, request, kwargs)
track_event('request-%s' % request.META.get('REQUEST_METHOD', request_type), data)
return response
示例6: index
# 需要导入模块: from mixpanel.tasks import EventTracker [as 别名]
# 或者: from mixpanel.tasks.EventTracker import run [as 别名]
def index(request):
et = EventTracker()
et.run('dj_event', {'distinct_id': 1}, token=settings.token )
return HttpResponse("Hello, world!.")