Skip to content

Commit

Permalink
Merge pull request #160 from buggregator/issue/#154-add-var-dump-addi…
Browse files Browse the repository at this point in the history
…tional-label

[#154] add var-dump label
  • Loading branch information
butschster authored Jun 7, 2024
2 parents 9ca5289 + 57daf77 commit 772311d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
34 changes: 21 additions & 13 deletions src/entities/var-dump/lib/normalize-var-dump-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,24 @@ import type { ServerEvent, NormalizedEvent } from "~/src/shared/types";
import { EVENT_TYPES } from "~/src/shared/types";
import type { VarDump } from "../types";

export const normalizeVarDumpEvent = (event: ServerEvent<VarDump>): NormalizedEvent<VarDump> => ({
id: event.uuid,
type: EVENT_TYPES.VAR_DUMP,
labels: [EVENT_TYPES.VAR_DUMP],
origin: {
file: event.payload.context.source.file,
name: event.payload.context.source.name,
line_number: event.payload.context.source.line,
},
serverName: "",
date: event.timestamp ? new Date(event.timestamp * 1000) : null,
payload: event.payload
})
export const normalizeVarDumpEvent = (event: ServerEvent<VarDump>): NormalizedEvent<VarDump> => {
const normalizedEvent: NormalizedEvent<VarDump> = {
id: event.uuid,
type: EVENT_TYPES.VAR_DUMP,
labels: [EVENT_TYPES.VAR_DUMP],
origin: {
file: event.payload.context.source.file,
name: event.payload.context.source.name,
line_number: event.payload.context.source.line,
},
serverName: "",
date: event.timestamp ? new Date(event.timestamp * 1000) : null,
payload: event.payload
}

if (event.payload?.payload?.label != null) {
normalizedEvent.labels.push(`label: ${event.payload.payload.label}`);
}

return normalizedEvent;
}
1 change: 1 addition & 0 deletions src/entities/var-dump/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export interface VarDump {
payload: {
label: string | null,
type: string,
value: string | number | boolean
},
Expand Down

0 comments on commit 772311d

Please sign in to comment.