Add resolved IP information to track_and_log
This commit is contained in:
parent
010dda2c52
commit
52927de7f6
2 changed files with 29 additions and 8 deletions
|
@ -5,7 +5,7 @@ from urlparse import urlparse
|
|||
|
||||
from flask import request
|
||||
|
||||
from app import analytics, userevents
|
||||
from app import analytics, userevents, ip_resolver
|
||||
from data import model
|
||||
from auth.registry_jwt_auth import get_granted_entity
|
||||
from auth.auth_context import (get_authenticated_user, get_validated_token,
|
||||
|
@ -85,6 +85,11 @@ def track_and_log(event_name, repo_obj, analytics_name=None, analytics_sample=1,
|
|||
|
||||
analytics.track(analytics_id, analytics_name, extra_params)
|
||||
|
||||
# Add the resolved information to the metadata.
|
||||
resolved_ip = ip_resolver.resolve_ip(request.remote_addr)
|
||||
if resolved_ip is not None:
|
||||
metadata['resolved_ip'] = resolved_ip._asdict()
|
||||
|
||||
# Log the action to the database.
|
||||
logger.debug('Logging the %s to logs system', event_name)
|
||||
model.log.log_action(event_name, namespace_name, performer=authenticated_user,
|
||||
|
|
Reference in a new issue