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