Closed ThisisBada closed 10 months ago
Hello, @ThisisBada 👋 and thanks for opening this issue. In v5.X of Amplify, theAmplify.record()
method appears to be an async
function but does not ever resolve. We realize that this is not ideal and have addressed this discrepancy in our next major version, v6 of Amplify JS. We actually just released the developer preview for it, which includes Analytics within the categories that can currently be used!
While the documentation does not specify that you should await this function, we consider the Analytics record
API to be one that ought to be synchronous and non-blocking for our customers' applications. Since you're on v5.X at this time, please follow the recommendations on the documentation and treat the function as synchronous. It should work as a "fire and forget" model.
Let us know if you have any further questions on the subject!
With the docs issue opened to track this, I'll close this issue. Thank you for creating this issue to help us make a needed improvement in our documentation!
Before opening, please confirm:
JavaScript Framework
React Native
Amplify APIs
Analytics
Amplify Categories
analytics
Environment information
Describe the bug
Hello Team,
When using Analytics Category of Amplify. Specifically, when using the
Analytics.record()
function, it is mentioned here that it returns a promise and it is confirmed here that it is an async function.The issue is that the
Analytics.record()
does not fire the.then()
when I call it.Note : in Amplify docs, it does not mention if the Analytics.record() is sync or async but there is no await in the doc's code so I assumed that it is sync then I went to the code and I saw that it is async.
Please find below the code that I used :
This will log only :
It will not log "Then Block"
Expected behavior
The expected behaviour is that the
Analytics.record()
function triggers the.then()
Reproduction steps
Note : I only included the amplify folder for your reference.
Code Snippet
Log output
aws-exports.js
Manual configuration
No response
Additional configuration
No response
Mobile Device
Simulator iPhone 15 pro max
Mobile Operating System
iOS 17
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response