@datadog/browser-core
Advanced tools
Comparing version 1.12.2 to 1.12.3
@@ -33,2 +33,3 @@ import { Context } from './utils'; | ||
flush(): void; | ||
sizeInBytes(candidate: string): number; | ||
private addOrUpdate; | ||
@@ -41,5 +42,4 @@ private process; | ||
private isFull; | ||
private sizeInBytes; | ||
private flushPeriodically; | ||
private flushOnVisibilityHidden; | ||
} |
@@ -6,2 +6,4 @@ "use strict"; | ||
var utils_1 = require("./utils"); | ||
// https://en.wikipedia.org/wiki/UTF-8 | ||
var HAS_MULTI_BYTES_CHARACTERS = /[^\u0000-\u007F]/; | ||
/** | ||
@@ -73,2 +75,12 @@ * Use POST request without content type to: | ||
}; | ||
Batch.prototype.sizeInBytes = function (candidate) { | ||
// Accurate byte size computations can degrade performances when there is a lot of events to process | ||
if (!HAS_MULTI_BYTES_CHARACTERS.test(candidate)) { | ||
return candidate.length; | ||
} | ||
if (window.TextEncoder !== undefined) { | ||
return new TextEncoder().encode(candidate).length; | ||
} | ||
return new Blob([candidate]).size; | ||
}; | ||
Batch.prototype.addOrUpdate = function (message, key) { | ||
@@ -131,6 +143,2 @@ var _a = this.process(message), processedMessage = _a.processedMessage, messageBytesSize = _a.messageBytesSize; | ||
}; | ||
Batch.prototype.sizeInBytes = function (candidate) { | ||
// tslint:disable-next-line no-bitwise | ||
return ~-encodeURI(candidate).split(/%..|./).length; | ||
}; | ||
Batch.prototype.flushPeriodically = function () { | ||
@@ -137,0 +145,0 @@ var _this = this; |
@@ -33,2 +33,3 @@ import { Context } from './utils'; | ||
flush(): void; | ||
sizeInBytes(candidate: string): number; | ||
private addOrUpdate; | ||
@@ -41,5 +42,4 @@ private process; | ||
private isFull; | ||
private sizeInBytes; | ||
private flushPeriodically; | ||
private flushOnVisibilityHidden; | ||
} |
import { __spreadArrays } from "tslib"; | ||
import { monitor } from './internalMonitoring'; | ||
import { deepMerge, DOM_EVENT, jsonStringify, noop, objectValues } from './utils'; | ||
// https://en.wikipedia.org/wiki/UTF-8 | ||
var HAS_MULTI_BYTES_CHARACTERS = /[^\u0000-\u007F]/; | ||
/** | ||
@@ -70,2 +72,12 @@ * Use POST request without content type to: | ||
}; | ||
Batch.prototype.sizeInBytes = function (candidate) { | ||
// Accurate byte size computations can degrade performances when there is a lot of events to process | ||
if (!HAS_MULTI_BYTES_CHARACTERS.test(candidate)) { | ||
return candidate.length; | ||
} | ||
if (window.TextEncoder !== undefined) { | ||
return new TextEncoder().encode(candidate).length; | ||
} | ||
return new Blob([candidate]).size; | ||
}; | ||
Batch.prototype.addOrUpdate = function (message, key) { | ||
@@ -128,6 +140,2 @@ var _a = this.process(message), processedMessage = _a.processedMessage, messageBytesSize = _a.messageBytesSize; | ||
}; | ||
Batch.prototype.sizeInBytes = function (candidate) { | ||
// tslint:disable-next-line no-bitwise | ||
return ~-encodeURI(candidate).split(/%..|./).length; | ||
}; | ||
Batch.prototype.flushPeriodically = function () { | ||
@@ -134,0 +142,0 @@ var _this = this; |
{ | ||
"name": "@datadog/browser-core", | ||
"version": "1.12.2", | ||
"version": "1.12.3", | ||
"license": "Apache-2.0", | ||
@@ -8,2 +8,3 @@ "main": "cjs/index.js", | ||
"types": "cjs/index.d.ts", | ||
"sideEffects": false, | ||
"scripts": { | ||
@@ -26,3 +27,3 @@ "build": "run-p build:cjs build:esm", | ||
}, | ||
"gitHead": "847f6c595516af2065c2ab1a70b95d765ee3e6a8" | ||
"gitHead": "8034232e961f5842c741768955a1fdd1ff3cf831" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
SPDX disjunction
LicenseSPDX disjunction for an artifact's license information
Found 1 instance in 1 package
SPDX disjunction
LicenseSPDX disjunction for an artifact's license information
Found 1 instance in 1 package
368341
6089