Skip to content

Commit

Permalink
fix offset
Browse files Browse the repository at this point in the history
  • Loading branch information
ari-party committed Jun 5, 2024
1 parent 2337a37 commit 9034e01
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "umami-views",
"version": "1.0.2",
"version": "1.0.3",
"author": "Astrid <git@astrid.email>",
"license": "MIT",
"type": "module",
Expand Down
11 changes: 7 additions & 4 deletions src/lib/umami/getViews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@ export default async function getViews(
token: string,
): Promise<PageViews | null> {
const oneDay = 24 * 60 * 60 * 1000;
const now = Date.now() - oneDay;
const monthAgo = now - 30 * oneDay;

let today: Date | number = new Date();
today.setHours(24, 0, 0, 0);
today = today.getTime();

const monthAgo = today - 30 * oneDay;

const response = await ky.get(
`${websiteAPI}api/websites/${websiteId}/pageviews?${new URLSearchParams({
startAt: String(monthAgo),
endAt: String(now),
endAt: String(today - oneDay),
unit: 'day',
offset: String(0),
timezone: 'Europe/Amsterdam',
})}`,
{
Expand Down

0 comments on commit 9034e01

Please sign in to comment.