Skip to content

Conversation

@kkartunov
Copy link
Contributor

$ctx.auth = {...$ctx.auth, ready: true, user: authUser ?? undefined};
});
function onSignIn(signup?: any) {

Choose a reason for hiding this comment

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

[⚠️ maintainability]
The signup parameter is typed as any, which can lead to potential type-related issues. Consider using a more specific type, such as boolean | undefined, to improve type safety and maintainability.

].filter(Boolean).join('&')
// Append UTM parameters from cookie if they exist
signupUrl = appendUtmParamsToUrl(signupUrl);

Choose a reason for hiding this comment

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

[❗❗ correctness]
Ensure that the appendUtmParamsToUrl function correctly handles URLs that already contain query parameters, to avoid malformed URLs. This is crucial for maintaining the correctness of the URL redirection.

const params: UtmParams = {};

try {
const searchParams = new URLSearchParams(window.location.search);

Choose a reason for hiding this comment

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

[⚠️ design]
Using window.location directly ties this function to a browser environment, which may limit testing or reuse in non-browser contexts. Consider passing the URL as a parameter to increase flexibility.

domain = getCookieDomain(),
path = COOKIE_PATH,
sameSite = COOKIE_SAMESITE,
secure = true,

Choose a reason for hiding this comment

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

[⚠️ security]
The secure option is hardcoded to true, which means this code will not work over HTTP. Consider making this configurable or documenting that this function requires HTTPS.

*/
export function getUtmCookie(): UtmParams | null {
try {
const cookies = document.cookie.split(';');

Choose a reason for hiding this comment

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

[💡 correctness]
Splitting document.cookie by ; assumes that cookies do not contain semicolons, which is generally safe but not guaranteed. Consider using a more robust cookie parsing library if this becomes an issue.

}

try {
const urlObj = new URL(url, window.location.origin);

Choose a reason for hiding this comment

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

[⚠️ design]
Using window.location.origin assumes the code is running in a browser environment. Consider passing the base URL as a parameter to make this function more versatile.

* @param input - The string to sanitize
* @returns Sanitized string
*/
export declare function sanitize(input: string): string;

Choose a reason for hiding this comment

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

[⚠️ correctness]
Consider specifying the behavior of the sanitize function when the input contains characters that are not A-Z, a-z, 0-9, hyphen (-), or underscore (_). This will improve the clarity of the function's contract.

* Extracts UTM parameters from URL, sanitizes them, and persists to cookie
* Only sets the cookie if it doesn't already exist
*/
export declare function initializeUtmCookieHandler(): void;

Choose a reason for hiding this comment

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

[⚠️ correctness]
The initializeUtmCookieHandler function should specify the expected behavior if the URL does not contain any UTM parameters. This will help ensure consistent handling of edge cases.

* @param url - The base URL to append parameters to
* @returns URL with UTM parameters appended, or original URL if no cookie exists
*/
export declare function appendUtmParamsToUrl(url: string): string;

Choose a reason for hiding this comment

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

[⚠️ correctness]
Clarify the behavior of appendUtmParamsToUrl when the url parameter already contains UTM parameters. This will help avoid potential conflicts or duplication of parameters.

url: getMarketingUrl('/talent'),
},
referralProgram: {
label: 'Referral Programme',

Choose a reason for hiding this comment

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

[💡 readability]
Consider using consistent spelling for 'Programme' as 'Program' to match the rest of the codebase and ensure uniformity across the application.

@kkartunov kkartunov merged commit 38b74ab into master Dec 17, 2025
12 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