Fixed amplitude bugs, and added staging environment
This commit is contained in:
parent
52af13d84b
commit
2d41b18323
|
@ -2,10 +2,10 @@
|
||||||
<div>
|
<div>
|
||||||
<form class="mt-4" @submit.prevent="register" @keydown="form.onKeydown($event)">
|
<form class="mt-4" @submit.prevent="register" @keydown="form.onKeydown($event)">
|
||||||
<!-- Name -->
|
<!-- Name -->
|
||||||
<text-input name="name" :form="form" label="Name" placeholder="Your name" :required="true" />
|
<text-input name="name" :form="form" label="Name" placeholder="Your name" :required="true"/>
|
||||||
|
|
||||||
<!-- Email -->
|
<!-- Email -->
|
||||||
<text-input name="email" :form="form" label="Email" :required="true" placeholder="Your email address" />
|
<text-input name="email" :form="form" label="Email" :required="true" placeholder="Your email address"/>
|
||||||
|
|
||||||
<select-input name="hear_about_us" :options="hearAboutUsOptions" :form="form" placeholder="Select option"
|
<select-input name="hear_about_us" :options="hearAboutUsOptions" :form="form" placeholder="Select option"
|
||||||
label="How did you hear about us?" :required="true"
|
label="How did you hear about us?" :required="true"
|
||||||
|
@ -23,11 +23,15 @@
|
||||||
|
|
||||||
<checkbox-input :form="form" name="agree_terms" :required="true">
|
<checkbox-input :form="form" name="agree_terms" :required="true">
|
||||||
<template #label>
|
<template #label>
|
||||||
I agree with the <NuxtLink :to="{name:'terms-conditions'}" target="_blank">
|
I agree with the
|
||||||
|
<NuxtLink :to="{name:'terms-conditions'}" target="_blank">
|
||||||
Terms and conditions
|
Terms and conditions
|
||||||
</NuxtLink> and <NuxtLink :to="{name:'privacy-policy'}" target="_blank">
|
</NuxtLink>
|
||||||
|
and
|
||||||
|
<NuxtLink :to="{name:'privacy-policy'}" target="_blank">
|
||||||
Privacy policy
|
Privacy policy
|
||||||
</NuxtLink> of the website and I accept them.
|
</NuxtLink>
|
||||||
|
of the website and I accept them.
|
||||||
</template>
|
</template>
|
||||||
</checkbox-input>
|
</checkbox-input>
|
||||||
|
|
||||||
|
@ -48,6 +52,9 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import {opnFetch} from "~/composables/useOpnApi.js";
|
||||||
|
import {fetchAllWorkspaces} from "~/stores/workspaces.js";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'RegisterForm',
|
name: 'RegisterForm',
|
||||||
components: {},
|
components: {},
|
||||||
|
@ -59,12 +66,12 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
setup () {
|
setup() {
|
||||||
const authStore = useAuthStore()
|
|
||||||
const amplitude = useAmplitude()
|
|
||||||
return {
|
return {
|
||||||
authStore,
|
authStore: useAuthStore(),
|
||||||
logEvent: amplitude.logEvent
|
formsStore: useFormsStore(),
|
||||||
|
workspaceStore: useWorkspacesStore(),
|
||||||
|
logEvent: useAmplitude().logEvent
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -77,28 +84,27 @@ export default {
|
||||||
agree_terms: false,
|
agree_terms: false,
|
||||||
appsumo_license: null
|
appsumo_license: null
|
||||||
}),
|
}),
|
||||||
mustVerifyEmail: false
|
|
||||||
}),
|
}),
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
hearAboutUsOptions () {
|
hearAboutUsOptions() {
|
||||||
const options = [
|
const options = [
|
||||||
{ name: 'Facebook', value: 'facebook' },
|
{name: 'Facebook', value: 'facebook'},
|
||||||
{ name: 'Twitter', value: 'twitter' },
|
{name: 'Twitter', value: 'twitter'},
|
||||||
{ name: 'Reddit', value: 'reddit' },
|
{name: 'Reddit', value: 'reddit'},
|
||||||
{ name: 'Github', value: 'github' },
|
{name: 'Github', value: 'github'},
|
||||||
{ name: 'Search Engine (Google, DuckDuckGo...)', value: 'search_engine' },
|
{name: 'Search Engine (Google, DuckDuckGo...)', value: 'search_engine'},
|
||||||
{ name: 'Friend or Colleague', value: 'friend_colleague' },
|
{name: 'Friend or Colleague', value: 'friend_colleague'},
|
||||||
{ name: 'Blog/Article', value: 'blog_article' }
|
{name: 'Blog/Article', value: 'blog_article'}
|
||||||
].map((value) => ({ value, sort: Math.random() }))
|
].map((value) => ({value, sort: Math.random()}))
|
||||||
.sort((a, b) => a.sort - b.sort)
|
.sort((a, b) => a.sort - b.sort)
|
||||||
.map(({ value }) => value)
|
.map(({value}) => value)
|
||||||
options.push({ name: 'Other', value: 'other' })
|
options.push({name: 'Other', value: 'other'})
|
||||||
return options
|
return options
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted () {
|
mounted() {
|
||||||
// Set appsumo license
|
// Set appsumo license
|
||||||
if (this.$route.query.appsumo_license !== undefined && this.$route.query.appsumo_license) {
|
if (this.$route.query.appsumo_license !== undefined && this.$route.query.appsumo_license) {
|
||||||
this.form.appsumo_license = this.$route.query.appsumo_license
|
this.form.appsumo_license = this.$route.query.appsumo_license
|
||||||
|
@ -106,42 +112,41 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
async register () {
|
async register() {
|
||||||
// Register the user.
|
// Register the user.
|
||||||
const { data } = await this.form.post('/api/register')
|
const data = await this.form.post('/register')
|
||||||
|
|
||||||
// Must verify email fist.
|
// Log in the user.
|
||||||
if (data.status) {
|
const tokenData = await this.form.post('/login')
|
||||||
this.mustVerifyEmail = true
|
|
||||||
|
// Save the token.
|
||||||
|
this.authStore.setToken(tokenData.token)
|
||||||
|
|
||||||
|
const userData = await opnFetch('user')
|
||||||
|
this.authStore.setUser(userData)
|
||||||
|
|
||||||
|
const workspaces = await fetchAllWorkspaces()
|
||||||
|
this.workspaceStore.set(workspaces.data.value)
|
||||||
|
|
||||||
|
// Load forms
|
||||||
|
this.formsStore.loadAll(this.workspaceStore.currentId)
|
||||||
|
|
||||||
|
this.logEvent('register', {source: this.form.hear_about_us})
|
||||||
|
|
||||||
|
// AppSumo License
|
||||||
|
if (data.appsumo_license === false) {
|
||||||
|
useAlert().error('Invalid AppSumo license. This probably happened because this license was already' +
|
||||||
|
' attached to another OpnForm account. Please contact support.')
|
||||||
|
} else if (data.appsumo_license === true) {
|
||||||
|
useAlert().success('Your AppSumo license was successfully activated! You now have access to all the' +
|
||||||
|
' features of the AppSumo deal.')
|
||||||
|
}
|
||||||
|
|
||||||
|
// Redirect
|
||||||
|
if (this.isQuick) {
|
||||||
|
this.$emit('afterQuickLogin')
|
||||||
} else {
|
} else {
|
||||||
// Log in the user.
|
this.$router.push({name: 'forms-create'})
|
||||||
const { data: { token } } = await this.form.post('/api/login')
|
|
||||||
|
|
||||||
// Save the token.
|
|
||||||
this.authStore.saveToken(token)
|
|
||||||
|
|
||||||
// Update the user.
|
|
||||||
await this.authStore.updateUser(data)
|
|
||||||
|
|
||||||
// Track event
|
|
||||||
|
|
||||||
logEvent('register', { source: this.form.hear_about_us })
|
|
||||||
|
|
||||||
// AppSumo License
|
|
||||||
if (data.appsumo_license === false) {
|
|
||||||
useAlert().error('Invalid AppSumo license. This probably happened because this license was already' +
|
|
||||||
' attached to another OpnForm account. Please contact support.')
|
|
||||||
} else if (data.appsumo_license === true) {
|
|
||||||
useAlert().success('Your AppSumo license was successfully activated! You now have access to all the' +
|
|
||||||
' features of the AppSumo deal.')
|
|
||||||
}
|
|
||||||
|
|
||||||
// Redirect
|
|
||||||
if (this.isQuick) {
|
|
||||||
this.$emit('afterQuickLogin')
|
|
||||||
} else {
|
|
||||||
this.$router.push({ name: 'forms-create' })
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,17 @@
|
||||||
import amplitude from 'amplitude-js'
|
import amplitude from 'amplitude-js'
|
||||||
|
|
||||||
export const useAmplitude = () => {
|
export const useAmplitude = () => {
|
||||||
const amplitudeCode = useRuntimeConfig().public.amplitudeCode
|
const config = useRuntimeConfig()
|
||||||
|
const amplitudeCode = config.public.amplitudeCode
|
||||||
const amplitudeClient = amplitudeCode ? amplitude.getInstance() : null;
|
const amplitudeClient = amplitudeCode ? amplitude.getInstance() : null;
|
||||||
if (amplitudeClient) {
|
if (amplitudeClient) {
|
||||||
amplitudeClient.init(amplitudeCode)
|
amplitudeClient.init(amplitudeCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
const logEvent = function (eventName, eventData) {
|
const logEvent = function (eventName, eventData) {
|
||||||
if (!config.production || !amplitudeClient) {
|
if (!config.public.env === 'production' || !amplitudeClient) {
|
||||||
console.log('[DEBUG] Amplitude logged event:', eventName, eventData)
|
console.log('[DEBUG] Amplitude logged event:', eventName, eventData)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eventData && typeof eventData !== 'object') {
|
if (eventData && typeof eventData !== 'object') {
|
||||||
|
|
|
@ -3,6 +3,7 @@ export default {
|
||||||
public: {
|
public: {
|
||||||
apiBase: '',
|
apiBase: '',
|
||||||
appUrl: '',
|
appUrl: '',
|
||||||
|
env: 'local',
|
||||||
hCaptchaSiteKey: null,
|
hCaptchaSiteKey: null,
|
||||||
googleAnalyticsCode: null,
|
googleAnalyticsCode: null,
|
||||||
amplitudeCode: null,
|
amplitudeCode: null,
|
||||||
|
|
60
vapor.yml
60
vapor.yml
|
@ -1,25 +1,43 @@
|
||||||
id: 34225
|
id: 34225
|
||||||
name: OpnForm
|
name: OpnForm
|
||||||
ignore:
|
ignore:
|
||||||
- 'storage/clockwork'
|
- storage/clockwork
|
||||||
- 'storage/logs'
|
- storage/logs
|
||||||
|
- client
|
||||||
environments:
|
environments:
|
||||||
production:
|
production:
|
||||||
warm: 5
|
warm: 5
|
||||||
memory: 1024
|
memory: 1024
|
||||||
cli-memory: 512
|
cli-memory: 512
|
||||||
cli-timeout: 900
|
cli-timeout: 900
|
||||||
runtime: 'php-8.2:al2-arm'
|
runtime: 'php-8.2:al2-arm'
|
||||||
storage: 'opnforms-prod'
|
storage: opnforms-prod
|
||||||
database: 'JuPersoDb'
|
database: JuPersoDb
|
||||||
domain: 'opnform.com'
|
domain: opnform.com
|
||||||
build:
|
build:
|
||||||
- 'COMPOSER_MIRROR_PATH_REPOS=1 composer install --no-dev'
|
- 'COMPOSER_MIRROR_PATH_REPOS=1 composer install --no-dev'
|
||||||
- 'php artisan event:cache'
|
- 'php artisan event:cache'
|
||||||
- 'php artisan disposable:update'
|
- 'php artisan disposable:update'
|
||||||
- 'npm ci && npm run build && rm -rf node_modules'
|
- 'npm ci && npm run build && rm -rf node_modules'
|
||||||
deploy:
|
deploy:
|
||||||
- 'php artisan migrate --force'
|
- 'php artisan migrate --force'
|
||||||
firewall:
|
firewall:
|
||||||
rate-limit: 1000
|
rate-limit: 1000
|
||||||
timeout: 30
|
timeout: 30
|
||||||
|
staging:
|
||||||
|
memory: 1024
|
||||||
|
cli-memory: 512
|
||||||
|
cli-timeout: 900
|
||||||
|
runtime: 'php-8.2:al2-arm'
|
||||||
|
storage: opnforms-staging
|
||||||
|
database: JuPersoDb
|
||||||
|
domain: stg.opnform.com
|
||||||
|
build:
|
||||||
|
- 'COMPOSER_MIRROR_PATH_REPOS=1 composer install --no-dev'
|
||||||
|
- 'php artisan event:cache'
|
||||||
|
- 'php artisan disposable:update'
|
||||||
|
deploy:
|
||||||
|
- 'php artisan migrate --force'
|
||||||
|
firewall:
|
||||||
|
rate-limit: 1000
|
||||||
|
timeout: 30
|
||||||
|
|
Loading…
Reference in New Issue