Export Features & Live Share Links

Alpha Insights provides powerful export capabilities and live sharing functionality to help you distribute your reports. This guide covers all export methods and configuration options based on the actual implementation.

Available Export Methods

PDF Export

How PDF Export Works

Alpha Insights uses a sophisticated PDF generation system that:

  1. Creates a temporary live share link for your report (expires in 1 hour)
  2. Sends the live link URL to the WPDavies API endpoint
  3. Uses Puppeteer (headless Chrome) to render the report page
  4. Generates a high-quality PDF with all charts and visualizations
  5. Returns the PDF as base64 encoded data
  6. Saves the PDF file to your server
  7. Automatically cleans up the temporary live link

Technical Requirements

How to Export to PDF

  1. Open any report in Alpha Insights
  2. Click the Export button in the report toolbar
  3. Select Export as PDF
  4. Wait for processing (10-60 seconds depending on report complexity)
  5. PDF automatically downloads to your computer

PDF File Naming

PDF files are automatically named using this format:

[sanitized-report-name]-[date-time-stamp].pdf

Example: weekly-performance-report-2024-10-23-14-30-45.pdf

What's Included in PDF Exports

PDF Export Best Practices

Troubleshooting PDF Export

Error: "You must have a valid license key to use this feature"

Error: "Report not found"

Error: "API request failed" or "PDF generation API returned error"

Warning: "Temporary live link could not be deleted"

CSV Export

How CSV Export Works

The CSV export system is highly sophisticated and handles complex nested data structures:

  1. Fetches all data from the report (orders, products, expenses, etc.)
  2. Intelligently analyzes the data structure for each entity
  3. Generates separate CSV files for different data types
  4. Packages all CSV files into a single ZIP archive
  5. Automatically cleans up temporary files

CSV Export Features

How to Export to CSV

  1. Open any report in Alpha Insights
  2. Click the Export button
  3. Select Export as CSV
  4. Wait for data processing (varies by data size)
  5. ZIP file downloads automatically
  6. Extract the ZIP to access individual CSV files

CSV File Structure

The export creates multiple CSV files based on your report data:

Orders Data:

orders_data_table_orders.csv
orders_totals.csv
orders_data_by_date.csv

Products Data:

products_data_table_products.csv
products_by_category.csv
products_totals.csv

Expenses Data:

expenses_data_table_expenses.csv
expenses_totals.csv
expenses_categorized_data.csv

CSV Data Type Handling

Data Tables: Standard tabular data with column headers

Totals: Key-value pairs

Data By Date: Time-series data

Categorized Data: Grouped data with category headers

CSV File Naming

ZIP archive naming format:

[report-name]_export_[timestamp].zip

Example: sales-overview_export_2024-10-23_14-30-45.zip

Storage & Cleanup

CSV Export Best Practices

Troubleshooting CSV Export

Error: "No data available to export"

Error: "ZipArchive class not available on this server"

Error: "Failed to create ZIP archive"

Issue: Excel shows garbled characters

Live Share Links

What Are Live Share Links?

Live Share Links are secure, publicly accessible URLs that display your reports in real-time. Anyone with the link can view the report without needing WordPress access, and the data updates automatically to reflect current information.

Live Share Architecture

The system uses a sophisticated URL rewrite structure:

https://yoursite.com/alpha-insights/reports/[report-slug]/?secret_key=[unique-key]

How to Create a Live Share Link

  1. Open the report you want to share
  2. Click Share button in the report toolbar
  3. Click Create Share Link
  4. Configure settings:
  5. Click Generate Link
  6. Copy the URL and share it

Live Share Link Configuration

Link Name:

Expiry Date:

Password Protection:

Live Share Link Storage

Links are stored in the report configuration option:

Option: wpd_dashboard_config_[report-slug]
Structure:
{
  "live_share_links": [
    {
      "id": "unique-id",
      "name": "Board Meeting Link",
      "secret_key": "abc123xyz789",
      "created_date": "2024-10-23 14:30:00",
      "expiry_date": "2024-11-23 14:30:00",
      "require_password": true,
      "password": "$2y$10$hashed..."
    }
  ]
}

