104a6 utm tracking in db (#578)

* utm tracking in db

* fix array key bug

* fix utm form

* fix import
This commit is contained in:
Favour Olayinka 2024-09-20 10:47:12 +01:00 committed by GitHub
parent 5020f9fa74
commit 5ab3477e0a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 9 deletions

View File

@ -113,11 +113,12 @@ class OAuthController extends Controller
return $user;
}
$utmData = request()->utm_data;
$user = User::create([
'name' => $socialiteUser->getName(),
'email' => $email,
'email_verified_at' => now(),
'utm_data' => json_decode(request()->utm_data, true)
'utm_data' => is_string($utmData) ? json_decode($utmData, true) : $utmData
]);
// Create and sync workspace

View File

@ -33,6 +33,7 @@
import { useNuxtApp } from "nuxt/app";
const { $utm } = useNuxtApp();
const router = useRouter()
const route = useRoute()
const authStore = useAuthStore()
@ -40,6 +41,10 @@ const workspacesStore = useWorkspacesStore()
const formsStore = useFormsStore()
const logEvent = useAmplitude().logEvent
const loading = ref(true)
const form = useForm({
code: '',
utm_data: null,
})
definePageMeta({
alias: '/oauth/:provider/callback'
@ -47,15 +52,10 @@ definePageMeta({
function handleCallback() {
const code = route.query.code
const provider = route.params.provider
opnFetch(`/oauth/${provider}/callback`, {
method: 'POST',
params: {
code,
utm_data: $utm.value
}
}).then(async (data) => {
form.code = route.query.code
form.utm_data = $utm.value
form.post(`/oauth/${provider}/callback`).then(async (data) => {
authStore.setToken(data.token)
const [userDataResponse, workspacesResponse] = await Promise.all([
opnFetch("user"),