Skip to content

Conversation

@tomheaton
Copy link
Member

Changes summary

Risks

Manual testing done

@tomheaton tomheaton self-assigned this Oct 28, 2025
@gemini-code-assist
Copy link

Summary of Changes

Hello @tomheaton, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request primarily focuses on integrating and configuring the SparkLayer B2B e-commerce solution within the application. It updates site identifiers, establishes a secure method for retrieving and exposing a SparkLayer authentication token to the client-side, and transitions the SparkLayer script loading to a production-ready CDN, ensuring the B2B features are correctly initialized and accessible.

Highlights

  • SparkLayer Site ID Update: The siteId for SparkLayer configurations has been consistently updated from "ecommercereclaim" to "wixcodux" across app/root.tsx and src/sparklayer/sparklayer.tsx.
  • SparkLayer Token Integration: A new mechanism in app/routes/members-area.my-account/route.tsx fetches a SparkLayer token via fetchWithAuth and makes it available to the frontend by assigning it to window.sparkWixToken.
  • Codux Configuration Update: The codux.config.json file has been updated with new projectId and metaSiteId values for Wix external providers.
  • SparkLayer Script Loading: The SparkLayer script in src/sparklayer/sparklayer.tsx now loads from a CDN (https://dev.sparkcdn.io) instead of a local development server.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces changes for SparkLayer integration, including configuration updates and new logic to fetch an authentication token. My review identifies several areas for improvement, primarily in app/routes/members-area.my-account/route.tsx. The feedback focuses on removing debugging artifacts, avoiding risky practices like monkey-patching global objects, and adopting more robust solutions for handling external URLs and global variables to enhance code quality and maintainability.

Comment on lines +28 to +38
const originalFetch = globalThis.fetch;

globalThis.fetch = async (input: RequestInfo | URL, init?: RequestInit) => {
const headers = init?.headers instanceof Headers
? Object.fromEntries(init.headers.entries())
: init?.headers;

console.log('[fetch] Request:', request);

return originalFetch(input, init);
};

Choose a reason for hiding this comment

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

high

Monkey-patching globalThis.fetch is a dangerous practice, especially in a server-side context. It can lead to unpredictable side effects and race conditions if requests are handled concurrently. This code appears to be for debugging and should be removed. If you need to inspect fetch requests during development, consider using a debugging proxy or other less intrusive methods.

};

// const response = await api.getWixClient().fetchWithAuth('https://03bf7894-a496-4460-b500-af40b7038e79.wix-app.run/functions/spark-current-member?siteId=wixcodux&siteEnv=live')
const response = await api.getWixClient().fetchWithAuth('https://9da4afbf-fe40-444f-9554-aadcd186caf8.wix-app.run/functions/spark-current-member?siteId=wixcodux&siteEnv=live')

Choose a reason for hiding this comment

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

high

This URL is hardcoded. Hardcoding configuration values like URLs makes it difficult to manage different environments (development, staging, production). It's a best practice to store such values in environment variables. For example, you could define SPARK_CURRENT_MEMBER_URL in your .env file.

Suggested change
const response = await api.getWixClient().fetchWithAuth('https://9da4afbf-fe40-444f-9554-aadcd186caf8.wix-app.run/functions/spark-current-member?siteId=wixcodux&siteEnv=live')
const response = await api.getWixClient().fetchWithAuth(process.env.SPARK_CURRENT_MEMBER_URL!)

Comment on lines +18 to +20
// eslint-disable-next-line no-console
console.log('HTTP_PROXY', process.env.HTTP_PROXY);

Choose a reason for hiding this comment

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

medium

This console.log statement appears to be for debugging purposes. It should be removed before merging into the main branch to keep the codebase clean and avoid leaking information in production logs.

Comment on lines +67 to +75
if (token) {
// eslint-disable-next-line no-console
console.log('token is defined', token);
// @ts-expect-error sparkWixToken is not defined on window
window.sparkWixToken = token;
} else {
// eslint-disable-next-line no-console
console.log('token is not defined');
}

Choose a reason for hiding this comment

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

medium

This block contains some temporary code that should be cleaned up:

  1. Debug logs: The console.log statements on lines 69 and 74 appear to be for debugging and should be removed.
  2. Unsafe global assignment: Assigning to window.sparkWixToken directly is not type-safe, as indicated by the @ts-expect-error. To fix this, you should extend the Window interface to make TypeScript aware of this property. You can do this by adding the following to a declaration file (e.g., remix.env.d.ts):
    declare global {
        interface Window {
            sparkWixToken?: string;
        }
    }
    export {};

This will provide type safety and allow you to remove the // @ts-expect-error comment.

    if (token) {
        window.sparkWixToken = token;
    }

@tomheaton tomheaton marked this pull request as draft November 14, 2025 17:22
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.

2 participants