Fixed amplitude bugs, and added staging environment

This commit is contained in:
Julien Nahum 2024-01-03 19:03:45 +01:00
parent 52af13d84b
commit 2d41b18323
4 changed files with 105 additions and 79 deletions

View File

@ -23,11 +23,15 @@
<checkbox-input :form="form" name="agree_terms" :required="true">
<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
</NuxtLink> and <NuxtLink :to="{name:'privacy-policy'}" target="_blank">
</NuxtLink>
and
<NuxtLink :to="{name:'privacy-policy'}" target="_blank">
Privacy policy
</NuxtLink> of the website and I accept them.
</NuxtLink>
of the website and I accept them.
</template>
</checkbox-input>
@ -48,6 +52,9 @@
</template>
<script>
import {opnFetch} from "~/composables/useOpnApi.js";
import {fetchAllWorkspaces} from "~/stores/workspaces.js";
export default {
name: 'RegisterForm',
components: {},
@ -60,11 +67,11 @@ export default {
},
setup() {
const authStore = useAuthStore()
const amplitude = useAmplitude()
return {
authStore,
logEvent: amplitude.logEvent
authStore: useAuthStore(),
formsStore: useFormsStore(),
workspaceStore: useWorkspacesStore(),
logEvent: useAmplitude().logEvent
}
},
@ -77,7 +84,6 @@ export default {
agree_terms: false,
appsumo_license: null
}),
mustVerifyEmail: false
}),
computed: {
@ -108,24 +114,24 @@ export default {
methods: {
async register() {
// Register the user.
const { data } = await this.form.post('/api/register')
const data = await this.form.post('/register')
// Must verify email fist.
if (data.status) {
this.mustVerifyEmail = true
} else {
// Log in the user.
const { data: { token } } = await this.form.post('/api/login')
const tokenData = await this.form.post('/login')
// Save the token.
this.authStore.saveToken(token)
this.authStore.setToken(tokenData.token)
// Update the user.
await this.authStore.updateUser(data)
const userData = await opnFetch('user')
this.authStore.setUser(userData)
// Track event
const workspaces = await fetchAllWorkspaces()
this.workspaceStore.set(workspaces.data.value)
logEvent('register', { source: this.form.hear_about_us })
// Load forms
this.formsStore.loadAll(this.workspaceStore.currentId)
this.logEvent('register', {source: this.form.hear_about_us})
// AppSumo License
if (data.appsumo_license === false) {
@ -145,5 +151,4 @@ export default {
}
}
}
}
</script>

View File

@ -1,15 +1,17 @@
import amplitude from 'amplitude-js'
export const useAmplitude = () => {
const amplitudeCode = useRuntimeConfig().public.amplitudeCode
const config = useRuntimeConfig()
const amplitudeCode = config.public.amplitudeCode
const amplitudeClient = amplitudeCode ? amplitude.getInstance() : null;
if (amplitudeClient) {
amplitudeClient.init(amplitudeCode)
}
const logEvent = function (eventName, eventData) {
if (!config.production || !amplitudeClient) {
if (!config.public.env === 'production' || !amplitudeClient) {
console.log('[DEBUG] Amplitude logged event:', eventName, eventData)
return
}
if (eventData && typeof eventData !== 'object') {

View File

@ -3,6 +3,7 @@ export default {
public: {
apiBase: '',
appUrl: '',
env: 'local',
hCaptchaSiteKey: null,
googleAnalyticsCode: null,
amplitudeCode: null,

View File

@ -1,8 +1,9 @@
id: 34225
name: OpnForm
ignore:
- 'storage/clockwork'
- 'storage/logs'
- storage/clockwork
- storage/logs
- client
environments:
production:
warm: 5
@ -10,9 +11,9 @@ environments:
cli-memory: 512
cli-timeout: 900
runtime: 'php-8.2:al2-arm'
storage: 'opnforms-prod'
database: 'JuPersoDb'
domain: 'opnform.com'
storage: opnforms-prod
database: JuPersoDb
domain: opnform.com
build:
- 'COMPOSER_MIRROR_PATH_REPOS=1 composer install --no-dev'
- 'php artisan event:cache'
@ -23,3 +24,20 @@ environments:
firewall:
rate-limit: 1000
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