Skip to content

Commit a4de92a

Browse files
committed
feat(radar): clarify positional mapping for dateRange filter arrays and dimension types
Improve documentation to explain that filter arrays (location, asn, continent, geoId) map positionally to dateRange arrays. When comparing time periods for the same location, users must repeat the filter value for each dateRange element, otherwise unmatched periods default to worldwide data. Also adds documentation for dimension types (timeseries, summary, timeseriesGroups) and includes ASN in filtering options.
1 parent 7ee34b3 commit a4de92a

File tree

2 files changed

+76
-8
lines changed

2 files changed

+76
-8
lines changed

apps/radar/src/radar.context.ts

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,64 @@ This server provides tools powered by the Cloudflare Radar API for global Intern
4444
4545
## Making Comparisons
4646
47-
Many tools support **array-based filters** for comparisons. Each array index corresponds to a distinct data series.
48-
Example: Compare HTTP traffic between Portugal and Spain over the last 7 days:
47+
Many tools support **array-based filters** for comparisons. Filter arrays (location, asn, continent, geoId) map **positionally** to dateRange arrays - each array index corresponds to a distinct data series.
48+
49+
### Cross-Location Comparison (Same Time Period)
50+
Compare HTTP traffic between Portugal and Spain over the last 7 days:
4951
- \`dateRange: ["7d", "7d"]\`
5052
- \`location: ["PT", "ES"]\`
5153
52-
## Geographic Filtering
54+
Result: \`summary_0\` = Portugal (7d), \`summary_1\` = Spain (7d)
55+
56+
### Time Period Comparison (Same Location)
57+
Compare Portugal bandwidth this week vs last week:
58+
- \`dateRange: ["7d", "7dcontrol"]\`
59+
- \`location: ["PT", "PT"]\` *(repeat the location for each dateRange)*
60+
61+
Result: \`summary_0\` = PT (current week), \`summary_1\` = PT (previous week)
62+
63+
### IMPORTANT: Positional Mapping Behavior
64+
Filter arrays must match the length of dateRange for consistent filtering. If you provide fewer filter values than dateRange values, unmatched periods default to worldwide/unfiltered data.
65+
66+
**Correct** (comparing Portugal across time periods):
67+
- \`dateRange: ["7d", "7dcontrol"], location: ["PT", "PT"]\`
68+
69+
**Incorrect** (control period will be worldwide, not Portugal):
70+
- \`dateRange: ["7d", "7dcontrol"], location: ["PT"]\` *(missing second location)*
71+
72+
This positional mapping applies to all filter arrays: **location**, **asn**, **continent**, and **geoId**.
73+
74+
## Geographic Options
5375
5476
- **location**: Filter by country (alpha-2 codes like "US", "PT")
5577
- **continent**: Filter by continent (alpha-2 codes like "EU", "NA")
78+
- **asn**: Filter by Autonomous System Number (e.g., "13335" for Cloudflare, "15169" for Google)
5679
- **geoId**: Filter by ADM1 region (GeoNames IDs for states/provinces) - available for HTTP and NetFlows
5780
81+
## Dimension Types
82+
83+
Many tools use a \`dimension\` parameter to control the response format:
84+
85+
### timeseries
86+
Returns data points over time with timestamps and values. Best for line charts showing trends.
87+
\`\`\`
88+
{ timestamps: ["2026-01-01T12:00:00Z", ...], values: ["0.735", "0.812", ...] }
89+
\`\`\`
90+
91+
### summary
92+
Returns aggregated percentages or values grouped by a category. Best for pie/bar charts.
93+
\`\`\`
94+
{ Chrome: "31.44%", ChromeMobile: "27.89%", Safari: "12.27%", ... }
95+
\`\`\`
96+
97+
### timeseriesGroups
98+
Combines both: time series data broken down by category. Best for stacked area/line charts.
99+
\`\`\`
100+
{ timestamps: [...], Chrome: ["28.15", "27.35", ...], Firefox: ["31.01", "31.23", ...] }
101+
\`\`\`
102+
103+
Use \`summary/*\` dimensions (e.g., \`summary/browser\`) for snapshots and \`timeseriesGroups/*\` (e.g., \`timeseriesGroups/browser\`) for trends over time.
104+
58105
## Visualizations
59106
60107
Generate charts when appropriate:

apps/radar/src/types/radar.ts

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ export const DateRangeArrayParam: z.ZodType<HTTPTimeseriesParams['dateRange']> =
6868
.describe(
6969
'Filters results by date range. ' +
7070
'For example, use `7d` and `7dcontrol` to compare this week with the previous week. ' +
71-
'Use this parameter or set specific start and end dates (`dateStart` and `dateEnd` parameters).'
71+
'Use this parameter or set specific start and end dates (`dateStart` and `dateEnd` parameters). ' +
72+
'IMPORTANT: When using multiple dateRange values for comparison, filter array parameters (location, asn, ' +
73+
'continent, geoId) map positionally to each dateRange element. For example, with dateRange: ["7d", "7dcontrol"] ' +
74+
'and location: ["PT", "PT"], the first period uses PT and the control period also uses PT. If you only provide ' +
75+
'location: ["PT"], only the first period is filtered by PT while the control period defaults to worldwide data.'
7276
)
7377

7478
export const DateStartParam = z
@@ -124,7 +128,12 @@ export const LocationArrayParam: z.ZodType<HTTPTimeseriesParams['location']> = z
124128
.optional()
125129
.describe(
126130
'Filters results by location. Provide an array of alpha-2 country codes (e.g., "US", "PT"). ' +
127-
'Prefix a code with `-` to exclude it (e.g., ["-US", "PT"] excludes the US and includes Portugal).'
131+
'Prefix a code with `-` to exclude it (e.g., ["-US", "PT"] excludes the US and includes Portugal). ' +
132+
'IMPORTANT: When using multiple dateRange values (e.g., ["7d", "7dcontrol"]), each array element ' +
133+
'maps positionally to each dateRange. To compare the same location across time periods, repeat the ' +
134+
'location code (e.g., location: ["PT", "PT"] with dateRange: ["7d", "7dcontrol"]). Using a single ' +
135+
'location with multiple dateRange values will filter only the first period, with subsequent periods ' +
136+
'defaulting to worldwide data.'
128137
)
129138

130139
export const ContinentArrayParam: z.ZodType<HTTPTimeseriesParams['continent']> = z
@@ -136,15 +145,23 @@ export const ContinentArrayParam: z.ZodType<HTTPTimeseriesParams['continent']> =
136145
.optional()
137146
.describe(
138147
'Filters results by continent. Provide an array of alpha-2 continent codes (e.g., "EU", "NA"). ' +
139-
'Prefix a code with `-` to exclude it (e.g., ["-EU", "NA"] excludes Europe and includes North America).'
148+
'Prefix a code with `-` to exclude it (e.g., ["-EU", "NA"] excludes Europe and includes North America). ' +
149+
'IMPORTANT: When using multiple dateRange values, each array element maps positionally to each dateRange. ' +
150+
'To compare the same continent across time periods, repeat the continent code (e.g., continent: ["EU", "EU"] ' +
151+
'with dateRange: ["7d", "7dcontrol"]). Using a single continent with multiple dateRange values will filter ' +
152+
'only the first period, with subsequent periods defaulting to worldwide data.'
140153
)
141154

142155
export const AsnArrayParam: z.ZodType<HTTPTimeseriesParams['asn']> = z
143156
.array(z.string().refine((val) => val !== '0', { message: 'ASN cannot be 0' }))
144157
.optional()
145158
.describe(
146159
'Filters results by ASN. Provide an array of ASN strings. ' +
147-
'Prefix with `-` to exclude (e.g., ["-174", "3356"] excludes AS174 and includes AS3356). '
160+
'Prefix with `-` to exclude (e.g., ["-174", "3356"] excludes AS174 and includes AS3356). ' +
161+
'IMPORTANT: When using multiple dateRange values, each array element maps positionally to each dateRange. ' +
162+
'To compare the same ASN across time periods, repeat the ASN (e.g., asn: ["13335", "13335"] with ' +
163+
'dateRange: ["7d", "7dcontrol"]). Using a single ASN with multiple dateRange values will filter only ' +
164+
'the first period, with subsequent periods defaulting to all ASNs.'
148165
)
149166

150167
export const AsOrderByParam: z.ZodType<ASNListParams['orderBy']> = z
@@ -330,7 +347,11 @@ export const GeoIdArrayParam = z
330347
.describe(
331348
'Filters results by Geolocation (ADM1 - administrative level 1, e.g., states/provinces). ' +
332349
'Provide an array of GeoNames IDs. Prefix with `-` to exclude. ' +
333-
'Example: ["2267056", "-360689"] includes Lisbon area but excludes another region.'
350+
'Example: ["2267056", "-360689"] includes Lisbon area but excludes another region. ' +
351+
'IMPORTANT: When using multiple dateRange values, each array element maps positionally to each dateRange. ' +
352+
'To compare the same region across time periods, repeat the GeoID (e.g., geoId: ["2267056", "2267056"] ' +
353+
'with dateRange: ["7d", "7dcontrol"]). Using a single geoId with multiple dateRange values will filter ' +
354+
'only the first period, with subsequent periods defaulting to all regions.'
334355
)
335356

336357
// BGP Parameters

0 commit comments

Comments
 (0)