track form open after link click

pull/105/head
Alex Turchyn 2 years ago
parent cf6cacdc92
commit fcfd2e13bd

@ -494,8 +494,9 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.recalculateButtonDisabledKey = Math.random() this.recalculateButtonDisabledKey = Math.random()
this.maybeTrackEmailClick() this.maybeTrackEmailClick().finally(() => {
this.trackViewForm() this.trackViewForm()
})
}) })
}, },
methods: { methods: {
@ -504,20 +505,24 @@ export default {
const queryParams = new URLSearchParams(window.location.search) const queryParams = new URLSearchParams(window.location.search)
if (queryParams.has('t')) { if (queryParams.has('t')) {
fetch(this.baseUrl + '/api/submitter_email_clicks', { const t = queryParams.get('t')
queryParams.delete('t')
const newUrl = [window.location.pathname, queryParams.toString()].filter(Boolean).join('?')
window.history.replaceState({}, document.title, newUrl)
return fetch(this.baseUrl + '/api/submitter_email_clicks', {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
body: JSON.stringify({ body: JSON.stringify({
t: queryParams.get('t'), t,
submitter_slug: this.submitterSlug submitter_slug: this.submitterSlug
}) })
}) })
} else {
queryParams.delete('t') return Promise.resolve({})
const newUrl = [window.location.pathname, queryParams.toString()].filter(Boolean).join('?')
window.history.replaceState({}, document.title, newUrl)
} }
}, },
trackViewForm () { trackViewForm () {

Loading…
Cancel
Save