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

@amplitude/analytics-core

Package Overview
Dependencies
Maintainers
21
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@amplitude/analytics-core - npm Package Compare versions

Comparing version 2.2.1 to 2.2.2

5

lib/cjs/plugins/destination.d.ts

@@ -26,9 +26,10 @@ import { Config, DestinationContext as Context, DestinationPlugin, Event, InvalidResponse, PayloadTooLargeResponse, RateLimitResponse, Response, Result, SuccessResponse } from '@amplitude/analytics-types';

/**
* Saves events to storage
* This is called on
* 1) new events are added to queue; or
* 2) response comes back for a request
*
* update the event storage
*/
saveEvents(): void;
updateEventStorage(eventsToRemove: Context[], eventsToAdd?: Context[]): Promise<void>;
}
//# sourceMappingURL=destination.d.ts.map

53

lib/cjs/plugins/destination.js

@@ -51,3 +51,2 @@ Object.defineProperty(exports, "__esModule", { value: true });

unsent = _b.sent();
this.saveEvents(); // sets storage to '[]'
if (unsent && unsent.length > 0) {

@@ -98,3 +97,3 @@ void Promise.all(unsent.map(function (event) { return _this.execute(event); })).catch();

});
this.saveEvents();
void this.updateEventStorage([], this.queue);
};

@@ -203,15 +202,15 @@ Destination.prototype.schedule = function (timeout) {

case analytics_types_1.Status.Success: {
this.handleSuccessResponse(res, list);
void this.handleSuccessResponse(res, list);
break;
}
case analytics_types_1.Status.Invalid: {
this.handleInvalidResponse(res, list);
void this.handleInvalidResponse(res, list);
break;
}
case analytics_types_1.Status.PayloadTooLarge: {
this.handlePayloadTooLargeResponse(res, list);
void this.handlePayloadTooLargeResponse(res, list);
break;
}
case analytics_types_1.Status.RateLimit: {
this.handleRateLimitResponse(res, list);
void this.handleRateLimitResponse(res, list);
break;

@@ -294,17 +293,43 @@ }

Destination.prototype.fulfillRequest = function (list, code, message) {
this.saveEvents();
list.forEach(function (context) { return context.callback((0, result_builder_1.buildResult)(context.event, code, message)); });
void this.updateEventStorage(list);
};
/**
* Saves events to storage
* This is called on
* 1) new events are added to queue; or
* 2) response comes back for a request
*
* update the event storage
*/
Destination.prototype.saveEvents = function () {
if (!this.config.storageProvider) {
return;
}
var events = Array.from(this.queue.map(function (context) { return context.event; }));
void this.config.storageProvider.set(this.storageKey, events);
Destination.prototype.updateEventStorage = function (eventsToRemove, eventsToAdd) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var filterEventInsertIdSet, savedEvents, updatedEvents;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!this.config.storageProvider) {
return [2 /*return*/];
}
filterEventInsertIdSet = eventsToRemove.reduce(function (filtered, context) {
if (context.event.insert_id) {
filtered.add(context.event.insert_id);
}
return filtered;
}, new Set());
return [4 /*yield*/, this.config.storageProvider.get(this.storageKey)];
case 1:
savedEvents = _a.sent();
updatedEvents = (eventsToAdd === null || eventsToAdd === void 0 ? void 0 : eventsToAdd.map(function (context) { return context.event; })) || [];
savedEvents === null || savedEvents === void 0 ? void 0 : savedEvents.forEach(function (event) {
if (event.insert_id && !filterEventInsertIdSet.has(event.insert_id)) {
updatedEvents.push(event);
}
});
return [4 /*yield*/, this.config.storageProvider.set(this.storageKey, updatedEvents)];
case 2:
_a.sent();
return [2 /*return*/];
}
});
});
};

@@ -311,0 +336,0 @@ return Destination;

