Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aws-rum-web

Package Overview
Dependencies
Maintainers
2
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aws-rum-web - npm Package Compare versions

Comparing version 1.14.0 to 1.14.1

7

CHANGELOG.md

@@ -5,2 +5,9 @@ # Changelog

### [1.14.1](https://github.com/aws-observability/aws-rum-web/compare/v1.14.0...v1.14.1) (2023-09-22)
### Bug Fixes
* XhrPlugin cleans cache on every record ([#454](https://github.com/aws-observability/aws-rum-web/issues/454)) ([54f6229](https://github.com/aws-observability/aws-rum-web/commit/54f62296e8f7f12199d5aa913f4a1c4832f9bb57))
## [1.14.0](https://github.com/aws-observability/aws-rum-web/compare/v1.13.0...v1.14.0) (2023-06-29)

@@ -7,0 +14,0 @@

2

dist/cjs/event-cache/EventCache.js

@@ -18,3 +18,3 @@ "use strict";

var PageManager_1 = require("../sessions/PageManager");
var webClientVersion = '1.14.0';
var webClientVersion = '1.14.1';
/**

@@ -21,0 +21,0 @@ * A cache which stores events generated by telemetry plugins.

@@ -58,5 +58,6 @@ import { MonkeyPatch, MonkeyPatched } from '../MonkeyPatched';

private config;
private xhrMap;
private map;
constructor(config?: PartialHttpPluginConfig);
protected onload(): void;
get cacheSize(): number;
protected get patches(): MonkeyPatch<XMLHttpRequest, "open" | "send">[];

@@ -63,0 +64,0 @@ private addXRayTraceIdHeader;

@@ -103,41 +103,41 @@ "use strict";

_this.handleXhrLoadEvent = function (e) {
var xhr = e.target;
var xhrDetails = _this.xhrMap.get(xhr);
if (xhrDetails) {
var endTimee = (0, http_utils_1.epochTime)();
xhrDetails.trace.end_time = endTimee;
xhrDetails.trace.subsegments[0].end_time = endTimee;
xhrDetails.trace.subsegments[0].http.response = {
status: xhr.status
var request = e.target;
var details = _this.map.get(request);
if (details) {
var endTime = (0, http_utils_1.epochTime)();
details.trace.end_time = endTime;
details.trace.subsegments[0].end_time = endTime;
details.trace.subsegments[0].http.response = {
status: request.status
};
if ((0, http_utils_1.is429)(xhr.status)) {
xhrDetails.trace.subsegments[0].throttle = true;
xhrDetails.trace.throttle = true;
if ((0, http_utils_1.is429)(request.status)) {
details.trace.subsegments[0].throttle = true;
details.trace.throttle = true;
}
else if ((0, http_utils_1.is4xx)(xhr.status)) {
xhrDetails.trace.subsegments[0].error = true;
xhrDetails.trace.error = true;
else if ((0, http_utils_1.is4xx)(request.status)) {
details.trace.subsegments[0].error = true;
details.trace.error = true;
}
else if ((0, http_utils_1.is5xx)(xhr.status)) {
xhrDetails.trace.subsegments[0].fault = true;
xhrDetails.trace.fault = true;
else if ((0, http_utils_1.is5xx)(request.status)) {
details.trace.subsegments[0].fault = true;
details.trace.fault = true;
}
var clStr = xhr.getResponseHeader('Content-Length');
var clStr = request.getResponseHeader('Content-Length');
var cl = clStr ? parseInt(clStr, 10) : NaN;
if (!isNaN(cl)) {
xhrDetails.trace.subsegments[0].http.response.content_length =
details.trace.subsegments[0].http.response.content_length =
cl;
}
_this.recordTraceEvent(xhrDetails.trace);
_this.recordHttpEventWithResponse(xhrDetails, xhr);
_this.recordTraceEvent(details.trace);
_this.recordHttpEventWithResponse(details, request);
}
};
_this.handleXhrErrorEvent = function (e) {
var xhr = e.target;
var xhrDetails = _this.xhrMap.get(xhr);
var request = e.target;
var details = _this.map.get(request);
var errorName = 'XMLHttpRequest error';
var errorMessage = xhr.statusText
? xhr.status.toString() + ': ' + xhr.statusText
: xhr.status.toString();
if (xhrDetails) {
var errorMessage = request.statusText
? request.status.toString() + ': ' + request.statusText
: request.status.toString();
if (details) {
var endTime = (0, http_utils_1.epochTime)();

@@ -148,7 +148,7 @@ // Guidance from X-Ray documentation:

// > returns an error.
xhrDetails.trace.fault = true;
xhrDetails.trace.end_time = endTime;
xhrDetails.trace.subsegments[0].end_time = endTime;
xhrDetails.trace.subsegments[0].fault = true;
xhrDetails.trace.subsegments[0].cause = {
details.trace.fault = true;
details.trace.end_time = endTime;
details.trace.subsegments[0].end_time = endTime;
details.trace.subsegments[0].fault = true;
details.trace.subsegments[0].cause = {
exceptions: [

@@ -161,25 +161,26 @@ {

};
_this.recordTraceEvent(xhrDetails.trace);
_this.recordHttpEventWithError(xhrDetails, new XhrError_1.XhrError(errorMessage));
_this.recordTraceEvent(details.trace);
_this.recordHttpEventWithError(details, request, new XhrError_1.XhrError(errorMessage));
}
};
_this.handleXhrAbortEvent = function (e) {
var xhr = e.target;
var xhrDetails = _this.xhrMap.get(xhr);
var errorName = 'XMLHttpRequest abort';
_this.handleXhrDetailsOnError(xhrDetails, errorName);
var request = e.target;
var details = _this.map.get(request);
if (details) {
_this.handleXhrDetailsOnError(details, request, 'XMLHttpRequest abort');
}
};
_this.handleXhrTimeoutEvent = function (e) {
var xhr = e.target;
var xhrDetails = _this.xhrMap.get(xhr);
var request = e.target;
var details = _this.map.get(request);
var errorName = 'XMLHttpRequest timeout';
_this.handleXhrDetailsOnError(xhrDetails, errorName);
_this.handleXhrDetailsOnError(details, request, errorName);
};
_this.initializeTrace = function (xhrDetails) {
_this.initializeTrace = function (details) {
var startTime = (0, http_utils_1.epochTime)();
xhrDetails.trace = (0, http_utils_1.createXRayTraceEvent)(_this.config.logicalServiceName, startTime);
xhrDetails.trace.subsegments.push((0, http_utils_1.createXRaySubsegment)((0, http_utils_1.requestInfoToHostname)(xhrDetails.url), startTime, {
details.trace = (0, http_utils_1.createXRayTraceEvent)(_this.config.logicalServiceName, startTime);
details.trace.subsegments.push((0, http_utils_1.createXRaySubsegment)((0, http_utils_1.requestInfoToHostname)(details.url), startTime, {
request: {
method: xhrDetails.method,
url: xhrDetails.url,
method: details.method,
url: details.url,
traced: true

@@ -193,4 +194,4 @@ }

return function () {
var xhrDetails = self.xhrMap.get(this);
if (xhrDetails) {
var details = self.map.get(this);
if (details) {
this.addEventListener('load', self.handleXhrLoadEvent);

@@ -200,7 +201,7 @@ this.addEventListener('error', self.handleXhrErrorEvent);

this.addEventListener('timeout', self.handleXhrTimeoutEvent);
self.initializeTrace(xhrDetails);
self.initializeTrace(details);
if (self.isTracingEnabled() &&
self.addXRayTraceIdHeader() &&
self.isSessionRecorded()) {
this.setRequestHeader(http_utils_1.X_AMZN_TRACE_ID, (0, http_utils_1.getAmznTraceIdHeaderValue)(xhrDetails.trace.trace_id, xhrDetails.trace.subsegments[0].id));
this.setRequestHeader(http_utils_1.X_AMZN_TRACE_ID, (0, http_utils_1.getAmznTraceIdHeaderValue)(details.trace.trace_id, details.trace.subsegments[0].id));
}

@@ -217,3 +218,3 @@ }

if ((0, http_utils_1.isUrlAllowed)(url, self.config)) {
self.xhrMap.set(this, { url: url, method: method, async: async });
self.map.set(this, { url: url, method: method, async: async });
}

@@ -225,3 +226,3 @@ return original.apply(this, arguments);

_this.config = __assign(__assign({}, http_utils_1.defaultConfig), config);
_this.xhrMap = new Map();
_this.map = new Map();
return _this;

@@ -232,2 +233,9 @@ }

};
Object.defineProperty(XhrPlugin.prototype, "cacheSize", {
get: function () {
return this.map.size;
},
enumerable: false,
configurable: true
});
Object.defineProperty(XhrPlugin.prototype, "patches", {

@@ -251,9 +259,9 @@ get: function () {

});
XhrPlugin.prototype.handleXhrDetailsOnError = function (xhrDetails, errorName) {
if (xhrDetails) {
XhrPlugin.prototype.handleXhrDetailsOnError = function (details, request, errorName) {
if (details) {
var endTime = (0, http_utils_1.epochTime)();
xhrDetails.trace.end_time = endTime;
xhrDetails.trace.subsegments[0].end_time = endTime;
xhrDetails.trace.subsegments[0].error = true;
xhrDetails.trace.subsegments[0].cause = {
details.trace.end_time = endTime;
details.trace.subsegments[0].end_time = endTime;
details.trace.subsegments[0].error = true;
details.trace.subsegments[0].cause = {
exceptions: [

@@ -265,4 +273,4 @@ {

};
this.recordTraceEvent(xhrDetails.trace);
this.recordHttpEventWithError(xhrDetails, errorName);
this.recordTraceEvent(details.trace);
this.recordHttpEventWithError(details, request, errorName);
}

@@ -273,20 +281,26 @@ };

};
XhrPlugin.prototype.recordHttpEventWithResponse = function (xhrDetails, xhr) {
if (this.config.recordAllRequests || !this.statusOk(xhr.status)) {
this.context.record(constant_1.HTTP_EVENT_TYPE, {
version: '1.0.0',
request: { method: xhrDetails.method, url: xhrDetails.url },
response: { status: xhr.status, statusText: xhr.statusText }
});
XhrPlugin.prototype.recordHttpEventWithResponse = function (details, request) {
this.map.delete(request);
var httpEvent = {
version: '1.0.0',
request: { method: details.method, url: details.url },
response: {
status: request.status,
statusText: request.statusText
}
};
if (this.config.recordAllRequests || !this.statusOk(request.status)) {
this.context.record(constant_1.HTTP_EVENT_TYPE, httpEvent);
}
};
XhrPlugin.prototype.recordHttpEventWithError = function (xhrDetails, error) {
XhrPlugin.prototype.recordHttpEventWithError = function (details, request, error) {
this.map.delete(request);
var httpEvent = {
version: '1.0.0',
request: { method: xhrDetails.method, url: xhrDetails.url }
request: { method: details.method, url: details.url },
error: (0, js_error_utils_1.errorEventToJsErrorEvent)({
type: 'error',
error: error
}, this.config.stackTraceLength)
};
httpEvent.error = (0, js_error_utils_1.errorEventToJsErrorEvent)({
type: 'error',
error: error
}, this.config.stackTraceLength);
this.context.record(constant_1.HTTP_EVENT_TYPE, httpEvent);

@@ -293,0 +307,0 @@ };

@@ -15,3 +15,3 @@ var __assign = (this && this.__assign) || function () {

import { PageManager } from '../sessions/PageManager';
var webClientVersion = '1.14.0';
var webClientVersion = '1.14.1';
/**

@@ -18,0 +18,0 @@ * A cache which stores events generated by telemetry plugins.

@@ -58,5 +58,6 @@ import { MonkeyPatch, MonkeyPatched } from '../MonkeyPatched';

private config;
private xhrMap;
private map;
constructor(config?: PartialHttpPluginConfig);
protected onload(): void;
get cacheSize(): number;
protected get patches(): MonkeyPatch<XMLHttpRequest, "open" | "send">[];

@@ -63,0 +64,0 @@ private addXRayTraceIdHeader;

@@ -100,41 +100,41 @@ var __extends = (this && this.__extends) || (function () {

_this.handleXhrLoadEvent = function (e) {
var xhr = e.target;
var xhrDetails = _this.xhrMap.get(xhr);
if (xhrDetails) {
var endTimee = epochTime();
xhrDetails.trace.end_time = endTimee;
xhrDetails.trace.subsegments[0].end_time = endTimee;
xhrDetails.trace.subsegments[0].http.response = {
status: xhr.status
var request = e.target;
var details = _this.map.get(request);
if (details) {
var endTime = epochTime();
details.trace.end_time = endTime;
details.trace.subsegments[0].end_time = endTime;
details.trace.subsegments[0].http.response = {
status: request.status
};
if (is429(xhr.status)) {
xhrDetails.trace.subsegments[0].throttle = true;
xhrDetails.trace.throttle = true;
if (is429(request.status)) {
details.trace.subsegments[0].throttle = true;
details.trace.throttle = true;
}
else if (is4xx(xhr.status)) {
xhrDetails.trace.subsegments[0].error = true;
xhrDetails.trace.error = true;
else if (is4xx(request.status)) {
details.trace.subsegments[0].error = true;
details.trace.error = true;
}
else if (is5xx(xhr.status)) {
xhrDetails.trace.subsegments[0].fault = true;
xhrDetails.trace.fault = true;
else if (is5xx(request.status)) {
details.trace.subsegments[0].fault = true;
details.trace.fault = true;
}
var clStr = xhr.getResponseHeader('Content-Length');
var clStr = request.getResponseHeader('Content-Length');
var cl = clStr ? parseInt(clStr, 10) : NaN;
if (!isNaN(cl)) {
xhrDetails.trace.subsegments[0].http.response.content_length =
details.trace.subsegments[0].http.response.content_length =
cl;
}
_this.recordTraceEvent(xhrDetails.trace);
_this.recordHttpEventWithResponse(xhrDetails, xhr);
_this.recordTraceEvent(details.trace);
_this.recordHttpEventWithResponse(details, request);
}
};
_this.handleXhrErrorEvent = function (e) {
var xhr = e.target;
var xhrDetails = _this.xhrMap.get(xhr);
var request = e.target;
var details = _this.map.get(request);
var errorName = 'XMLHttpRequest error';
var errorMessage = xhr.statusText
? xhr.status.toString() + ': ' + xhr.statusText
: xhr.status.toString();
if (xhrDetails) {
var errorMessage = request.statusText
? request.status.toString() + ': ' + request.statusText
: request.status.toString();
if (details) {
var endTime = epochTime();

@@ -145,7 +145,7 @@ // Guidance from X-Ray documentation:

// > returns an error.
xhrDetails.trace.fault = true;
xhrDetails.trace.end_time = endTime;
xhrDetails.trace.subsegments[0].end_time = endTime;
xhrDetails.trace.subsegments[0].fault = true;
xhrDetails.trace.subsegments[0].cause = {
details.trace.fault = true;
details.trace.end_time = endTime;
details.trace.subsegments[0].end_time = endTime;
details.trace.subsegments[0].fault = true;
details.trace.subsegments[0].cause = {
exceptions: [

@@ -158,25 +158,26 @@ {

};
_this.recordTraceEvent(xhrDetails.trace);
_this.recordHttpEventWithError(xhrDetails, new XhrError(errorMessage));
_this.recordTraceEvent(details.trace);
_this.recordHttpEventWithError(details, request, new XhrError(errorMessage));
}
};
_this.handleXhrAbortEvent = function (e) {
var xhr = e.target;
var xhrDetails = _this.xhrMap.get(xhr);
var errorName = 'XMLHttpRequest abort';
_this.handleXhrDetailsOnError(xhrDetails, errorName);
var request = e.target;
var details = _this.map.get(request);
if (details) {
_this.handleXhrDetailsOnError(details, request, 'XMLHttpRequest abort');
}
};
_this.handleXhrTimeoutEvent = function (e) {
var xhr = e.target;
var xhrDetails = _this.xhrMap.get(xhr);
var request = e.target;
var details = _this.map.get(request);
var errorName = 'XMLHttpRequest timeout';
_this.handleXhrDetailsOnError(xhrDetails, errorName);
_this.handleXhrDetailsOnError(details, request, errorName);
};
_this.initializeTrace = function (xhrDetails) {
_this.initializeTrace = function (details) {
var startTime = epochTime();
xhrDetails.trace = createXRayTraceEvent(_this.config.logicalServiceName, startTime);
xhrDetails.trace.subsegments.push(createXRaySubsegment(requestInfoToHostname(xhrDetails.url), startTime, {
details.trace = createXRayTraceEvent(_this.config.logicalServiceName, startTime);
details.trace.subsegments.push(createXRaySubsegment(requestInfoToHostname(details.url), startTime, {
request: {
method: xhrDetails.method,
url: xhrDetails.url,
method: details.method,
url: details.url,
traced: true

@@ -190,4 +191,4 @@ }

return function () {
var xhrDetails = self.xhrMap.get(this);
if (xhrDetails) {
var details = self.map.get(this);
if (details) {
this.addEventListener('load', self.handleXhrLoadEvent);

@@ -197,7 +198,7 @@ this.addEventListener('error', self.handleXhrErrorEvent);

this.addEventListener('timeout', self.handleXhrTimeoutEvent);
self.initializeTrace(xhrDetails);
self.initializeTrace(details);
if (self.isTracingEnabled() &&
self.addXRayTraceIdHeader() &&
self.isSessionRecorded()) {
this.setRequestHeader(X_AMZN_TRACE_ID, getAmznTraceIdHeaderValue(xhrDetails.trace.trace_id, xhrDetails.trace.subsegments[0].id));
this.setRequestHeader(X_AMZN_TRACE_ID, getAmznTraceIdHeaderValue(details.trace.trace_id, details.trace.subsegments[0].id));
}

@@ -214,3 +215,3 @@ }

if (isUrlAllowed(url, self.config)) {
self.xhrMap.set(this, { url: url, method: method, async: async });
self.map.set(this, { url: url, method: method, async: async });
}

@@ -222,3 +223,3 @@ return original.apply(this, arguments);

_this.config = __assign(__assign({}, defaultConfig), config);
_this.xhrMap = new Map();
_this.map = new Map();
return _this;

@@ -229,2 +230,9 @@ }

};
Object.defineProperty(XhrPlugin.prototype, "cacheSize", {
get: function () {
return this.map.size;
},
enumerable: false,
configurable: true
});
Object.defineProperty(XhrPlugin.prototype, "patches", {

@@ -248,9 +256,9 @@ get: function () {

});
XhrPlugin.prototype.handleXhrDetailsOnError = function (xhrDetails, errorName) {
if (xhrDetails) {
XhrPlugin.prototype.handleXhrDetailsOnError = function (details, request, errorName) {
if (details) {
var endTime = epochTime();
xhrDetails.trace.end_time = endTime;
xhrDetails.trace.subsegments[0].end_time = endTime;
xhrDetails.trace.subsegments[0].error = true;
xhrDetails.trace.subsegments[0].cause = {
details.trace.end_time = endTime;
details.trace.subsegments[0].end_time = endTime;
details.trace.subsegments[0].error = true;
details.trace.subsegments[0].cause = {
exceptions: [

@@ -262,4 +270,4 @@ {

};
this.recordTraceEvent(xhrDetails.trace);
this.recordHttpEventWithError(xhrDetails, errorName);
this.recordTraceEvent(details.trace);
this.recordHttpEventWithError(details, request, errorName);
}

@@ -270,20 +278,26 @@ };

};
XhrPlugin.prototype.recordHttpEventWithResponse = function (xhrDetails, xhr) {
if (this.config.recordAllRequests || !this.statusOk(xhr.status)) {
this.context.record(HTTP_EVENT_TYPE, {
version: '1.0.0',
request: { method: xhrDetails.method, url: xhrDetails.url },
response: { status: xhr.status, statusText: xhr.statusText }
});
XhrPlugin.prototype.recordHttpEventWithResponse = function (details, request) {
this.map.delete(request);
var httpEvent = {
version: '1.0.0',
request: { method: details.method, url: details.url },
response: {
status: request.status,
statusText: request.statusText
}
};
if (this.config.recordAllRequests || !this.statusOk(request.status)) {
this.context.record(HTTP_EVENT_TYPE, httpEvent);
}
};
XhrPlugin.prototype.recordHttpEventWithError = function (xhrDetails, error) {
XhrPlugin.prototype.recordHttpEventWithError = function (details, request, error) {
this.map.delete(request);
var httpEvent = {
version: '1.0.0',
request: { method: xhrDetails.method, url: xhrDetails.url }
request: { method: details.method, url: details.url },
error: errorEventToJsErrorEvent({
type: 'error',
error: error
}, this.config.stackTraceLength)
};
httpEvent.error = errorEventToJsErrorEvent({
type: 'error',
error: error
}, this.config.stackTraceLength);
this.context.record(HTTP_EVENT_TYPE, httpEvent);

@@ -290,0 +304,0 @@ };

@@ -58,5 +58,6 @@ import { MonkeyPatch, MonkeyPatched } from '../MonkeyPatched';

private config;
private xhrMap;
private map;
constructor(config?: PartialHttpPluginConfig);
protected onload(): void;
get cacheSize(): number;
protected get patches(): MonkeyPatch<XMLHttpRequest, "send" | "open">[];

@@ -63,0 +64,0 @@ private addXRayTraceIdHeader;

{
"name": "aws-rum-web",
"version": "1.14.0",
"version": "1.14.1",
"sideEffects": false,

@@ -5,0 +5,0 @@ "description": "The Amazon CloudWatch RUM web client.",

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