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

Function get_resource_from_uri

api/app_analytics/track.py:31–45  ·  view source on GitHub ↗

Split the uri so we can determine the resource that is being requested (note that because it starts with a /, the first item in the list will be a blank string) :param request_uri: (str) django.http.HttpRequest.path

(request_uri: str)

Source from the content-addressed store, hash-verified

29
30
31def get_resource_from_uri(request_uri: str) -> Resource | None:
32 """
33 Split the uri so we can determine the resource that is being requested
34 (note that because it starts with a /, the first item in the list will be a blank string)
35
36 :param request_uri: (str) django.http.HttpRequest.path
37 """
38 split_uri = request_uri.split("/")[1:]
39 if not (len(split_uri) >= 3 and split_uri[0] == "api"):
40 logger.debug("not tracking event for uri %s" % request_uri)
41 # this isn't an API request so we don't need to track an event for it
42 return None
43
44 # uri will be in the form /api/v1/<resource>/...
45 return Resource.get_from_name(split_uri[2])
46
47
48def track_request_googleanalytics(request): # type: ignore[no-untyped-def]

Callers 2

__call__Method · 0.85

Calls 1

get_from_nameMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…