Skip to content
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

Permutive RTD Module: Add module name to storage manager and catch errors #6596

Merged
1 commit merged into from
Apr 26, 2021
Merged
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
23 changes: 17 additions & 6 deletions modules/permutiveRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
import { getGlobal } from '../src/prebidGlobal.js'
import { submodule } from '../src/hook.js'
import { getStorageManager } from '../src/storageManager.js'
import { deepSetValue, deepAccess, isFn, mergeDeep } from '../src/utils.js'
import { deepSetValue, deepAccess, isFn, mergeDeep, logError } from '../src/utils.js'
import includes from 'core-js-pure/features/array/includes.js'
const MODULE_NAME = 'permutive'

export const storage = getStorageManager()
export const storage = getStorageManager(null, MODULE_NAME)

function init (config, userConsent) {
return true
Expand Down Expand Up @@ -60,13 +61,19 @@ function setSegments (reqBidsConfigObj, config) {
customFn(bid, data, acEnabled, utils, defaultFn)
} else if (defaultFn) {
defaultFn(bid, data, acEnabled)
} else {

}
})
})
}

function makeSafe (fn) {
try {
fn()
} catch (e) {
logError(e)
}
}

function getCustomBidderFn (config, bidder) {
const overwriteFn = deepAccess(config, `params.overwrites.${bidder}`)

Expand Down Expand Up @@ -170,8 +177,12 @@ function readSegments (key) {

/** @type {RtdSubmodule} */
export const permutiveSubmodule = {
name: 'permutive',
getBidRequestData: initSegments,
name: MODULE_NAME,
getBidRequestData: function (reqBidsConfigObj, callback, customConfig) {
makeSafe(function () {
initSegments(reqBidsConfigObj, callback, customConfig)
})
},
init: init
}

Expand Down