@honeypot-run/core
Advanced tools
Comparing version 0.2.55 to 0.2.56
@@ -20,3 +20,3 @@ "use strict"; | ||
execute: (event) => __awaiter(void 0, void 0, void 0, function* () { | ||
var _a; | ||
var _a, _b; | ||
try { | ||
@@ -28,3 +28,4 @@ const { user_id, event_type } = event; | ||
: event_type; | ||
const shouldIgnore = (_a = pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.ignoreEvents) === null || _a === void 0 ? void 0 : _a.includes(cleanedEventType); | ||
const shouldIgnore = ((_a = pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.excludeEvents) === null || _a === void 0 ? void 0 : _a.includes(cleanedEventType)) || | ||
(((_b = pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.includeEvents) === null || _b === void 0 ? void 0 : _b.length) && !(pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.includeEvents.includes(cleanedEventType))); | ||
if (shouldIgnore) { | ||
@@ -31,0 +32,0 @@ return event; |
@@ -23,3 +23,3 @@ "use strict"; | ||
const pluginConfig = { | ||
ignoreEvents: ['excluded_event'], | ||
excludeEvents: ['excluded_event'], | ||
}; | ||
@@ -38,2 +38,18 @@ plugin = (0, AmplitudePlugin_1.createAmplitudePlugin)(track, get, pluginConfig); | ||
})); | ||
test('should include event if it is in includeEvents', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const pluginConfig = { | ||
includeEvents: ['included_event'], | ||
}; | ||
plugin = (0, AmplitudePlugin_1.createAmplitudePlugin)(track, get, pluginConfig); | ||
const event = { | ||
event_type: 'excluded_event', | ||
event_properties: {}, | ||
user_id: '1234', | ||
device_id: '5678', | ||
}; | ||
const result = yield plugin.execute(event); | ||
expect(track).not.toHaveBeenCalled(); | ||
expect(get).not.toHaveBeenCalled(); | ||
expect(result === null || result === void 0 ? void 0 : result.event_properties).not.toHaveProperty('honey'); | ||
})); | ||
test('should enrich event if enrichEvents is enabled', () => __awaiter(void 0, void 0, void 0, function* () { | ||
@@ -40,0 +56,0 @@ const pluginConfig = { |
import { EnrichmentPlugin } from '@amplitude/analytics-types'; | ||
export type IdentityType = "account" | "email" | "merchant_id" | "partner_id" | "web3_wallet" | "geofence_ref"; | ||
export interface AmplitudePluginConfig { | ||
ignoreEvents?: string[]; | ||
excludeEvents?: string[]; | ||
includeEvents?: string[]; | ||
enrichEventProperties?: boolean; | ||
@@ -6,0 +7,0 @@ } |
@@ -17,3 +17,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
execute: (event) => __awaiter(void 0, void 0, void 0, function* () { | ||
var _a; | ||
var _a, _b; | ||
try { | ||
@@ -25,3 +25,4 @@ const { user_id, event_type } = event; | ||
: event_type; | ||
const shouldIgnore = (_a = pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.ignoreEvents) === null || _a === void 0 ? void 0 : _a.includes(cleanedEventType); | ||
const shouldIgnore = ((_a = pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.excludeEvents) === null || _a === void 0 ? void 0 : _a.includes(cleanedEventType)) || | ||
(((_b = pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.includeEvents) === null || _b === void 0 ? void 0 : _b.length) && !(pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.includeEvents.includes(cleanedEventType))); | ||
if (shouldIgnore) { | ||
@@ -28,0 +29,0 @@ return event; |
@@ -21,3 +21,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
const pluginConfig = { | ||
ignoreEvents: ['excluded_event'], | ||
excludeEvents: ['excluded_event'], | ||
}; | ||
@@ -36,2 +36,18 @@ plugin = createAmplitudePlugin(track, get, pluginConfig); | ||
})); | ||
test('should include event if it is in includeEvents', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const pluginConfig = { | ||
includeEvents: ['included_event'], | ||
}; | ||
plugin = createAmplitudePlugin(track, get, pluginConfig); | ||
const event = { | ||
event_type: 'excluded_event', | ||
event_properties: {}, | ||
user_id: '1234', | ||
device_id: '5678', | ||
}; | ||
const result = yield plugin.execute(event); | ||
expect(track).not.toHaveBeenCalled(); | ||
expect(get).not.toHaveBeenCalled(); | ||
expect(result === null || result === void 0 ? void 0 : result.event_properties).not.toHaveProperty('honey'); | ||
})); | ||
test('should enrich event if enrichEvents is enabled', () => __awaiter(void 0, void 0, void 0, function* () { | ||
@@ -38,0 +54,0 @@ const pluginConfig = { |
import { EnrichmentPlugin } from '@amplitude/analytics-types'; | ||
export type IdentityType = "account" | "email" | "merchant_id" | "partner_id" | "web3_wallet" | "geofence_ref"; | ||
export interface AmplitudePluginConfig { | ||
ignoreEvents?: string[]; | ||
excludeEvents?: string[]; | ||
includeEvents?: string[]; | ||
enrichEventProperties?: boolean; | ||
@@ -6,0 +7,0 @@ } |
@@ -5,3 +5,3 @@ { | ||
"author": "https://honeypot.run", | ||
"version": "0.2.55", | ||
"version": "0.2.56", | ||
"license": "BUSL-1.1", | ||
@@ -8,0 +8,0 @@ "keywords": [ |
46870
1086