Skip to content

Commit 6988558

Browse files
authored
feat(ourlogs): Add link to change timezone in logs tooltip (#97730)
### Summary People have been asking for a way to see their logs in local time, this should hint towards users setting their own local timezone. #### Screenshots <img width="274" height="130" alt="Screenshot 2025-08-12 at 6 08 41 PM" src="https://github.com/user-attachments/assets/dc84c630-d7c8-4d3d-a495-528fa5244183" />
1 parent 39825bf commit 6988558

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

static/app/utils/analytics/logsAnalyticsEvent.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ export type LogsAnalyticsEventParameters = {
6161
log_id: string;
6262
page_source: LogsAnalyticsPageSource;
6363
};
64+
'logs.timestamp_tooltip.add_timezone_clicked': {
65+
organization: Organization;
66+
};
6467
'logs.tracing_onboarding': {
6568
organization: Organization;
6669
platform: PlatformKey | 'unknown';
@@ -85,6 +88,8 @@ export const logsAnalyticsEventMap: Record<LogsAnalyticsEventKey, string | null>
8588
'logs.explorer.metadata': 'Log Explorer Pageload Metadata',
8689
'logs.onboarding': 'Logs Explore Empty State (Onboarding)',
8790
'logs.issue_details.drawer_opened': 'Issues Page Logs Drawer Opened',
91+
'logs.timestamp_tooltip.add_timezone_clicked':
92+
'Logs Timestamp Tooltip Add Timezone Clicked',
8893
'logs.table.row_expanded': 'Expanded Log Row Details',
8994
'logs.tracing_onboarding': 'Logs Tracing Onboarding',
9095
'logs.tracing_onboarding_performance_docs_viewed':

static/app/views/explore/logs/logsTimeTooltip.tsx

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, {Fragment} from 'react';
2+
import {Link} from 'react-router-dom';
23
import styled from '@emotion/styled';
34

45
import AutoSelectText from 'sentry/components/autoSelectText';
@@ -7,6 +8,8 @@ import {DateTime} from 'sentry/components/dateTime';
78
import {useTimezone} from 'sentry/components/timezoneProvider';
89
import {t} from 'sentry/locale';
910
import {space} from 'sentry/styles/space';
11+
import {trackAnalytics} from 'sentry/utils/analytics';
12+
import useOrganization from 'sentry/utils/useOrganization';
1013
import {OurLogKnownFieldKey} from 'sentry/views/explore/logs/types';
1114

1215
type Props = {
@@ -24,6 +27,7 @@ function TimestampTooltipBody({
2427
timestamp: string | number;
2528
}) {
2629
const currentTimezone = useTimezone();
30+
const organization = useOrganization();
2731
const preciseTimestamp = attributes[OurLogKnownFieldKey.TIMESTAMP_PRECISE];
2832
const preciseTimestampMs = preciseTimestamp
2933
? Number(preciseTimestamp) / 1_000_000
@@ -37,7 +41,7 @@ function TimestampTooltipBody({
3741
: null;
3842
const observedTime = observedTimeMs ? new Date(observedTimeMs) : null;
3943

40-
const isUTC = currentTimezone === 'UTC';
44+
const isUTCLocalTimezone = currentTimezone === 'UTC';
4145

4246
return (
4347
<DescriptionList>
@@ -47,7 +51,7 @@ function TimestampTooltipBody({
4751
<AutoSelectText>
4852
<DateTime date={timestampToUse} seconds milliseconds timeZone />
4953
</AutoSelectText>
50-
{!isUTC && (
54+
{!isUTCLocalTimezone && (
5155
<AutoSelectText>
5256
<DateTime date={timestampToUse} seconds milliseconds timeZone utc />
5357
</AutoSelectText>
@@ -57,6 +61,25 @@ function TimestampTooltipBody({
5761
</TimestampLabel>
5862
</TimestampValues>
5963
</dd>
64+
{isUTCLocalTimezone && (
65+
<Fragment>
66+
<dt />
67+
<TimestampLabelLinkContainer>
68+
<TimestampLabelLink
69+
target="_blank"
70+
to="/settings/account/details/#timezone"
71+
onClick={() =>
72+
trackAnalytics('logs.timestamp_tooltip.add_timezone_clicked', {
73+
organization,
74+
})
75+
}
76+
>
77+
<br />
78+
{t('Add your local timezone')}
79+
</TimestampLabelLink>
80+
</TimestampLabelLinkContainer>
81+
</Fragment>
82+
)}
6083

6184
{observedTime && (
6285
<Fragment>
@@ -128,6 +151,14 @@ const HorizontalRule = styled('hr')`
128151
border-top: 1px solid ${p => p.theme.border};
129152
`;
130153

154+
const TimestampLabelLink = styled(Link)`
155+
line-height: 0.8;
156+
`;
157+
131158
const TimestampLabel = styled('span')`
132159
color: ${p => p.theme.gray400};
133160
`;
161+
162+
const TimestampLabelLinkContainer = styled('dd')`
163+
line-height: 0.8;
164+
`;

0 commit comments

Comments
 (0)