-- Web hook event tracking web hook interactions on suno web pages
-- Clustered by partition date and hour for optimal query performance
CREATE TRANSIENT TABLE IF NOT EXISTS {web_hook_event_table_name} CLUSTER BY (p_date, p_hour)(
	-- User identification
	USER_UID VARCHAR(255) COMMENT 'Unique user identifier',
	SESSION_ID VARCHAR(255) COMMENT 'Web session identifier',
	
	-- Event details  
	EVENT_NAME VARCHAR(255) COMMENT 'Name of the tracked event',
	FEATURE_SESSION_TYPE VARCHAR(255) COMMENT 'Type of feature session',
	FEATURE_SESSION_ID VARCHAR(255) COMMENT 'Unique feature session identifier',
	ACTION_NAME VARCHAR(255) COMMENT 'Specific action taken by user',
	CONTEXT VARIANT COMMENT 'Additional event context (JSON format)',
	
	-- Web context
	PAGE_URL VARCHAR(16777216) COMMENT 'URL of the page where event occurred',
	USER_AGENT VARCHAR(16777216) COMMENT 'Browser user agent string',
	LOCALE VARCHAR(255) COMMENT 'User locale/language setting',
	TIMEZONE VARCHAR(255) COMMENT 'User timezone',
	
	-- Timestamps
	CLIENT_TIMESTAMP TIMESTAMP_TZ(9) COMMENT 'When event occurred on client side',
	SERVER_TIMESTAMP TIMESTAMP_TZ(9) COMMENT 'When event was received by server',
	SERVER_PROCESS_TIMESTAMP TIMESTAMP_TZ(9) COMMENT 'When event was processed by server',
	
	-- Location and device info
	CLIENT_IP VARCHAR(255) COMMENT 'User IP address',
	COUNTRY VARCHAR(255) COMMENT 'User country',
	CITY VARCHAR(255) COMMENT 'User city',
	REGION_NAME VARCHAR(255) COMMENT 'User region/state',
	HASHED_USER_AGENT_ID VARCHAR(255) COMMENT 'Hashed identifier for user agent',
	PLATFORM VARCHAR(255) COMMENT 'Platform (web, mobile web, etc.)',
	IS_MOBILE BOOLEAN COMMENT 'Whether user is on mobile device',
	
	-- Partitioning columns
	P_DATE DATE COMMENT 'Partition date for table optimization',
	P_HOUR NUMBER(38,0) COMMENT 'Partition hour for table optimization',
	
	-- Additional identifiers
	TRANSACTION_ID VARCHAR(255) COMMENT 'Transaction/request identifier',
	ANONYMOUS_ID VARCHAR(255) COMMENT 'Anonymous user identifier',
	BACKEND_SESSION_ID VARCHAR(255) COMMENT 'Backend session identifier'
) COMMENT='Table contains web hook events for user interactions';

