feat: integrate First8 Marketing hyper-personalization system

Enhanced Umami Analytics with First8 Marketing integration for
hyper-personalized recommendation engine.

Database Enhancements:
- PostgreSQL 17 with Apache AGE 1.6.0 (graph database)
- TimescaleDB 2.23.0 (time-series optimization)
- Extended schema for WooCommerce event tracking
- Custom tables for recommendation engine integration

Features Added:
- Real-time ETL pipeline to recommendation engine
- Extended event tracking (WordPress + WooCommerce)
- Graph database for relationship mapping
- Time-series optimization for analytics queries
- Custom migrations for hyper-personalization

Documentation:
- Updated README with integration details
- Added system architecture documentation
- Documented data flow and components
- Preserved original Umami Software credits

Integration Components:
- First8 Marketing Track plugin (event tracking)
- Recommendation Engine (ML backend)
- First8 Marketing Recommendation Engine plugin (presentation)

Status: Production-ready
Version: Based on Umami latest + First8 Marketing enhancements
This commit is contained in:
iskandarsulaili 2025-11-05 19:17:57 +08:00
parent a6d4519a98
commit 5f496fdb79
16 changed files with 8856 additions and 9790 deletions

View file

@ -0,0 +1,34 @@
-- Rollback Migration: Remove WooCommerce and Enhanced Tracking Fields
-- Created: 2025-01-15
-- Description: Removes WooCommerce e-commerce tracking fields and enhanced engagement metrics from website_event table
-- WARNING: This will permanently delete all WooCommerce tracking data!
-- Drop indexes first (must be done before dropping columns)
DROP INDEX IF EXISTS idx_website_event_wc_product;
DROP INDEX IF EXISTS idx_website_event_wc_category;
DROP INDEX IF EXISTS idx_website_event_wc_order;
DROP INDEX IF EXISTS idx_website_event_wc_revenue;
DROP INDEX IF EXISTS idx_website_event_engagement;
-- Remove WooCommerce e-commerce tracking fields
ALTER TABLE website_event
DROP COLUMN IF EXISTS wc_product_id,
DROP COLUMN IF EXISTS wc_category_id,
DROP COLUMN IF EXISTS wc_cart_value,
DROP COLUMN IF EXISTS wc_checkout_step,
DROP COLUMN IF EXISTS wc_order_id,
DROP COLUMN IF EXISTS wc_revenue;
-- Remove enhanced engagement tracking fields
ALTER TABLE website_event
DROP COLUMN IF EXISTS scroll_depth,
DROP COLUMN IF EXISTS time_on_page,
DROP COLUMN IF EXISTS click_count,
DROP COLUMN IF EXISTS form_interactions;
-- Log rollback completion
DO $$
BEGIN
RAISE NOTICE 'Rollback complete: WooCommerce and enhanced tracking fields removed from website_event table';
END $$;

View file

@ -0,0 +1,22 @@
-- Rollback Migration: Remove Recommendation Engine Tables
-- Created: 2025-01-15
-- Description: Drops all recommendation engine tables and their dependencies
-- WARNING: This will permanently delete all recommendation data, user profiles, and ML model registry!
-- Drop tables in reverse order of dependencies
-- Drop recommendations table first (has foreign key to website)
DROP TABLE IF EXISTS recommendations CASCADE;
-- Drop user_profiles table (has foreign key to website)
DROP TABLE IF EXISTS user_profiles CASCADE;
-- Drop ml_models table (no dependencies)
DROP TABLE IF EXISTS ml_models CASCADE;
-- Log rollback completion
DO $$
BEGIN
RAISE NOTICE 'Rollback complete: All recommendation engine tables removed';
RAISE NOTICE 'Dropped tables: recommendations, user_profiles, ml_models';
END $$;

View file

