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

Prebidmanager analytics adapter: fix console error when utm is null and collect page info #6002

Conversation

Prebid-Manager
Copy link
Contributor

Type of change

  • Bugfix
  • Feature
  • New bidder adapter
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Does this change affect user-facing APIs or examples documented on http://prebid.org?
  • Other

Description of change

  • fix console error when utm data in local storage is null
    prebid.js:3 Prebid ERROR: Prebid Manager Analytics: Error TypeError: Cannot read property 'length' of null

  • add collecting of page info (domain & referrer)


Be sure to test the integration with your adserver using the [Hello World](/integrationExamples/gpt/hello_world.html) sample page.

- contact email of the adapter’s maintainer
- [ ] official adapter submission

For any changes that affect user-facing APIs or example code documented on http://prebid.org, please provide:

- A link to a PR on the docs repo at https://github.com/prebid/prebid.github.io/

## Other information
<!-- References to related PR or issue #s, @mentions of the person or team responsible for reviewing changes, etc. -->

@@ -83,7 +83,7 @@ function collectUtmTagData() {
if (newUtm === false) {
utmTags.forEach(function (utmKey) {
let itemValue = localStorage.getItem(`pm_${utmKey}`);
if (itemValue.length !== 0) {
if (itemValue !== null && typeof itemValue !== 'undefined' && itemValue.length !== 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

very minor but simpler to just if (itemValue && itemValue.length !== 0) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

edited this line. thank you.

pageInfo.referrerDomain = utils.parseUrl(document.referrer).hostname;
}
return pageInfo;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

would be nice to add a unit test for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added a test in test/spec/modules/prebidmanagerAnalyticsAdapter_spec.js

@harpere harpere merged commit 6f147c6 into prebid:master Dec 1, 2020
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.

2 participants