fix(tracking): fire begin_checkout when onboarding checkout starts
trackBeginCheckout was defined but never called, so the begin_checkout (GTM/dataLayer) and checkout.started (PostHog) events never fired. Wire it into the onboarding Connect submit handler, before the redirect to Stripe, and pass the workspace plan from the controller so the event carries plan name + interval.
This commit is contained in:
parent
bfa018a4cd
commit
974c076e86
3 changed files with 28 additions and 0 deletions
|
|
@ -150,9 +150,15 @@ public function connect(Request $request): Response|RedirectResponse
|
|||
'network' => $platform->network(),
|
||||
])->values();
|
||||
|
||||
$plan = Plan::where('slug', Slug::Workspace)->firstOrFail();
|
||||
|
||||
return Inertia::render('onboarding/Connect', [
|
||||
'platforms' => $platforms,
|
||||
'accounts' => SocialAccountResource::collection($accounts)->resolve(),
|
||||
'plan' => [
|
||||
'name' => $plan->name,
|
||||
'interval' => 'monthly',
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,14 +9,18 @@ import NetworkConnectGrid, {
|
|||
type ConnectedAccount,
|
||||
} from '@/components/accounts/NetworkConnectGrid.vue';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { useTracking } from '@/composables/useTracking';
|
||||
|
||||
const props = defineProps<{
|
||||
platforms: AvailablePlatform[];
|
||||
accounts: ConnectedAccount[];
|
||||
plan: { name: string; interval: string };
|
||||
}>();
|
||||
|
||||
const form = useForm({});
|
||||
|
||||
const { trackBeginCheckout } = useTracking();
|
||||
|
||||
const hasConnected = computed((): boolean => props.accounts.length > 0);
|
||||
|
||||
const submit = (): void => {
|
||||
|
|
@ -24,6 +28,8 @@ const submit = (): void => {
|
|||
return;
|
||||
}
|
||||
|
||||
trackBeginCheckout({ name: props.plan.name, interval: props.plan.interval });
|
||||
|
||||
form.post(checkout.url());
|
||||
};
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -263,6 +263,22 @@ function subscribeOnboardingAccount(Account $account): void
|
|||
);
|
||||
});
|
||||
|
||||
test('connect passes the workspace plan so the client can fire begin_checkout', function () {
|
||||
$this->user->update(['persona' => Persona::Agency->value, 'goals' => [Goal::SaveTime->value]]);
|
||||
onboardingWorkspace($this->user);
|
||||
|
||||
$plan = Plan::where('slug', Slug::Workspace)->firstOrFail();
|
||||
|
||||
$response = $this->actingAs($this->user->fresh())->get(route('app.onboarding.connect'));
|
||||
|
||||
$response->assertOk();
|
||||
$response->assertInertia(fn ($page) => $page
|
||||
->component('onboarding/Connect')
|
||||
->where('plan.name', $plan->name)
|
||||
->where('plan.interval', 'monthly')
|
||||
);
|
||||
});
|
||||
|
||||
test('connect offers a single linkedin card and no standalone linkedin page card', function () {
|
||||
$this->user->update(['persona' => Persona::Agency->value, 'goals' => [Goal::SaveTime->value]]);
|
||||
onboardingWorkspace($this->user);
|
||||
|
|
|
|||
Loading…
Reference in a new issue