Skip to content

Commit

Permalink
preliminary changes for creating separate namespace for ih only profi…
Browse files Browse the repository at this point in the history
…le (#539)

* preliminary changes for creating separate namespace for ih only profile

* changes for replacing owpbjs namespace

* changes to support ihpwt and pwt namespaces in sso flow
  • Loading branch information
pm-manasi-moghe authored Jul 12, 2022
1 parent ca22a8a commit 4085583
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
9 changes: 4 additions & 5 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ console.timeEnd('Loading Plugins in Prebid');
const FAKE_SERVER_HOST = argv.host ? argv.host : 'localhost';
const FAKE_SERVER_PORT = 4444;
const { spawn } = require('child_process');

prebid.profile = argv.profile;
// these modules must be explicitly listed in --modules to be included in the build, won't be part of "all" modules
var explicitModules = [
'pre1api'
Expand Down Expand Up @@ -164,7 +164,6 @@ function makeDevpackPkg() {

const analyticsSources = helpers.getAnalyticsSources();
const moduleSources = helpers.getModulePaths(externalModules);

return gulp.src([].concat(moduleSources, analyticsSources, 'src/prebid.js'))
.pipe(helpers.nameModules(externalModules))
.pipe(webpackStream(cloned, webpack))
Expand Down Expand Up @@ -257,7 +256,7 @@ function bundle(dev, moduleArr) {
// gutil.log('Concatenating files:\n', entries);
// gutil.log('Appending ' + prebid.globalVarName + '.processQueue();');
// gutil.log('Generating bundle:', outputFileName);

var globalVarName = /*argv.profile === "IH" ? prebid.ihGlobalVarName : */ prebid.globalVarName;
return gulp.src(
entries
)
Expand All @@ -266,7 +265,7 @@ function bundle(dev, moduleArr) {
.pipe(gulpif(dev, sourcemaps.init({ loadMaps: true })))
.pipe(concat(outputFileName))
.pipe(gulpif(!argv.manualEnable, footer('\n<%= global %>.processQueue();', {
global: prebid.globalVarName
global: globalVarName
}
)))
.pipe(gulpif(dev, sourcemaps.write('.')));
Expand Down Expand Up @@ -457,4 +456,4 @@ gulp.task('bundle', gulpBundle.bind(null, false)); // used for just concatenatin
gulp.task(viewReview);
gulp.task('review-start', gulp.series(clean, lint, gulp.parallel('build-bundle-dev', watch, testCoverage), viewReview));

module.exports = nodeBundle;
module.exports = nodeBundle;
18 changes: 11 additions & 7 deletions modules/userId/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -799,9 +799,14 @@ function setUserIdentities(userIdentityData) {
delete userIdentityData.pubProvidedEmail;
}
Object.assign(userIdentity, userIdentityData);
if (window.PWT && window.PWT.loginEvent) {
if ((window.IHPWT && window.IHPWT.loginEvent) || (window.PWT && window.PWT.loginEvent)) {
reTriggerPartnerCallsWithEmailHashes();
window.PWT.loginEvent = false;
if (window.IHPWT) {
window.IHPWT.loginEvent = false;
}
if (window.PWT) {
window.PWT.loginEvent = false;
}
}
};

Expand All @@ -821,7 +826,7 @@ export function updateModuleParams(moduleToUpdate) {
if (!params) return;

let userIdentity = getUserIdentities() || {};
let enableSSO = (window.PWT && window.PWT.ssoEnabled) || false;
let enableSSO = (window.IHPWT && window.IHPWT.ssoEnabled) || (window.PWT && window.PWT.ssoEnabled) || false;
let emailHashes = enableSSO && userIdentity.emailHash ? userIdentity.emailHash : userIdentity.pubProvidedEmailHash ? userIdentity.pubProvidedEmailHash : undefined;
params.forEach(function(param) {
moduleToUpdate.params[param.key] = (moduleToUpdate.name === 'id5Id' ? getRawPDString(emailHashes, userIdentity.userID) : emailHashes ? emailHashes[param.hashType] : undefined);
Expand Down Expand Up @@ -887,9 +892,8 @@ function getUserIdentities() {
function processFBLoginData(refThis, response) {
let emailHash = {};
if (response.status === 'connected') {
window.PWT = window.PWT || {};
window.PWT.fbAt = response.authResponse.accessToken;
window.FB && window.FB.api('/me?fields=email&access_token=' + window.PWT.fbAt, function (response) {
// window.IHPWT = window.IHPWT || {};
window.FB && window.FB.api('/me?fields=email&access_token=' + response.authResponse.accessToken, function (response) {
logInfo('SSO - Data received from FB API');
if (response.error) {
logInfo('SSO - User information could not be retrieved by facebook api [', response.error.message, ']');
Expand All @@ -915,7 +919,7 @@ function onSSOLogin(data) {
let refThis = this;
let email;
let emailHash = {};
if (!window.PWT || !window.PWT.ssoEnabled) return;
if ((window.IHPWT && !window.IHPWT.ssoEnabled) || (window.PWT && !window.PWT.ssoEnabled)) return;

switch (data.provider) {
case undefined:
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"prebid"
],
"globalVarName": "owpbjs",
"ihGlobalVarName": "ihowpbjs",
"author": "the prebid.js contributors",
"license": "Apache-2.0",
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion plugins/pbjsGlobals.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ let prebid = require('../package.json');
const path = require('path');

module.exports = function(api, options) {
const pbGlobal = options.globalVarName || prebid.globalVarName;
const pbGlobal = prebid.profile === "IH" ? prebid.ihGlobalVarName : prebid.globalVarName; //options.globalVarName || prebid.globalVarName;
let replace = {
'$prebid.version$': prebid.version,
'$$PREBID_GLOBAL$$': pbGlobal,
Expand Down
2 changes: 1 addition & 1 deletion webpack.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module.exports = {
return entry;
})(),
output: {
chunkLoadingGlobal: prebid.globalVarName + 'Chunk',
chunkLoadingGlobal: (argv.profile === 'IH' ? prebid.ihGlobalVarName : prebid.globalVarName ) + 'Chunk',
chunkLoading: 'jsonp',
},
module: {
Expand Down

0 comments on commit 4085583

Please sign in to comment.