mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 09:27:50 +00:00
set posthog flush to zero and fix typos
This commit is contained in:
@@ -7,7 +7,7 @@ import { QueueJobs, QueueName, TQueueServiceFactory } from "@app/queue";
|
|||||||
|
|
||||||
import { getServerCfg } from "../super-admin/super-admin-service";
|
import { getServerCfg } from "../super-admin/super-admin-service";
|
||||||
import { TTelemetryDALFactory } from "./telemetry-dal";
|
import { TTelemetryDALFactory } from "./telemetry-dal";
|
||||||
import { TELEMETRY_SECRET_OPERATONS_KEY, TELEMETRY_SECRET_PROCESSED_KEY } from "./telemetry-service";
|
import { TELEMETRY_SECRET_OPERATIONS_KEY, TELEMETRY_SECRET_PROCESSED_KEY } from "./telemetry-service";
|
||||||
import { PostHogEventTypes } from "./telemetry-types";
|
import { PostHogEventTypes } from "./telemetry-types";
|
||||||
|
|
||||||
type TTelemetryQueueServiceFactoryDep = {
|
type TTelemetryQueueServiceFactoryDep = {
|
||||||
@@ -26,16 +26,16 @@ export const telemetryQueueServiceFactory = ({
|
|||||||
const appCfg = getConfig();
|
const appCfg = getConfig();
|
||||||
const postHog =
|
const postHog =
|
||||||
appCfg.isProductionMode && appCfg.TELEMETRY_ENABLED
|
appCfg.isProductionMode && appCfg.TELEMETRY_ENABLED
|
||||||
? new PostHog(appCfg.POSTHOG_PROJECT_API_KEY, { host: appCfg.POSTHOG_HOST })
|
? new PostHog(appCfg.POSTHOG_PROJECT_API_KEY, { host: appCfg.POSTHOG_HOST, flushAt: 1, flushInterval: 0 })
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
queueService.start(QueueName.TelemetryInstanceStats, async () => {
|
queueService.start(QueueName.TelemetryInstanceStats, async () => {
|
||||||
const { instanceId } = await getServerCfg();
|
const { instanceId } = await getServerCfg();
|
||||||
const telemtryStats = await telemetryDAL.getTelemetryInstanceStats();
|
const telemtryStats = await telemetryDAL.getTelemetryInstanceStats();
|
||||||
// parse the redis values into integer
|
// parse the redis values into integer
|
||||||
const numberOfSecretOperations = parseInt((await keyStore.getItem(TELEMETRY_SECRET_OPERATONS_KEY)) || "0", 10);
|
const numberOfSecretOperationsMade = parseInt((await keyStore.getItem(TELEMETRY_SECRET_OPERATIONS_KEY)) || "0", 10);
|
||||||
const numberOfSecretProcessed = parseInt((await keyStore.getItem(TELEMETRY_SECRET_PROCESSED_KEY)) || "0", 10);
|
const numberOfSecretProcessed = parseInt((await keyStore.getItem(TELEMETRY_SECRET_PROCESSED_KEY)) || "0", 10);
|
||||||
const stats = { ...telemtryStats, numberOfSecretProcessed, numberOfSecretOperations };
|
const stats = { ...telemtryStats, numberOfSecretProcessed, numberOfSecretOperationsMade };
|
||||||
|
|
||||||
// send to postHog
|
// send to postHog
|
||||||
postHog?.capture({
|
postHog?.capture({
|
||||||
@@ -45,7 +45,7 @@ export const telemetryQueueServiceFactory = ({
|
|||||||
});
|
});
|
||||||
// reset the stats
|
// reset the stats
|
||||||
await keyStore.deleteItem(TELEMETRY_SECRET_PROCESSED_KEY);
|
await keyStore.deleteItem(TELEMETRY_SECRET_PROCESSED_KEY);
|
||||||
await keyStore.deleteItem(TELEMETRY_SECRET_OPERATONS_KEY);
|
await keyStore.deleteItem(TELEMETRY_SECRET_OPERATIONS_KEY);
|
||||||
});
|
});
|
||||||
|
|
||||||
// every day at midnight a telemetry job executes on self hosted
|
// every day at midnight a telemetry job executes on self hosted
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ import { logger } from "@app/lib/logger";
|
|||||||
|
|
||||||
import { PostHogEventTypes, TPostHogEvent, TSecretModifiedEvent } from "./telemetry-types";
|
import { PostHogEventTypes, TPostHogEvent, TSecretModifiedEvent } from "./telemetry-types";
|
||||||
|
|
||||||
export const TELEMETRY_SECRET_PROCESSED_KEY = "telemtry-secret-processed";
|
export const TELEMETRY_SECRET_PROCESSED_KEY = "telemetry-secret-processed";
|
||||||
export const TELEMETRY_SECRET_OPERATONS_KEY = "telemtry-secret-operations";
|
export const TELEMETRY_SECRET_OPERATIONS_KEY = "telemetry-secret-operations";
|
||||||
|
|
||||||
export type TTelemetryServiceFactory = ReturnType<typeof telemetryServiceFactory>;
|
export type TTelemetryServiceFactory = ReturnType<typeof telemetryServiceFactory>;
|
||||||
export type TTelemetryServiceFactoryDep = {
|
export type TTelemetryServiceFactoryDep = {
|
||||||
@@ -30,10 +30,9 @@ To opt into telemetry, you can set "TELEMETRY_ENABLED=true" within the environme
|
|||||||
`);
|
`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const postHog =
|
const postHog = appCfg.TELEMETRY_ENABLED
|
||||||
appCfg.isProductionMode && appCfg.TELEMETRY_ENABLED
|
? new PostHog(appCfg.POSTHOG_PROJECT_API_KEY, { host: appCfg.POSTHOG_HOST })
|
||||||
? new PostHog(appCfg.POSTHOG_PROJECT_API_KEY, { host: appCfg.POSTHOG_HOST })
|
: undefined;
|
||||||
: undefined;
|
|
||||||
|
|
||||||
// used for email marketting email sending purpose
|
// used for email marketting email sending purpose
|
||||||
const sendLoopsEvent = async (email: string, firstName?: string, lastName?: string) => {
|
const sendLoopsEvent = async (email: string, firstName?: string, lastName?: string) => {
|
||||||
@@ -85,7 +84,7 @@ To opt into telemetry, you can set "TELEMETRY_ENABLED=true" within the environme
|
|||||||
TELEMETRY_SECRET_PROCESSED_KEY,
|
TELEMETRY_SECRET_PROCESSED_KEY,
|
||||||
(event as TSecretModifiedEvent).properties.numberOfSecrets
|
(event as TSecretModifiedEvent).properties.numberOfSecrets
|
||||||
);
|
);
|
||||||
await keyStore.incrementBy(TELEMETRY_SECRET_OPERATONS_KEY, 1);
|
await keyStore.incrementBy(TELEMETRY_SECRET_OPERATIONS_KEY, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ export type TTelemetryInstanceStatsEvent = {
|
|||||||
secrets: number;
|
secrets: number;
|
||||||
organizations: number;
|
organizations: number;
|
||||||
organizationNames: number;
|
organizationNames: number;
|
||||||
numberOfSecretOperations: number;
|
numberOfSecretOperationsMade: number;
|
||||||
numberOfSecretProcessed: number;
|
numberOfSecretProcessed: number;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Generated
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "npm-proj-1708687711895-0.8280111363176879xoEiUg",
|
"name": "frontend",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
|
|||||||
Reference in New Issue
Block a user