mirror of
https://github.com/hyperdxio/hyperdx
synced 2026-04-21 13:37:15 +00:00
## Summary This PR adds createdAt/By and updatedAt/By metadata to dashboard and saved searches. ### Screenshots or video <img width="1466" height="342" alt="Screenshot 2026-04-01 at 3 19 07 PM" src="https://github.com/user-attachments/assets/c349a3d5-f8e3-4155-9938-c8f005cdcd52" /> <img width="1216" height="433" alt="Screenshot 2026-04-01 at 3 19 57 PM" src="https://github.com/user-attachments/assets/9542a631-bdda-484c-9cef-6b780667d1dc" /> <img width="1196" height="345" alt="Screenshot 2026-04-01 at 3 19 46 PM" src="https://github.com/user-attachments/assets/c05cd0cc-2ca4-4397-8acb-e31a81b882ec" /> <img width="1409" height="433" alt="Screenshot 2026-04-01 at 3 19 38 PM" src="https://github.com/user-attachments/assets/593a96d7-86be-45b2-9f0a-b3a8f00d1353" /> <img width="1447" height="181" alt="Screenshot 2026-04-01 at 3 20 59 PM" src="https://github.com/user-attachments/assets/88742578-3dbd-4305-921f-e2ecdd11d5d4" /> ### How to test locally or on Vercel This should be tested locally. In the preview environment, these fields are not populated (since they're maintained through automatic MongoDB createdAt/updatedAt values and createdBy/updatedBy values pulled from User accounts. ### References - Linear Issue: Closes HDX-3461 - Related PRs:
53 lines
1.4 KiB
TypeScript
53 lines
1.4 KiB
TypeScript
import { DashboardSchema } from '@hyperdx/common-utils/dist/types';
|
|
import mongoose, { Schema } from 'mongoose';
|
|
import { z } from 'zod';
|
|
|
|
import type { ObjectId } from '.';
|
|
|
|
export interface IDashboard extends z.infer<typeof DashboardSchema> {
|
|
_id: ObjectId;
|
|
team: ObjectId;
|
|
createdBy?: ObjectId;
|
|
updatedBy?: ObjectId;
|
|
createdAt: Date;
|
|
updatedAt: Date;
|
|
}
|
|
|
|
export type DashboardDocument = mongoose.HydratedDocument<IDashboard>;
|
|
|
|
export default mongoose.model<IDashboard>(
|
|
'Dashboard',
|
|
new Schema<IDashboard>(
|
|
{
|
|
name: {
|
|
type: String,
|
|
required: true,
|
|
},
|
|
tiles: { type: mongoose.Schema.Types.Mixed, required: true },
|
|
team: { type: mongoose.Schema.Types.ObjectId, ref: 'Team' },
|
|
tags: {
|
|
type: [String],
|
|
default: [],
|
|
},
|
|
filters: { type: mongoose.Schema.Types.Array, default: [] },
|
|
savedQuery: { type: String, required: false },
|
|
savedQueryLanguage: { type: String, required: false },
|
|
savedFilterValues: { type: mongoose.Schema.Types.Array, required: false },
|
|
containers: { type: mongoose.Schema.Types.Array, required: false },
|
|
createdBy: {
|
|
type: mongoose.Schema.Types.ObjectId,
|
|
ref: 'User',
|
|
required: false,
|
|
},
|
|
updatedBy: {
|
|
type: mongoose.Schema.Types.ObjectId,
|
|
ref: 'User',
|
|
required: false,
|
|
},
|
|
},
|
|
{
|
|
timestamps: true,
|
|
toJSON: { getters: true },
|
|
},
|
|
),
|
|
);
|