MCPcopy Create free account
hub / github.com/diffgram/diffgram / send_to_eventhub

Method send_to_eventhub

shared/database/event/event.py:333–360  ·  view source on GitHub ↗

Sends the current event to Diffgram's EventHub for anonymous data tracking. :return:

(self)

Source from the content-addressed store, hash-verified

331
332
333 def send_to_eventhub(self):
334 """
335 Sends the current event to Diffgram's EventHub for anonymous data tracking.
336 :return:
337 """
338 from shared.settings import settings
339 EXCLUDED_EVENTHUB_TRACKING_EVENTS = ['user_visit']
340 if settings.DIFFGRAM_SYSTEM_MODE in ['testing', 'testing_e2e']:
341 return
342
343 if settings.DIFFGRAM_SYSTEM_MODE in ['sandbox'] and self.kind in EXCLUDED_EVENTHUB_TRACKING_EVENTS:
344 return
345
346 if settings.ALLOW_EVENTHUB is False:
347 return
348
349 try:
350 event_data = self.serialize()
351 event_data['event_type'] = 'user'
352 event_data['install_fingerprint'] = settings.DIFFGRAM_INSTALL_FINGERPRINT
353 result = requests.post(settings.EVENTHUB_URL, json = event_data, timeout = 3)
354 if result.status_code == 200:
355 logger.debug(f"Sent event: {self.id} to Diffgram Eventhub")
356 else:
357 logger.error(
358 f"Error sending ID: {self.id} to Eventhub. Status Code: {result.status_code}. result.text: {result.text}")
359 except Exception as e:
360 logger.error(f"Exception sending {str(e)} to Diffgram Eventhub: ")
361
362 @staticmethod
363 def identify_user(user):

Callers 1

test_send_to_eventhubMethod · 0.45

Calls 1

serializeMethod · 0.95

Tested by 1

test_send_to_eventhubMethod · 0.36