Skip to content

Commit

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

// toolbar fetch collapses queryparams but this URL has multiple with the same name
// 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
const response = await toolbarFetch(
url || defaultUrl,
'GET',
undefined,
url ? 'use-as-provided' : 'full'
url ? 'use-as-provided' : 'only-add-token'
)

if (response.status === 403) {
Expand Down
10 changes: 8 additions & 2 deletions frontend/src/toolbar/toolbarConfigLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,23 @@ 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 "use-as-provided" then the URL is used as-is, and the payload is not used
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
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' | 'use-as-provided' = 'full'
urlConstruction: 'full' | 'only-add-token' | '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 2e42a24

Please sign in to comment.