launchdarkly / api-client-python

LaunchDarkly API Client for Python
Other
5 stars 8 forks source link

CustomerMetricsApi.md#get_mau_by_category #5

Closed Michael-Dougherty closed 2 years ago

Michael-Dougherty commented 3 years ago

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

dbolson commented 2 years ago

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?

Michael-Dougherty commented 2 years ago

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.

dbolson commented 2 years ago

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.

Michael-Dougherty commented 2 years ago

Thank you it does. Mike

Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10

From: Danny @.> Sent: Friday, August 6, 2021 7:21 PM To: @.> Cc: Michael @.>; @.> Subject: Re: [launchdarkly/api-client-python] CustomerMetricsApi.md#get_mau_by_category (#5)

WARNING: This email originated from outside of the organization. DO NOT click links, open attachments, or respond unless you recognize the sender and know the content is safe.

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.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https:/github.com/launchdarkly/api-client-python/issues/5*issuecomment-894560688__;Iw!!F1Q1IbZmrAg!W8YuIk-FhAB12c0G1cfaRrqv3gvL-pL-hMhgzxhDJ51ySzCQ3ukrK1WmadVZQIIRxfjSP7I$, or unsubscribehttps://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/ALXMTURPTJVQGTO4JVWVERTT3RT2RANCNFSM5AQG4LEA__;!!F1Q1IbZmrAg!W8YuIk-FhAB12c0G1cfaRrqv3gvL-pL-hMhgzxhDJ51ySzCQ3ukrK1WmadVZQIIRjjHZv7M$. Triage notifications on the go with GitHub Mobile for iOShttps://urldefense.com/v3/__https:/apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675__;!!F1Q1IbZmrAg!W8YuIk-FhAB12c0G1cfaRrqv3gvL-pL-hMhgzxhDJ51ySzCQ3ukrK1WmadVZQIIRfV_0X-k$ or Androidhttps://urldefense.com/v3/__https:/play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email__;!!F1Q1IbZmrAg!W8YuIk-FhAB12c0G1cfaRrqv3gvL-pL-hMhgzxhDJ51ySzCQ3ukrK1WmadVZQIIRAJtdzzI$.


This email, including any attachments, may contain confidential and/or proprietary information intended only for the use of the recipient. If you are not the intended recipient, any distribution, copying, or use of this email or its attachments is prohibited. If you received this email in error, please reply to the sender immediately and delete this message and any copies.

Bentley Systems has taken all reasonable steps to ensure that this communication is free from viruses, data corruption, and unauthorized alteration. Bentley Systems does not accept liability for any damages that may be incurred as a result of this or any communication by email

[https://cdn2.webdamdb.com/310th_sm_UnR3pO7k0ir0.jpg?1616176329]

jazanne commented 2 years ago

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.