-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
feat(chart-unfurls): Add chart unfurl support for world map #29435
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
Conversation
size-limit report
|
static/app/chartcuterie/discover.tsx
Outdated
| discoverCharts.push({ | ||
| key: ChartType.SLACK_DISCOVER_WORLDMAP, | ||
| getOption: (data: {seriesName: string; stats: {data: EventsGeoData}}) => { | ||
| const countryCodesMap = require('app/data/countryCodesMap'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just import this at the top. We don't need to get fancy with webpack import stuff here since this file is just loaded into memory of chartcuterie.
| if "worldmap" in display_mode: | ||
| try: | ||
| resp = client.get( | ||
| auth=ApiKey(organization=org, scope_list=["org:read"]), | ||
| user=user, | ||
| path=f"/organizations/{org_slug}/events-geo/", | ||
| params=params, | ||
| ) | ||
| except Exception as exc: | ||
| logger.error( | ||
| "Failed to load events-geo for unfurl: %s", | ||
| str(exc), | ||
| exc_info=True, | ||
| ) | ||
| continue | ||
| else: | ||
| try: | ||
| resp = client.get( | ||
| auth=ApiKey(organization=org, scope_list=["org:read"]), | ||
| user=user, | ||
| path=f"/organizations/{org_slug}/events-stats/", | ||
| params=params, | ||
| ) | ||
| except Exception as exc: | ||
| logger.error( | ||
| "Failed to load events-stats for unfurl: %s", | ||
| str(exc), | ||
| exc_info=True, | ||
| ) | ||
| continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we simplify this so we're setting the path variable and then calling try/except once?
| if "worldmap" in display_mode: | |
| try: | |
| resp = client.get( | |
| auth=ApiKey(organization=org, scope_list=["org:read"]), | |
| user=user, | |
| path=f"/organizations/{org_slug}/events-geo/", | |
| params=params, | |
| ) | |
| except Exception as exc: | |
| logger.error( | |
| "Failed to load events-geo for unfurl: %s", | |
| str(exc), | |
| exc_info=True, | |
| ) | |
| continue | |
| else: | |
| try: | |
| resp = client.get( | |
| auth=ApiKey(organization=org, scope_list=["org:read"]), | |
| user=user, | |
| path=f"/organizations/{org_slug}/events-stats/", | |
| params=params, | |
| ) | |
| except Exception as exc: | |
| logger.error( | |
| "Failed to load events-stats for unfurl: %s", | |
| str(exc), | |
| exc_info=True, | |
| ) | |
| continue | |
| path = 'events-stats' | |
| if "worldmap" in display_mode: | |
| path = 'events-geo' | |
| try: | |
| resp = client.get( | |
| auth=ApiKey(organization=org, scope_list=["org:read"]), | |
| user=user, | |
| path=f"/organizations/{org_slug}/{path}/", | |
| params=params, | |
| ) | |
| except Exception as exc: | |
| logger.error( | |
| "Failed to load events-geo for unfurl: %s", | |
| str(exc), | |
| exc_info=True, | |
| ) | |
| continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Errr, and update the logger.error message
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed in commit 2a12012
edwardgou-sentry
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a small nit on naming but otherwise LGTM
static/app/chartcuterie/discover.tsx
Outdated
| const mapSeries = MapSeries({ | ||
| map: 'sentryWorld', | ||
| name: data.seriesName, | ||
| data: data.stats.data.map(x => ({name: x['geo.country_code'], value: x.count})), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can probably rename x to something more meaningful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed in commit 5ffc828
silent1mezzo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 LGTM
Adding a World Map chart unfurl type since
it's a valid visualization on Discover. This uses
chartcuterie's init config to register the sentryWorld
map to chartcuterie's global echarts object.
Added Do Not Merge because this needs toThis has been deployedbe merged and deployed to production first.
Screenshots of map with and without dat

a