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

Bingads #226

Merged
merged 9 commits into from
Mar 23, 2021
Merged

Bingads #226

merged 9 commits into from
Mar 23, 2021

Conversation

1abhishekpandey
Copy link
Contributor

@1abhishekpandey 1abhishekpandey commented Mar 18, 2021

Description of the change

Provided support for BingAds in JS-sdk.

Type of change

  • New feature (non-breaking change that adds functionality)

Related issues

Fix #1

Checklists

Development

  • Lint rules pass locally
  • The code changed/added as part of this pull request has been covered with tests
  • All tests related to the changed code pass in development

Code review

  • This pull request has a descriptive title and information useful to a reviewer. There may be a screenshot or screencast attached
  • "Ready for review" label attached to the PR and reviewers mentioned in a comment
  • Changes have been reviewed by at least one other engineer
  • Issue from task tracker has a link to this pull request

This change is Reviewable

*/

track(rudderElement) {
const typeofcall = rudderElement.message.type;
Copy link
Contributor

Choose a reason for hiding this comment

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

lets destructure this.
const { type, properties } = rudderElement.message
Also, destructure the properties
const {category,currency,etc) = properties

var event = {
ea: typeofcall
};
if (properties.category) event.ec = properties.category;
Copy link
Contributor

Choose a reason for hiding this comment

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

lets use like
event.ec = category ? category : null

if (properties.category) event.ec = properties.category;
if (properties.currency) event.gc = properties.currency;
if (properties.value) event.gv = properties.value;
if (properties.label) event.el = properties.label;
Copy link
Contributor

Choose a reason for hiding this comment

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

don't we need ea? (event action)


init() {
logger.debug("===in init BingAds===");
console.log(window);
Copy link
Contributor

Choose a reason for hiding this comment

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

remove console

}

loadBingadsScript() {
var apikey = this.apikey;
Copy link
Contributor

Choose a reason for hiding this comment

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

lets follow es6. dont use var. here use destructuring.
const.

@@ -0,0 +1,66 @@
import logger from "../../utils/logUtil";
import ScriptLoader from "../ScriptLoader";
Copy link
Contributor

Choose a reason for hiding this comment

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

remove this import

this.loadBingadsScript();
}

isLoaded() {
Copy link
Contributor

Choose a reason for hiding this comment

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

isLoaded = () => use this type of syntax for all the function. read about this too.

window.uetq.push(event);
}

page(rudderElement) {
Copy link
Contributor

Choose a reason for hiding this comment

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

no need to pass rudderelement as it is not used in the function

track(rudderElement) {
const typeofcall = rudderElement.message.type;
const properties = rudderElement.message.properties;
var event = {
Copy link
Contributor

Choose a reason for hiding this comment

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

dont use var

@1abhishekpandey 1abhishekpandey requested a review from arnab-p March 22, 2021 07:38
@arnab-p arnab-p requested a review from sayan-mitra March 22, 2021 08:05
let event = {
ea: type
};
if (category) event.ec = category;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (category) event.ec = category;
if (category) {
event.ec = category;
}

For better readability. Also, apply the same to others.

if (currency) {
event.gc = currency;
}
if (value) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this seems like revenue value.
Do we support other keys where revenue can come from?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this is revenue value, it is used to set BingAds gv (Variable revenue currency) parameter.
For now, we support only one key.
More detail: Revenue comes from properties fields: e.g.,
rudderanalytics.track('track conversion', { category: 'MyCategory', value: 125, currency: 'INR', order_id: 'order_1' });
What changes will I need to do, please suggest.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think revenue and total can also be considered as valid keys.
@ruchiramoitra plz confirm

Copy link
Contributor

Choose a reason for hiding this comment

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

yes we should consider them too... value, revenue, total

@@ -56,6 +56,13 @@ class BingAds {
if (value) {
event.gv = value;
}
else if(revenue) {
Copy link
Contributor

Choose a reason for hiding this comment

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

let's use if's only to keep parity with others.
Also update the doc accordingly, the highest preference is total > revenue > value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please check it once more. If any other changes is needed or not.

Else is removed.
@sayan-mitra sayan-mitra merged commit 0b47274 into production-staging Mar 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants