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


Python Mixpanel.people_track_charge方法代码示例

本文整理汇总了Python中mixpanel.Mixpanel.people_track_charge方法的典型用法代码示例。如果您正苦于以下问题:Python Mixpanel.people_track_charge方法的具体用法?Python Mixpanel.people_track_charge怎么用?Python Mixpanel.people_track_charge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mixpanel.Mixpanel的用法示例。


在下文中一共展示了Mixpanel.people_track_charge方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: MixpanelOnLawpal

# 需要导入模块: from mixpanel import Mixpanel [as 别名]
# 或者: from mixpanel.Mixpanel import people_track_charge [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: mixpanel_track_charge

# 需要导入模块: from mixpanel import Mixpanel [as 别名]
# 或者: from mixpanel.Mixpanel import people_track_charge [as 别名]
def mixpanel_track_charge(distinct_id, amount):
    if not settings.DEBUG and domain_exclude and distinct_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.people_track_charge(distinct_id, amount, {
        '$time': datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S')
    })
开发者ID:,项目名称:,代码行数:14,代码来源:


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