mirror of
https://github.com/OpenSquawk/OpenSquawk
synced 2026-08-06 17:53:19 +08:00
Wochenreport
This commit is contained in:
28
server/models/LandingAnalyticsEvent.ts
Normal file
28
server/models/LandingAnalyticsEvent.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import mongoose from 'mongoose'
|
||||
|
||||
export type LandingAnalyticsEventType = 'view' | 'scrolled' | 'waitlist_submit'
|
||||
export type AnalyticsProduct = 'classroom' | 'liveatc'
|
||||
|
||||
export interface LandingAnalyticsEventDocument extends mongoose.Document {
|
||||
type: LandingAnalyticsEventType
|
||||
product: AnalyticsProduct
|
||||
sessionId?: string
|
||||
path?: string
|
||||
source?: string
|
||||
scrollDepth?: number
|
||||
createdAt: Date
|
||||
}
|
||||
|
||||
const landingAnalyticsEventSchema = new mongoose.Schema<LandingAnalyticsEventDocument>({
|
||||
type: { type: String, enum: ['view', 'scrolled', 'waitlist_submit'], required: true, index: true },
|
||||
product: { type: String, enum: ['classroom', 'liveatc'], default: 'classroom', index: true },
|
||||
sessionId: { type: String, trim: true, index: true },
|
||||
path: { type: String, trim: true },
|
||||
source: { type: String, trim: true },
|
||||
scrollDepth: { type: Number, min: 0, max: 100 },
|
||||
createdAt: { type: Date, default: () => new Date(), index: true },
|
||||
})
|
||||
|
||||
export const LandingAnalyticsEvent =
|
||||
(mongoose.models.LandingAnalyticsEvent as mongoose.Model<LandingAnalyticsEventDocument> | undefined) ||
|
||||
mongoose.model<LandingAnalyticsEventDocument>('LandingAnalyticsEvent', landingAnalyticsEventSchema)
|
||||
Reference in New Issue
Block a user