Live Share Security Features

Secret Key Generation:

Password Hashing:

HTTPS Encryption:

Expiration Checking:

Live Share Page Structure

The live share page is a minimal HTML page with:

Live Share Data Fetching

Live share pages use AJAX mode instead of REST API:

Managing Live Share Links

View Active Links:

  1. Open the report
  2. Click Share button
  3. See all active links with details:

Delete a Link:

  1. Find the link in the share dialog
  2. Click Delete icon
  3. Confirm deletion
  4. Link immediately stops working

Regenerate a Link:

Live Share Use Cases

Board/Investor Access:

Team Collaboration:

Client Reporting (Agencies):

Temporary Sharing:

Live Share Best Practices

Troubleshooting Live Share Links

Error: "Invalid URL parameters"

Error: "Report not found"

Error: "Invalid secret key"

Error: "This live share link has expired"

Error: "Invalid password"

Page shows "Access Denied" icon but no specific message

Export Configuration

Report Configuration Structure

Each report stores its configuration including export settings in WordPress options:

Option Name: wpd_dashboard_config_[slug]

Structure:
{
  "dashboard_id": "report-slug",
  "name": "Report Name",
  "filters": {...},
  "widgets": [...],
  "live_share_links": [...]
}

Filters Configuration

Filters are stored in the report configuration and affect what data is exported:

"filters": {
  "date_preset": "last_30_days",
  "date_from": "2024-09-23",
  "date_to": "2024-10-23",
  "comparison_date_selection": "previous_period",
  "data_filters": {
    "orders": {
      "status": ["wc-completed", "wc-processing"],
      "billing_email": [],
      "product_ids": []
    },
    "products": {
      "category": [],
      "tag": []
    }
  }
}

Export File Locations

All exports are stored in organized directories:

Base Upload Directory:
wp-content/uploads/wp-davies/alpha-insights/

PDF Files:
/exports/pdf_files/

CSV ZIP Files:
/csv/

Temporary CSV Files:
/tmp/ (auto-cleaned after 1 hour)

Export Permissions

Export functionality requires specific WordPress capabilities:

Export API Reference

CSV Export AJAX Action:

Action: wpd_export_all_data_csv
Method: POST
Nonce: wpd_ajax_nonce
Parameters:
  - dashboard_id: Report slug
  - report_name: Optional display name
Response:
  - success: boolean
  - message: string
  - zip_url: download URL
  - filename: ZIP filename

PDF Export AJAX Action:

Action: wpd_export_react_report_to_pdf
Method: POST
Nonce: wpd_ajax_nonce
Parameters:
  - report_slug: Report slug
Response:
  - success: boolean
  - download_link: Public URL
  - file_name: PDF filename
  - file_size: File size in bytes
  - error_messages: Error string if failed

Create Live Share Link AJAX Action:

Action: wpd_create_live_share_link
Method: POST
Nonce: wpd_ajax_nonce
Parameters:
  - dashboard_id: Report slug
  - link_name: Display name
  - expiry_date: YYYY-MM-DD HH:MM:SS (optional)
  - password: Plain text password (optional)
  - require_password: boolean
Response:
  - success: boolean
  - message: string
  - data: {link: {id, secret_key, ...}}

Developer Integration

Developers can programmatically generate exports:

Generate PDF:

$result = wpd_generate_pdf_from_report_slug( 'report-slug' );

if ( $result['success'] ) {
    $pdf_url = $result['download_link'];
    $pdf_path = $result['server_file'];
}

Create CSV Export:

$exporter = new WPDAI_CSV_Exporter();
$result = $exporter->export_all_data_to_zip(
    $all_data,
    'Report Name'
);

if ( $result['success'] ) {
    $zip_url = $result['zip_url'];
}

Create Live Share Link:

$report = new WPDAI_Report_Builder( 'report-slug' );
$result = $report->create_live_share_link(
    'report-slug',
    'Link Name',
    '2024-12-31 23:59:59', // expiry
    'password123',         // password (optional)
    true                   // require_password
);

Technical Considerations

Server Requirements:

Performance Optimization:

Security Measures: