Skip to content

Commit abde780

Browse files
authored
feat(stories): Add RouteAnalyticsContextProvider to stories so we can see what is viewed (#81108)
I realized recently that we could have analytics about which story files are most commonly referenced. It would help to know what's used often because it might indicate something that needs more attention, similarly something not referenced might be because it's either intuitive, or unused in new code. This is a half step though. This `RouteAnalyticsContextProvider` used relies on the `react-hook:route-activated` hook provided to the HookStore, in dev that won't be implemented. So the data we collect will only be from people using sentry.io/stories which might not cover everyone.
1 parent 0a07bf2 commit abde780

File tree

1 file changed

+36
-33
lines changed

1 file changed

+36
-33
lines changed

static/app/views/stories/index.tsx

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {space} from 'sentry/styles/space';
66
import type {RouteComponentProps} from 'sentry/types/legacyReactRouter';
77
import {useHotkeys} from 'sentry/utils/useHotkeys';
88
import OrganizationContainer from 'sentry/views/organizationContainer';
9+
import RouteAnalyticsContextProvider from 'sentry/views/routeAnalyticsContextProvider';
910
import EmptyStory from 'sentry/views/stories/emptyStory';
1011
import ErrorStory from 'sentry/views/stories/errorStory';
1112
import storiesContext from 'sentry/views/stories/storiesContext';
@@ -25,40 +26,42 @@ export default function Stories({location}: Props) {
2526
useHotkeys([{match: '/', callback: () => searchInput.current?.focus()}], []);
2627

2728
return (
28-
<OrganizationContainer>
29-
<Layout>
30-
<StoryHeader style={{gridArea: 'head'}} />
31-
32-
<Sidebar style={{gridArea: 'aside'}}>
33-
<Input
34-
ref={searchInput}
35-
placeholder="Search files by name"
36-
onChange={e => setSearchTerm(e.target.value.toLowerCase())}
37-
/>
38-
<TreeContainer>
39-
<StoryTree
40-
files={storiesContext()
41-
.files()
42-
.filter(s => s.toLowerCase().includes(searchTerm))}
29+
<RouteAnalyticsContextProvider>
30+
<OrganizationContainer>
31+
<Layout>
32+
<StoryHeader style={{gridArea: 'head'}} />
33+
34+
<Sidebar style={{gridArea: 'aside'}}>
35+
<Input
36+
ref={searchInput}
37+
placeholder="Search files by name"
38+
onChange={e => setSearchTerm(e.target.value.toLowerCase())}
4339
/>
44-
</TreeContainer>
45-
</Sidebar>
46-
47-
{story.error ? (
48-
<VerticalScroll style={{gridArea: 'body'}}>
49-
<ErrorStory error={story.error} />
50-
</VerticalScroll>
51-
) : story.resolved ? (
52-
<Main style={{gridArea: 'body'}}>
53-
<StoryFile filename={story.filename} resolved={story.resolved} />
54-
</Main>
55-
) : (
56-
<VerticalScroll style={{gridArea: 'body'}}>
57-
<EmptyStory />
58-
</VerticalScroll>
59-
)}
60-
</Layout>
61-
</OrganizationContainer>
40+
<TreeContainer>
41+
<StoryTree
42+
files={storiesContext()
43+
.files()
44+
.filter(s => s.toLowerCase().includes(searchTerm))}
45+
/>
46+
</TreeContainer>
47+
</Sidebar>
48+
49+
{story.error ? (
50+
<VerticalScroll style={{gridArea: 'body'}}>
51+
<ErrorStory error={story.error} />
52+
</VerticalScroll>
53+
) : story.resolved ? (
54+
<Main style={{gridArea: 'body'}}>
55+
<StoryFile filename={story.filename} resolved={story.resolved} />
56+
</Main>
57+
) : (
58+
<VerticalScroll style={{gridArea: 'body'}}>
59+
<EmptyStory />
60+
</VerticalScroll>
61+
)}
62+
</Layout>
63+
</OrganizationContainer>
64+
</RouteAnalyticsContextProvider>
6265
);
6366
}
6467

0 commit comments

Comments
 (0)