Skip to content

Commit 8ad7f6d

Browse files
committed
Added ability to automatically resolve users browsers offset.
1 parent 9fd7d34 commit 8ad7f6d

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

src/Exceptionless.Web/ClientApp/src/lib/features/events/api.svelte.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { WebSocketMessageValue } from '$features/websockets/models';
22
import type { CountResult } from '$shared/models';
33

44
import { accessToken } from '$features/auth/index.svelte';
5+
import { DEFAULT_OFFSET } from '$features/shared/api/api.svelte';
56
import { type ProblemDetails, useFetchClient } from '@exceptionless/fetchclient';
67
import { createQuery, QueryClient, useQueryClient } from '@tanstack/svelte-query';
78

@@ -48,6 +49,10 @@ export interface GetCountRequest {
4849
}
4950

5051
export interface GetEventRequest {
52+
params?: {
53+
offset?: string;
54+
time?: string;
55+
};
5156
route: {
5257
id: string | undefined;
5358
};
@@ -117,7 +122,10 @@ export function getCountQuery(request: GetCountRequest) {
117122
queryFn: async ({ signal }: { signal: AbortSignal }) => {
118123
const client = useFetchClient();
119124
const response = await client.getJSON<CountResult>('events/count', {
120-
params: request.params,
125+
params: {
126+
...(DEFAULT_OFFSET ? { offset: DEFAULT_OFFSET } : {}),
127+
...request.params
128+
},
121129
signal
122130
});
123131

@@ -133,6 +141,10 @@ export function getEventQuery(request: GetEventRequest) {
133141
queryFn: async ({ signal }: { signal: AbortSignal }) => {
134142
const client = useFetchClient();
135143
const response = await client.getJSON<PersistentEvent>(`events/${request.route.id}`, {
144+
params: {
145+
...(DEFAULT_OFFSET ? { offset: DEFAULT_OFFSET } : {}),
146+
...request.params
147+
},
136148
signal
137149
});
138150

@@ -151,7 +163,10 @@ export function getProjectCountQuery(request: GetProjectCountRequest) {
151163
queryFn: async ({ signal }: { signal: AbortSignal }) => {
152164
const client = useFetchClient();
153165
const response = await client.getJSON<CountResult>(`/projects/${request.route.projectId}/events/count`, {
154-
params: request.params,
166+
params: {
167+
...(DEFAULT_OFFSET ? { offset: DEFAULT_OFFSET } : {}),
168+
...request.params
169+
},
155170
signal
156171
});
157172

@@ -171,6 +186,7 @@ export function getStackCountQuery(request: GetStackCountRequest) {
171186
const client = useFetchClient();
172187
const response = await client.getJSON<CountResult>('events/count', {
173188
params: {
189+
...(DEFAULT_OFFSET ? { offset: DEFAULT_OFFSET } : {}),
174190
...request.params,
175191
filter: request.params?.filter?.includes(`stack:${request.route.stackId}`)
176192
? request.params.filter
@@ -199,7 +215,10 @@ export function getStackEventsQuery(request: GetStackEventsRequest) {
199215
queryFn: async ({ signal }: { signal: AbortSignal }) => {
200216
const client = useFetchClient();
201217
const response = await client.getJSON<PersistentEvent[]>(`stacks/${request.route.stackId}/events`, {
202-
params: request.params,
218+
params: {
219+
...(DEFAULT_OFFSET ? { offset: DEFAULT_OFFSET } : {}),
220+
...request.params
221+
},
203222
signal
204223
});
205224

src/Exceptionless.Web/ClientApp/src/lib/features/shared/api/api.svelte.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ import { FetchClient, FetchClientProvider, getCurrentProvider } from '@exception
22

33
export const DEFAULT_LIMIT = 10;
44

5+
/**
6+
* Represents the default timezone offset based on the user's local time.
7+
* If the user's timezone offset is not 0 (UTC), returns the offset in minutes with a 'm' suffix.
8+
* If the user's timezone offset is 0, returns undefined.
9+
*/
10+
export const DEFAULT_OFFSET = new Date().getTimezoneOffset() !== 0 ? new Date().getTimezoneOffset() * -1 + 'm' : undefined;
11+
512
export class FetchClientStatus {
613
isLoading = $state(false);
714

0 commit comments

Comments
 (0)