Skip to content

Commit

Permalink
fix: Envelope header is required
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilogorek committed Sep 15, 2021
1 parent a7eaf2f commit 41a9980
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/browser/src/transports/base.ts
Expand Up @@ -107,6 +107,8 @@ export abstract class BaseTransport implements Transport {
logger.log(`Flushing outcomes:\n${JSON.stringify(outcomes, null, 2)}`);

const url = this._api.getEnvelopeEndpointWithUrlEncodedAuth();
// Envelope header is required to be at least an empty object
const envelopeHeader = JSON.stringify({});
const itemHeaders = JSON.stringify({
type: 'client_report',
});
Expand All @@ -121,7 +123,7 @@ export abstract class BaseTransport implements Transport {
};
}),
});
const envelope = `${itemHeaders}\n${item}`;
const envelope = `${envelopeHeader}\n${itemHeaders}\n${item}`;

navigator.sendBeacon(url, envelope);
}
Expand Down

0 comments on commit 41a9980

Please sign in to comment.