Skip to content
This repository was archived by the owner on Feb 19, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ const filters: Filter[] = [
operator: "is",
value: true,
},
{
property: "$groups.foo",
type: "string",
operator: "is",
value: "bar",
},
];

const meta = {
Expand All @@ -36,6 +42,9 @@ test("Event satisfies all conditions and passes", () => {
$host: "example.com",
foo: 20,
bar: true,
$groups: {
foo: "bar"
}
},
}) as unknown as PluginEvent;
const processedEvent = processEvent(event, meta);
Expand All @@ -49,6 +58,9 @@ test("Event does not satisfy one condition and is dropped", () => {
$host: "localhost:8000",
foo: 20,
bar: true,
$groups: {
foo: "bar"
}
},
}) as unknown as PluginEvent;
const processedEvent = processEvent(event, meta);
Expand All @@ -62,6 +74,9 @@ test("Event does not satisfy any condition and is dropped", () => {
$host: "localhost:8000",
foo: 5,
bar: false,
$groups: {
foo: "foo"
}
},
}) as unknown as PluginEvent;
const processedEvent = processEvent(event, meta);
Expand All @@ -75,6 +90,9 @@ test("Event is marked to be dropped is dropped", () => {
$host: "example.com",
foo: 20,
bar: true,
$groups: {
foo: "bar"
}
},
}) as unknown as PluginEvent;
const processedEvent = processEvent(event, meta);
Expand All @@ -88,6 +106,9 @@ test("Event is marked to be dropped when a property is undefined", () => {
$host: undefined,
foo: 20,
bar: true,
$groups: {
foo: "bar"
}
},
}) as unknown as PluginEvent;
const processedEvent = processEvent(event, meta);
Expand All @@ -101,6 +122,9 @@ test("Event is marked to be dropped when a property is undefined but keepUndefin
$host: undefined,
foo: 20,
bar: true,
$groups: {
foo: "bar"
}
},
}) as unknown as PluginEvent;
const processedEvent = processEvent(event, {
Expand Down Expand Up @@ -155,6 +179,9 @@ describe("empty filters", () => {
$host: "example.com",
foo: 20,
bar: true,
$groups: {
foo: "bar"
}
},
}) as unknown as PluginEvent;
const processedEvent = processEvent(event, meta_no_filters);
Expand All @@ -168,6 +195,9 @@ describe("empty filters", () => {
$host: "example.com",
foo: 20,
bar: true,
$groups: {
foo: "bar"
}
},
}) as unknown as PluginEvent;
const processedEvent = processEvent(event, meta_no_filters);
Expand Down
3 changes: 2 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ export function processEvent(
const keepEvent = filters.some((filterGroup) =>
// Check if all filters in the group are satisfied (AND logic within group)
filterGroup.every((filter) => {
const value = event.properties[filter.property];
const keys = filter.property.split('.');
const value = keys.reduce((val, key) => val[key], event.properties);
if (value === undefined) return keepUndefinedProperties;

const operation = operations[filter.type][filter.operator];
Expand Down