Amplitude
To capture an event you must follow these steps:
You must initialize amplitude first, for this you need to import the hook useInitAnalytics from the hooks folder.
Then add the initialization by adding the following code block, which can receive a user identifier as a parameter. This parameter is optional.
Now you must import the following code block in the file where it is required so the event can be captured.
The function trackAnalyticsOnClick
will receive an object of type ParamsTrackAnalytic
Update --02/08/2023--
eventName: Is the name of the event that is running (required)
params: Object with typeof Record<string, string>.
These params are used to send a pair of string values defined in the analytics document. The pair is composed by a PropertyName and PropertyValue, the properties will be attached to the event.
Here's an example
You can use convertPropertiesToRecord
helper method to convert an array of properties to the expected format Record<string, string>
For the errors it is preferred to call the helper method evaluateErrorMessage
because this method will parsed the data and will call the trackAnalyticsOnClick
internally.
Here's an example
Calling trackAnalyticsOnClick
with the old structure will still supported for the events implemented before.
Before --02/03/2023--
eventName: Is the name of the event that is running (required)
params: Object composed of
success
and another object calledeventInfo
wheresuccess: Represents the success or failure of the event
eventInfo: Represents values that allow identifying the reason for the event
Here's an example
Last updated