@@ -26,9 +26,10 @@ import { Config, DestinationContext as Context, DestinationPlugin, Event, InvalidResponse, PayloadTooLargeResponse, RateLimitResponse, Response, Result, SuccessResponse } from '@amplitude/analytics-types';

/**
* Saves events to storage
* This is called on
* 1) new events are added to queue; or
* 2) response comes back for a request
*
* update the event storage
*/
saveEvents(): void;
updateEventStorage(eventsToRemove: Context[], eventsToAdd?: Context[]): Promise<void>;
}
//# sourceMappingURL=destination.d.ts.map

@@ -48,3 +48,2 @@ import { __awaiter, __generator, __read, __rest, __spreadArray } from "tslib";

unsent = _b.sent();
this.saveEvents(); // sets storage to '[]'
if (unsent && unsent.length > 0) {

@@ -95,3 +94,3 @@ void Promise.all(unsent.map(function (event) { return _this.execute(event); })).catch();

});
this.saveEvents();
void this.updateEventStorage([], this.queue);
};

@@ -200,15 +199,15 @@ Destination.prototype.schedule = function (timeout) {

case Status.Success: {
this.handleSuccessResponse(res, list);
void this.handleSuccessResponse(res, list);
break;
}
case Status.Invalid: {
this.handleInvalidResponse(res, list);
void this.handleInvalidResponse(res, list);
break;
}
case Status.PayloadTooLarge: {
this.handlePayloadTooLargeResponse(res, list);
void this.handlePayloadTooLargeResponse(res, list);
break;
}
case Status.RateLimit: {
this.handleRateLimitResponse(res, list);
void this.handleRateLimitResponse(res, list);
break;

@@ -291,17 +290,43 @@ }

Destination.prototype.fulfillRequest = function (list, code, message) {
this.saveEvents();
list.forEach(function (context) { return context.callback(buildResult(context.event, code, message)); });
void this.updateEventStorage(list);
};
/**
* Saves events to storage
* This is called on
* 1) new events are added to queue; or
* 2) response comes back for a request
*
* update the event storage
*/
Destination.prototype.saveEvents = function () {
if (!this.config.storageProvider) {
return;
}
var events = Array.from(this.queue.map(function (context) { return context.event; }));
void this.config.storageProvider.set(this.storageKey, events);
Destination.prototype.updateEventStorage = function (eventsToRemove, eventsToAdd) {
return __awaiter(this, void 0, void 0, function () {
var filterEventInsertIdSet, savedEvents, updatedEvents;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!this.config.storageProvider) {
return [2 /*return*/];
}
filterEventInsertIdSet = eventsToRemove.reduce(function (filtered, context) {
if (context.event.insert_id) {
filtered.add(context.event.insert_id);
}
return filtered;
}, new Set());
return [4 /*yield*/, this.config.storageProvider.get(this.storageKey)];
case 1:
savedEvents = _a.sent();
updatedEvents = (eventsToAdd === null || eventsToAdd === void 0 ? void 0 : eventsToAdd.map(function (context) { return context.event; })) || [];
savedEvents === null || savedEvents === void 0 ? void 0 : savedEvents.forEach(function (event) {
if (event.insert_id && !filterEventInsertIdSet.has(event.insert_id)) {
updatedEvents.push(event);
}
});
return [4 /*yield*/, this.config.storageProvider.set(this.storageKey, updatedEvents)];
case 2:
_a.sent();
return [2 /*return*/];
}
});
});
};

@@ -308,0 +333,0 @@ return Destination;

{
"name": "@amplitude/analytics-core",
"version": "2.2.1",
"version": "2.2.2",
"description": "",

@@ -44,3 +44,3 @@ "author": "Amplitude Inc",

],
"gitHead": "33fa1bd2b8e307a8a8d0a86610f8d893bf8aa5aa"
"gitHead": "b6baaa56c61c3efcf9efd5203fcb62eea0e4d41f"
}

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