Skip to content

Commit 4367f6c

Browse files
committed
Include IP address when sending analytics
1 parent 5620e29 commit 4367f6c

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

app/analytics.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ def post(event_id):
5050
return
5151

5252
actor_id = os.environ["GITHUB_ACTOR_ID"]
53-
referrer = os.environ["GITHUB_SERVER_URL"]
53+
referrer = (
54+
os.environ["GITHUB_SERVER_URL"] + "/" + os.environ["GITHUB_REPOSITORY_OWNER"]
55+
)
56+
ip_address = requests.get("https://ifconfig.me", timeout=5).text
5457

5558
response = requests.post(
5659
"https://plausible.io/api/event",
@@ -65,6 +68,7 @@ def post(event_id):
6568
},
6669
headers={
6770
"User-Agent": f"kiwitcms-gitops/{__version__}.{actor_id}",
71+
"X-Forwarded-For": ip_address,
6872
"Content-Type": "application/json",
6973
},
7074
timeout=10,

0 commit comments

Comments
 (0)