Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
MisterPhilip committed Jan 8, 2020
2 parents 5f058d2 + b866091 commit 8944eab
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 38 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = function (grunt) {
},
"production": {
"name": "Omnibug",
"version": "1.13.1",
"version": "1.13.2",
"storageKey": "omnibug",
"feedbackUrl": "https://omnibug.io/feedback",
"analyticsID": "UA-114343677-2"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "omnibug",
"version": "1.13.1",
"version": "1.13.2",
"description": "Omnibug Extension",
"main": "Gruntfile.js",
"scripts": {
Expand Down
48 changes: 21 additions & 27 deletions src/providers/GoogleAds.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,25 @@
* @class
* @extends BaseProvider
*/
class GoogleAdsProvider extends BaseProvider
{
constructor()
{
class GoogleAdsProvider extends BaseProvider {
constructor() {
super();
this._key = "GOOGLEADS";
this._pattern = /googleads\.g\.doubleclick\.net\/pagead\//;
this._name = "Google Ads";
this._type = "marketing";
this._keywords = ["aw", "ad words"];
this._key = "GOOGLEADS";
this._pattern = /googleads\.g\.doubleclick\.net\/pagead\//;
this._name = "Google Ads";
this._type = "marketing";
this._keywords = ["aw", "ad words"];
}

/**
* Retrieve the column mappings for default columns (account, event type)
*
* @return {{}}
*/
get columnMapping()
{
get columnMapping() {
return {
"account": "omnibug-account",
"requestType": "requestType"
"account": "omnibug-account",
"requestType": "requestType"
}
}

Expand All @@ -35,8 +32,7 @@ class GoogleAdsProvider extends BaseProvider
*
* @returns {*[]}
*/
get groups()
{
get groups() {
return [
{
"key": "general",
Expand All @@ -50,8 +46,7 @@ class GoogleAdsProvider extends BaseProvider
*
* @returns {{}}
*/
get keys()
{
get keys() {
return {
"url": {
"name": "Page URL",
Expand Down Expand Up @@ -80,37 +75,36 @@ class GoogleAdsProvider extends BaseProvider
*
* @returns {Array}
*/
handleCustom(url, params)
{
handleCustom(url, params) {
let results = [],
pathParts = url.pathname.match(/\/([^\/]+)\/(\d+)\/?$/),
pathParts = url.pathname.match(/\/([^\/]+)\/(?:AW-)?(\d+)\/?$/),
account = "AW-" + pathParts[2],
data = params.get("data") || "",
dataEvent = data.match(/event=([^;]+)(?:$|;)/),
requestType = "";

/* istanbul ignore else */
if(account) {
if (account) {
results.push({
"key": "account",
"key": "account",
"field": "Account ID",
"value": account,
"group": "general"
});

// Add the conversion label, if available, to the accounts column
if(params.get("label")) {
if (params.get("label")) {
account += "/" + params.get("label");
}
results.push({
"key": "omnibug-account",
"key": "omnibug-account",
"value": account,
"hidden": true
});
}

if(dataEvent && dataEvent.length) {
if(dataEvent[1] === "gtag.config") {
if (dataEvent && dataEvent.length) {
if (dataEvent[1] === "gtag.config") {
requestType = "Page View"
} else {
requestType = dataEvent[1];
Expand All @@ -120,7 +114,7 @@ class GoogleAdsProvider extends BaseProvider
}

results.push({
"key": "requestType",
"key": "requestType",
"value": requestType,
"field": "Request Type",
"group": "general"
Expand Down
33 changes: 24 additions & 9 deletions test/providers/GoogleAds.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,36 @@ test("GoogleAdsProvider returns data", t => {

test("GoogleAdsProvider returns account", t => {
let provider = new GoogleAdsProvider(),
url = "https://googleads.g.doubleclick.net/pagead/viewthroughconversion/1111111/?random=1556397983526&cv=9&fst=1556397983526&num=1&bg=ffffff&guid=ON&resp=GooglemKTybQhCsO&u_h=1440&u_w=2560&u_ah=1400&u_aw=2560&u_cd=24&u_his=2&u_tz=-420&u_java=false&u_nplug=3&u_nmime=4&gtm=2ou430&sendb=1&data=event%3Dgtag.config&frm=0&url=https%3A%2F%2Fomnibug.io%2F&tiba=Omnibug%20%7C%20A%20Digital%20Marketing%20Debugging%20Tool&async=1&rfmt=3&fmt=4",
results = provider.parseUrl(url),
account = results.data.find((result) => {
urlOld = "https://googleads.g.doubleclick.net/pagead/viewthroughconversion/1111111/?random=1556397983526&cv=9&fst=1556397983526&num=1&bg=ffffff&guid=ON&resp=GooglemKTybQhCsO&u_h=1440&u_w=2560&u_ah=1400&u_aw=2560&u_cd=24&u_his=2&u_tz=-420&u_java=false&u_nplug=3&u_nmime=4&gtm=2ou430&sendb=1&data=event%3Dgtag.config&frm=0&url=https%3A%2F%2Fomnibug.io%2F&tiba=Omnibug%20%7C%20A%20Digital%20Marketing%20Debugging%20Tool&async=1&rfmt=3&fmt=4",
urlNew = "https://googleads.g.doubleclick.net/pagead/viewthroughconversion/AW-12345678/?random=1556397983526&cv=9&fst=1556397983526&num=1&bg=ffffff&guid=ON&resp=GooglemKTybQhCsO&u_h=1440&u_w=2560&u_ah=1400&u_aw=2560&u_cd=24&u_his=2&u_tz=-420&u_java=false&u_nplug=3&u_nmime=4&gtm=2ou430&sendb=1&data=event%3Dgtag.config&frm=0&url=https%3A%2F%2Fomnibug.io%2F&tiba=Omnibug%20%7C%20A%20Digital%20Marketing%20Debugging%20Tool&async=1&rfmt=3&fmt=4",
resultsOld = provider.parseUrl(urlOld),
resultsNew = provider.parseUrl(urlNew),
accountOld = resultsOld.data.find((result) => {
return result.key === "account";
}),
accountHidden = results.data.find((result) => {
accountNew = resultsNew.data.find((result) => {
return result.key === "account";
}),
accountHiddenOld = resultsOld.data.find((result) => {
return result.key === "omnibug-account";
}),
accountHiddenNew = resultsNew.data.find((result) => {
return result.key === "omnibug-account";
});

t.is(typeof account, "object");
t.is(account.field, "Account ID");
t.is(account.value, "AW-1111111");
t.is(typeof accountOld, "object");
t.is(accountOld.field, "Account ID");
t.is(accountOld.value, "AW-1111111");

t.is(typeof accountHidden, "object");
t.is(accountHidden.value, "AW-1111111");
t.is(typeof accountHiddenOld, "object");
t.is(accountHiddenOld.value, "AW-1111111");

t.is(typeof accountNew, "object");
t.is(accountNew.field, "Account ID");
t.is(accountNew.value, "AW-12345678");

t.is(typeof accountHiddenNew, "object");
t.is(accountHiddenNew.value, "AW-12345678");
});

test("GoogleAdsProvider returns account with conversion label", t => {
Expand Down

0 comments on commit 8944eab

Please sign in to comment.