11import functools
22import json
33import os
4+ import platform
45import sys
56import typing
67from inspect import signature
@@ -33,7 +34,7 @@ def __init__(self, token: TokenStr = None, config_path: str = None):
3334 if token :
3435 config = ConfigEntity (SA_TOKEN = token )
3536 elif config_path :
36- config_path = Path (config_path )
37+ config_path = Path (config_path ). expanduser ()
3738 if not Path (config_path ).is_file () or not os .access (
3839 config_path , os .R_OK
3940 ):
@@ -124,10 +125,10 @@ def _retrieve_configs_from_env() -> typing.Union[ConfigEntity, None]:
124125class Tracker :
125126 def get_mp_instance (self ) -> Mixpanel :
126127 client = self .get_client ()
127- mp_token = "ca95ed96f80e8ec3be791e2d3097cf51"
128- if client :
129- if client . host != constants . BACKEND_URL :
130- mp_token = "e741d4863e7e05b1a45833d01865ef0d"
128+ if client . controller . _config . API_URL == constants . BACKEND_URL : # noqa
129+ mp_token = "ca95ed96f80e8ec3be791e2d3097cf51"
130+ else :
131+ mp_token = "e741d4863e7e05b1a45833d01865ef0d"
131132 return Mixpanel (mp_token )
132133
133134 @staticmethod
@@ -137,6 +138,8 @@ def get_default_payload(team_name, user_id):
137138 "Team" : team_name ,
138139 "Team Owner" : user_id ,
139140 "Version" : __version__ ,
141+ "Python version" : platform .python_version (),
142+ "Python interpreter type" : platform .python_implementation (),
140143 }
141144
142145 def __init__ (self , function ):
@@ -170,6 +173,10 @@ def default_parser(function_name: str, kwargs: dict) -> tuple:
170173 for key , value in kwargs .items ():
171174 if key == "self" :
172175 continue
176+ elif key == "token" :
177+ properties ["sa_token" ] = str (bool (value ))
178+ elif key == "config_path" :
179+ properties [key ] = str (bool (value ))
173180 elif value is None :
174181 properties [key ] = value
175182 elif key == "project" :
@@ -241,5 +248,6 @@ def __new__(mcs, name, bases, attrs):
241248 attr_value , FunctionType
242249 ) and not attr_value .__name__ .startswith ("_" ):
243250 attrs [attr_name ] = Tracker (validate_arguments (attr_value ))
251+ attrs ["__init__" ] = Tracker (validate_arguments (attrs ["__init__" ]))
244252 tmp = super ().__new__ (mcs , name , bases , attrs )
245253 return tmp
0 commit comments