-- Web user event tracking web user activities on suno web pages
-- Clustered by partition date and hour for optimal query performance
create TRANSIENT TABLE IF NOT EXISTS {web_user_event_table_name} cluster by (p_date, p_hour)(
	-- User identification
	USER_UID VARCHAR(255),              -- Unique user identifier
	SESSION_ID VARCHAR(255),            -- Web session identifier (this is the same value as BACKEND_SESSION_ID, but it is attached by frontend when process the event)
	
	-- Event details  
	EVENT_NAME VARCHAR(255),            -- Name of the tracked event
	FEATURE_SESSION_TYPE VARCHAR(255),  -- Type of feature session
	FEATURE_SESSION_ID VARCHAR(255),    -- Unique feature session identifier
	COMPONENT_CONTEXT VARCHAR(16777216),-- Context of the UI component that triggered the event
	ACTION_NAME VARCHAR(255),           -- Specific action taken by user
	
	-- Event object details
	PRINCIPAL_OBJECT_TYPE VARCHAR(255),       -- Type of primary object involved in the event
	PRINCIPAL_OBJECT_VALUE VARCHAR(16777216), -- Value/ID of the primary object
	CONTEXT VARIANT,                          -- Additional event context (JSON format)
	
	-- Web context
	PAGE_URL VARCHAR(16777216),         -- URL of the page where event occurred
	USER_AGENT VARCHAR(16777216),       -- Browser user agent string
	LOCALE VARCHAR(255),                -- User's locale/language setting
	TIMEZONE VARCHAR(255),              -- User's timezone
	
	-- Timestamps
	CLIENT_TIMESTAMP TIMESTAMP_TZ(9),   -- When event occurred on client side
	SERVER_TIMESTAMP TIMESTAMP_TZ(9),   -- When event was received by server
	SERVER_PROCESS_TIMESTAMP TIMESTAMP_TZ(9), -- When event was processed by server
	
	-- Location and device info
	CLIENT_IP VARCHAR(255),             -- User's IP address
	COUNTRY VARCHAR(255),               -- User's country
	CITY VARCHAR(255),                  -- User's city
	REGION_NAME VARCHAR(255),           -- User's region/state
	HASHED_USER_AGENT_ID VARCHAR(255),  -- Hashed identifier for user agent
	PLATFORM VARCHAR(255),              -- Platform (web, mobile web, etc.)
	IS_MOBILE BOOLEAN,                  -- Whether user is on mobile device
	
	-- Partitioning columns
	P_DATE DATE,                        -- Partition date for table optimization
	P_HOUR NUMBER(38,0),                -- Partition hour for table optimization
	
	-- Additional identifiers
	TRANSACTION_ID VARCHAR(255),        -- Transaction/request identifier
	ANONYMOUS_ID VARCHAR(255),          -- Anonymous user identifier
	BACKEND_SESSION_ID VARCHAR(255),    -- Backend session identifier (this is the same value as SESSION_ID, but it is attached by backend when process the event)
    BROWSER_CONTEXT VARIANT              -- Browser context sent from Segment (JSON format)
);