Skip to content

Dashboard csv export v2 continued#6455

Merged
RobertJoonas merged 8 commits into
masterfrom
dashboard-csv-export-v2-continued
Jun 29, 2026
Merged

Dashboard csv export v2 continued#6455
RobertJoonas merged 8 commits into
masterfrom
dashboard-csv-export-v2-continued

Conversation

@RobertJoonas

Copy link
Copy Markdown
Contributor

Changes

Add custom_props.csv and conversions.csv to the v2 CSV export.

Tests

  • Automated tests have been added

Changelog

  • This PR does not make a user-facing change

Documentation

  • This change does not need a documentation update

Dark mode

  • This PR does not change the UI

@github-actions

Copy link
Copy Markdown
Preview environment👷🏼‍♀️🏗️
PR-6455

Comment thread lib/plausible/stats/dashboard/csv_export.ex
_ ->
%QueryResult{results: results} = QueryRunner.run(site, query)

Enum.map(results, fn r -> hd(r.dimensions) end)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue, blocking: I think we should limit the amount of prop keys we query to prevent too many concurrent queries being run on CH in the next step.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, makes sense. The query is currently unlimited but the queries are also executed synchronously. I've set a limit of 25 prop keys now in be7997c, which should be fine.


defp get_custom_props_csv(_site, []), do: nil

defp get_custom_props_csv(site, prop_value_queries_by_prop_key) do

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion, non-blocking: This function has a lot of responsibilities so it's a bit hard to read. I think it could be split along these lines

  • format header
  • run queries
  • format individual query result rows to array that matches header shape
  • flatten output
  • write to csv using a particular API

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've split it into smaller functions here: 8f251f1

},
'custom_props.csv': {
dimensions: ['event:props:*'],
metrics: getCustomPropsMetrics({ hasConversionGoalFilter: isGoalFilter })

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion, non-blocking: The function getCustomPropsMetrics depends on isRevenueAvailable, which isn't passed.

It seems we actually want to say that in the CSV report, revenue is not available (isRevenueAvailable: false), or do we? With MetricContext allowing undefined, I can't actually tell what the intent is for this CSV report.

I think we shouldn't allow undefined in MetricContext.

Shorter args list at call sites is not worth losing explicitly declared intent at call sites.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems we actually want to say that in the CSV report, revenue is not available (isRevenueAvailable: false), or do we? With MetricContext allowing undefined, I can't actually tell what the intent is for this CSV report.

Yeah, the intent is that revenue is not available. No specific reason other than sticking to legacy behaviour.

I think we shouldn't allow undefined in MetricContext.

IMHO it doesn't (currently) hurt readability because the behaviour between undefined and false is equivalent. Everything in the MetricContext that is irrelevant from the caller's perspective can simply be left unspecified and get interpreted as false, which, at least to me, is quite intuitive.

This would change with the addition of a context variable that would have a default value of true, but that's not the case, and I doubt it ever will be?

That said though, I've written out isRevenueAvailable: false to make this specific case explicit. 1632261.

@RobertJoonas RobertJoonas added this pull request to the merge queue Jun 29, 2026
Merged via the queue into master with commit e20b0c2 Jun 29, 2026
22 checks passed
@RobertJoonas RobertJoonas deleted the dashboard-csv-export-v2-continued branch June 29, 2026 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants