revert: drop Umami concurrency change
This commit is contained in:
1 parent
7a56a7d74f
commit
bfb834e087
2 files changed
+17
-21
No files matched your search
@@ -172,7 +172,7 @@ describe("UmamiIntegration", () => {
|
|||||||
expect(result[0]?.dataPoints.reduce((sum, point) => sum + point.y, 0)).toBe(20 * PAGE_SIZE);
|
expect(result[0]?.dataPoints.reduce((sum, point) => sum + point.y, 0)).toBe(20 * PAGE_SIZE);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("requests event series with bounded concurrency", async () => {
|
test("requests event series one at a time", async () => {
|
||||||
let inFlight = 0;
|
let inFlight = 0;
|
||||||
let maxInFlight = 0;
|
let maxInFlight = 0;
|
||||||
mockFetch.mockImplementation(async () => {
|
mockFetch.mockImplementation(async () => {
|
||||||
@@ -186,11 +186,14 @@ describe("UmamiIntegration", () => {
|
|||||||
}) as unknown as Awaited<ReturnType<typeof fetchWithTrustedCertificatesAsync>>;
|
}) as unknown as Awaited<ReturnType<typeof fetchWithTrustedCertificatesAsync>>;
|
||||||
});
|
});
|
||||||
|
|
||||||
const eventNames = ["signup", "purchase", "refund", "login", "logout", "download"];
|
const result = await createIntegration().getMultiEventTimeSeriesAsync(WEBSITE_ID, "24h", [
|
||||||
const result = await createIntegration().getMultiEventTimeSeriesAsync(WEBSITE_ID, "24h", eventNames);
|
"signup",
|
||||||
|
"purchase",
|
||||||
|
"refund",
|
||||||
|
]);
|
||||||
|
|
||||||
expect(result.map(({ eventName }) => eventName)).toEqual(eventNames);
|
expect(result).toHaveLength(3);
|
||||||
expect(maxInFlight).toBe(4);
|
expect(maxInFlight).toBe(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -32,7 +32,6 @@ const UMAMI_CUSTOM_EVENT_TYPE = 2;
|
|||||||
const UMAMI_EVENT_NAME_LIMIT = 5_000;
|
const UMAMI_EVENT_NAME_LIMIT = 5_000;
|
||||||
const UMAMI_EVENT_PAGE_SIZE = 5_000;
|
const UMAMI_EVENT_PAGE_SIZE = 5_000;
|
||||||
const UMAMI_EVENT_PAGE_MAX = 20;
|
const UMAMI_EVENT_PAGE_MAX = 20;
|
||||||
const UMAMI_EVENT_REQUEST_CONCURRENCY = 4;
|
|
||||||
|
|
||||||
const logger = createLogger({ module: "umami-integration" });
|
const logger = createLogger({ module: "umami-integration" });
|
||||||
|
|
||||||
@@ -247,22 +246,16 @@ export class UmamiIntegration extends Integration {
|
|||||||
const authHeaders = await this.getAuthHeadersAsync();
|
const authHeaders = await this.getAuthHeadersAsync();
|
||||||
const { startAt, endAt, unit } = this.computeTimeRange(timeFrame);
|
const { startAt, endAt, unit } = this.computeTimeRange(timeFrame);
|
||||||
const results: UmamiEventSeries[] = [];
|
const results: UmamiEventSeries[] = [];
|
||||||
for (let index = 0; index < eventNames.length; index += UMAMI_EVENT_REQUEST_CONCURRENCY) {
|
for (const eventName of eventNames) {
|
||||||
const batch = eventNames.slice(index, index + UMAMI_EVENT_REQUEST_CONCURRENCY);
|
const dataPoints = await this.getWebsiteEventTimeSeriesAsync(
|
||||||
const batchResults = await Promise.all(
|
websiteId,
|
||||||
batch.map(async (eventName) => {
|
startAt,
|
||||||
const dataPoints = await this.getWebsiteEventTimeSeriesAsync(
|
endAt,
|
||||||
websiteId,
|
unit,
|
||||||
startAt,
|
eventName,
|
||||||
endAt,
|
authHeaders,
|
||||||
unit,
|
|
||||||
eventName,
|
|
||||||
authHeaders,
|
|
||||||
);
|
|
||||||
return { eventName, dataPoints: dataPoints ?? [] };
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
results.push(...batchResults);
|
results.push({ eventName, dataPoints: dataPoints ?? [] });
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user