-
Notifications
You must be signed in to change notification settings - Fork 2.4k
InsurAds Rtd Provider: initial release #14558
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
Merged
patmmccann
merged 43 commits into
prebid:master
from
InsurAds-Tech-SA:InsurAds-RtdProvider
Apr 13, 2026
Merged
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
17a7958
InsurAds Rtd Provider
JoseClimaco 8727523
Update Example with Rtd config
JoseClimaco b31e731
Enrich the slot with targeting
JoseClimaco d6501a3
Wait for context before executing the callback
JoseClimaco 7ee1108
Remove import not in use
JoseClimaco 2332963
Remove changes that are not needed anymore on interpretResponse and i…
JoseClimaco 6ed96d8
Update test/spec/modules/insuradsRtdProvider_spec.js
JoseClimaco b3cac8a
Clear keyvalues on non-ok responses
JoseClimaco bd5a981
Merge branch 'InsurAds-RtdProvider' of https://github.com/InsurAds-Te…
JoseClimaco 6a736e9
Initialize api call promise as resolved as per suggestion
JoseClimaco 9aaa627
Update test/spec/modules/insuradsRtdProvider_spec.js
JoseClimaco 5fcd496
Clear keyValues on error or empty responses
JoseClimaco 3ee870e
Merge branch 'InsurAds-RtdProvider' of https://github.com/InsurAds-Te…
JoseClimaco d84988a
Remove tests on functions that doesn't exist anymore
JoseClimaco 795c57a
Fix module name
JoseClimaco 170e9cc
Improve rtdData handling
JoseClimaco 429a512
Remove tests not needed
JoseClimaco 1443fcf
Merge branch 'master' into InsurAds-RtdProvider
JoseClimaco c72e629
Fix tests to match updated rtcData location
JoseClimaco b9dd435
Fix failing tests
JoseClimaco bf488fc
Merge branch 'master' into InsurAds-RtdProvider
JoseClimaco 7017904
Merge branch 'master' into InsurAds-RtdProvider
JoseClimaco c7f54b3
Merge branch 'master' into InsurAds-RtdProvider
JoseClimaco 70e4422
InsurAds RTD Provider: Register in parentModules map and standardize …
JoseClimaco 4947d49
InsurAds Bid Adapter: Replace any type with AdapterRequest in getRtdT…
JoseClimaco fdd8cc1
InsurAds RTD Provider: Remove keepalive option from fetch request
JoseClimaco 002d384
Merge branch 'InsurAds-RtdProvider' of https://github.com/InsurAds-Te…
JoseClimaco 1658da6
InsurAds RTD Provider: Remove hardcoded credentials to honor privacy …
JoseClimaco 4897db3
InsurAds RTD Provider: Fix unit test expectations for fetch options
JoseClimaco f3e215a
Merge branch 'master' into InsurAds-RtdProvider
JoseClimaco 1875cb2
InsurAds RTD Provider: type config and validate publicId
JoseClimaco a1ff9df
Merge branch 'InsurAds-RtdProvider' of https://github.com/InsurAds-Te…
JoseClimaco cd20030
Merge branch 'master' into InsurAds-RtdProvider
JoseClimaco c9ec7ec
Merge branch 'master' into InsurAds-RtdProvider
JoseClimaco 268d485
align docs with bidder-only enrichment
JoseClimaco dd0dff9
Merge branch 'InsurAds-RtdProvider' of https://github.com/InsurAds-Te…
JoseClimaco 8f449c0
Update test/spec/modules/insuradsBidAdapter_spec.js
JoseClimaco 84b9d6b
Merge branch 'InsurAds-RtdProvider' of https://github.com/InsurAds-Te…
JoseClimaco 13e76e6
make async test deterministic
JoseClimaco 546367c
Update modules/insuradsBidAdapter.ts
JoseClimaco 4a7863c
Update test/spec/modules/insuradsRtdProvider_spec.js
JoseClimaco be131ca
document params.timeout
JoseClimaco 0b7e18b
Merge branch 'InsurAds-RtdProvider' of https://github.com/InsurAds-Te…
JoseClimaco File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| ## InsurAds Real-time Data Submodule | ||
|
|
||
| The [InsurAds](https://insurads.com) real-time data module in Prebid enables publishers to leverage | ||
| contextual targeting and audience segmentation capabilities. This module provides real-time | ||
| key-value targeting data that seamlessly integrates into your existing Prebid deployment, | ||
| helping you maximize your advertising strategies. | ||
|
|
||
| ## Building Prebid with InsurAds Support | ||
|
|
||
| Compile the InsurAds RTD module into your Prebid build: | ||
|
|
||
| `gulp serve --modules=rtdModule,insuradsBidAdapter,insuradsRtdProvider` | ||
|
|
||
|
JoseClimaco marked this conversation as resolved.
|
||
| Please visit https://insurads.com/ for more information. | ||
|
|
||
| ```javascript | ||
| pbjs.setConfig({ | ||
| ... | ||
| realTimeData: { | ||
| auctionDelay: 1000, | ||
| dataProviders: [{ | ||
| name: 'insuradsRtd', | ||
| waitForIt: true, | ||
| params: { | ||
| publicId: 'YOUR_PUBLIC_ID', | ||
| timeout: 1000 | ||
| } | ||
| }] | ||
| } | ||
| ... | ||
| }); | ||
| ``` | ||
|
|
||
| ### Parameter Descriptions for the InsurAds Configuration Section | ||
|
|
||
| | Name | Type | Description | Notes | | ||
| |:------------------|:--------|:--------------------------------------------------------------------------|:-------------------------| | ||
| | name | String | Real time data module name | Always 'insuradsRtd' | | ||
| | waitForIt | Boolean | When true, delays the auction until this provider calls back (bounded by `auctionDelay` / `params.timeout`) | Optional. Defaults to false | | ||
| | params | Object | | | | ||
| | params.publicId | String | This is the Public ID value obtained from InsurAds | Required | | ||
| | params.timeout | Number | Max time (ms) to wait for the InsurAds API response before continuing the auction without enrichment | Optional. Defaults to 1000 | | ||
|
|
||
|
JoseClimaco marked this conversation as resolved.
JoseClimaco marked this conversation as resolved.
|
||
| ## Testing | ||
|
|
||
| To view an example of InsurAds RTD provider: | ||
|
|
||
| `gulp serve --modules=rtdModule,insuradsBidAdapter,insuradsRtdProvider` | ||
|
|
||
| and then point your browser at: | ||
|
|
||
| `http://localhost:9999/integrationExamples/gpt/insurads.html` | ||
|
|
||
| ## How It Works | ||
|
|
||
| The InsurAds RTD provider: | ||
|
|
||
| 1. Fetches contextual targeting data from the InsurAds API using your `publicId` | ||
| 2. Stores the returned key-values internally | ||
| 3. Enriches bid requests for the `insurads` bidder by attaching the key-values onto `bid.params.rtdData` | ||
| 4. Leaves other bidders unchanged | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| import { submodule } from '../src/hook.js'; | ||
| import { logInfo } from '../src/utils.js' | ||
| import { fetch } from '../src/ajax.js'; | ||
| import type { RtdProviderSpec } from './rtdModule/spec.ts'; | ||
|
|
||
| /** | ||
| * @typedef {import('../modules/rtdModule/index.js').RtdSubmodule} RtdSubmodule | ||
| */ | ||
|
|
||
| const SERVER_IP = 'https://services.insurads.com'; | ||
| const MODULE_NAME = 'insuradsRtd'; | ||
| const ENDPOINT = `${SERVER_IP}/core/init/prebid`; | ||
| const LOG_PREFIX = 'insurads Rtd: '; | ||
| const GVLID = 596; | ||
|
|
||
| // Internal state to store keyValues | ||
| let keyValues = {}; | ||
| let apiCallPromise = Promise.resolve(); | ||
|
|
||
| declare module './rtdModule/spec.ts' { | ||
| interface ProviderConfig { | ||
| insuradsRtd: { | ||
| params: { | ||
| publicId: string; | ||
| timeout?: number; | ||
| }; | ||
| }; | ||
| } | ||
| } | ||
|
|
||
| export const insuradsRtdProvider: RtdProviderSpec<'insuradsRtd'> = { | ||
| name: MODULE_NAME, | ||
| gvlid: GVLID, | ||
| init: (config, userConsent) => { | ||
| const publicId = config?.params?.publicId; | ||
|
|
||
| if (typeof publicId !== 'string' || publicId.trim().length === 0) { | ||
| logInfo(LOG_PREFIX + 'publicId is required and must be a non-empty string'); | ||
| return false; | ||
| } | ||
|
|
||
| // Reset keyValues to avoid stale values after failed/empty response | ||
| keyValues = {}; | ||
|
|
||
| // Start fetch immediately without blocking init | ||
| apiCallPromise = makeApiCall(publicId); | ||
|
|
||
|
JoseClimaco marked this conversation as resolved.
|
||
| logInfo(LOG_PREFIX + 'submodule init', config, userConsent); | ||
| return true; | ||
| }, | ||
| getBidRequestData: (reqBidsConfigObj, callback, config, userConsent) => { | ||
| logInfo(LOG_PREFIX + 'submodule getBidRequestData', reqBidsConfigObj, config, userConsent); | ||
|
|
||
| // Wait for API call to complete before enriching bid requests | ||
| const timeout = config?.params?.timeout || 1000; // Default 1 second timeout | ||
| const timeoutPromise = new Promise((resolve) => setTimeout(resolve, timeout)); | ||
|
|
||
|
JoseClimaco marked this conversation as resolved.
|
||
| Promise.race([apiCallPromise, timeoutPromise]) | ||
| .then(() => { | ||
| // Enrich bid requests with RTD data for insurads bidder | ||
| if (keyValues && Object.keys(keyValues).length > 0) { | ||
| reqBidsConfigObj.adUnits.forEach(adUnit => { | ||
| adUnit.bids.forEach(bid => { | ||
| if (bid.bidder === 'insurads') { | ||
| // Add RTD data to bid params so it can be accessed by the adapter | ||
| bid.params = bid.params || {}; | ||
|
|
||
| (bid.params as any).rtdData = keyValues; | ||
| logInfo(LOG_PREFIX + 'Enriched bid request for insurads', (bid.params as any).rtdData); | ||
| } | ||
| }); | ||
| }); | ||
| } else { | ||
| logInfo(LOG_PREFIX + 'No keyValues available for bid enrichment'); | ||
| } | ||
|
|
||
| callback(); | ||
| }) | ||
| .catch((_e) => { | ||
| logInfo(LOG_PREFIX + 'Error waiting for API call'); | ||
| callback(); | ||
| }); | ||
| }, | ||
| }; | ||
|
|
||
| async function makeApiCall(publicId: string) { | ||
| const currentUrl = encodeURIComponent(location.href); | ||
|
|
||
| try { | ||
| const response = await fetch(`${ENDPOINT}/${publicId}?url=${currentUrl}`, { | ||
| method: 'GET', | ||
| headers: { | ||
| 'Content-Type': 'application/json' | ||
| } | ||
| }); | ||
| if (!response.ok) { | ||
| keyValues = {}; | ||
| logInfo(LOG_PREFIX + `Network error: ${response.status} ${response.statusText}, cleared cached values`); | ||
| return; | ||
| } | ||
| if (response.status === 204) { | ||
| keyValues = {}; | ||
| logInfo(LOG_PREFIX + '204 No Content received, cleared cached values'); | ||
| return; | ||
| } | ||
|
|
||
| const data = await response.json(); | ||
| if (data && data.keyValues) { | ||
| keyValues = data.keyValues; | ||
| logInfo(LOG_PREFIX + 'Received keyValues from endpoint', data.keyValues); | ||
|
JoseClimaco marked this conversation as resolved.
|
||
| } else { | ||
| keyValues = {}; | ||
| logInfo(LOG_PREFIX + 'No keyValues in response, cleared cached values'); | ||
| } | ||
| } catch (_e) { | ||
| keyValues = {}; | ||
| logInfo(LOG_PREFIX + 'API call failed, cleared cached keyValues'); | ||
| } | ||
| } | ||
|
|
||
| function beforeInit() { | ||
| // take actions to get data as soon as possible | ||
| submodule('realTimeData', insuradsRtdProvider); | ||
| } | ||
|
|
||
| beforeInit(); | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.