Skip to content

Commit

Permalink
basic 3.0 metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
shogunpurple committed Dec 3, 2024
1 parent f511408 commit 9ef6cbd
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/backend-core/src/events/publishers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ export { default as plugin } from "./plugin"
export { default as backup } from "./backup"
export { default as environmentVariable } from "./environmentVariable"
export { default as auditLog } from "./auditLog"
export { default as rowAction } from "./rowAction"
13 changes: 13 additions & 0 deletions packages/backend-core/src/events/publishers/rowAction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { publishEvent } from "../events"
import { Event, RowActionCreatedEvent } from "@budibase/types"

async function created(
rowAction: RowActionCreatedEvent,
timestamp?: string | number
) {
await publishEvent(Event.TABLE_CREATED, rowAction, timestamp)
}

export default {
created,
}
7 changes: 4 additions & 3 deletions packages/backend-core/src/events/publishers/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@ import {
ViewFilterDeletedEvent,
ViewFilterUpdatedEvent,
ViewUpdatedEvent,
View,
ViewV2,
ViewCalculation,
Table,
TableExportFormat,
} from "@budibase/types"

/* eslint-disable */

async function created(view: View, timestamp?: string | number) {
async function created(view: Partial<ViewV2>, timestamp?: string | number) {
const properties: ViewCreatedEvent = {
tableId: view.tableId,
name: view.name,
type: view.type,
}
await publishEvent(Event.VIEW_CREATED, properties, timestamp)
}
Expand Down
3 changes: 3 additions & 0 deletions packages/server/src/api/controllers/rowAction/crud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
RowActionResponse,
RowActionsResponse,
} from "@budibase/types"
import { events } from "@budibase/backend-core"
import sdk from "../../../sdk"

async function getTable(ctx: Ctx) {
Expand Down Expand Up @@ -59,6 +60,8 @@ export async function create(
name: ctx.request.body.name,
})

await events.rowAction.created(createdAction)

ctx.body = {
tableId,
id: createdAction.id,
Expand Down
4 changes: 4 additions & 0 deletions packages/server/src/api/controllers/view/viewsV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
CountDistinctCalculationFieldMetadata,
CountCalculationFieldMetadata,
} from "@budibase/types"
import { events } from "@budibase/backend-core"
import { builderSocket, gridSocket } from "../../../websockets"
import { helpers } from "@budibase/shared-core"

Expand Down Expand Up @@ -149,6 +150,9 @@ export async function create(ctx: Ctx<CreateViewRequest, ViewResponse>) {
primaryDisplay: view.primaryDisplay,
}
const result = await sdk.views.create(tableId, parsedView)

await events.view.created(view)

ctx.status = 201
ctx.body = {
data: result,
Expand Down
1 change: 1 addition & 0 deletions packages/types/src/sdk/events/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ export * from "./plugin"
export * from "./backup"
export * from "./environmentVariable"
export * from "./auditLog"
export * from "./rowAction"
6 changes: 6 additions & 0 deletions packages/types/src/sdk/events/rowAction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { BaseEvent } from "./event"

export interface RowActionCreatedEvent extends BaseEvent {
name: string
automationId: string
}
7 changes: 5 additions & 2 deletions packages/types/src/sdk/events/view.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { ViewCalculation } from "../../documents"
import { ViewCalculation, ViewV2Schema, ViewV2Type } from "../../documents"

Check failure on line 1 in packages/types/src/sdk/events/view.ts

View workflow job for this annotation

GitHub Actions / lint

'ViewV2Schema' is defined but never used. Allowed unused vars must match /^_/u
import { BaseEvent, TableExportFormat } from "./event"
import { LegacyFilter, SortOrder, SortType, UISearchFilter } from "../../api"

Check failure on line 3 in packages/types/src/sdk/events/view.ts

View workflow job for this annotation

GitHub Actions / lint

'LegacyFilter' is defined but never used. Allowed unused vars must match /^_/u

Check failure on line 3 in packages/types/src/sdk/events/view.ts

View workflow job for this annotation

GitHub Actions / lint

'SortOrder' is defined but never used. Allowed unused vars must match /^_/u

Check failure on line 3 in packages/types/src/sdk/events/view.ts

View workflow job for this annotation

GitHub Actions / lint

'SortType' is defined but never used. Allowed unused vars must match /^_/u

Check failure on line 3 in packages/types/src/sdk/events/view.ts

View workflow job for this annotation

GitHub Actions / lint

'UISearchFilter' is defined but never used. Allowed unused vars must match /^_/u
import { SearchFilters } from "../search"

Check failure on line 4 in packages/types/src/sdk/events/view.ts

View workflow job for this annotation

GitHub Actions / lint

'SearchFilters' is defined but never used. Allowed unused vars must match /^_/u

export interface ViewCreatedEvent extends BaseEvent {
tableId: string
name: string
type?: ViewV2Type
}

export interface ViewUpdatedEvent extends BaseEvent {
Expand Down

0 comments on commit 9ef6cbd

Please sign in to comment.