forked from LBRYCommunity/lbry-sdk
track more events
This commit is contained in:
parent
8afe4d1af8
commit
15e89650ff
3 changed files with 34 additions and 17 deletions
|
@ -15,6 +15,9 @@ DOWNLOAD_STARTED = 'Download Started'
|
||||||
DOWNLOAD_ERRORED = 'Download Errored'
|
DOWNLOAD_ERRORED = 'Download Errored'
|
||||||
DOWNLOAD_FINISHED = 'Download Finished'
|
DOWNLOAD_FINISHED = 'Download Finished'
|
||||||
HEARTBEAT = 'Heartbeat'
|
HEARTBEAT = 'Heartbeat'
|
||||||
|
CLAIM_ACTION = 'Claim Action' # publish/create/update/abandon
|
||||||
|
NEW_CHANNEL = 'New Channel'
|
||||||
|
CREDITS_SENT = 'Credits Sent'
|
||||||
|
|
||||||
BLOB_BYTES_UPLOADED = 'Blob Bytes Uploaded'
|
BLOB_BYTES_UPLOADED = 'Blob Bytes Uploaded'
|
||||||
BLOB_BYTES_AVAILABLE = 'Blob Bytes Available'
|
BLOB_BYTES_AVAILABLE = 'Blob Bytes Available'
|
||||||
|
@ -64,6 +67,15 @@ class Manager(object):
|
||||||
self._event(DOWNLOAD_FINISHED, self._download_properties(id_, name, stream_info))
|
self._event(DOWNLOAD_FINISHED, self._download_properties(id_, name, stream_info))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def send_claim_action(self, action):
|
||||||
|
self.analytics_api.track(self._event(CLAIM_ACTION, {'action': action}))
|
||||||
|
|
||||||
|
def send_new_channel(self):
|
||||||
|
self.analytics_api.track(self._event(NEW_CHANNEL))
|
||||||
|
|
||||||
|
def send_credits_sent(self):
|
||||||
|
self.analytics_api.track(self._event(CREDITS_SENT))
|
||||||
|
|
||||||
def _send_heartbeat(self):
|
def _send_heartbeat(self):
|
||||||
self.analytics_api.track(self._event(HEARTBEAT))
|
self.analytics_api.track(self._event(HEARTBEAT))
|
||||||
|
|
||||||
|
@ -236,7 +248,7 @@ class Api(object):
|
||||||
"""Initialize an instance using values from the configuration"""
|
"""Initialize an instance using values from the configuration"""
|
||||||
session = Session()
|
session = Session()
|
||||||
if enabled is None:
|
if enabled is None:
|
||||||
enabled = conf.settings['share_debug_info']
|
enabled = conf.settings['share_usage_data']
|
||||||
return cls(
|
return cls(
|
||||||
session,
|
session,
|
||||||
conf.settings['ANALYTICS_ENDPOINT'],
|
conf.settings['ANALYTICS_ENDPOINT'],
|
||||||
|
|
|
@ -199,7 +199,7 @@ ADJUSTABLE_SETTINGS = {
|
||||||
'run_on_startup': (bool, False),
|
'run_on_startup': (bool, False),
|
||||||
'run_reflector_server': (bool, False),
|
'run_reflector_server': (bool, False),
|
||||||
'sd_download_timeout': (int, 3),
|
'sd_download_timeout': (int, 3),
|
||||||
'share_debug_info': (bool, True), # whether to share diagnostic info with LBRY
|
'share_usage_data': (bool, True), # whether to share usage stats and diagnostic info with LBRY
|
||||||
'peer_search_timeout': (int, 3),
|
'peer_search_timeout': (int, 3),
|
||||||
'search_servers': (list, ['lighthouse1.lbry.io:50005']),
|
'search_servers': (list, ['lighthouse1.lbry.io:50005']),
|
||||||
'search_timeout': (float, 5.0),
|
'search_timeout': (float, 5.0),
|
||||||
|
@ -392,8 +392,11 @@ class Config(object):
|
||||||
if 'startup_scripts' in settings_dict:
|
if 'startup_scripts' in settings_dict:
|
||||||
del settings_dict['startup_scripts']
|
del settings_dict['startup_scripts']
|
||||||
if 'upload_log' in settings_dict:
|
if 'upload_log' in settings_dict:
|
||||||
settings_dict['share_debug_info'] = settings_dict['upload_log']
|
settings_dict['share_usage_data'] = settings_dict['upload_log']
|
||||||
del settings_dict['upload_log']
|
del settings_dict['upload_log']
|
||||||
|
if 'share_debug_info' in settings_dict:
|
||||||
|
settings_dict['share_usage_data'] = settings_dict['share_debug_info']
|
||||||
|
del settings_dict['share_debug_info']
|
||||||
for key in settings_dict.keys():
|
for key in settings_dict.keys():
|
||||||
if not self._is_valid_setting(key):
|
if not self._is_valid_setting(key):
|
||||||
log.warning('Ignoring invalid conf file setting: %s', key)
|
log.warning('Ignoring invalid conf file setting: %s', key)
|
||||||
|
|
|
@ -441,7 +441,7 @@ class Daemon(AuthJSONRPCServer):
|
||||||
'download_timeout': int,
|
'download_timeout': int,
|
||||||
'search_timeout': float,
|
'search_timeout': float,
|
||||||
'cache_time': int,
|
'cache_time': int,
|
||||||
'share_debug_info': bool,
|
'share_usage_data': bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
def can_update_key(settings, key, setting_type):
|
def can_update_key(settings, key, setting_type):
|
||||||
|
@ -698,6 +698,7 @@ class Daemon(AuthJSONRPCServer):
|
||||||
d = reupload.reflect_stream(publisher.lbry_file)
|
d = reupload.reflect_stream(publisher.lbry_file)
|
||||||
d.addCallbacks(lambda _: log.info("Reflected new publication to lbry://%s", name),
|
d.addCallbacks(lambda _: log.info("Reflected new publication to lbry://%s", name),
|
||||||
log.exception)
|
log.exception)
|
||||||
|
self.analytics_manager.send_claim_action('publish')
|
||||||
log.info("Success! Published to lbry://%s txid: %s nout: %d", name, claim_out['txid'],
|
log.info("Success! Published to lbry://%s txid: %s nout: %d", name, claim_out['txid'],
|
||||||
claim_out['nout'])
|
claim_out['nout'])
|
||||||
defer.returnValue(claim_out)
|
defer.returnValue(claim_out)
|
||||||
|
@ -1710,6 +1711,7 @@ class Daemon(AuthJSONRPCServer):
|
||||||
raise InsufficientFundsError()
|
raise InsufficientFundsError()
|
||||||
|
|
||||||
result = yield self.session.wallet.claim_new_channel(channel_name, amount)
|
result = yield self.session.wallet.claim_new_channel(channel_name, amount)
|
||||||
|
self.analytics_manager.send_new_channel()
|
||||||
log.info("Claimed a new channel! Result: %s", result)
|
log.info("Claimed a new channel! Result: %s", result)
|
||||||
response = yield self._render_response(result)
|
response = yield self._render_response(result)
|
||||||
defer.returnValue(response)
|
defer.returnValue(response)
|
||||||
|
@ -1824,20 +1826,18 @@ class Daemon(AuthJSONRPCServer):
|
||||||
# original format {'currency':{'address','amount'}}
|
# original format {'currency':{'address','amount'}}
|
||||||
# add address to fee if unspecified {'version': ,'currency', 'address' , 'amount'}
|
# add address to fee if unspecified {'version': ,'currency', 'address' , 'amount'}
|
||||||
if 'fee' in metadata:
|
if 'fee' in metadata:
|
||||||
new_fee_dict = {}
|
|
||||||
assert len(metadata['fee']) == 1, "Too many fees"
|
assert len(metadata['fee']) == 1, "Too many fees"
|
||||||
currency, fee_dict = metadata['fee'].items()[0]
|
currency, fee_dict = metadata['fee'].items()[0]
|
||||||
if 'address' not in fee_dict:
|
if 'address' not in fee_dict:
|
||||||
address = yield self.session.wallet.get_new_address()
|
address = yield self.session.wallet.get_new_address()
|
||||||
else:
|
else:
|
||||||
address = fee_dict['address']
|
address = fee_dict['address']
|
||||||
new_fee_dict = {
|
metadata['fee'] = {
|
||||||
'version': '_0_0_1',
|
'version': '_0_0_1',
|
||||||
'currency': currency,
|
'currency': currency,
|
||||||
'address': address,
|
'address': address,
|
||||||
'amount': fee_dict['amount']
|
'amount': fee_dict['amount']
|
||||||
}
|
}
|
||||||
metadata['fee'] = new_fee_dict
|
|
||||||
|
|
||||||
log.info("Publish: %s", {
|
log.info("Publish: %s", {
|
||||||
'name': name,
|
'name': name,
|
||||||
|
@ -1900,6 +1900,7 @@ class Daemon(AuthJSONRPCServer):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
abandon_claim_tx = yield self.session.wallet.abandon_claim(claim_id)
|
abandon_claim_tx = yield self.session.wallet.abandon_claim(claim_id)
|
||||||
|
self.analytics_manager.send_claim_action('abandon')
|
||||||
response = yield self._render_response(abandon_claim_tx)
|
response = yield self._render_response(abandon_claim_tx)
|
||||||
except BaseException as err:
|
except BaseException as err:
|
||||||
log.warning(err)
|
log.warning(err)
|
||||||
|
@ -1913,10 +1914,9 @@ class Daemon(AuthJSONRPCServer):
|
||||||
@AuthJSONRPCServer.auth_required
|
@AuthJSONRPCServer.auth_required
|
||||||
def jsonrpc_abandon_name(self, **kwargs):
|
def jsonrpc_abandon_name(self, **kwargs):
|
||||||
"""
|
"""
|
||||||
DEPRECATED, use abandon_claim
|
DEPRECATED. Use `claim_abandon` instead
|
||||||
"""
|
"""
|
||||||
|
return self.jsonrpc_claim_abandon(**kwargs)
|
||||||
return self.jsonrpc_abandon_claim(**kwargs)
|
|
||||||
|
|
||||||
@AuthJSONRPCServer.auth_required
|
@AuthJSONRPCServer.auth_required
|
||||||
def jsonrpc_support_claim(self, **kwargs):
|
def jsonrpc_support_claim(self, **kwargs):
|
||||||
|
@ -1926,6 +1926,7 @@ class Daemon(AuthJSONRPCServer):
|
||||||
return self.jsonrpc_claim_new_support(**kwargs)
|
return self.jsonrpc_claim_new_support(**kwargs)
|
||||||
|
|
||||||
@AuthJSONRPCServer.auth_required
|
@AuthJSONRPCServer.auth_required
|
||||||
|
@defer.inlineCallbacks
|
||||||
def jsonrpc_claim_new_support(self, name, claim_id, amount):
|
def jsonrpc_claim_new_support(self, name, claim_id, amount):
|
||||||
"""
|
"""
|
||||||
Support a name claim
|
Support a name claim
|
||||||
|
@ -1943,9 +1944,9 @@ class Daemon(AuthJSONRPCServer):
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
d = self.session.wallet.support_claim(name, claim_id, amount)
|
result = yield self.session.wallet.support_claim(name, claim_id, amount)
|
||||||
d.addCallback(lambda r: self._render_response(r))
|
self.analytics_manager.send_claim_action('new_support')
|
||||||
return d
|
defer.returnValue(result)
|
||||||
|
|
||||||
# TODO: merge this into claim_list
|
# TODO: merge this into claim_list
|
||||||
@AuthJSONRPCServer.auth_required
|
@AuthJSONRPCServer.auth_required
|
||||||
|
@ -2203,6 +2204,7 @@ class Daemon(AuthJSONRPCServer):
|
||||||
return d
|
return d
|
||||||
|
|
||||||
@AuthJSONRPCServer.auth_required
|
@AuthJSONRPCServer.auth_required
|
||||||
|
@defer.inlineCallbacks
|
||||||
def jsonrpc_send_amount_to_address(self, amount, address):
|
def jsonrpc_send_amount_to_address(self, amount, address):
|
||||||
"""
|
"""
|
||||||
Send credits to an address
|
Send credits to an address
|
||||||
|
@ -2216,10 +2218,10 @@ class Daemon(AuthJSONRPCServer):
|
||||||
|
|
||||||
reserved_points = self.session.wallet.reserve_points(address, amount)
|
reserved_points = self.session.wallet.reserve_points(address, amount)
|
||||||
if reserved_points is None:
|
if reserved_points is None:
|
||||||
return defer.fail(InsufficientFundsError())
|
raise InsufficientFundsError()
|
||||||
d = self.session.wallet.send_points_to_address(reserved_points, amount)
|
yield self.session.wallet.send_points_to_address(reserved_points, amount)
|
||||||
d.addCallback(lambda _: self._render_response(True))
|
self.analytics_manager.send_credits_sent()
|
||||||
return d
|
defer.returnValue(True)
|
||||||
|
|
||||||
def jsonrpc_get_block(self, **kwargs):
|
def jsonrpc_get_block(self, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Add table
Reference in a new issue