Socket
Socket
Sign inDemoInstall

@datadog/browser-core

Package Overview
Dependencies
Maintainers
1
Versions
256
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@datadog/browser-core - npm Package Compare versions

Comparing version 1.2.6 to 1.2.7

9

cjs/transport.d.ts

@@ -24,3 +24,4 @@ import { Context } from './utils';

private beforeFlushOnUnloadHandlers;
private buffer;
private pushOnlyBuffer;
private upsertBuffer;
private bufferBytesSize;

@@ -30,11 +31,15 @@ private bufferMessageCount;

add(message: T): void;
upsert(message: T, key: string): void;
beforeFlushOnUnload(handler: () => void): void;
flush(): void;
private flushPeriodically;
private addOrUpdate;
private process;
private push;
private remove;
private hasMessageFor;
private willReachedBytesLimitWith;
private isFull;
private sizeInBytes;
private flushPeriodically;
private flushOnVisibilityHidden;
}

@@ -43,3 +43,4 @@ "use strict";

this.beforeFlushOnUnloadHandlers = [];
this.buffer = '';
this.pushOnlyBuffer = [];
this.upsertBuffer = {};
this.bufferBytesSize = 0;

@@ -51,2 +52,21 @@ this.bufferMessageCount = 0;

Batch.prototype.add = function (message) {
this.addOrUpdate(message);
};
Batch.prototype.upsert = function (message, key) {
this.addOrUpdate(message, key);
};
Batch.prototype.beforeFlushOnUnload = function (handler) {
this.beforeFlushOnUnloadHandlers.push(handler);
};
Batch.prototype.flush = function () {
if (this.bufferMessageCount !== 0) {
var messages = this.pushOnlyBuffer.concat(utils_1.objectValues(this.upsertBuffer));
this.request.send(messages.join('\n'), this.bufferBytesSize);
this.pushOnlyBuffer = [];
this.upsertBuffer = {};
this.bufferBytesSize = 0;
this.bufferMessageCount = 0;
}
};
Batch.prototype.addOrUpdate = function (message, key) {
var _a = this.process(message), processedMessage = _a.processedMessage, messageBytesSize = _a.messageBytesSize;

@@ -57,6 +77,9 @@ if (messageBytesSize >= this.maxMessageSize) {

}
if (this.hasMessageFor(key)) {
this.remove(key);
}
if (this.willReachedBytesLimitWith(messageBytesSize)) {
this.flush();
}
this.push(processedMessage, messageBytesSize);
this.push(processedMessage, messageBytesSize, key);
if (this.isFull()) {

@@ -66,20 +89,2 @@ this.flush();

};
Batch.prototype.beforeFlushOnUnload = function (handler) {
this.beforeFlushOnUnloadHandlers.push(handler);
};
Batch.prototype.flush = function () {
if (this.buffer.length !== 0) {
this.request.send(this.buffer, this.bufferBytesSize);
this.buffer = '';
this.bufferBytesSize = 0;
this.bufferMessageCount = 0;
}
};
Batch.prototype.flushPeriodically = function () {
var _this = this;
setTimeout(function () {
_this.flush();
_this.flushPeriodically();
}, this.flushTimeout);
};
Batch.prototype.process = function (message) {

@@ -91,11 +96,29 @@ var contextualizedMessage = lodash_merge_1.default({}, this.contextProvider(), message);

};
Batch.prototype.push = function (processedMessage, messageBytesSize) {
if (this.buffer) {
this.buffer += '\n';
Batch.prototype.push = function (processedMessage, messageBytesSize, key) {
if (this.bufferMessageCount > 0) {
// \n separator at serialization
this.bufferBytesSize += 1;
}
this.buffer += processedMessage;
if (key !== undefined) {
this.upsertBuffer[key] = processedMessage;
}
else {
this.pushOnlyBuffer.push(processedMessage);
}
this.bufferBytesSize += messageBytesSize;
this.bufferMessageCount += 1;
};
Batch.prototype.remove = function (key) {
var removedMessage = this.upsertBuffer[key];
delete this.upsertBuffer[key];
var messageBytesSize = this.sizeInBytes(removedMessage);
this.bufferBytesSize -= messageBytesSize;
this.bufferMessageCount -= 1;
if (this.bufferMessageCount > 0) {
this.bufferBytesSize -= 1;
}
};
Batch.prototype.hasMessageFor = function (key) {
return key !== undefined && this.upsertBuffer[key] !== undefined;
};
Batch.prototype.willReachedBytesLimitWith = function (messageBytesSize) {

@@ -112,2 +135,9 @@ // byte of the separator at the end of the message

};
Batch.prototype.flushPeriodically = function () {
var _this = this;
setTimeout(function () {
_this.flush();
_this.flushPeriodically();
}, this.flushTimeout);
};
Batch.prototype.flushOnVisibilityHidden = function () {

@@ -114,0 +144,0 @@ var _this = this;

@@ -59,1 +59,4 @@ export declare type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;

export declare function getRelativeTime(timestamp: number): number;
export declare function objectValues(object: {
[key: string]: unknown;
}): unknown[];

@@ -167,2 +167,10 @@ "use strict";

exports.getRelativeTime = getRelativeTime;
function objectValues(object) {
var values = [];
Object.keys(object).forEach(function (key) {
values.push(object[key]);
});
return values;
}
exports.objectValues = objectValues;
//# sourceMappingURL=utils.js.map

@@ -24,3 +24,4 @@ import { Context } from './utils';

private beforeFlushOnUnloadHandlers;
private buffer;
private pushOnlyBuffer;
private upsertBuffer;
private bufferBytesSize;

@@ -30,11 +31,15 @@ private bufferMessageCount;

add(message: T): void;
upsert(message: T, key: string): void;
beforeFlushOnUnload(handler: () => void): void;
flush(): void;
private flushPeriodically;
private addOrUpdate;
private process;
private push;
private remove;
private hasMessageFor;
private willReachedBytesLimitWith;
private isFull;
private sizeInBytes;
private flushPeriodically;
private flushOnVisibilityHidden;
}
import lodashMerge from 'lodash.merge';
import { monitor } from './internalMonitoring';
import { jsonStringify } from './utils';
import { jsonStringify, objectValues } from './utils';
/**

@@ -40,3 +40,4 @@ * Use POST request without content type to:

this.beforeFlushOnUnloadHandlers = [];
this.buffer = '';
this.pushOnlyBuffer = [];
this.upsertBuffer = {};
this.bufferBytesSize = 0;

@@ -48,2 +49,21 @@ this.bufferMessageCount = 0;

Batch.prototype.add = function (message) {
this.addOrUpdate(message);
};
Batch.prototype.upsert = function (message, key) {
this.addOrUpdate(message, key);
};
Batch.prototype.beforeFlushOnUnload = function (handler) {
this.beforeFlushOnUnloadHandlers.push(handler);
};
Batch.prototype.flush = function () {
if (this.bufferMessageCount !== 0) {
var messages = this.pushOnlyBuffer.concat(objectValues(this.upsertBuffer));
this.request.send(messages.join('\n'), this.bufferBytesSize);
this.pushOnlyBuffer = [];
this.upsertBuffer = {};
this.bufferBytesSize = 0;
this.bufferMessageCount = 0;
}
};
Batch.prototype.addOrUpdate = function (message, key) {
var _a = this.process(message), processedMessage = _a.processedMessage, messageBytesSize = _a.messageBytesSize;

@@ -54,6 +74,9 @@ if (messageBytesSize >= this.maxMessageSize) {

}
if (this.hasMessageFor(key)) {
this.remove(key);
}
if (this.willReachedBytesLimitWith(messageBytesSize)) {
this.flush();
}
this.push(processedMessage, messageBytesSize);
this.push(processedMessage, messageBytesSize, key);
if (this.isFull()) {

@@ -63,20 +86,2 @@ this.flush();

};
Batch.prototype.beforeFlushOnUnload = function (handler) {
this.beforeFlushOnUnloadHandlers.push(handler);
};
Batch.prototype.flush = function () {
if (this.buffer.length !== 0) {
this.request.send(this.buffer, this.bufferBytesSize);
this.buffer = '';
this.bufferBytesSize = 0;
this.bufferMessageCount = 0;
}
};
Batch.prototype.flushPeriodically = function () {
var _this = this;
setTimeout(function () {
_this.flush();
_this.flushPeriodically();
}, this.flushTimeout);
};
Batch.prototype.process = function (message) {

@@ -88,11 +93,29 @@ var contextualizedMessage = lodashMerge({}, this.contextProvider(), message);

};
Batch.prototype.push = function (processedMessage, messageBytesSize) {
if (this.buffer) {
this.buffer += '\n';
Batch.prototype.push = function (processedMessage, messageBytesSize, key) {
if (this.bufferMessageCount > 0) {
// \n separator at serialization
this.bufferBytesSize += 1;
}
this.buffer += processedMessage;
if (key !== undefined) {
this.upsertBuffer[key] = processedMessage;
}
else {
this.pushOnlyBuffer.push(processedMessage);
}
this.bufferBytesSize += messageBytesSize;
this.bufferMessageCount += 1;
};
Batch.prototype.remove = function (key) {
var removedMessage = this.upsertBuffer[key];
delete this.upsertBuffer[key];
var messageBytesSize = this.sizeInBytes(removedMessage);
this.bufferBytesSize -= messageBytesSize;
this.bufferMessageCount -= 1;
if (this.bufferMessageCount > 0) {
this.bufferBytesSize -= 1;
}
};
Batch.prototype.hasMessageFor = function (key) {
return key !== undefined && this.upsertBuffer[key] !== undefined;
};
Batch.prototype.willReachedBytesLimitWith = function (messageBytesSize) {

@@ -109,2 +132,9 @@ // byte of the separator at the end of the message

};
Batch.prototype.flushPeriodically = function () {
var _this = this;
setTimeout(function () {
_this.flush();
_this.flushPeriodically();
}, this.flushTimeout);
};
Batch.prototype.flushOnVisibilityHidden = function () {

@@ -111,0 +141,0 @@ var _this = this;

@@ -59,1 +59,4 @@ export declare type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;

export declare function getRelativeTime(timestamp: number): number;
export declare function objectValues(object: {
[key: string]: unknown;
}): unknown[];

@@ -151,2 +151,9 @@ export var ONE_SECOND = 1000;

}
export function objectValues(object) {
var values = [];
Object.keys(object).forEach(function (key) {
values.push(object[key]);
});
return values;
}
//# sourceMappingURL=utils.js.map
{
"name": "@datadog/browser-core",
"version": "1.2.6",
"version": "1.2.7",
"license": "Apache-2.0",

@@ -25,3 +25,3 @@ "main": "cjs/index.js",

},
"gitHead": "506edcf6a2bb4a5923aaace0e489e81bcaf7b25c"
"gitHead": "57dbe04c2a8757456f875f66caf3ec1d7c47467b"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc