refactor(onboarding): send goals to PostHog exactly like persona

Mirror the persona handling: identify the user with a single `goals` person
property instead of an array plus a boolean per goal. Drops the goalProperties
helper.
This commit is contained in:
Paulo Castellano 2026-06-25 21:06:27 -03:00
parent 2525d834b0
commit f8f6d263ad

View file

@ -106,7 +106,9 @@ public function storeGoals(StoreOnboardingGoalsRequest $request, PostHogService
$user->update(['goals' => $goals]);
$postHog->identify($user->id, $this->goalProperties($goals));
$postHog->identify($user->id, [
'goals' => $goals,
]);
return redirect()->route('app.onboarding.connect');
}
@ -183,22 +185,4 @@ public function checkout(Request $request, StartSubscriptionCheckout $checkout):
route('app.onboarding.connect'),
);
}
/**
* PostHog person properties for the selected goals: the full array plus a
* boolean per goal, so campaigns can be cross-tabbed against each intent.
*
* @param array<int, string> $goals
* @return array<string, mixed>
*/
private function goalProperties(array $goals): array
{
$properties = ['onboarding_goals' => $goals];
foreach (Goal::cases() as $goal) {
$properties["goal_{$goal->value}"] = in_array($goal->value, $goals, true);
}
return $properties;
}
}