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

Rubicon analytics #2278

Merged
merged 50 commits into from
Apr 10, 2018
Merged

Rubicon analytics #2278

merged 50 commits into from
Apr 10, 2018

Conversation

snapwich
Copy link
Collaborator

@snapwich snapwich commented Mar 16, 2018

Type of change

  • Feature
  • Bugfixes

Description of change

This includes the new Rubicon analytics adapter. The endpoint will be changed, but for now can be configured with the endpoint option when calling pbjs.enableAnalytics

            pbjs.enableAnalytics({
                provider: 'rubicon',
                options: {
                    endpoint: 'http://localhost:9999/event',
                    accountId: 1001
                }
            });

Other information

The karma testing library was updated to use the mocha reporter. It includes more information, better debug information (such as object diffing), and is just overall a better reporter than the progress-reporter.

An additional BIDDER_DONE event was added that signals when a bid adapter has finished responding to bids (this is a solution to better determine no-bids).

The SET_TARGETING event was modified to also pass the targeting that was set as an event argument.

Also a few bug fixes, such as cleaning up handlers left around by other analytics adapters (was causing errors in unrelated tests).

Copy link
Member

@mkendall07 mkendall07 left a comment

Choose a reason for hiding this comment

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

Overall LGTM. Just a few comments/questions.

@@ -112,6 +112,8 @@ function getAdUnitCopyForPrebidServer(adUnits) {
let adUnitsCopy = utils.deepClone(adUnits);

adUnitsCopy.forEach((adUnit) => {
// TODO: fix! this should probably happen in the adapter rather than here. now all the analytics adapters as well as
// `getBids` above need to deal w/ potentially two different size formats.
Copy link
Member

Choose a reason for hiding this comment

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

good callout

@@ -130,6 +137,7 @@ export default function AnalyticsAdapter({ url, analyticsType, global, handler }
utils._each(_handlers, (handler, event) => {
events.off(event, handler);
});
this.enableAnalytics = this._oldEnable ? this._oldEnable : _enable;
Copy link
Member

Choose a reason for hiding this comment

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

i'm not clear on what this change is for.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

enableAnalytics is overwritten w/ the error message function above when an analytics adapter is enabled. This new code I added sets enableAnalytics back to the correct enable function when analytics is disabled (can't just set it back to _enable as some analytics extend enalbeAnalytics with a new function).

Probably not a use case you'd encounter much in production (disabling analytics and then enabling again), but in test cases it was an issue. Many of the analytics adapters were causing issues with other test suites as they were not cleaning up their event handlers, probably in part because cleaning them up (using disableAnalytics) didn't allow you to listen again since enableAnalytics was overwritten; this fixes that.

@@ -194,7 +194,7 @@ $$PREBID_GLOBAL$$.setTargetingForAst = function() {
targeting.setTargetingForAst();

// emit event
events.emit(SET_TARGETING);
events.emit(SET_TARGETING, targeting.getAllTargeting());
Copy link
Member

Choose a reason for hiding this comment

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

do we doc the event signatures anywhere? Probably needs to be done since we are adding params.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nowhere that I know of. The events themselves are documented on the publisher API reference page, but it doesn't include details of what arguments the events pass to the event handlers.

I did add a new event bidderDone event though that should be added to that page. Just created a pull-request: prebid/prebid.github.io#695

@mkendall07 mkendall07 added LGTM needs 2nd review Core module updates require two approvals from the core team labels Mar 29, 2018
Copy link
Collaborator

@jaiminpanchal27 jaiminpanchal27 left a comment

Choose a reason for hiding this comment

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

@snapwich Looks good. Left some minor comments

case GOOD:
bid.status = 'success';
break;
case NO_BID:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There's still some instances that can result in NO_BIDs such as in prebid server adapter, currency module, etc. I'll probably leave this here just in case; I can remove later if NO_BIDs end up being removed entirely from the prebid code base.

};

// basically lodash#pick that also allows transformation functions and property renaming
function _pick(obj, properties) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we move this to utils ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We could, but I don't think it's necessary. I'd rather leave it here until such time that someone else decides they need to heavily utilize a pick function. Plus I deviated a bit from lodash's implementation of pick, which could be confusing for others to use if they're not familiar with my intent.

# Conflicts:
#	src/adaptermanager.js
@snapwich
Copy link
Collaborator Author

snapwich commented Apr 4, 2018

resolved conflicts

Copy link
Collaborator

@harpere harpere left a comment

Choose a reason for hiding this comment

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

LGTM

@harpere harpere removed the needs 2nd review Core module updates require two approvals from the core team label Apr 10, 2018
@snapwich snapwich merged commit 0bf6c7d into prebid:master Apr 10, 2018
@bretg
Copy link
Collaborator

bretg commented Apr 12, 2018

@mjacobsonny -- Rich submitted a doc change for the new bidderDone event. Any others you were looking for? We don't want to put this on the analytics adapter list just yet.

dluxemburg pushed a commit to Genius/Prebid.js that referenced this pull request Jul 17, 2018
rubicon analytics adapter
@idettman idettman deleted the rubicon-analytics branch February 29, 2020 06:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants