2021-02-09 16:04:55 +00:00
|
|
|
import { DefaultClient, AKResponse, QueryArguments } from "./Client";
|
2020-12-28 13:26:41 +00:00
|
|
|
|
|
|
|
export interface EventUser {
|
|
|
|
pk: number;
|
|
|
|
email?: string;
|
|
|
|
username: string;
|
|
|
|
on_behalf_of?: EventUser;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface EventContext {
|
2020-12-31 10:21:52 +00:00
|
|
|
[key: string]: EventContext | string | number | string[];
|
2020-12-28 13:26:41 +00:00
|
|
|
}
|
2020-12-01 21:17:07 +00:00
|
|
|
|
2020-12-20 21:04:29 +00:00
|
|
|
export class Event {
|
2020-12-28 13:26:41 +00:00
|
|
|
pk: string;
|
|
|
|
user: EventUser;
|
|
|
|
action: string;
|
|
|
|
app: string;
|
|
|
|
context: EventContext;
|
|
|
|
client_ip: string;
|
|
|
|
created: string;
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
throw Error();
|
|
|
|
}
|
|
|
|
|
|
|
|
static get(pk: string): Promise<Event> {
|
|
|
|
return DefaultClient.fetch<Event>(["events", "events", pk]);
|
|
|
|
}
|
|
|
|
|
2021-02-09 16:04:55 +00:00
|
|
|
static list(filter?: QueryArguments): Promise<AKResponse<Event>> {
|
|
|
|
return DefaultClient.fetch<AKResponse<Event>>(["events", "events"], filter);
|
2020-12-28 13:26:41 +00:00
|
|
|
}
|
|
|
|
|
2020-12-20 21:04:29 +00:00
|
|
|
// events/events/top_per_user/?filter_action=authorize_application
|
2020-12-01 21:17:07 +00:00
|
|
|
static topForUser(action: string): Promise<TopNEvent[]> {
|
2020-12-20 21:04:29 +00:00
|
|
|
return DefaultClient.fetch<TopNEvent[]>(["events", "events", "top_per_user"], {
|
2020-12-01 21:17:07 +00:00
|
|
|
"filter_action": action,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface TopNEvent {
|
|
|
|
application: { [key: string]: string};
|
|
|
|
counted_events: number;
|
|
|
|
unique_users: number;
|
|
|
|
}
|