Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log API response errors #34

Open
moubry opened this issue Sep 7, 2022 · 2 comments
Open

Log API response errors #34

moubry opened this issue Sep 7, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@moubry
Copy link

moubry commented Sep 7, 2022

Integration and debugging would be easier if the package decoded the error messages returned from the Amplitude API and included these messages in the logs, or simply logged the JSON text verbatim without unmarshaling it.

Currently, if you make a mistake tracking an event, you see something like this in your logs:

[00] amplitude-analytics2022/09/07 17:40:05 Info: HTTP request response%!(EXTRA *http.Response=&{400 Bad Request 400 HTTP/2.0 2 0 map[Access-Control-Allow-Methods:[GET, POST] Access-Control-Allow-Origin:[*] Content-Length:[115] Content-Type:[application/json] Date:[Wed, 07 Sep 2022 22:40:05 GMT] Strict-Transport-Security:[max-age=15768000] Trace-Id:[Root=1-63191dc5-2c964e046f02f68c1df60a75]] 0x140000b96a0 79 [] false false map[] 0x1400050a200 0x14000138580})

But the actual HTTP response looks something like this:

{
  "code": 400,
  "events_with_invalid_id_lengths": {
    "user_id": [
      0
    ]
  },
  "error": "Invalid id length for user_id or device_id"
}

It would be nice to be able to see this error message “Invalid id length for user_id or device_id” logged.

@moubry moubry added the enhancement New feature or request label Sep 7, 2022
@qingzhuozhen
Copy link
Contributor

Hi @moubry thanks for submitting this. This seems a valid concern and we will try to support better debugging for our SDK. cc @justin-fiedler @falconandy

@falconandy
Copy link
Contributor

Hi @moubry
Could you please try version v0.0.3?
Example output:

amplitude-analytics - 2022/09/09 11:31:54 Info: HTTP response code: 400 Bad Request
amplitude-analytics - 2022/09/09 11:31:54 Info: HTTP response body: {"code":400,"events_with_invalid_id_lengths":{"user_id":[0]},"error":"Invalid id length for user_id or device_id"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants