Skip to content

Commit

Permalink
feat: display event type
Browse files Browse the repository at this point in the history
  • Loading branch information
pozil committed Apr 3, 2024
1 parent 655ad22 commit 45d0a89
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main/default/lwc/events/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ export const TABLE_COLUMNS = [
type: 'text',
initialWidth: 200
},
{
label: 'Type',
fieldName: 'type',
type: 'text',
initialWidth: 200
},
{
label: 'Replay Id',
fieldName: 'replayId',
Expand Down
5 changes: 5 additions & 0 deletions src/main/default/lwc/events/events.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
value={selectedEvent.channel}
readonly
></lightning-input>
<lightning-input
label="Type"
value={selectedEvent.type}
readonly
></lightning-input>
<lightning-input
label="Replay Id"
value={selectedEvent.replayId}
Expand Down
12 changes: 12 additions & 0 deletions src/main/default/lwc/streamingUtility/streamingUtility.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,17 @@ export function normalizeEvent(event) {
timestamp = time.getTime();
timeLabel = getTimeLabel(time);
}
// Get event type
let type = null;
if (event.data.event?.type) {
type = `PushTopic: ${event.data.event.type}`;
} else if (event.data.event.createdDate) {
type = `Generic`;
} else if (event.data.payload.ChangeEventHeader) {
type = `Change Event: ${event.data.payload.ChangeEventHeader.entityName} ${event.data.payload.ChangeEventHeader.changeType}`;
} else if (event.data.payload.CreatedDate) {
type = 'Platform Event';
}
// Assemble payload
let payload = null;
if (event.data.payload) {
Expand All @@ -122,6 +133,7 @@ export function normalizeEvent(event) {
timeLabel,
channel: event.channel,
replayId: event.data.event.replayId,
type,
payload: JSON.stringify(payload)
};
return eventData;
Expand Down

0 comments on commit 45d0a89

Please sign in to comment.