make CSV export return only conversions with goal filter (#2760)

* make CSV export return only conversions with goal filter

* update changelog
pull/2769/head
RobertJoonas 4 years ago committed by GitHub
parent d0895efbdd
commit 4175a7abae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file.
- Add support for more Bamboo adapters, i.e. `Bamboo.MailgunAdapter`, `Bamboo.MandrillAdapter`, `Bamboo.SendGridAdapter` plausible/analytics#2649
### Fixed
- Make goal-filtered CSV export return only unique_conversions timeseries in the 'visitors.csv' file
- Stop treating page filter as an entry page filter
- City report showing N/A instead of city names with imported data plausible/analytics#2675
- Empty values for Screen Size, OS and Browser are uniformly replaced with "(not set)"

@ -98,7 +98,7 @@ defmodule PlausibleWeb.StatsController do
metrics =
cond do
query.filters["event:goal"] ->
[:visitors, :pageviews, :bounce_rate, :visit_duration]
[:visitors]
FunWithFlags.enabled?(:visits_metric, for: conn.assigns[:current_user]) ->
[:visitors, :pageviews, :visits, :views_per_visit, :bounce_rate, :visit_duration]
@ -108,11 +108,18 @@ defmodule PlausibleWeb.StatsController do
end
graph = Plausible.Stats.timeseries(site, query, metrics)
headers = [:date | metrics]
columns = [:date | metrics]
column_headers =
if query.filters["event:goal"] do
[:date, :unique_conversions]
else
columns
end
visitors =
Enum.map(graph, fn row -> Enum.map(headers, &row[&1]) end)
|> (fn data -> [headers | data] end).()
Enum.map(graph, fn row -> Enum.map(columns, &row[&1]) end)
|> (fn data -> [column_headers | data] end).()
|> CSV.encode()
|> Enum.join()

@ -1,32 +1,32 @@
date,visitors,pageviews,bounce_rate,visit_duration
2021-09-20,0,0,,
2021-09-21,0,0,,
2021-09-22,0,0,,
2021-09-23,0,0,,
2021-09-24,0,0,,
2021-09-25,0,0,,
2021-09-26,0,0,,
2021-09-27,0,0,,
2021-09-28,0,0,,
2021-09-29,0,0,,
2021-09-30,0,0,,
2021-10-01,0,0,,
2021-10-02,0,0,,
2021-10-03,0,0,,
2021-10-04,0,0,,
2021-10-05,0,0,,
2021-10-06,0,0,,
2021-10-07,0,0,,
2021-10-08,0,0,,
2021-10-09,0,0,,
2021-10-10,0,0,,
2021-10-11,0,0,,
2021-10-12,0,0,,
2021-10-13,0,0,,
2021-10-14,0,0,,
2021-10-15,0,0,,
2021-10-16,0,0,,
2021-10-17,0,0,,
2021-10-18,0,0,,
2021-10-19,1,0,100,0
2021-10-20,0,0,,
date,unique_conversions
2021-09-20,0
2021-09-21,0
2021-09-22,0
2021-09-23,0
2021-09-24,0
2021-09-25,0
2021-09-26,0
2021-09-27,0
2021-09-28,0
2021-09-29,0
2021-09-30,0
2021-10-01,0
2021-10-02,0
2021-10-03,0
2021-10-04,0
2021-10-05,0
2021-10-06,0
2021-10-07,0
2021-10-08,0
2021-10-09,0
2021-10-10,0
2021-10-11,0
2021-10-12,0
2021-10-13,0
2021-10-14,0
2021-10-15,0
2021-10-16,0
2021-10-17,0
2021-10-18,0
2021-10-19,1
2021-10-20,0

1 date visitors unique_conversions pageviews bounce_rate visit_duration
2 2021-09-20 0 0
3 2021-09-21 0 0
4 2021-09-22 0 0
5 2021-09-23 0 0
6 2021-09-24 0 0
7 2021-09-25 0 0
8 2021-09-26 0 0
9 2021-09-27 0 0
10 2021-09-28 0 0
11 2021-09-29 0 0
12 2021-09-30 0 0
13 2021-10-01 0 0
14 2021-10-02 0 0
15 2021-10-03 0 0
16 2021-10-04 0 0
17 2021-10-05 0 0
18 2021-10-06 0 0
19 2021-10-07 0 0
20 2021-10-08 0 0
21 2021-10-09 0 0
22 2021-10-10 0 0
23 2021-10-11 0 0
24 2021-10-12 0 0
25 2021-10-13 0 0
26 2021-10-14 0 0
27 2021-10-15 0 0
28 2021-10-16 0 0
29 2021-10-17 0 0
30 2021-10-18 0 0
31 2021-10-19 1 0 100 0
32 2021-10-20 0 0
Loading…
Cancel
Save