fix(api): exclude some keys for export cache
This commit is contained in:
@@ -11,6 +11,7 @@ import {
|
|||||||
} from '@openpanel/db';
|
} from '@openpanel/db';
|
||||||
import { getChart } from '@openpanel/trpc/src/routers/chart.helpers';
|
import { getChart } from '@openpanel/trpc/src/routers/chart.helpers';
|
||||||
import { zChartInput } from '@openpanel/validation';
|
import { zChartInput } from '@openpanel/validation';
|
||||||
|
import { omit } from 'ramda';
|
||||||
|
|
||||||
async function getProjectId(
|
async function getProjectId(
|
||||||
request: FastifyRequest<{
|
request: FastifyRequest<{
|
||||||
@@ -125,7 +126,7 @@ export async function events(
|
|||||||
|
|
||||||
const [data, totalCount] = await Promise.all([
|
const [data, totalCount] = await Promise.all([
|
||||||
getEventList(options),
|
getEventList(options),
|
||||||
getEventsCountCached(options),
|
getEventsCountCached(omit(['cursor', 'take'], options)),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
reply.send({
|
reply.send({
|
||||||
|
|||||||
@@ -6,14 +6,35 @@ To authenticate with the Export API, you need to use your `clientId` and `client
|
|||||||
|
|
||||||
We expect you to send `openpanel-client-id` and `openpanel-client-secret` headers with your requests.
|
We expect you to send `openpanel-client-id` and `openpanel-client-secret` headers with your requests.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl 'https://api.openpanel.dev/export/events' \
|
||||||
|
-H 'openpanel-client-id: YOUR_CLIENT_ID' \
|
||||||
|
-H 'openpanel-client-secret: YOUR_CLIENT_SECRET'
|
||||||
|
```
|
||||||
|
|
||||||
## Events
|
## Events
|
||||||
|
|
||||||
Get all `screen_view` events from project `abc` between `2024-04-15` and `2024-04-18`.
|
Get events from a specific project within a date range.
|
||||||
|
|
||||||
|
Endpoint: `GET /export/events`
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
- project_id (required): The ID of the project
|
||||||
|
- event (optional): Filter by event name(s). Can be a single event or an array of events.
|
||||||
|
- start (optional): Start date (format: YYYY-MM-DD)
|
||||||
|
- end (optional): End date (format: YYYY-MM-DD)
|
||||||
|
- page (optional, default: 1): Page number for pagination
|
||||||
|
- limit (optional, default: 50, max: 50): Number of events per page
|
||||||
|
- includes (optional): Additional fields to include in the response
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl 'https://api.openpanel.dev/export/events?project_id=abc&event=screen_view&start=2024-04-15&end=2024-04-18' \
|
curl 'https://api.openpanel.dev/export/events?project_id=abc&event=screen_view&start=2024-04-15&end=2024-04-18' \
|
||||||
-H 'openpanel-client-id: CLIENT_ID' \
|
-H 'openpanel-client-id: YOUR_CLIENT_ID' \
|
||||||
-H 'openpanel-client-secret: CLIENT_SECRET'
|
-H 'openpanel-client-secret: YOUR_CLIENT_SECRET'
|
||||||
```
|
```
|
||||||
|
|
||||||
## Profiles
|
## Profiles
|
||||||
|
|||||||
@@ -511,7 +511,7 @@ export async function getEventList({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getEventsCountCached = cacheable(getEventsCount, 60 * 60);
|
export const getEventsCountCached = cacheable(getEventsCount, 60 * 10);
|
||||||
export async function getEventsCount({
|
export async function getEventsCount({
|
||||||
projectId,
|
projectId,
|
||||||
profileId,
|
profileId,
|
||||||
|
|||||||
Reference in New Issue
Block a user