Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add function to generate some of the metrics report #261

Merged
merged 9 commits into from
Apr 23, 2024

Conversation

EvanHahn
Copy link
Contributor

@EvanHahn EvanHahn commented Apr 18, 2024

I recommend reviewing this one commit at a time.

This introduces a (dormant) function for generating metrics reports. It returns a result like this:

{
  "type": "metrics-v1",
  "appVersion": "0.0.1",
  "os": "android",
  "osVersion": 10,
  "screen": { "width": 1024, "height": 768 },
  "countries": ["CAN", "USA", "MEX"]
}

This isn't all the metrics we want to collect but I think it's a useful starting point.

Closes #269 and #270.

@EvanHahn EvanHahn marked this pull request as ready for review April 18, 2024 22:50
@EvanHahn EvanHahn requested a review from ErikSin April 18, 2024 22:50
@@ -0,0 +1,29 @@
import borders from '@osm_borders/maritime_10000m';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This data is accurate within 10 kilometers. There are other choices with higher resolution but (1) this is small and therefore the best for performance1 (2) high accuracy might violate user privacy.

Footnotes

  1. I assume


const {features} = lookup.getContainers({
type: 'Point',
coordinates: [longitude, latitude],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought this was backwards, but I believe it's right (and this function is unit tested).

import type {Observation} from '@mapeo/schema';
import positionToCountries from './positionToCountries';

export default function generateMetricsReport({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function takes a bunch of dependencies. It's more verbose, but I think it has some advantages:

  • Easier to port to Electron in the future.
  • Clearer to the caller what goes in; data isn't pulled from anywhere unexpected.
  • Easier to test.

Copy link
Contributor

@ErikSin ErikSin left a comment

Choose a reason for hiding this comment

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

2 small question but otherwise looks good!

src/frontend/metrics/generateMetricsReport.test.ts Outdated Show resolved Hide resolved
src/frontend/metrics/generateMetricsReport.ts Outdated Show resolved Hide resolved
@EvanHahn EvanHahn merged commit e1ba816 into main Apr 23, 2024
3 checks passed
@EvanHahn EvanHahn deleted the generateMetricsReport branch April 23, 2024 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add basic metrics report JSON object
2 participants