Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

Address greptile comments

Carlos Monastyrskic866768e9c7d
diff --git a/backend/src/services/telemetry/telemetry-service.ts b/backend/src/services/telemetry/telemetry-service.ts
index 14dad062a1..25d87c9502 100644
--- a/backend/src/services/telemetry/telemetry-service.ts
+++ b/backend/src/services/telemetry/telemetry-service.ts
@@ -11,7 +11,7 @@ import { logger } from "@app/lib/logger";
import { ActorType } from "@app/services/auth/auth-type";
import { TOrgDALFactory } from "@app/services/org/org-dal";
-import { PostHogEventTypes, TPostHogEvent, TSecretModifiedEvent } from "./telemetry-types";
+import { HubSpotSignupMethod, PostHogEventTypes, TPostHogEvent, TSecretModifiedEvent } from "./telemetry-types";
export const TELEMETRY_SECRET_PROCESSED_KEY = "telemetry-secret-processed";
export const TELEMETRY_SECRET_OPERATIONS_KEY = "telemetry-secret-operations";
@@ -102,19 +102,38 @@ To opt into telemetry, you can set "TELEMETRY_ENABLED=true" within the environme
}
};
- const sendHubSpotSignupEvent = async (email: string, signupMethod: string, firstName?: string, lastName?: string) => {
+ const sendHubSpotSignupEvent = async (
+ email: string,
+ signupMethod: HubSpotSignupMethod,
+ firstName?: string,
+ lastName?: string
+ ) => {
const instanceType = licenseService.getInstanceType();
- if (instanceType === InstanceType.Cloud && appCfg.HUBSPOT_PORTAL_ID && appCfg.HUBSPOT_SIGNUP_FORM_ID) {
+ if (
+ appCfg.isProductionMode &&
+ instanceType === InstanceType.Cloud &&
+ appCfg.HUBSPOT_PORTAL_ID &&
+ appCfg.HUBSPOT_SIGNUP_FORM_ID
+ ) {
try {
+ const fields: { name: string; value: string }[] = [
+ { name: "email", value: email },
+ { name: "signup_method", value: signupMethod }
+ ];
+
+ const optionalFields: Record<string, string | undefined> = {
+ firstname: firstName,
+ lastname: lastName
+ };
+
+ for (const [name, value] of Object.entries(optionalFields)) {
+ if (value) fields.push({ name, value });
+ }
+
await request.post(
`https://api.hsforms.com/submissions/v3/integration/submit/${appCfg.HUBSPOT_PORTAL_ID}/${appCfg.HUBSPOT_SIGNUP_FORM_ID}`,
{
- fields: [
- { name: "email", value: email },
- { name: "signup_method", value: signupMethod },
- ...(firstName ? [{ name: "firstname", value: firstName }] : []),
- ...(lastName ? [{ name: "lastname", value: lastName }] : [])
- ],
+ fields,
context: {
pageUri: `${appCfg.SITE_URL || "https://app.infisical.com"}/signup`,
pageName: "App Signup"
diff --git a/backend/src/services/telemetry/telemetry-types.ts b/backend/src/services/telemetry/telemetry-types.ts
index 1bfd34df2c..7d64a9fed6 100644
--- a/backend/src/services/telemetry/telemetry-types.ts
+++ b/backend/src/services/telemetry/telemetry-types.ts
@@ -12,6 +12,9 @@ import {
UserActor
} from "@app/ee/services/audit-log/audit-log-types";
import { EnforcementLevel } from "@app/lib/types";
+import { AuthMethod } from "@app/services/auth/auth-type";
+
+export type HubSpotSignupMethod = AuthMethod | "invite";
export enum PostHogEventTypes {
SecretPush = "secrets pushed",