mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-10-31 07:44:21 +00:00
feat: centralize PostHog analytics with proper error handling
- Create lib/analytics.ts with centralized tracking functions - Use arrow functions and camelCase naming per code standards - Add error handling to prevent analytics failures from crashing app - Update auth forms and provider workflows to use new analytics lib - Export TypeScript interfaces for type-safe analytics payloads Addresses PR review comments: - Convert to arrow functions (requested by @paabloLC) - Use camelCase for event and property names - Centralize analytics logic for better maintainability
This commit is contained in:
1 parent
255df2dbc1
commit
bc34c9df4a
4 files changed
+161
-29
No files matched your search
@@ -5,7 +5,6 @@ import { Icon } from "@iconify/react";
|
||||
import { Checkbox } from "@nextui-org/react";
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/navigation";
|
||||
import posthog from "posthog-js";
|
||||
import { useState } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { z } from "zod";
|
||||
@@ -18,6 +17,7 @@ import { scanOnDemand, scheduleDaily } from "@/actions/scans";
|
||||
import { getTask } from "@/actions/task/tasks";
|
||||
import { CheckIcon, RocketIcon } from "@/components/icons";
|
||||
import { useToast } from "@/components/ui";
|
||||
import { trackCloudConnectionSuccess } from "@/lib/analytics";
|
||||
import { CustomButton } from "@/components/ui/custom";
|
||||
import { Form } from "@/components/ui/form";
|
||||
import { checkTaskStatus } from "@/lib/helper";
|
||||
@@ -146,12 +146,11 @@ export const TestConnectionForm = ({
|
||||
});
|
||||
} else {
|
||||
setIsRedirecting(true);
|
||||
// Capture PostHog event for successful cloud connection
|
||||
posthog.capture("cloud_connection_success", {
|
||||
provider_type: providerType,
|
||||
provider_alias: providerData.data.attributes.alias,
|
||||
scan_type: form.watch("runOnce") ? "single" : "scheduled",
|
||||
timestamp: Date.now(),
|
||||
// Track cloud connection success event
|
||||
trackCloudConnectionSuccess({
|
||||
providerType: providerType,
|
||||
providerAlias: providerData.data.attributes.alias,
|
||||
scanType: form.watch("runOnce") ? "single" : "scheduled",
|
||||
});
|
||||
router.push("/scans");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user