Skip to content

Commit

Permalink
+Invoca
Browse files Browse the repository at this point in the history
Closes #259
  • Loading branch information
MisterPhilip committed Aug 4, 2024
1 parent 5baeee4 commit c19d2ea
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 0 deletions.
Binary file added src/assets/images/icons/INVOCA16x16.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 @@ -34,6 +34,7 @@ $icons: (
"Google Tag Manager": $iconPath + "GOOGLETAGMANAGER16x16.png",
"Hotjar": $iconPath + "HOTJAR16x16.png",
"Hubspot": $iconPath + "HUBSPOT16x16.png",
"Invoca": $iconPath + "INVOCA16x16.png",
"LinkedIn Conversion": $iconPath + "LINKEDINPIXEL16x16.png",
"Lytics": $iconPath + "LYTICS16x16.png",
"Matomo": $iconPath + "MATOMO16x16.png",
Expand Down
69 changes: 69 additions & 0 deletions src/providers/Invoca.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/**
* Invoca
* https://community.invoca.com/t5/developer-features/an-introduction-to-invocajs-the-technology-behind-your-invoca/ta-p/562
*
* @class
* @extends BaseProvider
*/
class InvocaProvider extends BaseProvider {
constructor() {
super();
this._key = "INVOCA";
this._pattern = /solutions\.invocacdn\.com\/.*\/tag-(draft|live)\.js/;
this._name = "Invoca";
this._type = "marketing";
this._keywords = ["call"];
}

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

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

/**
* Parse custom properties for a given URL
*
* @param {string} url
* @param {object} params
*
* @returns {void|Array}
*/
handleCustom(url, params) {
const libraryType = url.pathname.match(/\/tag-([^.]+)\.js/)[1];
return [
{
"key": "account",
"field": "Account ID",
"value": url.pathname.match(/\/(\d+\/\d+)\/tag-/)[1],
"group": "general"
},
{
"key": "_requestType",
"value": `Library Load (${libraryType})`,
"hidden": true,
}
];
}
}
56 changes: 56 additions & 0 deletions test/providers/Invoca.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import test from 'ava';

import { default as InvocaProvider } from "./../source/providers/Invoca.js";
import { OmnibugProvider } from "./../source/providers.js";

test("InvocaProvider returns provider information", t => {
let provider = new InvocaProvider();
t.is(provider.key, "INVOCA", "Key should always be INVOCA");
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("InvocaProvider pattern should match the loader script", t => {
let provider = new InvocaProvider(),
urls = [
"https://solutions.invocacdn.com/js/networks/1234/123123123/tag-live.js",
"https://solutions.invocacdn.com/js/networks/1234/123123123/tag-draft.js"
],
negativeUrls = [
"https://static.invoca.com/file.js"
];

urls.forEach((url) => {
t.true(provider.checkUrl(url), `Provider should match ${url}`);
});
negativeUrls.forEach((url) => {
t.false(provider.checkUrl(url), `Provider should not match non-provider url ${url}`);
});
});

test("OmnibugProvider returns InvocaProvider", t => {
let url = "https://solutions.invocacdn.com/js/networks/1234/123123123/tag-live.js";

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

test("InvocaProvider returns static data", t => {
let provider = new InvocaProvider(),
url = "https://solutions.invocacdn.com/js/networks/1234/123123123/tag-live.js";

let results = provider.parseUrl(url);

t.is(typeof results.provider, "object", "Results has provider information");
t.is(results.provider.key, "INVOCA", "Results provider is Invoca");
t.is(typeof results.data, "object", "Results has data");
t.true(results.data.length > 0, "Data is returned");

let account = results.data.find((result) => {
return result.key === "account";
});

t.is(account.value, "1234/123123123");
});

0 comments on commit c19d2ea

Please sign in to comment.