Skip to content

add initPrebidAnalytics to prebid analytics addon#305

Open
etiennelatendresse-optable wants to merge 2 commits into
masterfrom
add-prebidanalytics
Open

add initPrebidAnalytics to prebid analytics addon#305
etiennelatendresse-optable wants to merge 2 commits into
masterfrom
add-prebidanalytics

Conversation

@etiennelatendresse-optable

@etiennelatendresse-optable etiennelatendresse-optable commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Why

Using the prebid analytics addon would previously require some boilerplate code in order to initialize it.

What Changed

  • Add initPrebidAnalytics to the prebid analytics addon (lib/addons/prebid/analytics.ts)
  • Takes the SDK constructor as a parameter so the module keeps a type-only SDK import
  • Forwards the analytics config straight to the OptablePrebidAnalytics constructor, so options such as getSplitTestAssignment (Get splitTestAssignment from SDK bundle, if provided #304) flow through without extra plumbing.
  • Tests + README for the new helper.

Notes

Composes with #304 (splitTestAssignment) rather than duplicating it.

How to Test

  • Tested
  • Docs / README updated

@etiennelatendresse-optable etiennelatendresse-optable changed the title add initPrebidAnalytics addon Add initPrebidAnalytics bootstrap to the prebid analytics addon Jul 17, 2026
@etiennelatendresse-optable etiennelatendresse-optable changed the title Add initPrebidAnalytics bootstrap to the prebid analytics addon add initPrebidAnalytics to prebid analytics addon Jul 17, 2026
@mosherBT
mosherBT force-pushed the add-prebidanalytics branch from 73803e0 to a51d386 Compare July 21, 2026 17:26
* the Witness payload, overriding any value already present on the bid. Use this
* to attach A/B assignment without mutating Prebid events yourself.
*/
getSplitTestAssignment?: () => string | undefined;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is this name "get" and why is this a function instead of a string ? Would be simpler if it was splitTestAssignment and accept a string, no ?

SDK: OptableSDK,
instance: { host: "na.edge.optable.co", node: "my-tenant", site: "my-site" },
analytics: {
tenant: "my-tenant",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I believe this could be remove and just use the value in instance.node, since it needs to match anyway (unless I am mistaken)

| -------------- | ------------------------------- | ---------- | ---------------------------------------------------------------------------------------------------- |
| `SDK` | `new (config) => OptableSDK` | required | The Optable SDK constructor. Passed in so this module keeps a type-only SDK import. |
| `instance` | `InitConfig` | required | Config for the read-only analytics SDK (`host`/`node`/`site`/…). `readOnly`/`cookies` default false. |
| `pbjs` | `object` | — | Prebid.js instance to hook into. When omitted, `window[prebidGlobal]` is used. |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd rename this prebidInstanceObject, or pbjsInstanceObject

| `SDK` | `new (config) => OptableSDK` | required | The Optable SDK constructor. Passed in so this module keeps a type-only SDK import. |
| `instance` | `InitConfig` | required | Config for the read-only analytics SDK (`host`/`node`/`site`/…). `readOnly`/`cookies` default false. |
| `pbjs` | `object` | — | Prebid.js instance to hook into. When omitted, `window[prebidGlobal]` is used. |
| `prebidGlobal` | `string` | `"pbjs"` | Window key used to find Prebid when `pbjs` is not passed. |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd rename this prebidInstanceName, or pbjsInstanceName, but have both align, either both pbjs or both prebid

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.

3 participants