From fafeeaae1da89e0b48bfb403807e23401c57120e Mon Sep 17 00:00:00 2001 From: Robbie Date: Wed, 2 Oct 2024 15:58:42 +0100 Subject: [PATCH] fix(web-analytics): Update kea router, and store conversion goals as flat parameters rather than JSON in URL (#25332) --- .../scenes/web-analytics/webAnalyticsLogic.tsx | 17 ++++++++++++----- package.json | 2 +- pnpm-lock.yaml | 14 +++++++------- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/frontend/src/scenes/web-analytics/webAnalyticsLogic.tsx b/frontend/src/scenes/web-analytics/webAnalyticsLogic.tsx index b2c6705b146..e1eeaf3b991 100644 --- a/frontend/src/scenes/web-analytics/webAnalyticsLogic.tsx +++ b/frontend/src/scenes/web-analytics/webAnalyticsLogic.tsx @@ -679,7 +679,7 @@ export const webAnalyticsLogic = kea([ ]) : null, !conversionGoal - ? createGraphsTrendsTab(GraphsTab.NUM_SESSION, 'Unique visitors', 'Visitors', [ + ? createGraphsTrendsTab(GraphsTab.NUM_SESSION, 'Unique sessions', 'Sessions', [ sessionsSeries, ]) : null, @@ -1345,7 +1345,11 @@ export const webAnalyticsLogic = kea([ urlParams.set('filters', JSON.stringify(webAnalyticsFilters)) } if (conversionGoal) { - urlParams.set('conversionGoal', JSON.stringify(conversionGoal)) + if ('actionId' in conversionGoal) { + urlParams.set('conversionGoal.actionId', conversionGoal.actionId.toString()) + } else { + urlParams.set('conversionGoal.customEventName', conversionGoal.customEventName) + } } if (dateFrom !== initialDateFrom || dateTo !== initialDateTo || interval !== initialInterval) { urlParams.set('date_from', dateFrom ?? '') @@ -1395,7 +1399,8 @@ export const webAnalyticsLogic = kea([ _, { filters, - conversionGoal, + 'conversionGoal.actionId': conversionGoalActionId, + 'conversionGoal.customEventName': conversionGoalCustomEventName, date_from, date_to, interval, @@ -1413,8 +1418,10 @@ export const webAnalyticsLogic = kea([ if (parsedFilters) { actions.setWebAnalyticsFilters(parsedFilters) } - if (conversionGoal) { - actions.setConversionGoal(conversionGoal) + if (conversionGoalActionId) { + actions.setConversionGoal({ actionId: parseInt(conversionGoalActionId, 10) }) + } else if (conversionGoalCustomEventName) { + actions.setConversionGoal({ customEventName: conversionGoalCustomEventName }) } if (date_from || date_to || interval) { actions.setDatesAndInterval(date_from, date_to, interval) diff --git a/package.json b/package.json index feb7c7b9d0e..49cbf4ef7a9 100644 --- a/package.json +++ b/package.json @@ -136,7 +136,7 @@ "kea-forms": "^3.2.0", "kea-loaders": "^3.0.0", "kea-localstorage": "^3.1.0", - "kea-router": "^3.1.4", + "kea-router": "^3.2.0", "kea-subscriptions": "^3.0.1", "kea-test-utils": "^0.2.4", "kea-waitfor": "^0.2.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7317eabd8f4..8b640fe1769 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -230,8 +230,8 @@ dependencies: specifier: ^3.1.0 version: 3.1.0(kea@3.1.5) kea-router: - specifier: ^3.1.4 - version: 3.1.4(kea@3.1.5) + specifier: ^3.2.0 + version: 3.2.0(kea@3.1.5) kea-subscriptions: specifier: ^3.0.1 version: 3.0.1(kea@3.1.5) @@ -15304,8 +15304,8 @@ packages: kea: 3.1.5(react@18.2.0) dev: false - /kea-router@3.1.4(kea@3.1.5): - resolution: {integrity: sha512-KjATA2vwh90GDcO3iiUrQwhRSzRbvyplvtyDzEWevfSHccbrtxdDm/ZCApAvMACPZZH0Klk4aHk1ZAZ1DJtcbg==} + /kea-router@3.2.0(kea@3.1.5): + resolution: {integrity: sha512-TZVHrQQNhD7tSL05xEXoNCeYu/vwwvxBc316pgwi5z8cH61MtCcUBUEZnWr2Nd7jSBDgxA/GRHpqai0YXq0T8w==} peerDependencies: kea: '>= 3' dependencies: @@ -18334,7 +18334,7 @@ packages: react: '>=15' dependencies: react: 18.2.0 - unlayer-types: 1.103.0 + unlayer-types: 1.111.0 dev: false /react-error-boundary@3.1.4(react@18.2.0): @@ -20881,8 +20881,8 @@ packages: resolution: {integrity: sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==} engines: {node: '>= 10.0.0'} - /unlayer-types@1.103.0: - resolution: {integrity: sha512-aVZS7g5F6dWEoxc0dhSDqYYncu+LIMB/SerJi6u5FKVSfTWnzA2MTpjFCbGkOOi8rUiIOabeuEOfyO/WDnarJg==} + /unlayer-types@1.111.0: + resolution: {integrity: sha512-CjdOROIUrZXrtkLUrInMvTucEWRdWWEmPleCOhwsDTwUXg9LocjzI6drgdYoia/lyyoYPfHOXYw5SxdJk7hlvw==} dev: false /unpipe@1.0.0: