MCPcopy Create free account
hub / github.com/Flagsmith/flagsmith / track_request_googleanalytics

Function track_request_googleanalytics

api/app_analytics/track.py:48–67  ·  view source on GitHub ↗

Utility function to track a request to the API with the specified URI :param request: (HttpRequest) the request being made

(request)

Source from the content-addressed store, hash-verified

46
47
48def 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
70def track_event(category, action, label="", value=""): # type: ignore[no-untyped-def]

Calls 6

get_resource_from_uriFunction · 0.85
track_eventFunction · 0.85
get_from_cacheMethod · 0.80
get_unique_slugMethod · 0.80
postMethod · 0.45
getMethod · 0.45

Used in the wild real call sites across dependent graphs

searching dependent graphs…