CustomerMetricsApi.md#get_mau_by_category
Michael-Dougherty opened this issue · 5 comments
I am trying to get metrics from LD using CustomerMetricsApi.md#get_mau_by_category. After the call the results are just 7 and only have the Date.
_0 0 Date 2021-07-10 00:00:00
_0 0 Date 2021-07-11 00:00:00
_0 0 Date 2021-07-12 00:00:00
_0 0 Date 2021-07-13 00:00:00
_0 0 Date 2021-07-14 00:00:00
_0 0 Date 2021-07-15 00:00:00
_0 0 Date 2021-07-16 00:00:00
This doesn’t appear to be working.
I also tried the get_mau this returns results but only for 7 days like above and they don’t appear to be what I am expecting.
'_0 1751990 Date 2021-07-10 00:00:00'
'_0 1799994 Date 2021-07-11 00:00:00'
'_0 1844373 Date 2021-07-12 00:00:00'
'_0 1902216 Date 2021-07-13 00:00:00'
'_0 1954580 Date 2021-07-14 00:00:00'
'_0 2005653 Date 2021-07-15 00:00:00'
'_0 2058751 Date 2021-07-16 00:00:00'
How do I get MAU for the client and server?
Mike
We're updating the default from 7 to 30 days that is reflected in the documentation. You can also change the date range using to and from parameters.
#get_mau_by_category is a legacy endpoint that does not have recent data, and you should exclusively use #get_mau which does appear to return data. Can you elaborate on any other differences you're seeing besides the 7/30 day difference?
Thank you for getting back to me. I tired setting the from and to dates using the python api and calling the end point directly but maybe I am not passing the param correctly because I get the error . "Exception has occurred: TypeError
get_mau() takes 1 positional argument but 3 were given"
Snippet of my code:
# Get monthly active user data by category.
api_instance.api_client.set_default_header("LD-API-Version", "beta")
#api_response = api_instance.get_mau_by_category()
base_datetime = datetime.datetime( 1970, 1, 1 )
# Get monthly active user data.
From = datetime.datetime.today() - timedelta(days=30)
api_response = api_instance.get_mau(From, datetime.datetime.today())
I get this exception
Exception has occurred: TypeError
get_mau() takes 1 positional argument but 3 were given
I also tried calling the end point directly but still only get 7 days.
Code Snippet:
url = "https://app.launchdarkly.com/api/v2/usage/mau"
headers = {
"Accept": "application/json",
"LD-API-Version": "beta",
"Authorization": apiKey
}
fromDate = datetime.datetime.today() - timedelta(days=30)
toDate = datetime.datetime.today()
# defining a params dict for the parameters to be sent to the API
PARAMS = {'from':fromDate,
'to':toDate
}
response = requests.request("GET", url, headers=headers, params=PARAMS)
Any suggestions would be helpful.
We plan to release an update soon that will enable those parameters. Until then you could use requests similar to your example with a couple of tweaks.
today = datetime.today()
params = {
"from": int((today - timedelta(days=30)).timestamp() * 1000), # these need to be in unix milliseconds
"to": int(today.timestamp() * 1000),
}
response = requests.get(url, headers=headers, params=params) // #get takes a dict of params
Hope that helps.
We have released a new version of this client where your original issue with the get_mau should be fixed. Please feel free to re-open this issue if you continue to have problems. Thank you.