mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-09 00:18:00 +01:00
chore: improve addon metrics usage
This commit is contained in:
parent
e2354dcceb
commit
d8ddb57818
@ -7,6 +7,7 @@ import type { IntegrationEventsService } from '../features/integration-events/in
|
||||
import type { IntegrationEventWriteModel } from '../features/integration-events/integration-events-store';
|
||||
import type EventEmitter from 'events';
|
||||
import type { IFlagResolver } from '../types';
|
||||
import { ADDON_EVENTS_HANDLED } from '../metric-events';
|
||||
|
||||
export default abstract class Addon {
|
||||
logger: Logger;
|
||||
@ -93,6 +94,12 @@ export default abstract class Addon {
|
||||
integrationEvent: IntegrationEventWriteModel,
|
||||
): Promise<void> {
|
||||
await this.integrationEventsService.registerEvent(integrationEvent);
|
||||
if (this.flagResolver.isEnabled('addonUsageMetrics')) {
|
||||
this.eventBus.emit(ADDON_EVENTS_HANDLED, {
|
||||
result: integrationEvent.state,
|
||||
destination: this.name,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
destroy?(): void;
|
||||
|
@ -13,7 +13,6 @@ import {
|
||||
} from './feature-event-formatter-md';
|
||||
import type { IEvent } from '../types/events';
|
||||
import type { IntegrationEventState } from '../features/integration-events/integration-events-store';
|
||||
import { ADDON_EVENTS_HANDLED } from '../metric-events';
|
||||
|
||||
interface IDatadogParameters {
|
||||
url: string;
|
||||
@ -116,13 +115,6 @@ export default class DatadogAddon extends Addon {
|
||||
this.logger.warn(failedMessage);
|
||||
}
|
||||
|
||||
if (this.flagResolver.isEnabled('addonUsageMetrics')) {
|
||||
this.eventBus.emit(ADDON_EVENTS_HANDLED, {
|
||||
result: state,
|
||||
destination: 'datadog',
|
||||
});
|
||||
}
|
||||
|
||||
this.registerEvent({
|
||||
integrationId,
|
||||
state,
|
||||
|
@ -16,7 +16,6 @@ import {
|
||||
import { gzip } from 'node:zlib';
|
||||
import { promisify } from 'util';
|
||||
import type { IntegrationEventState } from '../features/integration-events/integration-events-store';
|
||||
import { ADDON_EVENTS_HANDLED } from '../metric-events';
|
||||
|
||||
const asyncGzip = promisify(gzip);
|
||||
|
||||
@ -120,13 +119,6 @@ export default class NewRelicAddon extends Addon {
|
||||
this.logger.warn(failedMessage);
|
||||
}
|
||||
|
||||
if (this.flagResolver.isEnabled('addonUsageMetrics')) {
|
||||
this.eventBus.emit(ADDON_EVENTS_HANDLED, {
|
||||
result: state,
|
||||
destination: 'new-relic',
|
||||
});
|
||||
}
|
||||
|
||||
this.registerEvent({
|
||||
integrationId,
|
||||
state,
|
||||
|
@ -25,7 +25,6 @@ import {
|
||||
} from './feature-event-formatter-md';
|
||||
import type { IEvent } from '../types/events';
|
||||
import type { IntegrationEventState } from '../features/integration-events/integration-events-store';
|
||||
import { ADDON_EVENTS_HANDLED } from '../metric-events';
|
||||
|
||||
interface ISlackAppAddonParameters {
|
||||
accessToken: string;
|
||||
@ -182,13 +181,6 @@ export default class SlackAppAddon extends Addon {
|
||||
stateDetails.push(errorMessage);
|
||||
this.logger.warn(errorMessage, error);
|
||||
} finally {
|
||||
if (this.flagResolver.isEnabled('addonUsageMetrics')) {
|
||||
this.eventBus.emit(ADDON_EVENTS_HANDLED, {
|
||||
result: state,
|
||||
destination: 'slack-app',
|
||||
});
|
||||
}
|
||||
|
||||
this.registerEvent({
|
||||
integrationId,
|
||||
state,
|
||||
|
@ -14,7 +14,6 @@ import {
|
||||
} from './feature-event-formatter-md';
|
||||
import type { IEvent } from '../types/events';
|
||||
import type { IntegrationEventState } from '../features/integration-events/integration-events-store';
|
||||
import { ADDON_EVENTS_HANDLED } from '../metric-events';
|
||||
|
||||
interface ISlackAddonParameters {
|
||||
url: string;
|
||||
@ -134,13 +133,6 @@ export default class SlackAddon extends Addon {
|
||||
this.logger.warn(successWithErrorsMessage);
|
||||
}
|
||||
|
||||
if (this.flagResolver.isEnabled('addonUsageMetrics')) {
|
||||
this.eventBus.emit(ADDON_EVENTS_HANDLED, {
|
||||
result: state,
|
||||
destination: 'slack',
|
||||
});
|
||||
}
|
||||
|
||||
this.registerEvent({
|
||||
integrationId,
|
||||
state,
|
||||
|
@ -12,7 +12,6 @@ import {
|
||||
} from './feature-event-formatter-md';
|
||||
import type { IEvent } from '../types/events';
|
||||
import type { IntegrationEventState } from '../features/integration-events/integration-events-store';
|
||||
import { ADDON_EVENTS_HANDLED } from '../metric-events';
|
||||
|
||||
interface ITeamsParameters {
|
||||
url: string;
|
||||
@ -110,13 +109,6 @@ export default class TeamsAddon extends Addon {
|
||||
this.logger.warn(failedMessage);
|
||||
}
|
||||
|
||||
if (this.flagResolver.isEnabled('addonUsageMetrics')) {
|
||||
this.eventBus.emit(ADDON_EVENTS_HANDLED, {
|
||||
result: state,
|
||||
destination: 'teams',
|
||||
});
|
||||
}
|
||||
|
||||
this.registerEvent({
|
||||
integrationId,
|
||||
state,
|
||||
|
@ -12,7 +12,6 @@ import {
|
||||
type FeatureEventFormatter,
|
||||
FeatureEventFormatterMd,
|
||||
} from './feature-event-formatter-md';
|
||||
import { ADDON_EVENTS_HANDLED } from '../metric-events';
|
||||
|
||||
interface IParameters {
|
||||
url: string;
|
||||
@ -104,13 +103,6 @@ export default class Webhook extends Addon {
|
||||
this.logger.warn(failedMessage);
|
||||
}
|
||||
|
||||
if (this.flagResolver.isEnabled('addonUsageMetrics')) {
|
||||
this.eventBus.emit(ADDON_EVENTS_HANDLED, {
|
||||
result: state,
|
||||
destination: 'webhook',
|
||||
});
|
||||
}
|
||||
|
||||
if (this.flagResolver.isEnabled('webhookDomainLogging')) {
|
||||
const domain = new URL(url).hostname;
|
||||
this.logger.info(`Webhook invoked`, {
|
||||
|
@ -53,7 +53,6 @@ export type IFlagKey =
|
||||
| 'navigationSidebar'
|
||||
| 'extendedMetrics'
|
||||
| 'removeUnsafeInlineStyleSrc'
|
||||
| 'addonUsageMetrics'
|
||||
| 'onboardingMetrics'
|
||||
| 'onboardingUI'
|
||||
| 'projectRoleAssignment'
|
||||
@ -63,7 +62,8 @@ export type IFlagKey =
|
||||
| 'purchaseAdditionalEnvironments'
|
||||
| 'originMiddlewareRequestLogging'
|
||||
| 'unleashAI'
|
||||
| 'webhookDomainLogging';
|
||||
| 'webhookDomainLogging'
|
||||
| 'addonUsageMetrics';
|
||||
|
||||
export type IFlags = Partial<{ [key in IFlagKey]: boolean | Variant }>;
|
||||
|
||||
@ -268,10 +268,6 @@ const flags: IFlags = {
|
||||
process.env.UNLEASH_EXPERIMENTAL_REMOVE_UNSAFE_INLINE_STYLE_SRC,
|
||||
false,
|
||||
),
|
||||
addonUsageMetrics: parseEnvVarBoolean(
|
||||
process.env.UNLEASH_EXPERIMENTAL_ADDON_USAGE_METRICS,
|
||||
false,
|
||||
),
|
||||
onboardingMetrics: parseEnvVarBoolean(
|
||||
process.env.UNLEASH_EXPERIMENTAL_ONBOARDING_METRICS,
|
||||
false,
|
||||
@ -312,6 +308,10 @@ const flags: IFlags = {
|
||||
process.env.UNLEASH_EXPERIMENT_WEBHOOK_DOMAIN_LOGGING,
|
||||
false,
|
||||
),
|
||||
addonUsageMetrics: parseEnvVarBoolean(
|
||||
process.env.UNLEASH_EXPERIMENTAL_ADDON_USAGE_METRICS,
|
||||
false,
|
||||
),
|
||||
};
|
||||
|
||||
export const defaultExperimentalOptions: IExperimentalOptions = {
|
||||
|
@ -50,7 +50,6 @@ process.nextTick(async () => {
|
||||
manyStrategiesPagination: true,
|
||||
enableLegacyVariants: false,
|
||||
extendedMetrics: true,
|
||||
addonUsageMetrics: true,
|
||||
onboardingMetrics: true,
|
||||
onboardingUI: true,
|
||||
personalDashboardUI: true,
|
||||
@ -58,6 +57,7 @@ process.nextTick(async () => {
|
||||
originMiddlewareRequestLogging: true,
|
||||
unleashAI: true,
|
||||
webhookDomainLogging: true,
|
||||
addonUsageMetrics: true,
|
||||
},
|
||||
},
|
||||
authentication: {
|
||||
|
Loading…
Reference in New Issue
Block a user