-
Notifications
You must be signed in to change notification settings - Fork 2
feat(prebid): add Prebid.js analytics integration addon #241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add OptablePrebidAnalytics class to track auction and bid events from Prebid.js and send them to Optable's witness API. The addon supports configurable sampling rates, debug logging, and custom analytics data injection. Key features: - Tracks auctionEnd and bidWon events with detailed bid request/response data - Extracts and reports Optable EID matchers and sources from ORTB2 data - Implements deterministic and random sampling strategies - Handles missed events by processing Prebid's event history The witness API type definition is updated to support nested objects and arrays in event properties to accommodate complex auction data structures.
Add new fields to improve analytics tracking and debugging: - Replace 'missed' with 'optableLoaded' for clearer semantics - Rename 'hasOptable' to 'optableTargetingDone' for consistency - Include 'optableSampling' rate in witness payload - Add 'userAgent' to payload for better debugging - Expose 'optableTargetingDone' at bidder request level
jrosendahl-opt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two questions about sampling and handling auctions with no bid won events.
If i missed where this is happening, please feel free to explain.
Introduce `bidWinTimeout` to track bid win events. If a bid win is not received within the configured timeout after an auction ends, a witness event is sent with `bidWon: null` to indicate a missed bid. Add `samplingVolume` configuration, allowing analytics sampling to be applied either per `event` (default) or per `session`. Session-based sampling ensures a consistent sampling decision for a user throughout their browsing session. The analytics payload is enhanced with `auctionEndAt`, `bidWonAt`, and `optableLoaded` fields, and the `bidWon` object can now be `null` to explicitly represent cases where no bid was won or tracked. Update `witness.ts` to allow `null` values in the witness payload properties. Refactor `analytics.test.ts` to simplify `eids` structure and remove redundant fields.
932ed9e to
adfc6c3
Compare
Clears the `auctionEndTimeoutId` when a bid is won to prevent it from firing after the auction is complete. Additionally, removes the auction object from the internal map to prevent memory leaks and ensure proper resource cleanup.
Yoshiji
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM. Thank you for the test coverage 👍
Moves device object assignment to a higher scope for consistent use across the analytics payload. Removes the redundant `userAgentRaw` field, as the parsed `userAgent` is already available.
domngco
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add comprehensive JSDoc documentation to the `OptablePrebidAnalytics` class methods to improve maintainability and developer experience. Refactor type handling for global `optable` access to avoid `@ts-ignore` and ensure the `OptablePrebidAnalytics` constructor is available on the global SDK object. This ensures better integration between the browser SDK and the Prebid analytics addon.
Add pnpm-workspace.yaml and update pnpm-lock.yaml to define the project as a monorepo. This enables workspace-aware dependency management and prepares the repository for multi-package support.
Add Node.js type definitions to the project dependencies to improve type safety and development tooling support.
Update the reusable build workflow to use the `--prefix` flag for React and NPM demo builds. This ensures the build commands are executed within the correct subdirectories following the migration to pnpm workspaces.
Remove the `defaults.run.working-directory` configuration from the `build-react-demo` and `build-npm-demo` jobs. These settings are no longer necessary as the build commands now specify their own paths or prefixes.
Correct the directory path from `demo/` to `demos/` in the build steps to match the actual project structure.
Set working-directory defaults for React and NPM demo build jobs to simplify build commands. Remove the pnpm-workspace.yaml file as it is no longer required for this workflow configuration.
Add OptablePrebidAnalytics class to track auction and bid events from Prebid.js and send them to Optable's witness API. The addon supports configurable sampling rates, debug logging, and custom analytics data injection.
Key features:
The witness API type definition is updated to support nested objects and arrays in event properties to accommodate complex auction data structures.