diff --git a/.env.example b/.env.example index 241216ed..5d031bbf 100644 --- a/.env.example +++ b/.env.example @@ -132,6 +132,9 @@ PINTEREST_CLIENT_ID= PINTEREST_CLIENT_SECRET= PINTEREST_CLIENT_REDIRECT="${APP_URL}/accounts/pinterest/callback" +# Google Tag Manager (optional - analytics) +GTM_ID= + # PostHog (optional - analytics) POSTHOG_API_KEY= POSTHOG_HOST=https://us.i.posthog.com diff --git a/app/Http/Controllers/Auth/RegisteredUserController.php b/app/Http/Controllers/Auth/RegisteredUserController.php index a3a16545..54c95c14 100644 --- a/app/Http/Controllers/Auth/RegisteredUserController.php +++ b/app/Http/Controllers/Auth/RegisteredUserController.php @@ -55,6 +55,8 @@ public function store(Request $request): RedirectResponse } } - return redirect()->route('app.onboarding.role'); + session()->flash('auth_provider', 'email'); + + return redirect()->route('register.success'); } } diff --git a/app/Http/Controllers/Auth/SignupSuccessController.php b/app/Http/Controllers/Auth/SignupSuccessController.php new file mode 100644 index 00000000..d4236586 --- /dev/null +++ b/app/Http/Controllers/Auth/SignupSuccessController.php @@ -0,0 +1,20 @@ + $request->session()->get('auth_provider', 'email'), + ]); + } +} diff --git a/app/Http/Controllers/Auth/SocialLoginController.php b/app/Http/Controllers/Auth/SocialLoginController.php index e29a8850..3ef73a58 100644 --- a/app/Http/Controllers/Auth/SocialLoginController.php +++ b/app/Http/Controllers/Auth/SocialLoginController.php @@ -55,6 +55,8 @@ private function registerNewUser(\Laravel\Socialite\Contracts\User $googleUser): Auth::login($user, remember: true); - return redirect()->route('app.onboarding.role'); + session()->flash('auth_provider', 'google'); + + return redirect()->route('register.success'); } } diff --git a/app/Services/Social/ThreadsPublisher.php b/app/Services/Social/ThreadsPublisher.php index 38a025ca..2111b1f7 100644 --- a/app/Services/Social/ThreadsPublisher.php +++ b/app/Services/Social/ThreadsPublisher.php @@ -74,8 +74,6 @@ public function publish(PostPlatform $postPlatform): array private function publishTextPost(string $userId, string $accessToken, string $content): array { - Log::info('Threads publishing text post', ['user_id' => $userId]); - // Step 1: Create container $containerResponse = Http::post("{$this->baseUrl}/{$userId}/threads", [ 'media_type' => 'TEXT', @@ -99,8 +97,6 @@ private function publishTextPost(string $userId, string $accessToken, string $co private function publishImagePost(string $userId, string $accessToken, ?string $content, $media): array { - Log::info('Threads publishing image post', ['user_id' => $userId, 'image_url' => $media->url]); - // Step 1: Create container $containerResponse = Http::post("{$this->baseUrl}/{$userId}/threads", [ 'media_type' => 'IMAGE', diff --git a/config/services.php b/config/services.php index 55e4ea73..42763152 100644 --- a/config/services.php +++ b/config/services.php @@ -104,6 +104,10 @@ 'redirect' => env('PINTEREST_CLIENT_REDIRECT'), ], + 'gtm' => [ + 'id' => env('GTM_ID'), + ], + 'posthog' => [ 'api_key' => env('POSTHOG_API_KEY'), 'host' => env('POSTHOG_HOST', 'https://us.i.posthog.com'), diff --git a/lang/en/auth.php b/lang/en/auth.php index 7ec6b7d6..d83b0b51 100644 --- a/lang/en/auth.php +++ b/lang/en/auth.php @@ -55,6 +55,12 @@ 'google_login' => 'Log in with Google', 'google_signup' => 'Sign up with Google', + 'signup_success' => [ + 'page_title' => 'Welcome', + 'title' => 'Setting up your account', + 'description' => 'This usually takes just a few seconds...', + ], + 'login' => [ 'title' => 'Log in to your account', 'description' => 'Enter your email and password below to log in', diff --git a/lang/es/auth.php b/lang/es/auth.php index 6e6187bf..5a64fb13 100644 --- a/lang/es/auth.php +++ b/lang/es/auth.php @@ -43,6 +43,12 @@ 'google_login' => 'Iniciar sesión con Google', 'google_signup' => 'Registrarse con Google', + 'signup_success' => [ + 'page_title' => 'Bienvenido', + 'title' => 'Configurando tu cuenta', + 'description' => 'Esto suele tardar solo unos segundos...', + ], + 'login' => [ 'title' => 'Inicia sesión en tu cuenta', 'description' => 'Introduce tu correo y contraseña para iniciar sesión', diff --git a/lang/pt-br/auth.php b/lang/pt-br/auth.php index 1ef12819..4afceb5f 100644 --- a/lang/pt-br/auth.php +++ b/lang/pt-br/auth.php @@ -55,6 +55,12 @@ 'google_login' => 'Entrar com Google', 'google_signup' => 'Cadastrar com Google', + 'signup_success' => [ + 'page_title' => 'Bem-vindo', + 'title' => 'Configurando sua conta', + 'description' => 'Isso geralmente leva apenas alguns segundos...', + ], + 'login' => [ 'title' => 'Entrar na sua conta', 'description' => 'Digite seu email e senha abaixo para entrar', diff --git a/resources/js/composables/useTracking.ts b/resources/js/composables/useTracking.ts new file mode 100644 index 00000000..c4f3ff6e --- /dev/null +++ b/resources/js/composables/useTracking.ts @@ -0,0 +1,51 @@ +import posthog from '@/posthog'; + +const push = (data: Record) => { + window.dataLayer = window.dataLayer || []; + window.dataLayer.push(data); +}; + +export const useTracking = () => ({ + trackSignUp: (authProvider: string) => { + posthog.capture('user.signed_up', { + auth_provider: authProvider, + }); + + push({ + event: 'sign_up', + method: authProvider, + }); + }, + + trackBeginCheckout: (plan: { name: string; price: number; interval: string }) => { + posthog.capture('checkout.started', { + plan_name: plan.name, + plan_price: plan.price, + interval: plan.interval, + }); + + push({ + event: 'begin_checkout', + currency: 'USD', + plan_name: plan.name, + plan_price: plan.price, + plan_interval: plan.interval, + }); + }, + + trackPurchase: (plan: { name: string; price: number; interval: string }) => { + posthog.capture('checkout.completed', { + plan_name: plan.name, + plan_price: plan.price, + interval: plan.interval, + }); + + push({ + event: 'purchase', + currency: 'USD', + plan_name: plan.name, + plan_price: plan.price, + plan_interval: plan.interval, + }); + }, +}); diff --git a/resources/js/pages/auth/SignupSuccess.vue b/resources/js/pages/auth/SignupSuccess.vue new file mode 100644 index 00000000..e1c8748f --- /dev/null +++ b/resources/js/pages/auth/SignupSuccess.vue @@ -0,0 +1,41 @@ + + + diff --git a/resources/js/types/globals.d.ts b/resources/js/types/globals.d.ts index b08451c4..202cb978 100644 --- a/resources/js/types/globals.d.ts +++ b/resources/js/types/globals.d.ts @@ -1,5 +1,11 @@ import { AppPageProps } from '@/types/index'; +declare global { + interface Window { + dataLayer: Record[]; + } +} + // Extend ImportMeta interface for Vite... declare module 'vite/client' { interface ImportMetaEnv { diff --git a/resources/views/app.blade.php b/resources/views/app.blade.php index 923945bf..85d598fe 100644 --- a/resources/views/app.blade.php +++ b/resources/views/app.blade.php @@ -5,6 +5,8 @@ + @include('partials.gtm') + {{-- Inline script to detect system dark mode preference and apply it immediately --}} + +@endif diff --git a/routes/auth.php b/routes/auth.php index 15924317..0c070d38 100644 --- a/routes/auth.php +++ b/routes/auth.php @@ -9,6 +9,7 @@ use App\Http\Controllers\Auth\NewPasswordController; use App\Http\Controllers\Auth\PasswordResetLinkController; use App\Http\Controllers\Auth\RegisteredUserController; +use App\Http\Controllers\Auth\SignupSuccessController; use App\Http\Controllers\Auth\SocialLoginController; use App\Http\Controllers\Auth\VerifyEmailController; use Illuminate\Support\Facades\Route; @@ -51,6 +52,8 @@ function () { 'middleware' => ['auth'], ], function () { + Route::get('/register/success', SignupSuccessController::class)->name('register.success'); + Route::get('/verify-email', EmailVerificationPromptController::class)->name('verification.notice'); Route::get('/verify-email/{id}/{hash}', VerifyEmailController::class) diff --git a/tests/Feature/Auth/RegistrationTest.php b/tests/Feature/Auth/RegistrationTest.php index 39719fa8..7c2583f7 100644 --- a/tests/Feature/Auth/RegistrationTest.php +++ b/tests/Feature/Auth/RegistrationTest.php @@ -19,7 +19,7 @@ $response->assertSessionHasNoErrors(); $this->assertAuthenticated(); - $response->assertRedirect(route('app.onboarding.role', absolute: false)); + $response->assertRedirect(route('register.success', absolute: false)); }); test('new users get a default workspace on registration', function () { diff --git a/tests/Feature/SocialLoginControllerTest.php b/tests/Feature/SocialLoginControllerTest.php index fc14a8c2..22cb30cb 100644 --- a/tests/Feature/SocialLoginControllerTest.php +++ b/tests/Feature/SocialLoginControllerTest.php @@ -59,7 +59,7 @@ $response = $this->get(route('auth.google.callback')); - $response->assertRedirect(route('app.onboarding.role')); + $response->assertRedirect(route('register.success')); $user = User::where('email', 'new@example.com')->first(); expect($user)->not->toBeNull();