Let's say I have a function - checker - on front-end which works every 10 seconds.
async check() {
this.globalLoader = true
const result = await finalizePayment({
id: this.id ? this.id : undefined,
paymentId: this.paymentId ? this.paymentId : undefined,
token: localStorage.getItem('token'),
})
this.globalLoader = false
This function returns transaction status, and if it's done, I implement my Google Analytics code:
if (result.status === 'done') {
...
}
But there is a problem, I need to implement this GA code only one time, when transaction is done. If user reloads page, this check() function will return result.status === 'done' and my GA code will run again, but I don't need that again, because I have already made GA record about transaction.
So, how can I make it? I was thinking about localStorage value, but what if user removes this value from local storage?
If you want an alternative to localStorage then I suggest you to go with vue-persist