add analytics_id, remove session_id and stop sending installation id

This commit is contained in:
Victor Shyba 2021-06-28 00:21:28 -03:00
parent 115034fccb
commit 6495694ac8
3 changed files with 7 additions and 16 deletions

View file

@ -32,11 +32,9 @@ TIME_TO_FIRST_BYTES = "Time To First Bytes"
log = logging.getLogger(__name__)
def _event_properties(installation_id: str, session_id: str,
event_properties: typing.Optional[typing.Dict]) -> typing.Dict:
def _event_properties(analytics_id: str, event_properties: typing.Optional[typing.Dict]) -> typing.Dict:
properties = {
'lbry_id': installation_id,
'session_id': session_id,
'analytics_id': analytics_id
}
properties.update(event_properties or {})
return properties
@ -105,15 +103,14 @@ def _make_context(platform):
class AnalyticsManager:
def __init__(self, conf: Config, installation_id: str, session_id: str):
def __init__(self, conf: Config):
self.conf = conf
self.cookies = {}
self.url = ANALYTICS_ENDPOINT
self._write_key = utils.deobfuscate(ANALYTICS_TOKEN)
self._tracked_data = collections.defaultdict(list)
self.context = _make_context(system_info.get_platform())
self.installation_id = installation_id
self.session_id = session_id
self.analytics_id = utils.generate_id().hex()
self.task: typing.Optional[asyncio.Task] = None
self.external_ip: typing.Optional[str] = None
@ -227,7 +224,7 @@ class AnalyticsManager:
return {
'userId': 'lbry',
'event': event,
'properties': _event_properties(self.installation_id, self.session_id, properties),
'properties': _event_properties(self.analytics_id, properties),
'context': self.context,
'timestamp': utils.isonow()
}

View file

@ -325,8 +325,7 @@ class Daemon(metaclass=JSONRPCServerType):
self._video_file_analyzer = VideoFileAnalyzer(conf)
self._node_id = None
self._installation_id = None
self.session_id = base58.b58encode(utils.generate_id()).decode()
self.analytics_manager = analytics.AnalyticsManager(conf, self.installation_id, self.session_id)
self.analytics_manager = analytics.AnalyticsManager(conf)
self.component_manager = component_manager or ComponentManager(
conf, analytics_manager=self.analytics_manager,
skip_components=conf.components_to_skip or []

View file

@ -9,7 +9,6 @@ from decimal import Decimal
from lbry.file.file_manager import FileManager
from tests.unit.blob_exchange.test_transfer_blob import BlobExchangeTestBase
from lbry.testcase import get_fake_exchange_rate_manager
from lbry.utils import generate_id
from lbry.error import InsufficientFundsError
from lbry.error import KeyFeeAboveMaxAllowedError, ResolveError, DownloadSDTimeoutError, DownloadDataTimeoutError
from lbry.wallet import WalletManager, Wallet, Ledger, Transaction, Input, Output, Database
@ -140,11 +139,7 @@ class TestStreamManager(BlobExchangeTestBase):
self.sd_hash = descriptor.sd_hash
self.mock_wallet, self.uri = await get_mock_wallet(self.sd_hash, self.client_storage, self.client_wallet_dir,
balance, fee)
analytics_manager = AnalyticsManager(
self.client_config,
binascii.hexlify(generate_id()).decode(),
binascii.hexlify(generate_id()).decode()
)
analytics_manager = AnalyticsManager(self.client_config)
self.stream_manager = StreamManager(
self.loop, self.client_config, self.client_blob_manager, self.mock_wallet,
self.client_storage, get_mock_node(self.server_from_client),