From 29b6506e1a4167a22da9c0deb4d30dcc2454579e Mon Sep 17 00:00:00 2001 From: Gokhan Sari Date: Mon, 27 Feb 2023 19:36:23 +0300 Subject: [PATCH] Enable exporting reports and events as CSV (#160) * [WIP]Add site report exporting * Update go modules * Update frontend dependencies * Add report and event exports * Update frontend dependencies * Add tests for export downloads --- .github/workflows/test.yaml | 13 +- .idea/codeStyles/Project.xml | 2 + .vscode/settings.json | 5 + backend/go.mod | 12 +- backend/go.sum | 35 +- backend/pkg/restapi/error_handler.go | 2 +- .../restapi/middleware/authentication/main.go | 5 +- .../user_access_token_form_auth.go | 92 +++ backend/pkg/restapi/root/tracker.go | 2 +- .../pkg/restapi/sitereport/export_events.go | 24 + .../pkg/restapi/sitereport/export_reports.go | 24 + backend/pkg/restapi/sitereport/main.go | 11 +- .../pkg/restapi/sitereport/visitor_trends.go | 6 +- .../pkg/service/sitereport/export/events.go | 48 ++ .../pkg/service/sitereport/export/reports.go | 516 +++++++++++++ .../timetrends}/main.go | 2 +- .../timetrends}/main_test.go | 2 +- backend/pkg/validator/non_disposable_email.go | 10 +- frontend/@types/siteTimeTrendsReport.d.ts | 15 + frontend/@types/siteVisitorTrendsReport.d.ts | 15 - frontend/Dockerfile | 2 +- .../SiteReports/Geo/Country/index.tsx | 174 ++--- .../SiteReports/Path/Modal/index.tsx | 2 +- .../components/SiteReports/Path/index.tsx | 2 +- .../SiteReports/Referrer/Path/Modal/index.tsx | 2 +- .../SiteReports/Referrer/Path/index.tsx | 2 +- .../SiteReports/Referrer/Site/Modal/index.tsx | 2 +- .../SiteReports/Referrer/Site/index.tsx | 2 +- .../SiteReports/TimeTrends/Chart/index.tsx | 8 +- frontend/components/SiteReports/index.tsx | 69 +- frontend/development.Dockerfile | 2 +- ...port.ts => hydrateSiteTimeTrendsReport.ts} | 6 +- frontend/helpers/index.ts | 2 +- frontend/hooks/index.ts | 2 +- ...dsReport.ts => useSiteTimeTrendsReport.ts} | 12 +- frontend/package-lock.json | 717 +++++++++--------- frontend/playwright.config.ts | 8 +- frontend/styles/style.scss | 6 +- frontend/tests/sites.spec.ts | 31 +- 39 files changed, 1355 insertions(+), 537 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 backend/pkg/restapi/middleware/authentication/user_access_token_form_auth.go create mode 100644 backend/pkg/restapi/sitereport/export_events.go create mode 100644 backend/pkg/restapi/sitereport/export_reports.go create mode 100644 backend/pkg/service/sitereport/export/events.go create mode 100644 backend/pkg/service/sitereport/export/reports.go rename backend/pkg/service/{sitevisitortrends => sitereport/timetrends}/main.go (98%) rename backend/pkg/service/{sitevisitortrends => sitereport/timetrends}/main_test.go (99%) create mode 100644 frontend/@types/siteTimeTrendsReport.d.ts delete mode 100644 frontend/@types/siteVisitorTrendsReport.d.ts rename frontend/helpers/{hydrateSiteVisitorTrendsReport.ts => hydrateSiteTimeTrendsReport.ts} (53%) rename frontend/hooks/{useSiteVisitorTrendsReport.ts => useSiteTimeTrendsReport.ts} (63%) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 08f36728..28b0ee52 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -15,8 +15,9 @@ jobs: - uses: actions/setup-node@v3 with: - node-version: 19.6.0 + node-version: 19.7.0 + # TODO: Delete this step when https://github.com/reviewdog/action-eslint/issues/152 is resolved. - name: Install custom npm version run: npm i -g npm@8.19.3 @@ -41,14 +42,6 @@ jobs: - name: Setup reviewdog uses: reviewdog/action-setup@v1 - # TODO: Delete this step when https://github.com/reviewdog/action-eslint/issues/152 is resolved. - - name: Install custom npm version - run: npm i -g npm@8.19.3 - - - name: Install dependencies - run: npm install - working-directory: frontend - - env: REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} name: Run tsc @@ -125,7 +118,7 @@ jobs: - uses: actions/setup-node@v3 with: - node-version: 19.6.0 + node-version: 19.7.0 - id: restore-npm-cache name: Restore npm cache diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index 5d34d2fe..8606a687 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -69,6 +69,7 @@