-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Advanced Analytics Filters #3436
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
+4,222
−717
Merged
Changes from 15 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
fd64edb
multi-select ui filter for link analytics
pepeladeira 36dfe29
initial support for advanced filters in link
pepeladeira f77562e
test: e2e for advanced filters
pepeladeira 5b37146
review advanced analytic schema description
pepeladeira 6dbf7b1
return with stripe instance as it was
pepeladeira b4ff07c
feat: ensure multi select filter for other attrs
pepeladeira 0cf46ed
Merge branch 'main' into feat/advanced-filters
pepeladeira 1230beb
feat: apply isMultiple again and add filters in Events page
pepeladeira a0db5f6
feat: apply isMultiple again and add filters in Events page
pepeladeira f0ac778
feat(advanced-filters): ensure filter component is working for every …
pepeladeira a2e03b0
test(advanced-filters): fix and create new tests
pepeladeira cbd9e11
feat(advanced-filters): prevent filter-list from closing after select…
pepeladeira 24638cc
test(events): get-events tests suite
pepeladeira c27ffe5
feat(advanced-filter): analytics pipe helpers
pepeladeira 35627a2
Merge pull request #1 from pepeladeira/feat/advanced-filters
pepeladeira e2ef1a8
fix: remove repetitive code
pepeladeira fa4f077
fix(advanced-filter): remove null checks before referencing stripe
pepeladeira 80b4274
fix(advanced-fiters): Double folderId filter causes contradictory WHE…
pepeladeira e1027b0
fix(advanced-filters): onRemoveFilter('link') won't clear the link fi…
pepeladeira 00684ac
fix(advanced-filters): Add typeof guard for regionForPipe to match th…
pepeladeira 82b2473
fix(advanced-filters): newParam could be undefined when parsed is und…
pepeladeira 47e11b6
fix(advanced-filters): Address static analysis warning on forEach cal…
pepeladeira d938d52
fix(advanced-filters): Edge case: { key, values, operator: undefined …
pepeladeira 4b0e1b7
fix(advanced-filters): add field-based JSON filter handling in sale_e…
pepeladeira 6f23007
fix(advanced-filters): add field-based JSON filter handling in sale_e…
pepeladeira 7926796
fix(advanced-filters): onToggleOperator preserve pagination state.
pepeladeira 8326b1a
fix(advanced-filters): pluralize os
pepeladeira e989305
fix(advanced-filters): appropriate extraction functions for numeric m…
pepeladeira f03501e
fix(advanced-filters): add field-based JSON filter handling in sale_e…
pepeladeira d7f39c4
fix(advanced-filters): ensure keyboar toggleValue checkbox for filter…
pepeladeira 08d73a5
fix(advanced-filters): mismatch prevents root filter from rendering s…
pepeladeira 7d45f87
Merge branch 'main' into main
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
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
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,47 @@ | ||
| import { ParsedFilter, type SQLOperator } from "@dub/utils"; | ||
|
|
||
| export interface AdvancedFilter { | ||
| field: string; | ||
| operator: SQLOperator; | ||
| values: string[]; | ||
| } | ||
|
|
||
| const SUPPORTED_FIELDS = [ | ||
| "country", | ||
| "city", | ||
| "continent", | ||
| "device", | ||
| "browser", | ||
| "os", | ||
| "referer", | ||
| "refererUrl", | ||
| "url", | ||
| "trigger", | ||
| "utm_source", | ||
| "utm_medium", | ||
| "utm_campaign", | ||
| "utm_term", | ||
| "utm_content", | ||
| "saleType", | ||
| ] as const; | ||
|
|
||
| type SupportedField = (typeof SUPPORTED_FIELDS)[number]; | ||
|
|
||
| export function buildAdvancedFilters( | ||
| params: Partial<Record<SupportedField, ParsedFilter | undefined>>, | ||
| ): AdvancedFilter[] { | ||
| const filters: AdvancedFilter[] = []; | ||
|
|
||
| for (const field of SUPPORTED_FIELDS) { | ||
| const parsed = params[field]; | ||
| if (!parsed) continue; | ||
|
|
||
| filters.push({ | ||
| field, | ||
| operator: parsed.sqlOperator, | ||
| values: parsed.values, | ||
| }); | ||
| } | ||
|
|
||
| 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| import { ParsedFilter } from "@dub/utils"; | ||
|
|
||
| /** | ||
| * Prepare trigger and region filters for Tinybird pipes. | ||
| * Handles backward compatibility for qr parameter and region splitting. | ||
| */ | ||
| export function prepareFiltersForPipe(params: { | ||
| qr?: boolean; | ||
| trigger?: ParsedFilter; | ||
| region?: string | ParsedFilter; | ||
| country?: ParsedFilter; | ||
| }) { | ||
| // Handle qr backward compatibility | ||
| let triggerForPipe = params.trigger; | ||
| if (params.qr && !params.trigger) { | ||
| triggerForPipe = { | ||
| operator: "IS" as const, | ||
| sqlOperator: "IN" as const, | ||
| values: ["qr"], | ||
| }; | ||
| } | ||
|
|
||
| // Handle region split (format: "US-CA") | ||
| let countryForPipe = params.country; | ||
| let regionForPipe = params.region; | ||
| if (params.region && typeof params.region === "string") { | ||
| const split = params.region.split("-"); | ||
| countryForPipe = { | ||
| operator: "IS" as const, | ||
| sqlOperator: "IN" as const, | ||
| values: [split[0]], | ||
| }; | ||
| regionForPipe = split[1]; | ||
| } | ||
|
|
||
| return { triggerForPipe, countryForPipe, regionForPipe }; | ||
| } | ||
|
|
||
| /** | ||
| * Extract workspace link filters (domain, tagIds, folderId, root) into | ||
| * separate values and operators for Tinybird. | ||
| * | ||
| * These filters are applied on the workspace_links node in Tinybird, | ||
| * so they need to be passed as separate parameters (not in the filters JSON). | ||
| */ | ||
| export function extractWorkspaceLinkFilters(params: { | ||
| domain?: ParsedFilter; | ||
| tagIds?: ParsedFilter; | ||
| folderId?: ParsedFilter; | ||
| root?: ParsedFilter; | ||
| }) { | ||
| const extractFilter = (filter?: ParsedFilter) => ({ | ||
| values: filter?.values, | ||
| operator: (filter?.sqlOperator === "NOT IN" ? "NOT IN" : "IN") as | ||
| | "IN" | ||
| | "NOT IN", | ||
| }); | ||
|
|
||
| const domain = extractFilter(params.domain); | ||
| const tagIds = extractFilter(params.tagIds); | ||
| const folderId = extractFilter(params.folderId); | ||
| const root = extractFilter(params.root); | ||
|
|
||
| return { | ||
| domain: domain.values, | ||
| domainOperator: domain.operator, | ||
| tagIds: tagIds.values, | ||
| tagIdsOperator: tagIds.operator, | ||
| folderId: folderId.values, | ||
| folderIdOperator: folderId.operator, | ||
| root: root.values, | ||
| rootOperator: root.operator, | ||
| }; | ||
| } |
Oops, something went wrong.
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.