Skip to content

Commit f593337

Browse files
committed
Made analytics robust to redundant spaces in 'context'.
1 parent 14bcf61 commit f593337

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/analytics/eventContext.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ import { type PosthogEvent } from "./events";
55
* @returns Context values, all lowercase strings.
66
*/
77
export function getEventContextValues(event: PosthogEvent): string[] {
8-
return event.properties.context?.split(" ").map((v) => v.toLowerCase()) ?? [];
8+
return (
9+
event.properties.context
10+
?.split(" ")
11+
.filter((str) => str !== "")
12+
.map((v) => v.toLowerCase()) ?? []
13+
);
914
}
1015

1116
export function setEventContextValues(

0 commit comments

Comments
 (0)