Skip to content

[PROD] - UTM register btn#7167

Merged
kkartunov merged 7 commits intomasterfrom
PM-3204_cookies-utm-codes
Feb 5, 2026
Merged

[PROD] - UTM register btn#7167
kkartunov merged 7 commits intomasterfrom
PM-3204_cookies-utm-codes

Conversation

@kkartunov
Copy link
Copy Markdown
Collaborator

@kkartunov kkartunov requested a review from jmgasper as a code owner December 17, 2025 08:40
@kkartunov kkartunov requested a review from vas3a December 17, 2025 08:40
if (!auth.tokenV3) {
const utmSource = communityId || 'community-app-main';
window.location.href = `${config.URL.AUTH}/member?retUrl=${encodeURIComponent(`${window.location.origin}${window.location.pathname}`)}&utm_source=${utmSource}&regSource=challenges`;
window.location.href = appendUtmParamsToUrl(
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[❗❗ security]
The appendUtmParamsToUrl function is used to construct a URL with query parameters. Ensure that this function properly encodes all URL components to prevent potential security issues such as URL injection.

Comment thread src/shared/utils/utm.js

// handle values that might contain '='
const cookieValue = decodeURIComponent(cookieStr.split('=').slice(1).join('='));
return JSON.parse(cookieValue);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ maintainability]
Consider logging the error or handling it in a way that provides more context. Swallowing errors silently can make debugging difficult.

Comment thread src/shared/utils/utm.js

return urlObj.toString();
} catch (error) {
return url;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ maintainability]
Consider logging the error or handling it in a way that provides more context. Swallowing errors silently can make debugging difficult.

Comment thread src/shared/utils/utm.js
* @param url - The base URL to append parameters to
* @returns URL with UTM parameters appended, or original URL if no cookie exists
*/
export function appendUtmParamsToUrl(url, defaultParams = {}) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ correctness]
The function appendUtmParamsToUrl should validate the url parameter more robustly. Currently, it only checks for falsy values, but malformed URLs could still cause issues.

@vas3a
Copy link
Copy Markdown
Collaborator

vas3a commented Dec 17, 2025

@kkartunov let's close this one

@kkartunov kkartunov merged commit 8b81f58 into master Feb 5, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants