def _send_new_download_stats(self, action, download_id, name, claim_dict, e=None): self.analytics_api.track({ 'userId': 'lbry', # required, see https://segment.com/docs/sources/server/http/#track 'event': NEW_DOWNLOAD_STAT, 'properties': self._event_properties({ 'download_id': download_id, 'name': name, 'sd_hash': None if not claim_dict else claim_dict.source_hash.decode(), 'action': action, 'error': e, }), 'context': self.context, 'timestamp': utils.isonow(), })
def _event(self, event, event_properties=None): return { 'userId': 'lbry', 'event': event, 'properties': self._event_properties(event_properties), 'context': self.context, 'timestamp': utils.isonow() }
def makeEvent(stats): return { 'userId': 'lbry', 'event': 'Content Availability', 'properties': { 'total_published': stats['sd_hash'], 'sd_blob_available_on_dht': stats['is_available'], 'sd_blob_available_for_download': stats['sd_blob'], }, 'context': { 'app': { 'name': 'Availability Tracker', 'version': 1, }, 'library': { 'name': 'lbrynet-analytics', 'version': '1.0.0' }, }, 'timestamp': utils.isonow() }