Commit graph

27 commits

Author SHA1 Message Date
iskandarsulaili
7c1db78050 feat: Add UserMapping constraints and schema improvements
## Database Schema Enhancements

### Migration 19 - Fixed
- Removed invalid composite index on session(visitor_id, user_id)
- visitor_id column doesn't exist in session table
- Fixed migration to only create valid indexes

### Migration 20 - New Constraints (with rollback support)
- Added websiteId foreign key to UserMapping table
- Added foreign key constraint to Website table for referential integrity
- Added composite index on UserMapping(websiteId, userId) for query performance
- Added composite index on Session(websiteId, userId) for join optimization

### Schema Updates
- Updated UserMapping model with websiteId field
- Added foreign key relationship: UserMapping -> Website
- Added userMappings relation to Website model
- Added composite indexes for better query performance

## Files Changed

### Modified
- prisma/schema.prisma - Added foreign keys and composite indexes
- prisma/migrations/19_add_user_id_mapping/migration.sql - Fixed invalid index

### New
- prisma/migrations/20_add_user_mapping_constraints/migration.sql - Forward migration
- prisma/migrations/20_add_user_mapping_constraints/rollback.sql - Rollback script

## Benefits
-  Referential integrity enforced at database level
-  Optimized queries for Umami sync operations
-  Better join performance on Session table
-  Rollback capability for safe schema changes

## Breaking Changes
- UserMapping table now requires websiteId field
- Existing data will be migrated to use first available website_id

## Migration Notes
Run the migration with:
```bash
npx prisma migrate deploy
```

To rollback if needed:
```bash
psql -d umami -f prisma/migrations/20_add_user_mapping_constraints/rollback.sql
```
2025-11-06 22:04:57 +08:00
iskandarsulaili
5cf1e0c16a feat: Add user ID mapping migration for WordPress integration
Added Prisma migration to support user identification:

1. Session Table Enhancement
   - Added user_id column (VARCHAR(36)) to session table
   - Stores WordPress user ID for logged-in users
   - Indexed for efficient lookups

2. User Mapping Table
   - New table to track visitor_id to user_id relationships
   - Maps anonymous visitors to authenticated users
   - Tracks first_seen_at, last_seen_at, and session_count
   - Unique constraint on (visitor_id, user_id) pair

3. Indexes
   - idx_session_user_id - Fast user_id lookups
   - idx_session_visitor_user - Composite index for visitor+user queries
   - idx_user_mapping_visitor - Visitor ID lookups
   - idx_user_mapping_user - User ID lookups
   - idx_user_mapping_last_seen - Time-based queries

This migration enables unified user tracking across anonymous and authenticated sessions, supporting the WordPress plugin's user identification feature.
2025-11-06 19:53:33 +08:00
iskandarsulaili
5f496fdb79 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
2025-11-05 19:17:57 +08:00
Mike Cao
366c52d703 Merge remote-tracking branch 'origin/dev' into dev
Some checks are pending
Node.js CI / build (postgresql, 18.18) (push) Waiting to run
2025-09-10 17:16:15 -07:00
Mike Cao
67105f2cff Updated packages. 2025-09-10 17:16:04 -07:00
Francis Cao
f3125c2add clean up funnel migration and report errors 2025-09-10 16:38:51 -07:00
Francis Cao
1825524e95 convert report type before data migratino
Some checks are pending
Node.js CI / build (postgresql, 18.18) (push) Waiting to run
2025-09-10 09:29:49 -07:00
Francis Cao
964651bad3 add data migration to convert funnel and goals reports to new structure 2025-09-10 09:21:27 -07:00
Francis Cao
32febf0fbb add unique index to slug columns 2025-08-18 09:58:26 -07:00
Mike Cao
3c5c1e48e9 Refactored settings. Updated sidebar. 2025-08-15 22:16:28 -07:00
Mike Cao
eabdd18604 Updated Prisma build. 2025-08-15 12:29:33 -07:00
Mike Cao
88639dfe83 New schema for pixels and links. 2025-08-13 20:27:54 -07:00
Mike Cao
3122bab419 Refactor migrations. 2022-06-19 00:07:01 -07:00
Anbraten
9ea175eb3f Run migrations on start 2022-06-12 08:38:58 +02:00
Mike Cao
afe68f6e21 Update prisma seed files. 2022-03-31 19:25:04 -07:00
Mike Cao
b2d04c00ac Change to synchronous password hashing. 2021-05-23 17:29:27 -07:00
Beorn Facchini
3925258bc7 Prisma Migrate with database seeding fixes #559 2021-03-20 23:01:10 +11:00
Mike Cao
560f1316c1 Enable public website sharing. 2020-08-15 01:17:15 -07:00
Mike Cao
585706cc16 Fix css issue. 2020-08-13 00:29:07 -07:00
Mike Cao
000f84df96 Rename website column. Table component. 2020-08-06 23:02:24 -07:00
Mike Cao
e17c9da3d5 Added device collection. 2020-08-06 19:14:44 -07:00
Mike Cao
0f0b1e39e7 Build cli using rollup. 2020-07-24 17:00:56 -07:00
Mike Cao
cb0c912c5b Switch to json web tokens. 2020-07-22 20:45:09 -07:00
Mike Cao
d8c8df2955 Updated schema. 2020-07-18 23:54:25 -07:00
Mike Cao
58a1c63407 Added CORS middleware. Updated umami script. 2020-07-18 10:36:46 -07:00
Mike Cao
c681441601 Add indexes to tables. 2020-07-17 19:33:40 -07:00
Mike Cao
f7f0c05e12 Initial commit. 2020-07-17 01:03:38 -07:00