change(tracker): configure automatic headers, compress anything bigger than 24k, add third party lib to list

This commit is contained in:
nick-delirium 2023-04-07 17:10:05 +02:00 committed by Delirium
parent 4f7112baab
commit 08a6705508
3 changed files with 14 additions and 12 deletions

View file

@ -1,4 +1,4 @@
## Licenses (as of March 24, 2023)
## Licenses (as of April 7, 2023), 2023)
Below is the list of dependencies used in OpenReplay software. Licenses may change between versions, so please keep this up to date with every new library you use.
@ -117,3 +117,4 @@ Below is the list of dependencies used in OpenReplay software. Licenses may chan
| html2canvas | MIT | JavaScript |
| eget | MIT | Infrastructure |
| @medv/finder | MIT | JavaScript |
| fflate | MIT | JavaScript |

View file

@ -173,7 +173,7 @@ export default class App {
this.worker.onmessage = ({ data }: MessageEvent<FromWorkerData>) => {
if (data === 'restart') {
this.stop(false)
this.start({}, true)
void this.start({}, true)
} else if (data === 'not_init') {
console.warn('WebWorker: writer not initialised. Restarting tracker')
} else if (data.type === 'failure') {
@ -182,9 +182,7 @@ export default class App {
} else if (data.type === 'compress') {
const batch = data.batch
const batchSize = batch.byteLength
console.log(batchSize)
// 1000 * 10
if (batchSize > 1) {
if (batchSize > 1000 * 25) {
gzip(data.batch, { mtime: 0 }, (err, result) => {
if (err) console.error(err)
// @ts-ignore
@ -217,6 +215,7 @@ export default class App {
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
context,
// @ts-ignore
error: `${e}`,
}),
})

View file

@ -59,16 +59,18 @@ export default class QueueSender {
private sendBatch(batch: Uint8Array, isCompressed?: boolean): void {
this.busy = true
// @ts-ignore
const headers = {
Authorization: `Bearer ${this.token as string}`,
} as Record<string, string>
if (isCompressed) {
headers['Content-Encoding'] = 'gzip'
}
fetch(this.ingestURL, {
body: batch,
method: 'POST',
// @ts-ignore
headers: {
Authorization: `Bearer ${this.token as string}`,
//"Content-Type": "",
'Content-Encoding': isCompressed ? 'gzip' : undefined,
},
headers,
keepalive: batch.length < KEEPALIVE_SIZE_LIMIT,
})
.then((r: Record<string, any>) => {