Skip to content

Commit

Permalink
remove old adloader#trackPixel (#1159)
Browse files Browse the repository at this point in the history
  • Loading branch information
snapwich authored and Nate Cozi committed May 2, 2017
1 parent 2652fc0 commit 7fde081
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 56 deletions.
20 changes: 0 additions & 20 deletions src/adloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,23 +83,3 @@ function requestResource(tagSrc, callback) {
elToAppend.insertBefore(jptScript, elToAppend.firstChild);
}
}

//track a impbus tracking pixel
//TODO: Decide if tracking via AJAX is sufficent, or do we need to
//run impression trackers via page pixels?
exports.trackPixel = function (pixelUrl) {
let delimiter;
let trackingPixel;

if (!pixelUrl || typeof (pixelUrl) !== 'string') {
utils.logMessage('Missing or invalid pixelUrl.');
return;
}

delimiter = pixelUrl.indexOf('?') > 0 ? '&' : '?';

//add a cachebuster so we don't end up dropping any impressions
trackingPixel = pixelUrl + delimiter + 'rnd=' + Math.floor(Math.random() * 1E7);
(new Image()).src = trackingPixel;
return trackingPixel;
};
36 changes: 0 additions & 36 deletions test/spec/adloader_spec.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,4 @@
describe('adLoader', function () {
var assert = require('chai').assert,
adLoader = require('../../src/adloader');

describe('trackPixel', function () {
it('correctly appends a cachebuster query paramter to a pixel with no existing parameters', function () {
var inputUrl = 'http://www.example.com/tracking_pixel',
token = '?rnd=',
expectedPartialUrl = inputUrl + token,
actual = adLoader.trackPixel(inputUrl),
actualPartialUrl = actual.split(token)[0] + token,
randomNumber = parseInt(actual.split(token)[1]);
assert.strictEqual(actualPartialUrl, expectedPartialUrl);
assert.isNumber(randomNumber);
});
});

it('correctly appends a cachebuster query paramter to a pixel with one existing parameter', function () {
var inputUrl = 'http://www.example.com/tracking_pixel?food=bard',
token = '&rnd=',
expectedPartialUrl = inputUrl + token,
actual = adLoader.trackPixel(inputUrl),
actualPartialUrl = actual.split(token)[0] + token,
randomNumber = parseInt(actual.split(token)[1]);
assert.strictEqual(actualPartialUrl, expectedPartialUrl);
assert.isNumber(randomNumber);
});

it('correctly appends a cachebuster query paramter to a pixel with multiple existing parameters', function () {
var inputUrl = 'http://www.example.com/tracking_pixel?food=bard&zing=zang',
token = '&rnd=',
expectedPartialUrl = inputUrl + token,
actual = adLoader.trackPixel(inputUrl),
actualPartialUrl = actual.split(token)[0] + token,
randomNumber = parseInt(actual.split(token)[1]);
assert.strictEqual(actualPartialUrl, expectedPartialUrl);
assert.isNumber(randomNumber);
});

});

0 comments on commit 7fde081

Please sign in to comment.