Skip to content

Commit 86a85a3

Browse files
committed
fix(analytics): strip sensitive query params and remove redundant guard
1 parent e407ddc commit 86a85a3

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

apps/sim/lib/analytics/profound.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const logger = createLogger('ProfoundAnalytics')
1313

1414
const FLUSH_INTERVAL_MS = 10_000
1515
const MAX_BATCH_SIZE = 500
16+
const SENSITIVE_PARAMS = new Set(['token', 'callbackUrl', 'code', 'state', 'secret'])
1617

1718
interface ProfoundLogEntry {
1819
timestamp: string
@@ -91,7 +92,9 @@ export function sendToProfound(request: Request, statusCode: number): void {
9192
const url = new URL(request.url)
9293
const queryParams: Record<string, string> = {}
9394
url.searchParams.forEach((value, key) => {
94-
queryParams[key] = value
95+
if (!SENSITIVE_PARAMS.has(key)) {
96+
queryParams[key] = value
97+
}
9598
})
9699

97100
buffer.push({

apps/sim/proxy.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createLogger } from '@sim/logger'
22
import { getSessionCookie } from 'better-auth/cookies'
33
import { type NextRequest, NextResponse } from 'next/server'
4-
import { isProfoundEnabled, sendToProfound } from './lib/analytics/profound'
4+
import { sendToProfound } from './lib/analytics/profound'
55
import { isAuthDisabled, isHosted } from './lib/core/config/feature-flags'
66
import { generateRuntimeCSP } from './lib/core/security/csp'
77

@@ -201,9 +201,7 @@ export async function proxy(request: NextRequest) {
201201
* Sends request data to Profound analytics (fire-and-forget) and returns the response.
202202
*/
203203
function track(request: NextRequest, response: NextResponse): NextResponse {
204-
if (isProfoundEnabled()) {
205-
sendToProfound(request, response.status)
206-
}
204+
sendToProfound(request, response.status)
207205
return response
208206
}
209207

0 commit comments

Comments
 (0)