Skip to content

Commit

Permalink
Merge 30dd8ed into 74aac40
Browse files Browse the repository at this point in the history
  • Loading branch information
johndavidsimmons committed May 1, 2019
2 parents 74aac40 + 30dd8ed commit 8a92f0d
Show file tree
Hide file tree
Showing 4 changed files with 155 additions and 0 deletions.
Binary file added src/assets/images/icons/COMSCORE16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/styles/icons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ $icons: (
"Adobe Heartbeat": $iconPath + "ADOBEHEARTBEAT16x16.png",
"Adobe Launch": $iconPath + "ADOBELAUNCH16x16.png",
"Adobe Target": $iconPath + "ADOBETARGET16x16.png",
"Comscore": $iconPath + "COMSCORE16x16.png",
"Ensighten Manage": $iconPath + "ENSIGHTEN16x16.png",
"Facebook Pixel": $iconPath + "FACEBOOK16x16.png",
"Google Ads": $iconPath + "GOOGLEADS16x16.png",
Expand Down
67 changes: 67 additions & 0 deletions src/providers/Comscore.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* Comscore
* https://direct.comscore.com/clients/help/FAQ.aspx#faqTagging
*
* @class
* @extends BaseProvider
*/

class ComscoreProvider extends BaseProvider {
constructor() {
super();
this._key = "COMSCORE";
this._pattern = /sb\.scorecardresearch\.com(?!.*\.js($|[?#]))/;
this._name = "Comscore";
this._type = "marketing";
}

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

/**
* Retrieve the group names & order
*
* @returns {*[]}
*/
get groups() {
return [
{
key: "custom",
name: "Custom"
}
];
}

/**
* Parse a given URL parameter into human-readable form
*
* @param {string} name
* @param {string} value
*
* @returns {void|{}}
*/
handleQueryParam(name, value) {
let result = {};
const customRegex = /^c\S+$/;
if (name.match(customRegex)) {
result = {
key: name,
field: name,
value: value,
group: "custom"
};
} else {
result = super.handleQueryParam(name, value);
}
return result;
}
}
87 changes: 87 additions & 0 deletions test/providers/Comscore.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import test from "ava";

import { default as ComscoreProvider } from "./../source/providers/Comscore.js";
import { OmnibugProvider } from "./../source/providers.js";

test("Generic Comscore Provider Information", t => {
let provider = new ComscoreProvider();
t.is(provider.key, "COMSCORE", "Key should always be COMSCORE");
t.is(provider.type, "Marketing", "Type should always be marketing");
t.true(
typeof provider.name === "string" && provider.name !== "",
"Name should exist"
);
t.true(
typeof provider.pattern === "object" && provider.pattern instanceof RegExp,
"Pattern should be a RegExp value"
);
});

test("Pattern should match Comscore event requests", t => {
let provider = new ComscoreProvider(),
url =
"https://sb.scorecardresearch.com/p?c1=2&c2=123456789&ns_type=hidden&cv=2.0&cj=1&c4=https://www.example.com";

t.true(provider.checkUrl(url));

t.false(
provider.checkUrl("https://omnibug.io/testing"),
"Provider should not match on non-provider based URLs"
);
});

test("OmnibugProvider returns ComscoreProvider", t => {
let url =
"https://sb.scorecardresearch.com/p?c1=2&c2=123456789&ns_type=hidden&cv=2.0&cj=1&c4=https://www.example.com";

let results = OmnibugProvider.parseUrl(url);
t.true(
typeof results === "object" && results !== null,
"Results is a non-null object"
);
t.is(results.provider.key, "COMSCORE", "Results provider is Comscore");
});

test("Custom parameters group populates with c parameters", t => {
let provider = new ComscoreProvider(),
url =
"https://sb.scorecardresearch.com/p?c1=2&c2=123456789&ns_type=hidden&cv=2.0&cj=1&c4=https://www.example.com";

let results = provider.parseUrl(url);
let c4 = results.data.find(result => {
return result.key === "c4";
}),
cv = results.data.find(result => {
return result.key === "cv";
});

t.is(typeof c4, "object", "c4 data is an object");
t.is(c4.field, "c4", "c4 is field value");
t.is(
c4.value,
"https://www.example.com",
"c4 value is https://www.example.com"
);
t.is(c4.group, "custom", "c4 is in custom group");

t.is(typeof cv, "object", "cv data is an object");
t.is(cv.field, "cv", "cv is field value");
t.is(cv.value, "2.0", "cv value is 2.0");
t.is(cv.group, "custom", "cv is in custom group");
});

test("Other parameters group populates with non-c parameters", t => {
let provider = new ComscoreProvider(),
url =
"https://sb.scorecardresearch.com/p?c1=2&c2=123456789&ns_type=hidden&cv=2.0&cj=1&c4=https://www.example.com";

let results = provider.parseUrl(url);
let ns_type = results.data.find(result => {
return result.key === "ns_type";
});

t.is(typeof ns_type, "object", "ns_type data is an object");
t.is(ns_type.field, "ns_type", "ns_type is field value");
t.is(ns_type.value, "hidden", "ns_type value is hidden");
t.is(ns_type.group, "other", "ns_type is in other group");
});

0 comments on commit 8a92f0d

Please sign in to comment.