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