-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
feat(new-widget-builder-experience): Add Metrics dataset - Part 1 - [DD-537] #33047
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
Changes from all commits
2b3315a
2bbbb27
f74b349
3dd22a3
c7c334f
79a57bc
41cd3aa
d068e51
f5de69d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import {useEffect} from 'react'; | ||
|
|
||
| import {fetchMetricsFields} from 'sentry/actionCreators/metrics'; | ||
| import MetricsMetaStore from 'sentry/stores/metricsMetaStore'; | ||
| import PageFiltersStore from 'sentry/stores/pageFiltersStore'; | ||
| import {useLegacyStore} from 'sentry/stores/useLegacyStore'; | ||
| import useApi from 'sentry/utils/useApi'; | ||
|
|
||
| import useOrganization from './useOrganization'; | ||
|
|
||
| export function useMetricMetas() { | ||
| const api = useApi(); | ||
| const organization = useOrganization(); | ||
| const {selection} = useLegacyStore(PageFiltersStore); | ||
| const {metricsMeta, loaded} = useLegacyStore(MetricsMetaStore); | ||
| const shouldFetchMetricsMeta = !loaded; | ||
|
|
||
| useEffect(() => { | ||
| let unmounted = false; | ||
|
|
||
| if (!unmounted && shouldFetchMetricsMeta) { | ||
| fetchMetricsFields(api, organization.slug, selection.projects); | ||
| } | ||
|
|
||
| return () => { | ||
| unmounted = true; | ||
| }; | ||
| }, [selection.projects, organization.slug, shouldFetchMetricsMeta]); | ||
|
|
||
| return {metricMetas: metricsMeta}; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import {useEffect} from 'react'; | ||
|
|
||
| import {fetchMetricsTags} from 'sentry/actionCreators/metrics'; | ||
| import MetricsTagStore from 'sentry/stores/metricsTagStore'; | ||
| import PageFiltersStore from 'sentry/stores/pageFiltersStore'; | ||
| import {useLegacyStore} from 'sentry/stores/useLegacyStore'; | ||
| import useApi from 'sentry/utils/useApi'; | ||
|
|
||
| import useOrganization from './useOrganization'; | ||
|
|
||
| export function useMetricTags() { | ||
| const api = useApi(); | ||
| const organization = useOrganization(); | ||
| const {selection} = useLegacyStore(PageFiltersStore); | ||
| const {metricsTags, loaded} = useLegacyStore(MetricsTagStore); | ||
| const shouldFetchMetricTags = !loaded; | ||
|
|
||
| useEffect(() => { | ||
| let unmounted = false; | ||
|
|
||
| if (!unmounted && shouldFetchMetricTags) { | ||
| fetchMetricsTags(api, organization.slug, selection.projects); | ||
| } | ||
|
|
||
| return () => { | ||
| unmounted = true; | ||
| }; | ||
| }, [selection.projects, organization.slug, shouldFetchMetricTags]); | ||
|
Comment on lines
+18
to
+28
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a blocker, but I think it's possible for Maybe we can investigate reducing this to a single request by having some kind of state for
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes I've noticed that and was talking about it with @narsaynorath yesterday... that's why we are still keeping the fetching(tags and fields) on the top of the widget builder, but that's something we want to improve and will investigate afterward |
||
|
|
||
| return {metricTags: metricsTags}; | ||
| } | ||
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.
When I go into a dashboard and try to add from the 'Add Widget' button, I get an error saying
useOrganization called but organization is not setThere 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.
this shouldn't happened :/ the OrganizationContainerContext is wrapping the whole app... I will take a look into it...thanks.