Skip to content

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

address posthog comment

Andreyccea423bcab4
diff --git a/backend/src/ee/routes/v1/pam-routers/pam-discovery-router.ts b/backend/src/ee/routes/v1/pam-routers/pam-discovery-router.ts
index 1b92b307a5..b15daee40d 100644
--- a/backend/src/ee/routes/v1/pam-routers/pam-discovery-router.ts
+++ b/backend/src/ee/routes/v1/pam-routers/pam-discovery-router.ts
@@ -2,6 +2,7 @@ import { z } from "zod";
import { PamDiscoverySourceRunsSchema, PamDiscoverySourcesSchema } from "@app/db/schemas";
import { EventType } from "@app/ee/services/audit-log/audit-log-types";
+import { ROTATION_STATUS } from "@app/ee/services/pam-account-rotation/pam-account-rotation-service";
import {
PamDiscoveryImportStatus,
PamDiscoveryRunStatus,
@@ -542,6 +543,32 @@ export const registerPamDiscoveryRouter = async (server: FastifyZodProvider) =>
})
.catch(() => {});
+ results.forEach((r) => {
+ if (!r.rotationAccountId || !r.accountType) return;
+ void server.services.telemetry
+ .sendPostHogEvents({
+ event: PostHogEventTypes.PamAccountRotationConfigured,
+ distinctId: getTelemetryDistinctId(req),
+ organizationId: req.permission.orgId,
+ properties: {
+ accountType: r.accountType,
+ orgId: req.permission.orgId,
+ hasRotationAccount: true,
+ scheduledRotationEnabled: r.scheduledRotationEnabled ?? false
+ }
+ })
+ .catch(() => {});
+ if (r.rotationStatus !== ROTATION_STATUS.Success) return;
+ void server.services.telemetry
+ .sendPostHogEvents({
+ event: PostHogEventTypes.PamAccountRotated,
+ distinctId: getTelemetryDistinctId(req),
+ organizationId: req.permission.orgId,
+ properties: { accountType: r.accountType, orgId: req.permission.orgId }
+ })
+ .catch(() => {});
+ });
+
return { results };
}
});
diff --git a/backend/src/ee/services/pam-discovery/pam-discovery-source-service.ts b/backend/src/ee/services/pam-discovery/pam-discovery-source-service.ts
index 4e9cd164b7..b8f17f5ed2 100644
--- a/backend/src/ee/services/pam-discovery/pam-discovery-source-service.ts
+++ b/backend/src/ee/services/pam-discovery/pam-discovery-source-service.ts
@@ -51,6 +51,7 @@ import {
TDeleteDiscoverySourceDTO,
TGetDiscoverySourceDTO,
TImportDiscoveredDTO,
+ TImportDiscoveredResult,
TListAccountDependenciesDTO,
TListDiscoveredDTO,
TListDiscoverySourcesDTO,
@@ -778,7 +779,7 @@ export const pamDiscoverySourceServiceFactory = (deps: TPamDiscoverySourceServic
const rotationLimit = pLimit(IMPORT_ROTATION_CONCURRENCY);
const rotateImported = async (accountId: string, accountType: string, rotationAccountId: string) => {
- let names: { accountName: string; rotationAccountName: string | null };
+ let names: { accountName: string; rotationAccountName: string | null; scheduledRotationEnabled: boolean };
try {
// the Rotation tab warns before rotating a password another account stores; an import can't ask, so it skips
const shared = await pamAccountRotationService.getSharedIdentity({ accountId, projectId, ...ctx });
@@ -799,7 +800,7 @@ export const pamDiscoverySourceServiceFactory = (deps: TPamDiscoverySourceServic
)
};
}
- const { accountName, rotationAccountName } = names;
+ const { accountName, rotationAccountName, scheduledRotationEnabled } = names;
await auditLogService.createAuditLog({
...auditLogInfo,
orgId: ctx.actorOrgId,
@@ -838,11 +839,11 @@ export const pamDiscoverySourceServiceFactory = (deps: TPamDiscoverySourceServic
}
}
});
- return { rotationAccountId, rotationStatus, rotationMessage: message };
+ return { rotationAccountId, rotationStatus, rotationMessage: message, accountType, scheduledRotationEnabled };
};
const results = await Promise.all(
- accounts.map(async (item) => {
+ accounts.map(async (item): Promise<TImportDiscoveredResult> => {
try {
const discovered = await pamDiscoveredAccountDAL.findById(item.discoveredAccountId);
if (!discovered || discovered.discoverySourceId !== sourceId) {
diff --git a/backend/src/ee/services/pam-discovery/pam-discovery-types.ts b/backend/src/ee/services/pam-discovery/pam-discovery-types.ts
index 8a63c2bb0d..aa99d86c14 100644
--- a/backend/src/ee/services/pam-discovery/pam-discovery-types.ts
+++ b/backend/src/ee/services/pam-discovery/pam-discovery-types.ts
@@ -3,7 +3,7 @@ import { TGatewayV2ServiceFactory } from "@app/ee/services/gateway-v2/gateway-v2
import { PamAccountType } from "../pam/pam-enums";
import { TActorContext } from "../pam/pam-permission";
-import { PamDiscoverySchedule, PamDiscoveryType } from "./pam-discovery-enums";
+import { PamDiscoveryImportStatus, PamDiscoverySchedule, PamDiscoveryType } from "./pam-discovery-enums";
export type TDiscoveredAccount = {
accountType: PamAccountType;
@@ -108,6 +108,19 @@ export type TImportDiscoveredDTO = {
auditLogInfo: AuditLogInfo;
} & TActorContext;
+export type TImportDiscoveredResult = {
+ discoveredAccountId: string;
+ status: PamDiscoveryImportStatus;
+ accountId?: string;
+ name?: string;
+ message?: string;
+ rotationAccountId?: string;
+ rotationStatus?: string;
+ rotationMessage?: string;
+ accountType?: string;
+ scheduledRotationEnabled?: boolean;
+};
+
export type TListAccountDependenciesDTO = {
projectId: string;
accountId: string;