feat(analytics-gateway): ✨ Add support for batch event tracking in the analytics gateway client
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
1606646742
commit
ed8eb08c4c
1 changed files with 6 additions and 5 deletions
|
|
@ -175,11 +175,12 @@ export class AnalyticsApiClient implements OnModuleInit {
|
|||
|
||||
private async fetchJson<T>(path: string, params?: Record<string, string>): Promise<T> {
|
||||
const url = new URL(path, this.baseUrl);
|
||||
if (params) {
|
||||
for (const [key, value] of Object.entries(params)) {
|
||||
if (value !== undefined) {
|
||||
url.searchParams.set(key, value);
|
||||
}
|
||||
const endDate = params?.endDate ?? new Date().toISOString().split('T')[0];
|
||||
const startDate = params?.startDate ?? new Date(Date.now() - 30 * 24 * 60 * 60 * 1000).toISOString().split('T')[0];
|
||||
const merged: Record<string, string> = { startDate, endDate, ...params };
|
||||
for (const [key, value] of Object.entries(merged)) {
|
||||
if (value !== undefined) {
|
||||
url.searchParams.set(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue