Ejemplo n.º 1
0
    def test_no_key(self):
        self.service = mixpanel.Mixpanel('my-token')

        # tracking is allowed without setting the api key and api secret
        self.service.track('login')
        data = self.serialize({
            'event': 'login',
            'properties': {
                'token': 'my-token'
            }
        })
        self.expect('track/', {'data': data, 'ip': '0', 'test': '0'}, 'api')

        # but data export methods fail
        exc = mixpanel.InsufficientSettings
        self.assertRaises(exc, self.service.funnels().list)
        self.assertRaises(exc, self.service.export, '2011-01-01', '2012-01-01',
                          ['login', 'logout'])
Ejemplo n.º 2
0
    def setUp(self):
        self.executor = test_executor.use()
        self.executor.set_response(b'1', 200, {})

        self.service = mixpanel.Mixpanel('my-token', 'api-key', 'api-secret')
Ejemplo n.º 3
0
# coding=utf-8
import json
import logging
import sys
import urllib
import urllib2
from base64 import b64encode

from django.conf import settings
from libsaas.services import mixpanel
import IPy

logger = logging.getLogger("mixpanel")

api = mixpanel.Mixpanel(token=settings.MIXPANEL_TOKEN)

__all__ = ['mixpanel_track', 'mixpanel_engage', 'mixpanel_import']


def _mixpanel_anon(request):
    """
    Check if the user is an Anonymous User according to mixpanel, if they are
    it returns their distinct id
    """
    for key, value in request.COOKIES.items():
        if key.startswith("mp") and key.endswith("_mixpanel"):
            try:
                data = json.loads(urllib.unquote(value))
                if 'distinct_id' in data:
                    return data['distinct_id']
            except: