Skip to content

Commit c13409d

Browse files
k-fishandrewshie-sentry
authored andcommitted
fix(ourlogs): Analytic events renames and fixes (#97679)
### Summary This gives names to the log onboarding events so they appear in our analytics, and fixes the issues section double firing analytics due to a missing stopPropagation call.
1 parent 73a6dcd commit c13409d

File tree

2 files changed

+51
-35
lines changed

2 files changed

+51
-35
lines changed

static/app/components/events/ourlogs/ourlogsSection.tsx

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -71,37 +71,41 @@ function OurlogsSectionContent({
7171
const sharedHoverTimeoutRef = useRef<NodeJS.Timeout | null>(null);
7272

7373
const limitToTraceId = event.contexts?.trace?.trace_id;
74-
const onOpenLogsDrawer = useCallback(() => {
75-
trackAnalytics('logs.issue_details.drawer_opened', {
76-
organization,
77-
});
78-
openDrawer(
79-
() => (
80-
<LogsQueryParamsProvider source="state">
81-
<LogsPageParamsProvider
82-
analyticsPageSource={LogsAnalyticsPageSource.ISSUE_DETAILS}
83-
isTableFrozen
84-
limitToTraceId={limitToTraceId}
85-
>
86-
<LogsPageDataProvider>
87-
<TraceItemAttributeProvider traceItemType={TraceItemDataset.LOGS} enabled>
88-
<OurlogsDrawer group={group} event={event} project={project} />
89-
</TraceItemAttributeProvider>
90-
</LogsPageDataProvider>
91-
</LogsPageParamsProvider>
92-
</LogsQueryParamsProvider>
93-
),
94-
{
95-
ariaLabel: 'logs drawer',
96-
drawerKey: 'logs-issue-drawer',
74+
const onOpenLogsDrawer = useCallback(
75+
(e: React.MouseEvent<HTMLDivElement | HTMLButtonElement>) => {
76+
e.stopPropagation();
77+
trackAnalytics('logs.issue_details.drawer_opened', {
78+
organization,
79+
});
80+
openDrawer(
81+
() => (
82+
<LogsQueryParamsProvider source="state">
83+
<LogsPageParamsProvider
84+
analyticsPageSource={LogsAnalyticsPageSource.ISSUE_DETAILS}
85+
isTableFrozen
86+
limitToTraceId={limitToTraceId}
87+
>
88+
<LogsPageDataProvider>
89+
<TraceItemAttributeProvider traceItemType={TraceItemDataset.LOGS} enabled>
90+
<OurlogsDrawer group={group} event={event} project={project} />
91+
</TraceItemAttributeProvider>
92+
</LogsPageDataProvider>
93+
</LogsPageParamsProvider>
94+
</LogsQueryParamsProvider>
95+
),
96+
{
97+
ariaLabel: 'logs drawer',
98+
drawerKey: 'logs-issue-drawer',
9799

98-
shouldCloseOnInteractOutside: element => {
99-
const viewAllButton = viewAllButtonRef.current;
100-
return !viewAllButton?.contains(element);
101-
},
102-
}
103-
);
104-
}, [group, event, project, openDrawer, organization, limitToTraceId]);
100+
shouldCloseOnInteractOutside: element => {
101+
const viewAllButton = viewAllButtonRef.current;
102+
return !viewAllButton?.contains(element);
103+
},
104+
}
105+
);
106+
},
107+
[group, event, project, openDrawer, organization, limitToTraceId]
108+
);
105109
if (!feature) {
106110
return null;
107111
}
@@ -121,7 +125,7 @@ function OurlogsSectionContent({
121125
title={t('Logs')}
122126
data-test-id="logs-data-section"
123127
>
124-
<SmallTableContentWrapper onClick={() => onOpenLogsDrawer()}>
128+
<SmallTableContentWrapper onClick={onOpenLogsDrawer}>
125129
<SmallTable>
126130
<TableBody>
127131
{abbreviatedTableData?.map((row, index) => (
@@ -143,7 +147,7 @@ function OurlogsSectionContent({
143147
icon={<IconChevron direction="right" />}
144148
aria-label={t('View more')}
145149
size="sm"
146-
onClick={() => onOpenLogsDrawer()}
150+
onClick={onOpenLogsDrawer}
147151
ref={viewAllButtonRef}
148152
>
149153
{t('View more')}

static/app/utils/analytics/logsAnalyticsEvent.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,31 +36,40 @@ export type LogsAnalyticsEventParameters = {
3636
'logs.issue_details.drawer_opened': {
3737
organization: Organization;
3838
};
39+
'logs.onboarding': {
40+
organization: Organization;
41+
platform: PlatformKey | 'unknown';
42+
supports_onboarding_checklist: boolean;
43+
};
44+
'logs.onboarding_platform_docs_viewed': {
45+
organization: Organization;
46+
platform: PlatformKey | 'unknown';
47+
};
48+
3949
'logs.save_as': {
4050
save_type: 'alert' | 'dashboard' | 'update_query';
4151
ui_source: 'toolbar' | 'chart' | 'compare chart' | 'searchbar';
4252
};
53+
4354
'logs.save_query_modal': {
4455
action: 'open' | 'submit';
4556
save_type: 'save_new_query' | 'rename_query';
4657
ui_source: 'toolbar' | 'table';
4758
};
59+
4860
'logs.table.row_expanded': {
4961
log_id: string;
5062
page_source: LogsAnalyticsPageSource;
5163
};
52-
5364
'logs.tracing_onboarding': {
5465
organization: Organization;
5566
platform: PlatformKey | 'unknown';
5667
supports_onboarding_checklist: boolean;
5768
};
58-
5969
'logs.tracing_onboarding_performance_docs_viewed': {
6070
organization: Organization;
6171
platform: PlatformKey | 'unknown';
6272
};
63-
6473
'logs.tracing_onboarding_platform_docs_viewed': {
6574
organization: Organization;
6675
platform: PlatformKey | 'unknown';
@@ -74,6 +83,7 @@ export const logsAnalyticsEventMap: Record<LogsAnalyticsEventKey, string | null>
7483
'logs.auto_refresh.toggled': 'Log Auto-refresh Toggled',
7584
'logs.doc_link.clicked': 'Logs documentation link clicked',
7685
'logs.explorer.metadata': 'Log Explorer Pageload Metadata',
86+
'logs.onboarding': 'Logs Explore Empty State (Onboarding)',
7787
'logs.issue_details.drawer_opened': 'Issues Page Logs Drawer Opened',
7888
'logs.table.row_expanded': 'Expanded Log Row Details',
7989
'logs.tracing_onboarding': 'Logs Tracing Onboarding',
@@ -83,4 +93,6 @@ export const logsAnalyticsEventMap: Record<LogsAnalyticsEventKey, string | null>
8393
'Logs Tracing Onboarding Platform Docs Viewed',
8494
'logs.save_as': 'Logs Save As',
8595
'logs.save_query_modal': 'Logs Save Query Modal',
96+
'logs.onboarding_platform_docs_viewed':
97+
'Logs Explore Empty State (Onboarding) - Platform Docs Viewed',
8698
};

0 commit comments

Comments
 (0)