@ -0,0 +1,38 @@
-- Rollback Migration: Remove Apache AGE Graph Database
-- Created: 2025-01-15
-- Description: Drops Apache AGE graph and extension
-- WARNING: This will permanently delete all graph data!
-- Set search path to include ag_catalog
SET search_path = ag_catalog, "$user", public;
-- ============================================================================
-- Step 1: Drop Helper Functions
-- ============================================================================
DROP FUNCTION IF EXISTS execute_cypher(text, text) CASCADE;
-- ============================================================================
-- Step 2: Drop Graph (this will cascade to all vertices and edges)
-- ============================================================================
SELECT ag_catalog.drop_graph('user_journey', true);
-- ============================================================================
-- Step 3: Drop Apache AGE Extension
-- ============================================================================
-- Note: Only drop extension if no other graphs exist
-- Uncomment the following line if you want to completely remove Apache AGE
-- DROP EXTENSION IF EXISTS age CASCADE;
-- ============================================================================
-- Rollback Complete
-- ============================================================================
DO $$
BEGIN
RAISE NOTICE '=================================================================';
RAISE NOTICE 'Apache AGE Rollback Complete';
RAISE NOTICE 'Dropped graph: user_journey';
RAISE NOTICE 'Dropped helper functions: execute_cypher()';
RAISE NOTICE 'Note: Apache AGE extension was NOT dropped (may be used by other graphs)';
RAISE NOTICE '=================================================================';
END $$;

View file

@ -0,0 +1,52 @@
-- Rollback Migration: Remove TimescaleDB Time-Series Tables
-- Created: 2025-01-15
-- Description: Drops all TimescaleDB hypertables, continuous aggregates, and policies
-- WARNING: This will permanently delete all time-series analytics data!
-- ============================================================================
-- Step 1: Remove Continuous Aggregate Policies
-- ============================================================================
SELECT remove_continuous_aggregate_policy('website_metrics_hourly_agg', if_exists => TRUE);
SELECT remove_continuous_aggregate_policy('product_metrics_daily_agg', if_exists => TRUE);
-- ============================================================================
-- Step 2: Drop Continuous Aggregates (Materialized Views)
-- ============================================================================
DROP MATERIALIZED VIEW IF EXISTS website_metrics_hourly_agg CASCADE;
DROP MATERIALIZED VIEW IF EXISTS product_metrics_daily_agg CASCADE;
-- ============================================================================
-- Step 3: Remove Retention Policies
-- ============================================================================
SELECT remove_retention_policy('time_series_events', if_exists => TRUE);
SELECT remove_retention_policy('website_metrics_hourly', if_exists => TRUE);
SELECT remove_retention_policy('product_metrics_daily', if_exists => TRUE);
-- ============================================================================
-- Step 4: Drop Hypertables (this will drop the tables and all chunks)
-- ============================================================================
DROP TABLE IF EXISTS time_series_events CASCADE;
DROP TABLE IF EXISTS website_metrics_hourly CASCADE;
DROP TABLE IF EXISTS product_metrics_daily CASCADE;
-- ============================================================================
-- Step 5: Drop TimescaleDB Extension (Optional)
-- ============================================================================
-- Note: Only drop extension if no other hypertables exist
-- Uncomment the following line if you want to completely remove TimescaleDB
-- DROP EXTENSION IF EXISTS timescaledb CASCADE;
-- ============================================================================
-- Rollback Complete
-- ============================================================================
DO $$
BEGIN
RAISE NOTICE '=================================================================';
RAISE NOTICE 'TimescaleDB Rollback Complete';
RAISE NOTICE 'Dropped hypertables: time_series_events, website_metrics_hourly, product_metrics_daily';
RAISE NOTICE 'Dropped continuous aggregates: website_metrics_hourly_agg, product_metrics_daily_agg';
RAISE NOTICE 'Removed all retention policies';
RAISE NOTICE 'Note: TimescaleDB extension was NOT dropped (may be used by other tables)';
RAISE NOTICE '=================================================================';
END $$;