slice icon Context Slice

Travel History Report Guide

Guide for merging flight data from multiple sources and formatting the final travel history report.

Merging Flight Data

When combining email and calendar flight records:

Deduplication:

  • Match on: same date + same route + same flight number (if available)
  • If flight number missing, match on: same date + same departure city + same arrival city
  • Keep one record, merge metadata from both sources

Data priority:

  • Confirmation codes: prefer email (calendars rarely have them)
  • Times: prefer calendar if email only has dates
  • Source: note both "email+calendar" if merged

Building Country Timeline

Transform flight records into country-level presence spans.

Core logic:

  1. Sort flights by departure date/time
  2. User's location = arrival country of most recent flight
  3. Presence starts at arrival, ends at next departure
  4. First flight's origin = assumed home base

Country spans format for timeline visualizer:

[
  {
    "label": "USA",
    "startDate": "2024-01-01",
    "endDate": "2024-01-15",
    "category": "2024"
  },
  {
    "label": "France",
    "startDate": "2024-01-15",
    "endDate": "2024-01-22",
    "category": "2024"
  }
]

Aggregation rules:

  • Combine consecutive days in same country into single span
  • Domestic flights (within same country) don't create new spans
  • Use country name for label (not city)
  • Group by year for category

Report Structure

# Travel History

Generated on {date}. Covers {start_date} to {end_date}.

## Summary

- **Countries visited:** X (list them)
- **Total flights:** X
- **Total trips:** X
- **Days abroad:** X
- **Most visited:** {country}
- **Longest stay:** X days in {country}

## Timeline

![Travel Timeline](PUBLIC_URL)

## Trips

| Trip | Dates | Route | Days |
|------|-------|-------|------|
| 1 | Jan 15-22, 2024 | San Francisco → Paris | 7 |
| 2 | Jan 22-25, 2024 | Paris → Berlin → Frankfurt | 3 |

## Flight Log

1. **Jan 15, 2024** - UA 837: SFO → CDG (San Francisco to Paris)
2. **Jan 22, 2024** - LH 1234: CDG → TXL (Paris to Berlin)

---
*Data sources: Gmail flight confirmations, Google Calendar events*

Edge Cases

Same-day connections: SFO→LAX→CDG = single trip SFO→CDG. Layover doesn't count as "in" USA.

Overnight flights: Use arrival date for presence start.

One-way flights: Presence extends until next known departure or 30 days, then "unknown".

Gaps >30 days: Note as gap rather than assuming continuous presence.

Missing home base: First flight's origin = assumed home base.

Trip Grouping

A "trip" = continuous time away from home base.

Count trips by:

  1. Identify home base (most common origin city)
  2. Each departure from home starts a trip
  3. Trip ends when returning to home
  4. Multi-city trips count as one trip

Example: SFO→Paris→Berlin→SFO = 1 trip with 3 flights