@datadog/browser-core
Advanced tools
Comparing version 1.12.8 to 1.12.9
@@ -10,3 +10,3 @@ import { Configuration } from './configuration'; | ||
} | ||
export interface MonitoringMessage { | ||
export interface MonitoringMessage extends utils.Context { | ||
message: string; | ||
@@ -13,0 +13,0 @@ status: StatusType; |
@@ -38,17 +38,19 @@ "use strict"; | ||
function createMonitoringBatch(endpointUrl) { | ||
return new transport_1.Batch(new transport_1.HttpRequest(endpointUrl, configuration.batchBytesLimit), configuration.maxBatchSize, configuration.batchBytesLimit, configuration.maxMessageSize, configuration.flushTimeout, function () { | ||
return utils.deepMerge({ | ||
date: new Date().getTime(), | ||
view: { | ||
referrer: document.referrer, | ||
url: window.location.href, | ||
}, | ||
}, externalContextProvider !== undefined ? externalContextProvider() : {}); | ||
}); | ||
return new transport_1.Batch(new transport_1.HttpRequest(endpointUrl, configuration.batchBytesLimit), configuration.maxBatchSize, configuration.batchBytesLimit, configuration.maxMessageSize, configuration.flushTimeout); | ||
} | ||
function withContext(message) { | ||
return utils.deepMerge({ | ||
date: new Date().getTime(), | ||
view: { | ||
referrer: document.referrer, | ||
url: window.location.href, | ||
}, | ||
}, externalContextProvider !== undefined ? externalContextProvider() : {}, message); | ||
} | ||
return { | ||
add: function (message) { | ||
primaryBatch.add(message); | ||
var contextualizedMessage = withContext(message); | ||
primaryBatch.add(contextualizedMessage); | ||
if (replicaBatch) { | ||
replicaBatch.add(message); | ||
replicaBatch.add(contextualizedMessage); | ||
} | ||
@@ -55,0 +57,0 @@ }, |
@@ -17,3 +17,3 @@ import { Context } from './utils'; | ||
} | ||
export declare class Batch<T> { | ||
export declare class Batch { | ||
private request; | ||
@@ -24,3 +24,2 @@ private maxSize; | ||
private flushTimeout; | ||
private contextProvider; | ||
private beforeUnloadCallback; | ||
@@ -31,5 +30,5 @@ private pushOnlyBuffer; | ||
private bufferMessageCount; | ||
constructor(request: HttpRequest, maxSize: number, bytesLimit: number, maxMessageSize: number, flushTimeout: number, contextProvider: () => Context, beforeUnloadCallback?: () => void); | ||
add(message: T): void; | ||
upsert(message: T, key: string): void; | ||
constructor(request: HttpRequest, maxSize: number, bytesLimit: number, maxMessageSize: number, flushTimeout: number, beforeUnloadCallback?: () => void); | ||
add(message: Context): void; | ||
upsert(message: Context, key: string): void; | ||
flush(): void; | ||
@@ -36,0 +35,0 @@ sizeInBytes(candidate: string): number; |
@@ -42,3 +42,3 @@ "use strict"; | ||
var Batch = /** @class */ (function () { | ||
function Batch(request, maxSize, bytesLimit, maxMessageSize, flushTimeout, contextProvider, beforeUnloadCallback) { | ||
function Batch(request, maxSize, bytesLimit, maxMessageSize, flushTimeout, beforeUnloadCallback) { | ||
if (beforeUnloadCallback === void 0) { beforeUnloadCallback = utils_1.noop; } | ||
@@ -50,3 +50,2 @@ this.request = request; | ||
this.flushTimeout = flushTimeout; | ||
this.contextProvider = contextProvider; | ||
this.beforeUnloadCallback = beforeUnloadCallback; | ||
@@ -104,4 +103,3 @@ this.pushOnlyBuffer = []; | ||
Batch.prototype.process = function (message) { | ||
var contextualizedMessage = utils_1.deepMerge({}, this.contextProvider(), message); | ||
var processedMessage = utils_1.jsonStringify(contextualizedMessage); | ||
var processedMessage = utils_1.jsonStringify(message); | ||
var messageBytesSize = this.sizeInBytes(processedMessage); | ||
@@ -108,0 +106,0 @@ return { processedMessage: processedMessage, messageBytesSize: messageBytesSize }; |
@@ -45,2 +45,4 @@ export declare type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>; | ||
export declare function deepMerge(destination: ContextValue, ...toMerge: ContextValue[]): ContextValue; | ||
export declare function combine<A, B, C>(a: A, b: B, c: C): A & B & C; | ||
export declare function combine<A, B, C, D>(a: A, b: B, c: C, d: D): A & B & C & D; | ||
interface Assignable { | ||
@@ -47,0 +49,0 @@ [key: string]: any; |
@@ -104,2 +104,10 @@ "use strict"; | ||
exports.deepMerge = deepMerge; | ||
function combine(a) { | ||
var b = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
b[_i - 1] = arguments[_i]; | ||
} | ||
return deepMerge.apply(void 0, tslib_1.__spreadArrays([a], b)); | ||
} | ||
exports.combine = combine; | ||
function assign(target) { | ||
@@ -106,0 +114,0 @@ var toAssign = []; |
@@ -10,3 +10,3 @@ import { Configuration } from './configuration'; | ||
} | ||
export interface MonitoringMessage { | ||
export interface MonitoringMessage extends utils.Context { | ||
message: string; | ||
@@ -13,0 +13,0 @@ status: StatusType; |
@@ -35,17 +35,19 @@ import { __assign } from "tslib"; | ||
function createMonitoringBatch(endpointUrl) { | ||
return new Batch(new HttpRequest(endpointUrl, configuration.batchBytesLimit), configuration.maxBatchSize, configuration.batchBytesLimit, configuration.maxMessageSize, configuration.flushTimeout, function () { | ||
return utils.deepMerge({ | ||
date: new Date().getTime(), | ||
view: { | ||
referrer: document.referrer, | ||
url: window.location.href, | ||
}, | ||
}, externalContextProvider !== undefined ? externalContextProvider() : {}); | ||
}); | ||
return new Batch(new HttpRequest(endpointUrl, configuration.batchBytesLimit), configuration.maxBatchSize, configuration.batchBytesLimit, configuration.maxMessageSize, configuration.flushTimeout); | ||
} | ||
function withContext(message) { | ||
return utils.deepMerge({ | ||
date: new Date().getTime(), | ||
view: { | ||
referrer: document.referrer, | ||
url: window.location.href, | ||
}, | ||
}, externalContextProvider !== undefined ? externalContextProvider() : {}, message); | ||
} | ||
return { | ||
add: function (message) { | ||
primaryBatch.add(message); | ||
var contextualizedMessage = withContext(message); | ||
primaryBatch.add(contextualizedMessage); | ||
if (replicaBatch) { | ||
replicaBatch.add(message); | ||
replicaBatch.add(contextualizedMessage); | ||
} | ||
@@ -52,0 +54,0 @@ }, |
@@ -17,3 +17,3 @@ import { Context } from './utils'; | ||
} | ||
export declare class Batch<T> { | ||
export declare class Batch { | ||
private request; | ||
@@ -24,3 +24,2 @@ private maxSize; | ||
private flushTimeout; | ||
private contextProvider; | ||
private beforeUnloadCallback; | ||
@@ -31,5 +30,5 @@ private pushOnlyBuffer; | ||
private bufferMessageCount; | ||
constructor(request: HttpRequest, maxSize: number, bytesLimit: number, maxMessageSize: number, flushTimeout: number, contextProvider: () => Context, beforeUnloadCallback?: () => void); | ||
add(message: T): void; | ||
upsert(message: T, key: string): void; | ||
constructor(request: HttpRequest, maxSize: number, bytesLimit: number, maxMessageSize: number, flushTimeout: number, beforeUnloadCallback?: () => void); | ||
add(message: Context): void; | ||
upsert(message: Context, key: string): void; | ||
flush(): void; | ||
@@ -36,0 +35,0 @@ sizeInBytes(candidate: string): number; |
import { __spreadArrays } from "tslib"; | ||
import { monitor } from './internalMonitoring'; | ||
import { deepMerge, DOM_EVENT, jsonStringify, noop, objectValues } from './utils'; | ||
import { DOM_EVENT, jsonStringify, noop, objectValues } from './utils'; | ||
// https://en.wikipedia.org/wiki/UTF-8 | ||
@@ -40,3 +40,3 @@ var HAS_MULTI_BYTES_CHARACTERS = /[^\u0000-\u007F]/; | ||
var Batch = /** @class */ (function () { | ||
function Batch(request, maxSize, bytesLimit, maxMessageSize, flushTimeout, contextProvider, beforeUnloadCallback) { | ||
function Batch(request, maxSize, bytesLimit, maxMessageSize, flushTimeout, beforeUnloadCallback) { | ||
if (beforeUnloadCallback === void 0) { beforeUnloadCallback = noop; } | ||
@@ -48,3 +48,2 @@ this.request = request; | ||
this.flushTimeout = flushTimeout; | ||
this.contextProvider = contextProvider; | ||
this.beforeUnloadCallback = beforeUnloadCallback; | ||
@@ -102,4 +101,3 @@ this.pushOnlyBuffer = []; | ||
Batch.prototype.process = function (message) { | ||
var contextualizedMessage = deepMerge({}, this.contextProvider(), message); | ||
var processedMessage = jsonStringify(contextualizedMessage); | ||
var processedMessage = jsonStringify(message); | ||
var messageBytesSize = this.sizeInBytes(processedMessage); | ||
@@ -106,0 +104,0 @@ return { processedMessage: processedMessage, messageBytesSize: messageBytesSize }; |
@@ -45,2 +45,4 @@ export declare type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>; | ||
export declare function deepMerge(destination: ContextValue, ...toMerge: ContextValue[]): ContextValue; | ||
export declare function combine<A, B, C>(a: A, b: B, c: C): A & B & C; | ||
export declare function combine<A, B, C, D>(a: A, b: B, c: C, d: D): A & B & C & D; | ||
interface Assignable { | ||
@@ -47,0 +49,0 @@ [key: string]: any; |
@@ -100,2 +100,9 @@ import { __assign, __spreadArrays } from "tslib"; | ||
} | ||
export function combine(a) { | ||
var b = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
b[_i - 1] = arguments[_i]; | ||
} | ||
return deepMerge.apply(void 0, __spreadArrays([a], b)); | ||
} | ||
export function assign(target) { | ||
@@ -102,0 +109,0 @@ var toAssign = []; |
{ | ||
"name": "@datadog/browser-core", | ||
"version": "1.12.8", | ||
"version": "1.12.9", | ||
"license": "Apache-2.0", | ||
@@ -26,3 +26,3 @@ "main": "cjs/index.js", | ||
}, | ||
"gitHead": "abb6ed462283d022ffab4b640beac9b81481ee76" | ||
"gitHead": "b4172cdf024d1a0d2c72b9ff3ce9b7758c946a01" | ||
} |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
377091
6241