Skip to content

Commit

Permalink
feat: add tracking endpoint and IP address service
Browse files Browse the repository at this point in the history
Introduce a new tracking endpoint in `com_tracardi/endpoint/track.py`
to handle tracking events. Add IP address extraction logic in
`tracardi/service/ip_address.py` to support tracking from reverse proxy
headers. Integrate the tracking endpoint into the application in
`app/main.py`. Update `app/api/track/event_server_endpoint.py` to use
the new IP address service.
  • Loading branch information
atompie committed Sep 19, 2024
1 parent f4b38db commit f79c560
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tracardi/service/ip_address.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from tracardi.config import server


def get_ip_address(request) -> str:

"""
Returns IP address - if address is forwarded from reverse proxy it takes USE_X_FORWARDED_IP env to figure out
where the forwarded ip is stored in headers.
"""

if server.x_forwarded_ip_header is not None and server.x_forwarded_ip_header in request.headers:
return request.headers[server.x_forwarded_ip_header]
return request.client.host

0 comments on commit f79c560

Please sign in to comment.