Adding events for environment variables (created, deleted, upgrade panel opened).
This commit is contained in:
parent
8e25ff9469
commit
5a2937c8d2
|
@ -0,0 +1,38 @@
|
|||
import {
|
||||
Event,
|
||||
EnvironmentVariableCreatedEvent,
|
||||
EnvironmentVariableDeletedEvent,
|
||||
EnvironmentVariableUpgradePanelOpenedEvent,
|
||||
} from "@budibase/types"
|
||||
import { publishEvent } from "../events"
|
||||
|
||||
async function created(name: string, environments: string[]) {
|
||||
const properties: EnvironmentVariableCreatedEvent = {
|
||||
name,
|
||||
environments,
|
||||
}
|
||||
await publishEvent(Event.ENVIRONMENT_VARIABLE_CREATED, properties)
|
||||
}
|
||||
|
||||
async function deleted(name: string) {
|
||||
const properties: EnvironmentVariableDeletedEvent = {
|
||||
name,
|
||||
}
|
||||
await publishEvent(Event.ENVIRONMENT_VARIABLE_DELETED, properties)
|
||||
}
|
||||
|
||||
async function upgradePanelOpened(userId: string) {
|
||||
const properties: EnvironmentVariableUpgradePanelOpenedEvent = {
|
||||
userId,
|
||||
}
|
||||
await publishEvent(
|
||||
Event.ENVIRONMENT_VARIABLE_UPGRADE_PANEL_OPENED,
|
||||
properties
|
||||
)
|
||||
}
|
||||
|
||||
export default {
|
||||
created,
|
||||
deleted,
|
||||
upgradePanelOpened,
|
||||
}
|
|
@ -20,3 +20,4 @@ export { default as backfill } from "./backfill"
|
|||
export { default as group } from "./group"
|
||||
export { default as plugin } from "./plugin"
|
||||
export { default as backup } from "./backup"
|
||||
export { default as environmentVariable } from "./environmentVariable"
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
import { BaseEvent } from "./event"
|
||||
|
||||
export interface EnvironmentVariableCreatedEvent extends BaseEvent {
|
||||
name: string
|
||||
environments: string[]
|
||||
}
|
||||
|
||||
export interface EnvironmentVariableDeletedEvent extends BaseEvent {
|
||||
name: string
|
||||
}
|
||||
|
||||
export interface EnvironmentVariableUpgradePanelOpenedEvent extends BaseEvent {
|
||||
userId: string
|
||||
}
|
|
@ -172,6 +172,11 @@ export enum Event {
|
|||
// BACKUP
|
||||
APP_BACKUP_RESTORED = "app:backup:restored",
|
||||
APP_BACKUP_TRIGGERED = "app:backup:triggered",
|
||||
|
||||
// ENVIRONMENT VARIABLE
|
||||
ENVIRONMENT_VARIABLE_CREATED = "environment_variable:created",
|
||||
ENVIRONMENT_VARIABLE_DELETED = "environment_variable:deleted",
|
||||
ENVIRONMENT_VARIABLE_UPGRADE_PANEL_OPENED = "environment_variable:upgrade_panel_opened",
|
||||
}
|
||||
|
||||
// properties added at the final stage of the event pipeline
|
||||
|
|
|
@ -21,3 +21,4 @@ export * from "./identification"
|
|||
export * from "./userGroup"
|
||||
export * from "./plugin"
|
||||
export * from "./backup"
|
||||
export * from "./environmentVariable"
|
||||
|
|
Loading…
Reference in New Issue