Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions lib/core/flags.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,20 @@ if (controlGroup === "1") {

## Available flags

| Flag | Read by | Effect |
| --------------------------- | ---------------------- | ------------------------------------------------------------------------------------- |
| `optableDebug` | `debugLog`, RTD module | Verbose logging. |
| `optableDisableConsent` | `getConsent` | Bypass the CMP and treat all permissions as granted. |
| `optableControlGroup` | `setupAB` | `1` forces the control variant, `0` forces treatment. Two-state — read the raw value. |
| `optableForceTargeting` | wrapper code | Re-run targeting even when a session guard says it already ran. |
| `optableForceTokenize` | wrapper code | Re-run tokenize even when a session guard says it already ran. |
| `optableForceGlobalRouting` | `buildRTD` | Route every EID to `global` instead of per-bidder. |
| `optableForceSkipMerge` | `buildRTD` | Skip merging EIDs into the auction entirely. |
| `optableResolve1P` | wrapper code | Resolve using a first-party test identifier. |
| `optableResolve3P` | wrapper code | Resolve using a third-party test IP. |
| `optableEnableAnalytics` | wrapper code | Force analytics on, ignoring the sampling rate. |
| `optableResolveId5` | wrapper code | Return a placeholder ID5 value without loading the ID5 API. |
| `optableResolveID5ID` | wrapper code | Return a specific ID5 value without loading the ID5 API. |
| Flag | Read by | Effect |
| --------------------------- | ---------------------------------------- | ------------------------------------------------------------------------------------- |
| `optableDebug` | `debugLog`, `optableMessage`, RTD module | Verbose logging. |
| `optableDisableConsent` | `getConsent` | Bypass the CMP and treat all permissions as granted. |
| `optableControlGroup` | `setupAB` | `1` forces the control variant, `0` forces treatment. Two-state — read the raw value. |
| `optableForceTargeting` | wrapper code | Re-run targeting even when a session guard says it already ran. |
| `optableForceTokenize` | wrapper code | Re-run tokenize even when a session guard says it already ran. |
| `optableForceGlobalRouting` | `buildRTD` | Route every EID to `global` instead of per-bidder. |
| `optableForceSkipMerge` | `buildRTD` | Skip merging EIDs into the auction entirely. |
| `optableResolve1P` | wrapper code | Resolve using a first-party test identifier. |
| `optableResolve3P` | wrapper code | Resolve using a third-party test IP. |
| `optableEnableAnalytics` | wrapper code | Force analytics on, ignoring the sampling rate. |
| `optableResolveId5` | wrapper code | Return a placeholder ID5 value without loading the ID5 API. |
| `optableResolveID5ID` | wrapper code | Return a specific ID5 value without loading the ID5 API. |

"Wrapper code" means the flag is recognised and persisted by the SDK, but acted on by the bundle built around it. Unknown query parameters are ignored — only the keys above are parsed.

Expand Down
31 changes: 30 additions & 1 deletion lib/core/log.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { consoleLog, debugLog } from "./log";
import { consoleLog, debugLog, optableMessage } from "./log";
import { resetFlags } from "./flags";

beforeEach(() => {
Expand Down Expand Up @@ -45,6 +45,35 @@ describe("debugLog", () => {
});
});

describe("optableMessage", () => {
it("is silent when optableDebug is not set", () => {
const spy = jest.spyOn(console, "log").mockImplementation(() => {});
optableMessage("hello");
expect(spy).not.toHaveBeenCalled();
spy.mockRestore();
});

it("logs with the wrapper prefix and passes arguments through", () => {
sessionStorage.setItem("optableDebug", "1");
resetFlags();

const spy = jest.spyOn(console, "log").mockImplementation(() => {});
optableMessage("hello", { detail: 1 });
expect(spy).toHaveBeenCalledWith("[OPTABLE WRAPPER]", "hello", { detail: 1 });
spy.mockRestore();
});

it("stays silent when optableDebug is explicitly disabled", () => {
sessionStorage.setItem("optableDebug", "0");
resetFlags();

const spy = jest.spyOn(console, "log").mockImplementation(() => {});
optableMessage("hello");
expect(spy).not.toHaveBeenCalled();
spy.mockRestore();
});
});

describe("consoleLog", () => {
it("writes unconditionally with the given prefix", () => {
const spy = jest.spyOn(console, "warn").mockImplementation(() => {});
Expand Down
10 changes: 9 additions & 1 deletion lib/core/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,12 @@ function debugLog(level: string, message: string, ...args: any[]): void {
}
}

export { consoleLog, debugLog };
// Debug logger for wrapper bundles, gated on the optableDebug flag. The
// "[OPTABLE WRAPPER]" prefix is what QA filters on.
function optableMessage(...args: any[]): void {
if (flagEnabled("optableDebug")) {
console.log("[OPTABLE WRAPPER]", ...args); // eslint-disable-line no-console
}
}

export { consoleLog, debugLog, optableMessage };