Require explicit opt-in for SkipAgent
cgen-a9796ba56fe34d64b1f0d2e9ee3b8014
This commit is contained in:
parent
80ca82dbb2
commit
9458eb2fcb
1 changed files with 18 additions and 3 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import { useEffect } from "react";
|
||||
import { useLocation } from "react-router-dom";
|
||||
|
||||
import { setSkipAgentActive } from "@/lib/skip-agent";
|
||||
import { setSkipAgentActive, disableSkipAgent } from "@/lib/skip-agent";
|
||||
|
||||
const DOCS_PATH_PREFIX = "/docs";
|
||||
|
||||
|
|
@ -9,8 +9,23 @@ const SkipAgentController = () => {
|
|||
const location = useLocation();
|
||||
|
||||
useEffect(() => {
|
||||
const disableForDocs = location.pathname.startsWith(DOCS_PATH_PREFIX);
|
||||
void setSkipAgentActive(!disableForDocs);
|
||||
// Require an explicit opt-in to enable third-party agents.
|
||||
// Set `window.__AETHEX_ENABLE_SKIP_AGENT = true` in the browser console or a hosting config
|
||||
// to opt into loading partner SDKs outside of /docs pages.
|
||||
const optedIn = typeof window !== "undefined" && (window as any).__AETHEX_ENABLE_SKIP_AGENT === true;
|
||||
const onDocs = location.pathname.startsWith(DOCS_PATH_PREFIX);
|
||||
|
||||
if (optedIn && !onDocs) {
|
||||
void setSkipAgentActive(true);
|
||||
} else {
|
||||
// Ensure the agent is disabled by default or on docs routes
|
||||
disableSkipAgent();
|
||||
}
|
||||
|
||||
return () => {
|
||||
// Keep the agent disabled on unmount to avoid leaks across route changes
|
||||
disableSkipAgent();
|
||||
};
|
||||
}, [location.pathname]);
|
||||
|
||||
return null;
|
||||
|
|
|
|||
Loading…
Reference in a new issue