Skip to content
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
2 changes: 1 addition & 1 deletion libraries/tracker-core/src/emitter/emitter_request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export function newEmitterRequest({
eventMethod = 'post',
customHeaders,
connectionTimeout,
keepalive = true,
keepalive = false,
postPath = '/com.snowplowanalytics.snowplow/tp2',
useStm = true,
maxPostBytes = 40000,
Expand Down
3 changes: 2 additions & 1 deletion libraries/tracker-core/src/emitter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ export interface EmitterConfigurationBase {
/**
* Indicates that the request should be allowed to outlive the webpage that initiated it.
* Enables collector requests to complete even if the page is closed or navigated away from.
* @defaultValue true (not supported in Node.js)
* Note: Browsers put a limit on keepalive requests of 64KB. In case of multiple keepalive requests in parallel (may happen in case of multiple trackers), the limit is shared.
* @defaultValue false
*/
keepalive?: boolean;
/**
Expand Down
5 changes: 2 additions & 3 deletions libraries/tracker-core/test/emitter/emitter_request.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ test('toRequest returns a Request object with default settings', (t) => {
t.is(req.method, 'POST');
t.is(req.headers.get('Content-Type'), 'application/json; charset=UTF-8');
t.is(req.headers.get('SP-Anonymous'), null);
t.is(req.keepalive, true);
});

test('toRequest builds a GET request when method is get', (t) => {
Expand Down Expand Up @@ -194,12 +193,12 @@ test('toRequest includes server anonymization header', (t) => {
test('toRequest contains keepalive', (t) => {
const request = newEmitterRequest({
endpoint: 'https://example.com',
keepalive: false,
keepalive: true,
});

t.true(request.addEvent(newEmitterEventFromPayload({ e: 'pv', p: 'web' })));
const req = request.toRequest()!;
t.is(req.keepalive, false);
t.is(req.keepalive, true);
});

test('toRequest URL contains custom POST path', (t) => {
Expand Down