Skip to content

Commit

Permalink
fix: sync browser clock before checkout page loads VUE-847
Browse files Browse the repository at this point in the history
  • Loading branch information
emuvente committed Nov 19, 2021
1 parent 5be065a commit 98f7aed
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions src/pages/Checkout/CheckoutPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,14 @@ export default {
this.activeLoginDuration = parseInt(_get(data, 'general.activeLoginDuration.value'), 10) || 3600;
}
},
beforeRouteEnter(to, from, next) {
// Ensure browser clock is correct before loading the page
if (typeof window !== 'undefined') {
syncDate().then(next).catch(next);
} else {
next();
}
},
created() {
// show guest account claim confirmation message
if (this.myId && this.$route.query?.claimed === '1') {
Expand Down Expand Up @@ -432,22 +440,19 @@ export default {
}
},
mounted() {
// Ensure browser clock is correct before using current time
syncDate().then(() => {
// update current time every second for reactivity
this.currentTimeInterval = setInterval(() => {
this.currentTime = Date.now();
}, 1000);
this.$nextTick(() => {
// fire tracking event when the page loads
// - this event will be duplicated when the page reloads with a newly registered/logged in user
let userStatus = this.isLoggedIn ? 'Logged-In' : 'Un-Authenticated';
if (this.isActivelyLoggedIn) {
userStatus = 'Actively Logged-In';
}
this.$kvTrackEvent('Checkout', 'EXP-Checkout-Loaded', userStatus);
});
// update current time every second for reactivity
this.currentTimeInterval = setInterval(() => {
this.currentTime = Date.now();
}, 1000);
this.$nextTick(() => {
// fire tracking event when the page loads
// - this event will be duplicated when the page reloads with a newly registered/logged in user
let userStatus = this.isLoggedIn ? 'Logged-In' : 'Un-Authenticated';
if (this.isActivelyLoggedIn) {
userStatus = 'Actively Logged-In';
}
this.$kvTrackEvent('Checkout', 'EXP-Checkout-Loaded', userStatus);
});
// cover ssr or spa page load
Expand Down

0 comments on commit 98f7aed

Please sign in to comment.