Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix postPath configuration being ignored (close #1376) #1377

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@snowplow/tracker-core",
"comment": "Fix customPostPath configuration being ignored (close #1376)",
"type": "none"
}
],
"packageName": "@snowplow/tracker-core"
}
2 changes: 2 additions & 0 deletions libraries/tracker-core/src/emitter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ interface RequestResult {
export function newEmitter({
endpoint,
eventMethod = 'post',
postPath,
protocol,
port,
maxPostBytes = 40000,
Expand Down Expand Up @@ -320,6 +321,7 @@ export function newEmitter({
maxPostBytes,
useStm,
credentials,
postPath,
});
}

Expand Down
18 changes: 18 additions & 0 deletions libraries/tracker-core/test/emitter/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,3 +333,21 @@ test('adds a timeout to the request', async (t) => {
t.is(requests.length, 1);
t.is(await eventStore.count(), 1);
});

test('uses custom POST path configured in the emitter', async (t) => {
const requests: Request[] = [];
const mockFetch = createMockFetch(200, requests);
const eventStore = newInMemoryEventStore({});
const emitter: Emitter = newEmitter({
endpoint: 'https://example.com',
customFetch: mockFetch,
postPath: '/custom',
eventStore,
});

await emitter.input({ e: 'pv' });
await emitter.flush();

t.is(requests.length, 1);
t.is(requests[0].url, 'https://example.com/custom');
});
Loading