Created
September 27, 2022 13:24
-
-
Save SahanAmarsha/682ea7312e8136a5eba07371c277d1b3 to your computer and use it in GitHub Desktop.
Record search word event using AWS Amplify Analytics category
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// import analytics | |
import { Analytics } from "aws-amplify"; | |
// record searched word in Analytics | |
const recordWordInAnalytics = (searchWord: string) => { | |
if (searchWord !== "") { | |
const lowerCaseWord = searchWord?.toLowerCase(); | |
console.log("recordWordInAnalytics: ", lowerCaseWord); | |
try { | |
Analytics.record({ | |
name: "WordSearched", | |
attributes: { | |
word: lowerCaseWord, | |
}, | |
}); | |
} catch (err) { | |
console.log("Analytics Error: ", err); | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment