fix(frontend): reo tracker should be available only in the SaaS environment, not in self-hosted instances (#11367)

This commit is contained in:
Hiep Le 2025-10-14 22:16:45 +07:00 committed by GitHub
parent fe82cfd277
commit d991b9880d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 3 deletions

View File

@ -3,6 +3,7 @@ import { useConfig } from "./query/use-config";
import { useGitUser } from "./query/use-git-user";
import { getLoginMethod, LoginMethod } from "#/utils/local-storage";
import reoService, { ReoIdentity } from "#/utils/reo";
import { isProductionDomain } from "#/utils/utils";
/**
* Maps login method to Reo identity type
@ -92,10 +93,14 @@ export const useReoTracking = () => {
const { data: user } = useGitUser();
const [hasIdentified, setHasIdentified] = React.useState(false);
// Initialize Reo.dev when in SaaS mode
// Initialize Reo.dev when in SaaS mode and on the correct domain
React.useEffect(() => {
const initReo = async () => {
if (config?.APP_MODE === "saas" && !reoService.isInitialized()) {
if (
config?.APP_MODE === "saas" &&
isProductionDomain() &&
!reoService.isInitialized()
) {
await reoService.init();
}
};
@ -103,10 +108,11 @@ export const useReoTracking = () => {
initReo();
}, [config?.APP_MODE]);
// Identify user when user data is available and we're in SaaS mode
// Identify user when user data is available and we're in SaaS mode on correct domain
React.useEffect(() => {
if (
config?.APP_MODE !== "saas" ||
!isProductionDomain() ||
!user ||
hasIdentified ||
!reoService.isInitialized()

View File

@ -5,6 +5,7 @@ import { SuggestedTaskGroup } from "#/utils/types";
import { ConversationStatus } from "#/types/conversation-status";
import { GitRepository } from "#/types/git";
import { sanitizeQuery } from "#/utils/sanitize-query";
import { PRODUCT_URL } from "#/utils/constants";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
@ -49,6 +50,13 @@ export const isMobileDevice = (): boolean =>
"ontouchstart" in window ||
navigator.maxTouchPoints > 0;
/**
* Checks if the current domain is the production domain
* @returns True if the current domain matches the production URL
*/
export const isProductionDomain = (): boolean =>
window.location.origin === PRODUCT_URL.PRODUCTION;
interface EventActionHistory {
args?: {
LLM_API_KEY?: string;