Skip to content

Commit

Permalink
Merge pull request #1791 from gtech-mulearn/dev
Browse files Browse the repository at this point in the history
[FEAT] Add IP address, city, and region tracking to URL analytics
  • Loading branch information
adnankattekaden authored Dec 11, 2023
2 parents ba55746 + 64165f7 commit 8f50b7c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions api/url_shortener/url_shortener_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ def get(self, request, url_id):
devices = {}
sources = {}
countries = {}
dimensions = {}
ip_address = {}
city = {}
region = {}
time_based_data = {'all_time': []}

for query in queryset:
Expand All @@ -160,8 +162,10 @@ def get(self, request, url_id):
query.device_type, 0) + 1
sources[query.referrer] = sources.get(query.referrer, 0) + 1
countries[query.country] = countries.get(query.country, 0) + 1
dimensions[query.device_type] = dimensions.get(
query.device_type, 0) + 1
ip_address[query.ip_address] = ip_address.get(
query.ip_address, 0) + 1
city[query.city] = city.get(query.city, 0) + 1
region[query.region] = region.get(query.region, 0) + 1

# Create a list of time-based data
time_based_data['all_time'].append([
Expand All @@ -177,8 +181,10 @@ def get(self, request, url_id):
'platforms': platforms,
'devices': devices,
'sources': sources,
'ip_address': ip_address,
'city': city,
'region': region,
'countries': countries,
'dimensions': dimensions,
'time_based_data': time_based_data,
'long_url': url_shortener.long_url,
'short_url': url_shortener.short_url,
Expand Down

0 comments on commit 8f50b7c

Please sign in to comment.