This command guides users through fetching either events or profiles from Mixpanel.
Fetches Mixpanel events or user profiles into local DuckDB tables. Use this to pull data for analysis when you need offline access or to combine with other data sources.
/plugin marketplace add jaredmcfarland/mixpanel_data/plugin install mixpanel-data@mixpanel-dataThis command guides users through fetching either events or profiles from Mixpanel.
Ask the user what they want to fetch:
If date arguments are provided ($1, $2), assume events. Otherwise, ask.
Guide the user through fetching events from Mixpanel into a local DuckDB table.
First, verify credentials are configured:
!$(mp auth test 2>&1 || echo "No credentials configured")
If credentials aren't configured, suggest running /mp-auth first.
From date: $1 if provided, otherwise ask in YYYY-MM-DD format
To date: $2 if provided, otherwise ask in YYYY-MM-DD format
Validation:
Calculate range:
from datetime import datetime
from_date = datetime.strptime("YYYY-MM-DD", "%Y-%m-%d")
to_date = datetime.strptime("YYYY-MM-DD", "%Y-%m-%d")
days = (to_date - from_date).days
Recommend parallel fetching for large ranges:
--parallel for faster export (up to 10x speedup)--parallel is required (sequential has 100-day limit)Table name: $3 if provided, otherwise suggest "events" as default
Check if table exists:
!$(mp inspect tables 2>/dev/null | grep -q "^$table_name$" && echo "EXISTS" || echo "NEW")
If table exists:
--append: Add new data to existing table--replace: Replace entire table (destructive!)Parallel mode (--parallel or -p):
Workers (--workers, default: 10):
Chunk days (--chunk-days, default: 7):
Important: --limit is incompatible with --parallel
Ask if the user wants to apply filters:
Event filter (optional):
--events "Purchase" "Sign Up" "Page View"WHERE clause (optional):
--where 'properties["country"] == "US" and properties["amount"] > 100'Limit (optional):
--parallelmp fetch events <table-name> --from <from-date> --to <to-date>
mp fetch events <table-name> --from <from-date> --to <to-date> --parallel
Add flags based on user choices:
--parallel or -p for parallel fetching (recommended for > 7 days)--workers N to control concurrency (default: 10)--chunk-days N to control chunk size (default: 7)--append if appending to existing table--events "Event1" "Event2" if filtering events--where 'expression' if filtering by properties--limit N if limiting results (NOT with --parallel)Parallel fetch for large date range (recommended):
mp fetch events q4_events \
--from 2024-10-01 \
--to 2024-12-31 \
--parallel
Parallel fetch with custom workers and chunk size:
mp fetch events yearly_events \
--from 2024-01-01 \
--to 2024-12-31 \
--parallel \
--workers 5 \
--chunk-days 14
Sequential fetch with filters (small range):
mp fetch events jan_purchases \
--from 2024-01-01 \
--to 2024-01-31 \
--events "Purchase" \
--where 'properties["amount"] > 100' \
--append
After fetch completes, show:
Fetch results (sequential):
Fetch results (parallel):
Verification query:
mp query sql "SELECT COUNT(*) as total_events, COUNT(DISTINCT distinct_id) as unique_users FROM <table-name>" --format table
Handle parallel failures (if any): If some batches failed, offer to retry failed date ranges:
mp fetch events <table-name> --from <failed-start> --to <failed-end> --append
Next steps:
/mp-inspect to explore table structure and events/mp-query to analyze the datamp inspect breakdown -t <table-name>mp inspect schema -t <table-name>mp query sql "SELECT * FROM <table-name> LIMIT 10" --format tableFull year with parallel (recommended):
mp fetch events events_2024 --from 2024-01-01 --to 2024-12-31 --parallel
Quarter with parallel:
mp fetch events q4_events --from 2024-10-01 --to 2024-12-31 --parallel
Monthly data (sequential for small range):
mp fetch events jan --from 2024-01-01 --to 2024-01-31
Testing/sampling:
mp fetch events sample --from 2024-01-01 --to 2024-01-01 --limit 1000
Specific event analysis:
mp fetch events purchases --from 2024-01-01 --to 2024-01-31 --events "Purchase"
DateRangeTooLargeError: Range > 100 days (sequential mode)
--parallel flag for ranges > 100 daysValueError: --limit used with --parallel
--limit or use sequential modeParallel batch failures: Some batches failed during parallel fetch
--append:
mp fetch events <table> --from <failed-start> --to <failed-end> --append
TableExistsError: Table exists without --append
AuthenticationError: Credentials invalid
/mp-auth to reconfigureRateLimitError: API rate limited
--workers countEventNotFoundError: Event doesn't exist
mp inspect eventsGuide the user through fetching user profiles from Mixpanel into a local DuckDB table.
First, verify credentials are configured:
!$(mp auth test 2>&1 || echo "No credentials configured")
If credentials aren't configured, suggest running /mp-auth first.
Table name: $3 if provided, otherwise suggest "profiles" as default
Check if table exists:
!$(mp inspect tables 2>/dev/null | grep -q "^$table_name$" && echo "EXISTS" || echo "NEW")
If table exists:
--append: Add new data to existing table--replace: Replace entire table (destructive!)Parallel mode (--parallel or -p):
Workers (--workers, default: 5, max: 5):
Ask if the user wants to apply filters:
Cohort filter (optional):
--cohort 12345WHERE clause (optional):
--where 'properties["plan"] == "premium"'Output properties (optional):
--output-properties email,name,planDistinct IDs (optional):
--distinct-ids user_1 --distinct-ids user_2Group profiles (optional):
--group-id companiesBehavioral filters (optional):
--behaviors '[{"window":"30d","name":"buyers","event_selectors":[{"event":"Purchase"}]}]' --where '(behaviors["buyers"] > 0)'mp fetch profiles <table-name>
mp fetch profiles <table-name> --parallel
Add flags based on user choices:
--parallel or -p for parallel fetching (recommended for large datasets)--workers N to control concurrency (default: 5, max: 5)--append if appending to existing table--cohort ID if filtering by cohort--where 'expression' if filtering by properties--output-properties prop1,prop2 if selecting specific propertiesParallel fetch for large profile dataset (recommended):
mp fetch profiles all_users --parallel
Parallel fetch with custom workers:
mp fetch profiles users --parallel --workers 3
Sequential fetch with filters (small dataset):
mp fetch profiles premium_users \
--cohort 12345 \
--where 'properties["plan"] == "premium"' \
--append
Behavioral filter:
mp fetch profiles purchasers \
--behaviors '[{"window":"30d","name":"buyers","event_selectors":[{"event":"Purchase"}]}]' \
--where '(behaviors["buyers"] > 0)'
After fetch completes, show:
Fetch results (sequential):
Fetch results (parallel):
Verification query:
mp query sql "SELECT COUNT(*) as total_profiles FROM <table-name>" --format table
Handle parallel failures (if any): If some pages failed, offer to retry with append:
mp fetch profiles <table-name> --append
Next steps:
/mp-inspect to explore table structure/mp-query to analyze the datamp inspect schema -t <table-name>mp query sql "SELECT * FROM <table-name> LIMIT 10" --format tableAll profiles with parallel (recommended):
mp fetch profiles users --parallel
Cohort members:
mp fetch profiles cohort_users --cohort 12345
Premium users:
mp fetch profiles premium --where 'properties["plan"] == "premium"'
Group profiles (companies):
mp fetch profiles companies --group-id companies
Parallel page failures: Some pages failed during parallel fetch
--append:
mp fetch profiles <table> --append
TableExistsError: Table exists without --append
AuthenticationError: Credentials invalid
/mp-auth to reconfigureRateLimitError: API rate limited
--workers count (max 5)ValidationError: Invalid parameter combination
--distinct-id and --distinct-ids are mutually exclusive--behaviors and --cohort are mutually exclusive--include-all-users requires --cohort