當前位置: 首頁>>代碼示例>>Python>>正文


Python Mixpanel.alias方法代碼示例

本文整理匯總了Python中mixpanel.Mixpanel.alias方法的典型用法代碼示例。如果您正苦於以下問題:Python Mixpanel.alias方法的具體用法?Python Mixpanel.alias怎麽用?Python Mixpanel.alias使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在mixpanel.Mixpanel的用法示例。


在下文中一共展示了Mixpanel.alias方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: MixpanelOnLawpal

# 需要導入模塊: from mixpanel import Mixpanel [as 別名]
# 或者: from mixpanel.Mixpanel import alias [as 別名]
class MixpanelOnLawpal(object):
    token = None
    service = None
    def __init__(self, *args, **kwargs):
        self.token = kwargs.get('token', MIXPANEL_SETTINGS.get('token', None))
        if self.token is not None:
            self.service = Mixpanel(self.token)

    def mixpanel_alias(self, alias_id, original, **kwargs):
        if self.service is not None:
            try:
                self.service.alias(alias_id=alias_id, original=original, **kwargs)
            except Exception as e:
                logger.error('Mixpanel error: distinct_id, missing or empty: %s :%s' % (alias_id, e))

    def mixpanel_track_charge(self, user, amount, time, distinct_id=None, **kwargs):
        if self.service is not None:
            if distinct_id is None:
                distinct_id = user.pk
            try:
                self.service.people_track_charge(distinct_id=distinct_id, amount=amount, properties={ '$time': time })
            except Exception as e:
                logger.error('Mixpanel error: %s' % e)

    def event(self, key, user, distinct_id=None, **kwargs):
        if self.service is not None:
            if distinct_id is None:
                distinct_id = user.pk

            user_profile = user.profile
            all_properties = {
                'account_type': user_profile.account_type,
                'plan': user_profile.plan,
                'plan_interval': user_profile.plan_interval,
                'user': user.get_full_name(),
                'user_type': user_profile.type,
                'via': 'web'
            }
            all_properties.update(kwargs)
            try:
                self.service.track(distinct_id=distinct_id, event_name=key, properties=all_properties)
            except Exception as e:
                logger.error('Mixpanel error: %s' % e)

    def anon_event(self, key, distinct_id, **kwargs):
        if self.service is not None:

            all_properties = {
                'user_id': distinct_id,
                'account_type': 'anonymous',
                'via': 'web'
            }
            all_properties.update(kwargs)
            try:
                self.service.track(distinct_id=distinct_id, event_name=key, properties=all_properties)
            except Exception as e:
                logger.error('Mixpanel error: %s' % e)
開發者ID:rosscdh,項目名稱:toolkit,代碼行數:59,代碼來源:analytics.py

示例2: test_alias

# 需要導入模塊: from mixpanel import Mixpanel [as 別名]
# 或者: from mixpanel.Mixpanel import alias [as 別名]
 def test_alias(self):
     token = '12345'
     mp = Mixpanel(token)
     mock_response = Mock()
     mock_response.read.return_value = '1'
     with patch('urllib2.urlopen', return_value = mock_response) as mock_urlopen:
         mp.alias('amq','3680')
     data = mp._prepare_data({'event': '$create_alias', 'properties': {'distinct_id': '3680', 'alias': 'amq', 'token': '12345'}})
     mock_urlopen.assert_called_once_with(self.engage_request_url, data)
開發者ID:daemonburrito,項目名稱:mixpanel-python,代碼行數:11,代碼來源:test.py

示例3: mixpanel_alias

# 需要導入模塊: from mixpanel import Mixpanel [as 別名]
# 或者: from mixpanel.Mixpanel import alias [as 別名]
def mixpanel_alias(new_id, old_id):
    if not settings.DEBUG and domain_exclude and new_id.endswith(domain_exclude):
        return

    id = settings.METRICS.get('mixpanel', {}).get('id')
    if not id:
        logger.info('Mixpanel id not defined, task ignored')
        return
    mp = Mixpanel(id)
    mp.alias(new_id, old_id)
開發者ID:,項目名稱:,代碼行數:12,代碼來源:


注:本文中的mixpanel.Mixpanel.alias方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。