-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Filter events & analytics by metadata #2648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
e8996e9
Add metadata filtering to analytics & events wip
devkiran fea11d2
Update analytics.ts
devkiran fd9f27c
Merge branch 'main' into filter-events-by-metadata
devkiran 2d5934a
Add filter extraction and processing for event metadata in analytics
devkiran 9aefa03
Implement query filter parsing for analytics and events; refactor fil…
devkiran 5a36767
Update analytics-query-parser.ts
devkiran 127ca9c
Update analytics.ts
devkiran 1c26a43
Merge branch 'main' into filter-events-by-metadata
devkiran a2287c2
Merge branch 'main' into filter-events-by-metadata
devkiran 8ce567b
support Stripe-like query filter
devkiran 8c69b57
Update analytics-query-parser.ts
devkiran d6c229b
Update analytics-query-parser.test.ts
devkiran 9e7bd00
Refactor analytics query parser to use descriptive operator names and…
devkiran 76d5670
Update analytics-query-parser.ts
devkiran 01dab20
fix tests
devkiran a244e8a
Merge branch 'main' into filter-events-by-metadata
devkiran 284925f
Merge branch 'main' into filter-events-by-metadata
steven-tey 56de4b2
Merge branch 'main' into filter-events-by-metadata
steven-tey b99c72d
Merge branch 'main' into filter-events-by-metadata
steven-tey 200e1c3
Merge branch 'main' into filter-events-by-metadata
steven-tey ad5aede
Merge branch 'main' into filter-events-by-metadata
devkiran 4d76c88
Merge branch 'main' into filter-events-by-metadata
steven-tey 090552a
Merge branch 'main' into filter-events-by-metadata
devkiran ccaa34f
Merge branch 'main' into filter-events-by-metadata
steven-tey cfed824
Merge branch 'main' into filter-events-by-metadata
steven-tey 4dd148f
rearrange parseFiltersFromQuery
steven-tey cfdc5cf
finalize schemas
steven-tey a240dc5
add metadata column
steven-tey 1bb0850
Merge branch 'main' into filter-events-by-metadata
steven-tey c9ee2b9
add metadata.productId filter test
steven-tey d6ece15
parseFiltersFromQuery → queryParser
steven-tey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import { z } from "zod"; | ||
| import { EventsFilters } from "../types"; | ||
|
|
||
| interface Filter { | ||
| operand: string; | ||
| operator: "equals"; // can be expanded later | ||
| value: string; | ||
| } | ||
|
|
||
| export const parseFiltersFromQuery = (query: EventsFilters["query"]) => { | ||
| if (!query) { | ||
| return undefined; | ||
| } | ||
|
|
||
| const result = z | ||
| .object({ | ||
| metadata: z.record(z.string(), z.string()), | ||
| }) | ||
| .safeParse(query); | ||
|
|
||
| if (!result.success) { | ||
| console.log(`Ignoring the invalid query ${JSON.stringify(query)}`); | ||
| return undefined; | ||
| } | ||
|
|
||
| const filters: Filter[] = Object.entries(result.data.metadata) | ||
| .slice(0, 1) | ||
devkiran marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| .map(([key, value]) => { | ||
| return { | ||
| operand: key, | ||
| operator: "equals", | ||
| value, | ||
| }; | ||
| }); | ||
|
|
||
| console.log("filters", filters); | ||
|
|
||
| return filters; | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.