feat: add PostHog event tracking for feature opt-in banner and dialog (#27579)
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
4367028492
commit
5804cc4fb0
3 files changed
+63
-2
No files matched your search
@@ -15,6 +15,12 @@ type UserRoleContext = {
|
||||
adminTeamNames: { id: number; name: string }[];
|
||||
};
|
||||
|
||||
type FeatureOptInTrackingData = {
|
||||
enableFor: "user" | "organization" | "teams";
|
||||
teamCount?: number;
|
||||
autoOptIn: boolean;
|
||||
};
|
||||
|
||||
type FeatureOptInBannerState = {
|
||||
shouldShow: boolean;
|
||||
isLoading: boolean;
|
||||
@@ -28,6 +34,7 @@ type FeatureOptInBannerState = {
|
||||
dismiss: () => void;
|
||||
markOptedIn: () => void;
|
||||
mutations: FeatureOptInMutations;
|
||||
trackFeatureEnabled: (data: FeatureOptInTrackingData) => void;
|
||||
};
|
||||
|
||||
interface FeatureOptInBannerWrapperProps {
|
||||
@@ -60,6 +67,7 @@ function FeatureOptInBannerWrapper({ state }: FeatureOptInBannerWrapperProps): R
|
||||
featureConfig={state.featureConfig}
|
||||
userRoleContext={state.userRoleContext}
|
||||
mutations={state.mutations}
|
||||
onTrackFeatureEnabled={state.trackFeatureEnabled}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
|
||||
@@ -41,6 +41,12 @@ export type FeatureOptInMutations = {
|
||||
invalidateQueries: () => void;
|
||||
};
|
||||
|
||||
type FeatureOptInTrackingData = {
|
||||
enableFor: "user" | "organization" | "teams";
|
||||
teamCount?: number;
|
||||
autoOptIn: boolean;
|
||||
};
|
||||
|
||||
interface FeatureOptInConfirmDialogProps {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
@@ -49,6 +55,7 @@ interface FeatureOptInConfirmDialogProps {
|
||||
featureConfig: OptInFeatureConfig;
|
||||
userRoleContext: UserRoleContext;
|
||||
mutations: FeatureOptInMutations;
|
||||
onTrackFeatureEnabled?: (data: FeatureOptInTrackingData) => void;
|
||||
}
|
||||
|
||||
export function FeatureOptInConfirmDialog({
|
||||
@@ -59,6 +66,7 @@ export function FeatureOptInConfirmDialog({
|
||||
featureConfig,
|
||||
userRoleContext,
|
||||
mutations,
|
||||
onTrackFeatureEnabled,
|
||||
}: FeatureOptInConfirmDialogProps): ReactElement {
|
||||
const { t } = useLocale();
|
||||
const router = useRouter();
|
||||
@@ -159,6 +167,13 @@ export function FeatureOptInConfirmDialog({
|
||||
|
||||
await Promise.all(promises);
|
||||
|
||||
const enableFor = enableForOrg ? "organization" : hasTeamsSelected ? "teams" : "user";
|
||||
onTrackFeatureEnabled?.({
|
||||
enableFor,
|
||||
teamCount: hasTeamsSelected ? selectedTeamIds.length : undefined,
|
||||
autoOptIn,
|
||||
});
|
||||
|
||||
setIsSuccess(true);
|
||||
setShouldInvalidate(true);
|
||||
onOptInSuccess?.();
|
||||
|
||||
Reference in new issue
Block a user