Open-source social media scheduler built for AI agents and the teams behind them. Create, schedule and publish posts to every network through MCP or the REST API, or write them yourself in a composer your team will love.
PHP ai-agentsblueskyfacebookinstagramlaravellinkedinmastodonmcpmcp-serveropen-sourcerest-apiself-hostedsocial-mediasocial-media-managementsocial-media-schedulerthreadstiktokvuejsxyoutube
chore: tracking, gtm and more
Paulo Castellano7d95fd1efa03
diff --git a/.env.example b/.env.exampleindex 241216ed9..5d031bbf6 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.comdiff --git a/app/Http/Controllers/Auth/RegisteredUserController.php b/app/Http/Controllers/Auth/RegisteredUserController.phpindex a3a165455..54c95c14a 100644--- a/app/Http/Controllers/Auth/RegisteredUserController.php+++ b/app/Http/Controllers/Auth/RegisteredUserController.php@@ -55,6 +55,8 @@ class RegisteredUserController extends Controller}}- 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.phpnew file mode 100644index 000000000..d42365863--- /dev/null+++ b/app/Http/Controllers/Auth/SignupSuccessController.php@@ -0,0 +1,20 @@+<?php++declare(strict_types=1);++namespace App\Http\Controllers\Auth;++use App\Http\Controllers\Controller;+use Illuminate\Http\Request;+use Inertia\Inertia;+use Inertia\Response;++class SignupSuccessController extends Controller+{+ public function __invoke(Request $request): Response+ {+ return Inertia::render('auth/SignupSuccess', [+ 'authProvider' => $request->session()->get('auth_provider', 'email'),+ ]);+ }+}diff --git a/app/Http/Controllers/Auth/SocialLoginController.php b/app/Http/Controllers/Auth/SocialLoginController.phpindex e29a88507..3ef73a582 100644--- a/app/Http/Controllers/Auth/SocialLoginController.php+++ b/app/Http/Controllers/Auth/SocialLoginController.php@@ -55,6 +55,8 @@ class SocialLoginController extends ControllerAuth::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.phpindex 38a025ca2..2111b1f7f 100644--- a/app/Services/Social/ThreadsPublisher.php+++ b/app/Services/Social/ThreadsPublisher.php@@ -74,8 +74,6 @@ class ThreadsPublisherprivate 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 @@ class ThreadsPublisherprivate 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.phpindex 55e4ea738..427631522 100644--- a/config/services.php+++ b/config/services.php@@ -104,6 +104,10 @@ return ['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.phpindex 7ec6b7d60..d83b0b51f 100644--- a/lang/en/auth.php+++ b/lang/en/auth.php@@ -55,6 +55,12 @@ return ['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.phpindex 6e6187bf7..5a64fb138 100644--- a/lang/es/auth.php+++ b/lang/es/auth.php@@ -43,6 +43,12 @@ return ['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.phpindex 1ef12819c..4afceb5f8 100644--- a/lang/pt-br/auth.php+++ b/lang/pt-br/auth.php@@ -55,6 +55,12 @@ return ['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.tsnew file mode 100644index 000000000..c4f3ff6eb--- /dev/null+++ b/resources/js/composables/useTracking.ts@@ -0,0 +1,51 @@+import posthog from '@/posthog';++const push = (data: Record<string, unknown>) => {+ 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.vuenew file mode 100644index 000000000..e1c8748f4--- /dev/null+++ b/resources/js/pages/auth/SignupSuccess.vue@@ -0,0 +1,41 @@+<script setup lang="ts">+import { Head, router } from '@inertiajs/vue3';+import { IconLoader2 } from '@tabler/icons-vue';+import { onMounted } from 'vue';++import { useTracking } from '@/composables/useTracking';+import AuthBase from '@/layouts/AuthLayout.vue';+import { role } from '@/routes/app/onboarding';++const props = defineProps<{+ authProvider: string;+}>();++const { trackSignUp } = useTracking();++onMounted(() => {+ trackSignUp(props.authProvider);++ setTimeout(() => {+ router.visit(role.url());+ }, 5000);+});+</script>++<template>+ <Head :title="$t('auth.signup_success.page_title')" />++ <AuthBase>+ <div class="flex flex-col items-center gap-4 text-center">+ <IconLoader2 class="size-8 animate-spin text-muted-foreground" />+ <div>+ <h2 class="text-lg font-semibold tracking-tight">+ {{ $t('auth.signup_success.title') }}+ </h2>+ <p class="mt-1 text-sm text-muted-foreground">+ {{ $t('auth.signup_success.description') }}+ </p>+ </div>+ </div>+ </AuthBase>+</template>diff --git a/resources/js/types/globals.d.ts b/resources/js/types/globals.d.tsindex b08451c49..202cb9787 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<string, unknown>[];+ }+}+// Extend ImportMeta interface for Vite...declare module 'vite/client' {interface ImportMetaEnv {diff --git a/resources/views/app.blade.php b/resources/views/app.blade.phpindex 923945bf2..85d598fe1 100644--- a/resources/views/app.blade.php+++ b/resources/views/app.blade.php@@ -5,6 +5,8 @@<meta name="viewport" content="width=device-width, initial-scale=1"><meta name="csrf-token" content="{{ csrf_token() }}">+ @include('partials.gtm')+{{-- Inline script to detect system dark mode preference and apply it immediately --}}<script>(function() {@@ -44,6 +46,7 @@@inertiaHead</head><body class="font-sans antialiased">+ @include('partials.gtm-noscript')@inertia</body></html>diff --git a/resources/views/partials/gtm-noscript.blade.php b/resources/views/partials/gtm-noscript.blade.phpnew file mode 100644index 000000000..ba77fc263--- /dev/null+++ b/resources/views/partials/gtm-noscript.blade.php@@ -0,0 +1,6 @@+@if(config('services.gtm.id'))+<!-- Google Tag Manager (noscript) -->+<noscript><iframe src="https://www.googletagmanager.com/ns.html?id={{ config('services.gtm.id') }}"+height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>+<!-- End Google Tag Manager (noscript) -->+@endifdiff --git a/resources/views/partials/gtm.blade.php b/resources/views/partials/gtm.blade.phpnew file mode 100644index 000000000..e1aea0972--- /dev/null+++ b/resources/views/partials/gtm.blade.php@@ -0,0 +1,9 @@+@if(config('services.gtm.id'))+<!-- Google Tag Manager -->+<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':+new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],+j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=+'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);+})(window,document,'script','dataLayer','{{ config('services.gtm.id') }}');</script>+<!-- End Google Tag Manager -->+@endifdiff --git a/routes/auth.php b/routes/auth.phpindex 15924317f..0c070d381 100644--- a/routes/auth.php+++ b/routes/auth.php@@ -9,6 +9,7 @@ use App\Http\Controllers\Auth\EmailVerificationPromptController;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 @@ Route::group('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.phpindex 39719fa80..7c2583f78 100644--- a/tests/Feature/Auth/RegistrationTest.php+++ b/tests/Feature/Auth/RegistrationTest.php@@ -19,7 +19,7 @@ test('new users can register', function () {$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.phpindex fc14a8c26..22cb30cb1 100644--- a/tests/Feature/SocialLoginControllerTest.php+++ b/tests/Feature/SocialLoginControllerTest.php@@ -59,7 +59,7 @@ test('google callback creates new user when email does not exist', function () {$response = $this->get(route('auth.google.callback'));- $response->assertRedirect(route('app.onboarding.role'));+ $response->assertRedirect(route('register.success'));$user = User::where('email', '[email protected]')->first();expect($user)->not->toBeNull();