Skip to content

Commit eaa30fc

Browse files
committed
Fix customPostPath configuration being ignored (close #1376)
PR #1377
1 parent d248feb commit eaa30fc

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@snowplow/tracker-core",
5+
"comment": "Fix customPostPath configuration being ignored (close #1376)",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "@snowplow/tracker-core"
10+
}

libraries/tracker-core/src/emitter/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ interface RequestResult {
198198
export function newEmitter({
199199
endpoint,
200200
eventMethod = 'post',
201+
postPath,
201202
protocol,
202203
port,
203204
maxPostBytes = 40000,
@@ -320,6 +321,7 @@ export function newEmitter({
320321
maxPostBytes,
321322
useStm,
322323
credentials,
324+
postPath,
323325
});
324326
}
325327

libraries/tracker-core/test/emitter/index.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,3 +333,21 @@ test('adds a timeout to the request', async (t) => {
333333
t.is(requests.length, 1);
334334
t.is(await eventStore.count(), 1);
335335
});
336+
337+
test('uses custom POST path configured in the emitter', async (t) => {
338+
const requests: Request[] = [];
339+
const mockFetch = createMockFetch(200, requests);
340+
const eventStore = newInMemoryEventStore({});
341+
const emitter: Emitter = newEmitter({
342+
endpoint: 'https://example.com',
343+
customFetch: mockFetch,
344+
postPath: '/custom',
345+
eventStore,
346+
});
347+
348+
await emitter.input({ e: 'pv' });
349+
await emitter.flush();
350+
351+
t.is(requests.length, 1);
352+
t.is(requests[0].url, 'https://example.com/custom');
353+
});

0 commit comments

Comments
 (0)