Skip to content

Conversation

@shruthilayaj
Copy link
Member

@shruthilayaj shruthilayaj commented Oct 20, 2021

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 to
be merged and deployed to production first.
This has been deployed

Screenshots of map with and without dat
Screen Shot 2021-10-27 at 9 15 19 AM
a

@shruthilayaj shruthilayaj changed the title Add initial chart unfurl support for world map (WIP): Add initial chart unfurl support for world map Oct 20, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Oct 20, 2021

size-limit report

Path Base Size (b5d120a) Current Size Change
src/sentry/static/sentry/dist/entrypoints/app.js 52.75 KB 52.74 KB -0.01% 🔽
src/sentry/static/sentry/dist/entrypoints/sentry.css 70.89 KB 70.89 KB 0%

discoverCharts.push({
key: ChartType.SLACK_DISCOVER_WORLDMAP,
getOption: (data: {seriesName: string; stats: {data: EventsGeoData}}) => {
const countryCodesMap = require('app/data/countryCodesMap');
Copy link
Member

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.

@shruthilayaj shruthilayaj marked this pull request as ready for review October 27, 2021 13:52
@shruthilayaj shruthilayaj requested review from a team and removed request for a team October 27, 2021 13:52
@shruthilayaj shruthilayaj changed the title feat(chart-unfurls): Add initial chart unfurl support for world map feat(chart-unfurls): Add chart unfurl support for world map Oct 27, 2021
Comment on lines 187 to 216
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
Copy link
Contributor

@silent1mezzo silent1mezzo Oct 29, 2021

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?

Suggested change
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

Copy link
Contributor

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

Copy link
Member Author

Choose a reason for hiding this comment

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

addressed in commit 2a12012

Copy link
Contributor

@edwardgou-sentry edwardgou-sentry left a 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

const mapSeries = MapSeries({
map: 'sentryWorld',
name: data.seriesName,
data: data.stats.data.map(x => ({name: x['geo.country_code'], value: x.count})),
Copy link
Contributor

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

Copy link
Member Author

Choose a reason for hiding this comment

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

addressed in commit 5ffc828

Copy link
Contributor

@silent1mezzo silent1mezzo left a comment

Choose a reason for hiding this comment

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

👍 LGTM

@shruthilayaj shruthilayaj merged commit c9cdb86 into master Oct 29, 2021
@shruthilayaj shruthilayaj deleted the feat/world-map-chart-unfurl branch October 29, 2021 14:46
@github-actions github-actions bot locked and limited conversation to collaborators Nov 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants