Skip to content

Commit

Permalink
Revert "fix: element stats API is only returning rage clicks (#21178)"
Browse files Browse the repository at this point in the history
This reverts commit 195f0c5.
  • Loading branch information
pauldambra authored Mar 27, 2024
1 parent 195f0c5 commit 6f2a504
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
6 changes: 2 additions & 4 deletions frontend/src/toolbar/elements/heatmapLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,12 @@ export const heatmapLogic = kea<heatmapLogicType>([
)}${includeEventsParams}`
}

// toolbar fetch collapses URL query params to an object
// but this URL has multiple with the same name,
// so we must pass it through only-add-token
// toolbar fetch collapses queryparams but this URL has multiple with the same name
const response = await toolbarFetch(
url || defaultUrl,
'GET',
undefined,
url ? 'use-as-provided' : 'only-add-token'
url ? 'use-as-provided' : 'full'
)

if (response.status === 403) {
Expand Down
10 changes: 2 additions & 8 deletions frontend/src/toolbar/toolbarConfigLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,23 +103,17 @@ export async function toolbarFetch(
/*
allows caller to control how the provided URL is altered before use
if "full" then the payload and URL are taken apart and reconstructed
if "only-add-token" the URL is unchanged, but the temporary token is added to the URL
if "use-as-provided" then the URL is used as-is, the token is not added
if "use-as-provided" then the URL is used as-is, and the payload is not used
this is because the heatmapLogic needs more control over how the query parameters are constructed
the call to elementStats allows multiple query parameter with the same name
passing it through url construction loses information
*/
urlConstruction: 'full' | 'only-add-token' | 'use-as-provided' = 'full'
urlConstruction: 'full' | 'use-as-provided' = 'full'
): Promise<Response> {
const temporaryToken = toolbarConfigLogic.findMounted()?.values.temporaryToken
const apiURL = toolbarConfigLogic.findMounted()?.values.apiURL

let fullUrl: string
if (urlConstruction === 'use-as-provided') {
fullUrl = url
} else if (urlConstruction === 'only-add-token') {
fullUrl = `${url}&temporary_token=${temporaryToken}`
} else {
const { pathname, searchParams } = combineUrl(url)
const params = { ...searchParams, temporary_token: temporaryToken }
Expand Down

0 comments on commit 6f2a504

Please sign in to comment.