forked from umami-software/umami
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates to insights, event data, telemetry.
- Loading branch information
Showing
44 changed files
with
413 additions
and
278 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export function buildSql(query: string, parameters: object) { | ||
const params = { ...parameters }; | ||
|
||
const sql = query.replaceAll(/\$[\w_]+/g, name => { | ||
return name; | ||
}); | ||
|
||
return { sql, params }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { canViewWebsite } from 'lib/auth'; | ||
import { useCors, useAuth } from 'lib/middleware'; | ||
import { NextApiRequestQueryBody } from 'lib/types'; | ||
import { NextApiResponse } from 'next'; | ||
import { ok, methodNotAllowed, unauthorized } from 'next-basics'; | ||
import { getEventDataEvents } from 'queries'; | ||
|
||
export interface EventDataFieldsRequestBody { | ||
websiteId: string; | ||
dateRange: { | ||
startDate: string; | ||
endDate: string; | ||
}; | ||
} | ||
|
||
export default async ( | ||
req: NextApiRequestQueryBody<any, EventDataFieldsRequestBody>, | ||
res: NextApiResponse<any>, | ||
) => { | ||
await useCors(req, res); | ||
await useAuth(req, res); | ||
|
||
if (req.method === 'GET') { | ||
const { websiteId, startAt, endAt, field, event } = req.query; | ||
|
||
if (!(await canViewWebsite(req.auth, websiteId))) { | ||
return unauthorized(res); | ||
} | ||
|
||
const data = await getEventDataEvents(websiteId, new Date(+startAt), new Date(+endAt), { | ||
field, | ||
event, | ||
}); | ||
|
||
return ok(res, data); | ||
} | ||
|
||
return methodNotAllowed(res); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.