mirror of
https://github.com/velocitatem/PHANTOM.git
synced 2026-07-16 01:53:37 +00:00
* chore: cleaning gitignore * formating and env documentation * feat: context switching of hotel/airline depndent on env var via middleware * fixed alignment and building * wrong file * prods * fixed applying style * better session cookie management * tentative session storage with maybe using airtable * migrated api of ingestion * events and products apge * fixing build * 13 create outline for research paper draft (#18) * updated outline for paper from issue * extra paper sections and some formalization of series data * algorithms and acknowledgements * updated outline for paper from issue * upadted text formating * event unification * refactor tracking to ues callbacks instead of refs * implement a pricing display api with session passing * moved middleware to proxy according to new changes in Nextjs * refactoed kafka ingestion to go via backend not web-db * Refactor docker-compose services to use individual Dockerfiles (#20) * Initial plan * Refactor services into individual Dockerfiles Co-authored-by: velocitatem <60182044+velocitatem@users.noreply.github.com> * Add EXPOSE directives to all Dockerfiles with port documentation Co-authored-by: velocitatem <60182044+velocitatem@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: velocitatem <60182044+velocitatem@users.noreply.github.com> * fixing small bugs and adding exepriments to tracking * added some doc
92 lines
2.1 KiB
TypeScript
92 lines
2.1 KiB
TypeScript
import { z } from 'zod';
|
|
|
|
// canonical events for tracking user interactions
|
|
export type EventName =
|
|
// navigation & discovery
|
|
| 'page_view'
|
|
| 'view_item_page'
|
|
| 'learn_more_about_item'
|
|
// cart operations
|
|
| 'add_item_to_cart'
|
|
| 'remove_item'
|
|
| 'checkout_start'
|
|
| 'purchase_complete'
|
|
// filtering & search
|
|
| 'search'
|
|
| 'filter_for_date'
|
|
| 'filter_for_amenities'
|
|
| 'filter_for_price'
|
|
| 'sort_change'
|
|
// dwell signals (Ns threshold)
|
|
| 'hover_over_title'
|
|
| 'hover_over_paragraph'
|
|
| 'hover_over_link'
|
|
| 'hover_over_button'
|
|
// session
|
|
| 'session_start';
|
|
|
|
export const eventNames: readonly EventName[] = [
|
|
'page_view',
|
|
'view_item_page',
|
|
'learn_more_about_item',
|
|
'add_item_to_cart',
|
|
'remove_item',
|
|
'checkout_start',
|
|
'purchase_complete',
|
|
'search',
|
|
'filter_for_date',
|
|
'filter_for_amenities',
|
|
'filter_for_price',
|
|
'sort_change',
|
|
'hover_over_title',
|
|
'hover_over_paragraph',
|
|
'hover_over_link',
|
|
'hover_over_button',
|
|
'session_start',
|
|
] as const;
|
|
|
|
export interface EventBase {
|
|
sessionId: string;
|
|
experimentId?: string;
|
|
storeMode: 'hotel' | 'airline';
|
|
ts: string; // ISO8601
|
|
page: string;
|
|
eventName: EventName;
|
|
productId?: string;
|
|
metadata?: Record<string, unknown>;
|
|
userAgent?: string;
|
|
}
|
|
|
|
// zod schema for runtime validation
|
|
export const eventBaseSchema = z.object({
|
|
sessionId: z.string().min(1),
|
|
experimentId: z.string().optional(),
|
|
storeMode: z.enum(['hotel', 'airline']),
|
|
ts: z.string().datetime(), // validates ISO8601
|
|
page: z.string().min(1),
|
|
eventName: z.enum([
|
|
'page_view',
|
|
'view_item_page',
|
|
'learn_more_about_item',
|
|
'add_item_to_cart',
|
|
'remove_item',
|
|
'checkout_start',
|
|
'purchase_complete',
|
|
'search',
|
|
'filter_for_date',
|
|
'filter_for_amenities',
|
|
'filter_for_price',
|
|
'sort_change',
|
|
'hover_over_title',
|
|
'hover_over_paragraph',
|
|
'hover_over_link',
|
|
'hover_over_button',
|
|
'session_start',
|
|
]),
|
|
productId: z.string().optional(),
|
|
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
userAgent: z.string().optional(),
|
|
});
|
|
|
|
export type EventBaseValidated = z.infer<typeof eventBaseSchema>;
|