get_metric_usage
async
¶
get_metric_usage(
app_id: AppId,
user_id: UserId,
started_at: Timestamp,
ended_at: Timestamp,
scope: RequestScope,
*,
config_overrides: Optional[AsyncAppMonetizationClientConfig] = None,
max_results: Optional[GetMetricUsageMaxResults] = None,
next_token: Optional[NextToken] = None,
) -> GetMetricUsageResponse
Returns a user's raw per-metric usage over a caller-supplied window. Usage is aggregated by event time with each metric's aggregation function: summed or counted, or the largest value for a MAX metric, in the environment the scope selects (the live app or its sandbox). It returns usage only: it does not resolve the user's plan, apply quota, or attribute usage to a plan. Combine it with GetSubscriptionHistory to compute charges for each plan the user was on, or compare it against a plan's allowance to make an entitlement decision. Usage is read at hour resolution: startedAt is floored to its hour and endedAt is rounded up to the next hour boundary, so the window read can be wider than the requested one. Paginated over the app's metric set: one page of per-metric usage per call, continued with nextToken. The window is fixed across a pagination sequence.
Parameters:
-
app_id(AppId) –The ID of the app.
-
user_id(UserId) –The end user whose usage is read. Do not include personally identifiable or otherwise sensitive data in this value.
-
started_at(Timestamp) –Inclusive start of the reporting window (half-open [startedAt, endedAt)).
-
ended_at(Timestamp) –Exclusive end of the reporting window. Must be after startedAt; the window may span at most 744 hours (31 days, the longest monthly billing period). Must not be in the future beyond a small clock-skew allowance.
-
scope(RequestScope) –Required. The environment: live or sandbox. sandbox reads the app's isolated test environment. Usage is kept separately per environment.
-
max_results(Optional[GetMetricUsageMaxResults], default:None) –Maximum number of per-metric usage entries to return in this page (1-25, default 25).
-
next_token(Optional[NextToken], default:None) –Opaque continuation token from a prior response. The window (startedAt/endedAt) must be unchanged across a pagination sequence.
Raises:
-
AccessDeniedException–The caller does not have sufficient permission to perform this action.
-
InternalServerException–An unexpected error occurred while processing the request.
-
ResourceNotFoundException–The referenced resource does not exist.
-
ThrottlingException–The request was denied due to request throttling.
-
ValidationException–The request failed input validation.
-
UnknownServiceError–The service returned an error code this client does not model.
Source code in docs_src/capo_appmonetization/_services/async_app_monetization.py
1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 | |