mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-15 09:45:04 +01:00
Merge pull request #1714 from umami-software/feat/um-136-camel-case
Remove snake_case.
This commit is contained in:
commit
677566b5f3
@ -109,8 +109,8 @@ export default function EventDataForm({ websiteId, onClose, className }) {
|
||||
const handleSubmit = async () => {
|
||||
const params = {
|
||||
website_id: websiteId,
|
||||
start_at: +startDate,
|
||||
end_at: +endDate,
|
||||
startAt: +startDate,
|
||||
endAt: +endDate,
|
||||
timezone,
|
||||
columns,
|
||||
filters,
|
||||
|
@ -21,7 +21,7 @@ export default function UserPasswordForm({ onSave, userId }) {
|
||||
const payload = isCurrentUser
|
||||
? data
|
||||
: {
|
||||
password: data.new_password,
|
||||
password: data.newPassword,
|
||||
};
|
||||
|
||||
mutate(payload, {
|
||||
@ -33,7 +33,7 @@ export default function UserPasswordForm({ onSave, userId }) {
|
||||
};
|
||||
|
||||
const samePassword = value => {
|
||||
if (value !== ref?.current?.getValues('new_password')) {
|
||||
if (value !== ref?.current?.getValues('newPassword')) {
|
||||
return "Passwords don't match";
|
||||
}
|
||||
return true;
|
||||
@ -42,16 +42,12 @@ export default function UserPasswordForm({ onSave, userId }) {
|
||||
return (
|
||||
<Form ref={ref} className={styles.form} onSubmit={handleSubmit} error={error}>
|
||||
{isCurrentUser && (
|
||||
<FormInput
|
||||
name="current_password"
|
||||
label="Current password"
|
||||
rules={{ required: 'Required' }}
|
||||
>
|
||||
<FormInput name="currentPassword" label="Current password" rules={{ required: 'Required' }}>
|
||||
<PasswordField autoComplete="off" />
|
||||
</FormInput>
|
||||
)}
|
||||
<FormInput
|
||||
name="new_password"
|
||||
name="newPassword"
|
||||
label="New password"
|
||||
rules={{
|
||||
required: 'Required',
|
||||
@ -61,7 +57,7 @@ export default function UserPasswordForm({ onSave, userId }) {
|
||||
<PasswordField autoComplete="off" />
|
||||
</FormInput>
|
||||
<FormInput
|
||||
name="confirm_password"
|
||||
name="confirmPassword"
|
||||
label="Confirm password"
|
||||
rules={{
|
||||
required: 'Required',
|
||||
|
@ -19,12 +19,12 @@ export default function EventsChart({ websiteId, className, token }) {
|
||||
`/websites/${websiteId}/events`,
|
||||
{
|
||||
params: {
|
||||
start_at: +startDate,
|
||||
end_at: +endDate,
|
||||
startAt: +startDate,
|
||||
endAt: +endDate,
|
||||
unit,
|
||||
tz: timezone,
|
||||
url,
|
||||
event_name: eventName,
|
||||
eventName,
|
||||
token,
|
||||
},
|
||||
},
|
||||
|
@ -22,8 +22,8 @@ export default function MetricsBar({ websiteId, className }) {
|
||||
`/websites/${websiteId}/stats`,
|
||||
{
|
||||
params: {
|
||||
start_at: +startDate,
|
||||
end_at: +endDate,
|
||||
startAt: +startDate,
|
||||
endAt: +endDate,
|
||||
url,
|
||||
referrer,
|
||||
os,
|
||||
|
@ -42,8 +42,8 @@ export default function MetricsTable({
|
||||
{
|
||||
params: {
|
||||
type,
|
||||
start_at: +startDate,
|
||||
end_at: +endDate,
|
||||
startAt: +startDate,
|
||||
endAt: +endDate,
|
||||
url,
|
||||
referrer,
|
||||
os,
|
||||
|
@ -37,8 +37,8 @@ export default function WebsiteChart({
|
||||
`/websites/${websiteId}/pageviews`,
|
||||
{
|
||||
params: {
|
||||
start_at: +startDate,
|
||||
end_at: +endDate,
|
||||
startAt: +startDate,
|
||||
endAt: +endDate,
|
||||
unit,
|
||||
tz: timezone,
|
||||
url,
|
||||
|
@ -35,7 +35,7 @@ export default function RealtimeDashboard() {
|
||||
const [websiteId, setWebsiteId] = useState(null);
|
||||
const { data: init, loading } = useFetch('/realtime/init');
|
||||
const { data: updates } = useFetch('/realtime/update', {
|
||||
params: { start_at: data?.timestamp },
|
||||
params: { startAt: data?.timestamp },
|
||||
disabled: !init?.websites?.length || !data,
|
||||
interval: REALTIME_INTERVAL,
|
||||
headers: { [SHARE_TOKEN_HEADER]: init?.token },
|
||||
|
@ -64,8 +64,8 @@ function getCommaSeparatedStringFormat(data) {
|
||||
return data.map(a => `'${a}'`).join(',') || '';
|
||||
}
|
||||
|
||||
function getBetweenDates(field, start_at, end_at) {
|
||||
return `${field} between ${getDateFormat(start_at)} and ${getDateFormat(end_at)}`;
|
||||
function getBetweenDates(field, startAt, endAt) {
|
||||
return `${field} between ${getDateFormat(startAt)} and ${getDateFormat(endAt)}`;
|
||||
}
|
||||
|
||||
function getJsonField(column, property) {
|
||||
@ -120,7 +120,7 @@ function getFilterQuery(filters = {}, params = []) {
|
||||
case 'browser':
|
||||
case 'device':
|
||||
case 'country':
|
||||
case 'event_name':
|
||||
case 'eventName':
|
||||
arr.push(`and ${key}=$${params.length + 1}`);
|
||||
params.push(decodeURIComponent(filter));
|
||||
break;
|
||||
@ -147,18 +147,18 @@ function getFilterQuery(filters = {}, params = []) {
|
||||
}
|
||||
|
||||
function parseFilters(filters = {}, params = []) {
|
||||
const { domain, url, event_url, referrer, os, browser, device, country, event_name, query } =
|
||||
const { domain, url, event_url, referrer, os, browser, device, country, eventName, query } =
|
||||
filters;
|
||||
|
||||
const pageviewFilters = { domain, url, referrer, query };
|
||||
const sessionFilters = { os, browser, device, country };
|
||||
const eventFilters = { url: event_url, event_name };
|
||||
const eventFilters = { url: event_url, eventName };
|
||||
|
||||
return {
|
||||
pageviewFilters,
|
||||
sessionFilters,
|
||||
eventFilters,
|
||||
event: { event_name },
|
||||
event: { eventName },
|
||||
filterQuery: getFilterQuery(filters, params),
|
||||
};
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ function getFilterQuery(filters = {}, params = []): string {
|
||||
case 'browser':
|
||||
case 'device':
|
||||
case 'country':
|
||||
case 'event_name':
|
||||
case 'eventName':
|
||||
arr.push(`and ${key}=$${params.length + 1}`);
|
||||
params.push(decodeURIComponent(filter));
|
||||
break;
|
||||
@ -187,18 +187,18 @@ function parseFilters(
|
||||
params = [],
|
||||
sessionKey = 'session_id',
|
||||
) {
|
||||
const { domain, url, event_url, referrer, os, browser, device, country, event_name, query } =
|
||||
const { domain, url, event_url, referrer, os, browser, device, country, eventName, query } =
|
||||
filters;
|
||||
|
||||
const pageviewFilters = { domain, url, referrer, query };
|
||||
const sessionFilters = { os, browser, device, country };
|
||||
const eventFilters = { url: event_url, event_name };
|
||||
const eventFilters = { url: event_url, eventName };
|
||||
|
||||
return {
|
||||
pageviewFilters,
|
||||
sessionFilters,
|
||||
eventFilters,
|
||||
event: { event_name },
|
||||
event: { eventName },
|
||||
joinSession:
|
||||
os || browser || device || country
|
||||
? `inner join session on ${sessionKey} = session.${sessionKey}`
|
||||
|
@ -31,7 +31,7 @@ export default async (req: NextApiRequestCollect, res: NextApiResponse) => {
|
||||
|
||||
const { type, payload } = getJsonBody(req);
|
||||
|
||||
const { referrer, event_name: eventName, event_data: eventData } = payload;
|
||||
const { referrer, eventName, event_data: eventData } = payload;
|
||||
let { url } = payload;
|
||||
|
||||
// Validate eventData is JSON
|
||||
|
@ -8,7 +8,7 @@ import { NextApiResponse } from 'next';
|
||||
import { RealtimeUpdate } from 'lib/types';
|
||||
|
||||
export interface InitUpdateRequestQuery {
|
||||
start_at: string;
|
||||
startAt: string;
|
||||
}
|
||||
|
||||
export default async (
|
||||
@ -18,7 +18,7 @@ export default async (
|
||||
await useAuth(req, res);
|
||||
|
||||
if (req.method === 'GET') {
|
||||
const { start_at } = req.query;
|
||||
const { startAt } = req.query;
|
||||
|
||||
const token = req.headers[SHARE_TOKEN_HEADER];
|
||||
|
||||
@ -28,7 +28,7 @@ export default async (
|
||||
|
||||
const { websites } = parseToken(token, secret());
|
||||
|
||||
const data = await getRealtimeData(websites, new Date(+start_at));
|
||||
const data = await getRealtimeData(websites, new Date(+startAt));
|
||||
|
||||
return ok(res, data);
|
||||
}
|
||||
|
@ -11,8 +11,8 @@ export interface TeamUserRequestQuery {
|
||||
|
||||
export interface TeamUserRequestBody {
|
||||
email: string;
|
||||
role_id: string;
|
||||
team_user_id?: string;
|
||||
roleId: string;
|
||||
teamUserId?: string;
|
||||
}
|
||||
|
||||
export default async (
|
||||
@ -41,7 +41,7 @@ export default async (
|
||||
return unauthorized(res, 'You must be the owner of this team.');
|
||||
}
|
||||
|
||||
const { email, role_id: roleId } = req.body;
|
||||
const { email, roleId: roleId } = req.body;
|
||||
|
||||
// Check for User
|
||||
const user = await getUser({ username: email });
|
||||
@ -59,9 +59,9 @@ export default async (
|
||||
if (await canUpdateTeam(userId, teamId)) {
|
||||
return unauthorized(res, 'You must be the owner of this team.');
|
||||
}
|
||||
const { team_user_id } = req.body;
|
||||
const { teamUserId } = req.body;
|
||||
|
||||
await deleteTeamUser(team_user_id);
|
||||
await deleteTeamUser(teamUserId);
|
||||
|
||||
return ok(res);
|
||||
}
|
||||
|
@ -17,8 +17,8 @@ export interface UserPasswordRequestQuery {
|
||||
}
|
||||
|
||||
export interface UserPasswordRequestBody {
|
||||
current_password: string;
|
||||
new_password: string;
|
||||
currentPassword: string;
|
||||
newPassword: string;
|
||||
}
|
||||
|
||||
export default async (
|
||||
@ -27,7 +27,7 @@ export default async (
|
||||
) => {
|
||||
await useAuth(req, res);
|
||||
|
||||
const { current_password, new_password } = req.body;
|
||||
const { currentPassword, newPassword } = req.body;
|
||||
const { id } = req.query;
|
||||
const {
|
||||
user: { id: userId, isAdmin },
|
||||
@ -40,11 +40,11 @@ export default async (
|
||||
|
||||
const user = await getUser({ id }, { includePassword: true });
|
||||
|
||||
if (!checkPassword(current_password, user.password)) {
|
||||
if (!checkPassword(currentPassword, user.password)) {
|
||||
return badRequest(res, 'Current password is incorrect');
|
||||
}
|
||||
|
||||
const password = hashPassword(new_password);
|
||||
const password = hashPassword(newPassword);
|
||||
|
||||
const updated = await updateUser({ password }, { id });
|
||||
|
||||
|
@ -10,9 +10,9 @@ export interface WebsiteEventDataRequestQuery {
|
||||
}
|
||||
|
||||
export interface WebsiteEventDataRequestBody {
|
||||
start_at: string;
|
||||
end_at: string;
|
||||
event_name: string;
|
||||
startAt: string;
|
||||
endAt: string;
|
||||
eventName: string;
|
||||
columns: { [key: string]: 'count' | 'max' | 'min' | 'avg' | 'sum' };
|
||||
filters?: { [key: string]: any };
|
||||
}
|
||||
@ -34,10 +34,10 @@ export default async (
|
||||
return unauthorized(res);
|
||||
}
|
||||
|
||||
const { start_at, end_at, event_name: eventName, columns, filters } = req.body;
|
||||
const { startAt, endAt, event_name: eventName, columns, filters } = req.body;
|
||||
|
||||
const startDate = new Date(+start_at);
|
||||
const endDate = new Date(+end_at);
|
||||
const startDate = new Date(+startAt);
|
||||
const endDate = new Date(+endAt);
|
||||
|
||||
const events = await getEventData(websiteId, {
|
||||
startDate,
|
||||
|
@ -10,12 +10,12 @@ const unitTypes = ['year', 'month', 'hour', 'day'];
|
||||
|
||||
export interface WebsiteEventsRequestQuery {
|
||||
id: string;
|
||||
start_at: string;
|
||||
end_at: string;
|
||||
startAt: string;
|
||||
endAt: string;
|
||||
unit: string;
|
||||
tz: string;
|
||||
url: string;
|
||||
event_name: string;
|
||||
eventName: string;
|
||||
}
|
||||
|
||||
export default async (
|
||||
@ -28,7 +28,7 @@ export default async (
|
||||
const {
|
||||
user: { id: userId },
|
||||
} = req.auth;
|
||||
const { id: websiteId, start_at, end_at, unit, tz, url, event_name } = req.query;
|
||||
const { id: websiteId, startAt, endAt, unit, tz, url, eventName } = req.query;
|
||||
|
||||
if (req.method === 'GET') {
|
||||
if (canViewWebsite(userId, websiteId)) {
|
||||
@ -38,8 +38,8 @@ export default async (
|
||||
if (!moment.tz.zone(tz) || !unitTypes.includes(unit)) {
|
||||
return badRequest(res);
|
||||
}
|
||||
const startDate = new Date(+start_at);
|
||||
const endDate = new Date(+end_at);
|
||||
const startDate = new Date(+startAt);
|
||||
const endDate = new Date(+endAt);
|
||||
|
||||
const events = await getEventMetrics(websiteId, {
|
||||
startDate,
|
||||
@ -48,7 +48,7 @@ export default async (
|
||||
unit,
|
||||
filters: {
|
||||
url,
|
||||
eventName: event_name,
|
||||
eventName,
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -38,8 +38,8 @@ function getColumn(type) {
|
||||
export interface WebsiteMetricsRequestQuery {
|
||||
id: string;
|
||||
type: string;
|
||||
start_at: number;
|
||||
end_at: number;
|
||||
startAt: number;
|
||||
endAt: number;
|
||||
url: string;
|
||||
referrer: string;
|
||||
os: string;
|
||||
@ -61,8 +61,8 @@ export default async (
|
||||
const {
|
||||
id: websiteId,
|
||||
type,
|
||||
start_at,
|
||||
end_at,
|
||||
startAt,
|
||||
endAt,
|
||||
url,
|
||||
referrer,
|
||||
os,
|
||||
@ -76,8 +76,8 @@ export default async (
|
||||
return unauthorized(res);
|
||||
}
|
||||
|
||||
const startDate = new Date(+start_at);
|
||||
const endDate = new Date(+end_at);
|
||||
const startDate = new Date(+startAt);
|
||||
const endDate = new Date(+endAt);
|
||||
|
||||
if (sessionColumns.includes(type)) {
|
||||
let data = await getSessionMetrics(websiteId, {
|
||||
|
@ -11,8 +11,8 @@ const unitTypes = ['year', 'month', 'hour', 'day'];
|
||||
export interface WebsitePageviewRequestQuery {
|
||||
id: string;
|
||||
websiteId: string;
|
||||
start_at: number;
|
||||
end_at: number;
|
||||
startAt: number;
|
||||
endAt: number;
|
||||
unit: string;
|
||||
tz: string;
|
||||
url?: string;
|
||||
@ -35,8 +35,8 @@ export default async (
|
||||
} = req.auth;
|
||||
const {
|
||||
id: websiteId,
|
||||
start_at,
|
||||
end_at,
|
||||
startAt,
|
||||
endAt,
|
||||
unit,
|
||||
tz,
|
||||
url,
|
||||
@ -52,8 +52,8 @@ export default async (
|
||||
return unauthorized(res);
|
||||
}
|
||||
|
||||
const startDate = new Date(+start_at);
|
||||
const endDate = new Date(+end_at);
|
||||
const startDate = new Date(+startAt);
|
||||
const endDate = new Date(+endAt);
|
||||
|
||||
if (!moment.tz.zone(tz) || !unitTypes.includes(unit)) {
|
||||
return badRequest(res);
|
||||
|
@ -9,8 +9,8 @@ import { getWebsiteStats } from 'queries';
|
||||
export interface WebsiteStatsRequestQuery {
|
||||
id: string;
|
||||
type: string;
|
||||
start_at: number;
|
||||
end_at: number;
|
||||
startAt: number;
|
||||
endAt: number;
|
||||
url: string;
|
||||
referrer: string;
|
||||
os: string;
|
||||
@ -29,29 +29,19 @@ export default async (
|
||||
const {
|
||||
user: { id: userId },
|
||||
} = req.auth;
|
||||
const {
|
||||
id: websiteId,
|
||||
start_at,
|
||||
end_at,
|
||||
url,
|
||||
referrer,
|
||||
os,
|
||||
browser,
|
||||
device,
|
||||
country,
|
||||
} = req.query;
|
||||
const { id: websiteId, startAt, endAt, url, referrer, os, browser, device, country } = req.query;
|
||||
|
||||
if (req.method === 'GET') {
|
||||
if (!(await canViewWebsite(userId, websiteId))) {
|
||||
return unauthorized(res);
|
||||
}
|
||||
|
||||
const startDate = new Date(+start_at);
|
||||
const endDate = new Date(+end_at);
|
||||
const startDate = new Date(+startAt);
|
||||
const endDate = new Date(+endAt);
|
||||
|
||||
const distance = end_at - start_at;
|
||||
const prevStartDate = new Date(+start_at - distance);
|
||||
const prevEndDate = new Date(+end_at - distance);
|
||||
const distance = endAt - startAt;
|
||||
const prevStartDate = new Date(+startAt - distance);
|
||||
const prevEndDate = new Date(+endAt - distance);
|
||||
|
||||
const metrics = await getWebsiteStats(websiteId, {
|
||||
startDate,
|
||||
|
@ -9,20 +9,20 @@ export function getEvents(...args) {
|
||||
});
|
||||
}
|
||||
|
||||
function relationalQuery(websites, start_at) {
|
||||
function relationalQuery(websites, startAt) {
|
||||
return prisma.client.event.findMany({
|
||||
where: {
|
||||
websiteId: {
|
||||
in: websites,
|
||||
},
|
||||
createdAt: {
|
||||
gte: start_at,
|
||||
gte: startAt,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function clickhouseQuery(websites, start_at) {
|
||||
function clickhouseQuery(websites, startAt) {
|
||||
const { rawQuery, getDateFormat, getCommaSeparatedStringFormat } = clickhouse;
|
||||
|
||||
return rawQuery(
|
||||
@ -40,6 +40,6 @@ function clickhouseQuery(websites, start_at) {
|
||||
? `website_id in (${getCommaSeparatedStringFormat(websites)})`
|
||||
: '0 = 0'
|
||||
}
|
||||
and created_at >= ${getDateFormat(start_at)}`,
|
||||
and created_at >= ${getDateFormat(startAt)}`,
|
||||
);
|
||||
}
|
||||
|
@ -9,20 +9,20 @@ export async function getPageviews(...args) {
|
||||
});
|
||||
}
|
||||
|
||||
async function relationalQuery(websites, start_at) {
|
||||
async function relationalQuery(websites, startAt) {
|
||||
return prisma.client.pageview.findMany({
|
||||
where: {
|
||||
websiteId: {
|
||||
in: websites,
|
||||
},
|
||||
createdAt: {
|
||||
gte: start_at,
|
||||
gte: startAt,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async function clickhouseQuery(websites, start_at) {
|
||||
async function clickhouseQuery(websites, startAt) {
|
||||
const { rawQuery, getCommaSeparatedStringFormat } = clickhouse;
|
||||
|
||||
return rawQuery(
|
||||
@ -38,6 +38,6 @@ async function clickhouseQuery(websites, start_at) {
|
||||
? `website_id in (${getCommaSeparatedStringFormat(websites)})`
|
||||
: '0 = 0'
|
||||
}
|
||||
and created_at >= ${clickhouse.getDateFormat(start_at)}`,
|
||||
and created_at >= ${clickhouse.getDateFormat(startAt)}`,
|
||||
);
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ export async function getSessions(...args) {
|
||||
});
|
||||
}
|
||||
|
||||
async function relationalQuery(websites, start_at) {
|
||||
async function relationalQuery(websites, startAt) {
|
||||
return prisma.client.session.findMany({
|
||||
where: {
|
||||
...(websites && websites.length > 0
|
||||
@ -20,13 +20,13 @@ async function relationalQuery(websites, start_at) {
|
||||
}
|
||||
: {}),
|
||||
createdAt: {
|
||||
gte: start_at,
|
||||
gte: startAt,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async function clickhouseQuery(websites, start_at) {
|
||||
async function clickhouseQuery(websites, startAt) {
|
||||
const { rawQuery, getDateFormat, getCommaSeparatedStringFormat } = clickhouse;
|
||||
|
||||
return rawQuery(
|
||||
@ -47,6 +47,6 @@ async function clickhouseQuery(websites, start_at) {
|
||||
? `website_id in (${getCommaSeparatedStringFormat(websites)})`
|
||||
: '0 = 0'
|
||||
}
|
||||
and created_at >= ${getDateFormat(start_at)}`,
|
||||
and created_at >= ${getDateFormat(startAt)}`,
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user