mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-05 08:26:29 +00:00
feat: integrate telemetry service for secret synchronization events and update project role permissions to reflect workspace integrations
This commit is contained in:
@@ -1329,7 +1329,8 @@ export const registerRoutes = async (
|
||||
eventBusService,
|
||||
licenseService,
|
||||
membershipRoleDAL,
|
||||
membershipUserDAL
|
||||
membershipUserDAL,
|
||||
telemetryService
|
||||
});
|
||||
|
||||
const projectService = projectServiceFactory({
|
||||
|
||||
@@ -64,6 +64,8 @@ import { expandSecretReferencesFactory, getAllSecretReferences } from "../secret
|
||||
import { TSecretVersionV2DALFactory } from "../secret-v2-bridge/secret-version-dal";
|
||||
import { TSecretVersionV2TagDALFactory } from "../secret-v2-bridge/secret-version-tag-dal";
|
||||
import { SmtpTemplates, TSmtpService } from "../smtp/smtp-service";
|
||||
import { TTelemetryServiceFactory } from "../telemetry/telemetry-service";
|
||||
import { PostHogEventTypes } from "../telemetry/telemetry-types";
|
||||
import { TUserDALFactory } from "../user/user-dal";
|
||||
import { TWebhookDALFactory } from "../webhook/webhook-dal";
|
||||
import { fnTriggerWebhook } from "../webhook/webhook-fns";
|
||||
@@ -120,6 +122,7 @@ type TSecretQueueFactoryDep = {
|
||||
reminderService: Pick<TReminderServiceFactory, "createReminderInternal" | "deleteReminderBySecretId">;
|
||||
eventBusService: TEventBusService;
|
||||
licenseService: Pick<TLicenseServiceFactory, "getPlan">;
|
||||
telemetryService: Pick<TTelemetryServiceFactory, "sendPostHogEvents">;
|
||||
};
|
||||
|
||||
export type TGetSecrets = {
|
||||
@@ -184,7 +187,8 @@ export const secretQueueFactory = ({
|
||||
eventBusService,
|
||||
licenseService,
|
||||
membershipUserDAL,
|
||||
membershipRoleDAL
|
||||
membershipRoleDAL,
|
||||
telemetryService
|
||||
}: TSecretQueueFactoryDep) => {
|
||||
const integrationMeter = opentelemetry.metrics.getMeter("Integrations");
|
||||
const errorHistogram = integrationMeter.createHistogram("integration_secret_sync_errors", {
|
||||
@@ -1029,6 +1033,29 @@ export const secretQueueFactory = ({
|
||||
isSynced: response?.isSynced ?? true
|
||||
});
|
||||
|
||||
await telemetryService.sendPostHogEvents({
|
||||
event: PostHogEventTypes.IntegrationSynced,
|
||||
distinctId: `project/${projectId}`,
|
||||
organizationId: project.orgId,
|
||||
properties: {
|
||||
integrationId: integration.id,
|
||||
integration: integration.integration,
|
||||
environment,
|
||||
secretPath,
|
||||
projectId,
|
||||
url: integration.url ?? undefined,
|
||||
app: integration.app ?? undefined,
|
||||
appId: integration.appId ?? undefined,
|
||||
targetEnvironment: integration.targetEnvironment ?? undefined,
|
||||
targetEnvironmentId: integration.targetEnvironmentId ?? undefined,
|
||||
targetService: integration.targetService ?? undefined,
|
||||
targetServiceId: integration.targetServiceId ?? undefined,
|
||||
path: integration.path ?? undefined,
|
||||
region: integration.region ?? undefined,
|
||||
isManualSync: isManual ?? false
|
||||
}
|
||||
});
|
||||
|
||||
// May be undefined, if it's undefined we assume the sync was successful, hence the strict equality type check.
|
||||
if (response?.isSynced === false) {
|
||||
integrationsFailedToSync.push({
|
||||
|
||||
Reference in New Issue
Block a user