1
1
2
- VERSION = '0.3.2 '
2
+ VERSION = '0.3.3 '
3
3
4
4
import sys
5
5
6
6
try :
7
7
import requests
8
8
except ImportError :
9
- print >> sys .stderr , 'analytics-node requires that you have a Python "requests" library installed. Try running "pip install requests"'
9
+ print >> sys .stderr , 'analytics-python requires that you have a Python "requests" library installed. Try running "pip install requests"'
10
+
11
+ import sys
12
+ this_module = sys .modules [__name__ ]
10
13
11
14
from stats import Statistics
12
15
stats = Statistics ()
13
16
14
17
from client import Client
15
18
19
+ methods = ['identify' , 'track' , 'flush' , 'on_success' , 'on_failure' ]
20
+
21
+
22
+ def uninitialized (* args , ** kwargs ):
23
+ print >> sys .stderr , 'Please call analytics.init(secret) before calling analytics methods.'
24
+
25
+ for method in methods :
26
+ setattr (this_module , method , uninitialized )
27
+
16
28
17
29
def init (secret , ** kwargs ):
18
30
"""Create a default instance of a analytics-python client
@@ -35,8 +47,7 @@ def init(secret, **kwargs):
35
47
36
48
"""
37
49
38
- import sys
39
- this_module = sys .modules [__name__ ]
50
+ # if we have already initialized, no-op
40
51
if hasattr (this_module , 'default_client' ):
41
52
return
42
53
@@ -51,6 +62,5 @@ def proxy_to_default_client(*args, **kwargs):
51
62
52
63
setattr (this_module , method , proxy_to_default_client )
53
64
54
- methods = ['identify' , 'track' , 'flush' , 'on_success' , 'on_failure' ]
55
65
for method in methods :
56
66
proxy (method )
0 commit comments