Skip to content
Closed
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
10 changes: 8 additions & 2 deletions lib/addons/prebid/analytics.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,11 @@ Each sampled auction sends an `optable.prebid.auction` event with, among others:
`bidderRequests` (with per-bid `status`, `cpm`, `size`, `splitTestAssignment`),
`optableMatchers`, `optableSources`, `optableTargetingDone`, `liveintentEIDs`
(with per-bidder `hasLiEids` and `liSources`), `bidWon`, `missed`,
`url`, `tenant`, `prebidjsVersion`, `sessionDepth`, `pageAuctionsCount`,
`originSlug`, and the parsed `userAgent`/`device`.
`url`, `tenant`, `prebidjsVersion`, `rtdInstalled`, `rtdConfigured`,
`sessionDepth`, `pageAuctionsCount`, `originSlug`, and the parsed
`userAgent`/`device`.

`rtdInstalled` is `true` when `optableRtdProvider` is in `pbjs.installedModules`
(compiled into the Prebid build). `rtdConfigured` is `true` when
`realTimeData.dataProviders` contains a provider named `optable`. Together they
separate "module missing from the build" from "built in but not configured".
38 changes: 38 additions & 0 deletions lib/addons/prebid/analytics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,44 @@ describe("OptablePrebidAnalytics", () => {
expect(result.optableSources).toEqual(["uidapi.com", "id5-sync.com"]);
expect(result.liveintentEIDs).toEqual(["uidapi.com"]);
});

describe("RTD presence", () => {
const emptyAuction = { auctionId: "rtd-auction", bidderRequests: [] };

it("reports the RTD module as installed and configured", async () => {
(analytics as any).prebidInstance = {
installedModules: ["rtdModule", "optableRtdProvider"],
getConfig: jest.fn().mockReturnValue({ dataProviders: [{ name: "other" }, { name: "optable" }] }),
};

const result = await analytics.toWitness(emptyAuction, []);

expect(result.rtdInstalled).toBe(true);
expect(result.rtdConfigured).toBe(true);
expect((analytics as any).prebidInstance.getConfig).toHaveBeenCalledWith("realTimeData");
});

it("reports installed but not configured when no optable data provider is set", async () => {
(analytics as any).prebidInstance = {
installedModules: ["optableRtdProvider"],
getConfig: jest.fn().mockReturnValue(undefined),
};

const result = await analytics.toWitness(emptyAuction, []);

expect(result.rtdInstalled).toBe(true);
expect(result.rtdConfigured).toBe(false);
});

it("reports false for both when Prebid exposes neither installedModules nor getConfig", async () => {
(analytics as any).prebidInstance = {};

const result = await analytics.toWitness(emptyAuction, []);

expect(result.rtdInstalled).toBe(false);
expect(result.rtdConfigured).toBe(false);
});
});
});

describe("trackAuctionEnd", () => {
Expand Down
6 changes: 6 additions & 0 deletions lib/addons/prebid/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,12 @@ class OptablePrebidAnalytics {
userAgent: Bowser.parse(window.navigator.userAgent) as unknown as Record<string, any>,
device,
prebidjsVersion: this.prebidInstance?.version || "unknown",
// rtdInstalled: optableRtdProvider is compiled into the Prebid build.
// rtdConfigured: the "optable" provider is listed in realTimeData.dataProviders.
rtdInstalled: (this.prebidInstance?.installedModules ?? []).includes("optableRtdProvider"),
rtdConfigured: (this.prebidInstance?.getConfig?.("realTimeData")?.dataProviders ?? []).some(
(p: { name?: string }) => p?.name === "optable"
),
sessionDepth: sessionStorage?.optableSessionDepth || 1,
pageAuctionsCount: (window as any).optable?.pageAuctionsCount || 1,
originSlug: this.optableInstance?.dcn?.site || (window as any).optable?.site || "unknown",
Expand Down
4 changes: 4 additions & 0 deletions lib/addons/prototypes/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,10 @@ class OptablePrebidAnalytics {
tenant: this.config.tenant,
optableWrapperVersion: SDK_WRAPPER_VERSION, // eslint-disable-line no-undef
prebidjsVersion: this.prebidInstance?.version || "unknown",
rtdInstalled: (this.prebidInstance?.installedModules ?? []).includes("optableRtdProvider"),
rtdConfigured: (this.prebidInstance?.getConfig?.("realTimeData")?.dataProviders ?? []).some(
(p) => p?.name === "optable"
),
sessionDepth: sessionStorage?.optableSessionDepthIndex || 1,
pageAuctionsCount: window.optable?.pageAuctionIndex || 1,
originSlug: window.optable?.site || this.optableInstance?.dcn?.site || "unknown", // optable.site first since dcn is analytics always
Expand Down