Skip to content
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

revert: "fix: element stats API is only returning rage clicks" #21180

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading