Sample pull_repo events
This commit is contained in:
parent
68deff0e24
commit
a8183ed87b
2 changed files with 8 additions and 4 deletions
|
@ -1,4 +1,5 @@
|
|||
import logging
|
||||
import random
|
||||
|
||||
from app import analytics, app, userevents
|
||||
from data import model
|
||||
|
@ -7,7 +8,7 @@ from auth.auth_context import get_authenticated_user, get_validated_token, get_v
|
|||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
def track_and_log(event_name, repo, **kwargs):
|
||||
def track_and_log(event_name, repo, analytics_name=None, analytics_sample=1, **kwargs):
|
||||
repository = repo.name
|
||||
namespace = repo.namespace_user.username
|
||||
metadata = {
|
||||
|
@ -62,8 +63,11 @@ def track_and_log(event_name, repo, **kwargs):
|
|||
event.publish_event_data('docker-cli', user_event_data)
|
||||
|
||||
# Save the action to mixpanel.
|
||||
logger.debug('Logging the %s to Mixpanel', event_name)
|
||||
analytics.track(analytics_id, event_name, extra_params)
|
||||
if random.random() < analytics_sample:
|
||||
if analytics_name is None:
|
||||
analytics_name = event_name
|
||||
logger.debug('Logging the %s to Mixpanel', analytics_name)
|
||||
analytics.track(analytics_id, analytics_name, extra_params)
|
||||
|
||||
# Log the action to the database.
|
||||
logger.debug('Logging the %s to logs system', event_name)
|
||||
|
|
Reference in a new issue