Utility function to track a request to the API with the specified URI :param request: (HttpRequest) the request being made
(request)
| 46 | |
| 47 | |
| 48 | def track_request_googleanalytics(request): # type: ignore[no-untyped-def] |
| 49 | """ |
| 50 | Utility function to track a request to the API with the specified URI |
| 51 | |
| 52 | :param request: (HttpRequest) the request being made |
| 53 | """ |
| 54 | pageview_data = DEFAULT_DATA + "t=pageview&dp=" + quote(request.path, safe="") |
| 55 | # send pageview request |
| 56 | requests.post(GOOGLE_ANALYTICS_COLLECT_URL, data=pageview_data) |
| 57 | |
| 58 | resource = get_resource_from_uri(request.path) |
| 59 | |
| 60 | if resource and resource.is_tracked: |
| 61 | environment = Environment.get_from_cache( |
| 62 | request.headers.get("X-Environment-Key") |
| 63 | ) |
| 64 | if environment is None: |
| 65 | return |
| 66 | |
| 67 | track_event(environment.project.organisation.get_unique_slug(), resource) # type: ignore[no-untyped-call] |
| 68 | |
| 69 | |
| 70 | def track_event(category, action, label="", value=""): # type: ignore[no-untyped-def] |
searching dependent graphs…