Skip to content

Commit

Permalink
Merge pull request #46 from Moesif/no-referrer-if-same-domain
Browse files Browse the repository at this point in the history
support search string for some non-conforming uris.
  • Loading branch information
dgilling authored Apr 2, 2021
2 parents b7bc2e5 + c10e30f commit 391afd2
Show file tree
Hide file tree
Showing 14 changed files with 218 additions and 156 deletions.
31 changes: 20 additions & 11 deletions build/moesif.amd.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ define(function () { 'use strict';

var Config = {
DEBUG: false,
LIB_VERSION: '1.8.3'
LIB_VERSION: '1.8.5'
};

// since es6 imports are static and we run unit tests from the console, window won't be defined when importing this file
Expand Down Expand Up @@ -971,6 +971,21 @@ define(function () { 'use strict';
return tmp_arr.join(arg_separator);
};

function splitFromQuestionMark(myHref) {
if (myHref) {
var startOfQuery = myHref.indexOf('?');
if (startOfQuery >= 0) {
var res = myHref.substring(startOfQuery);
return res;
}
}
return '';
}

_.getUrlParams = function() {
return location && (location.search || splitFromQuestionMark(location.href));
};

_.getQueryParamByName = function(name, query) {
// expects a name
// and a query string. aka location part.
Expand Down Expand Up @@ -2303,6 +2318,8 @@ define(function () { 'use strict';
}
}

// eslint-disable-line

var logger$5 = console_with_prefix('referrer');

function _getReferrerStr() {
Expand Down Expand Up @@ -2354,10 +2371,6 @@ define(function () { 'use strict';
UTM_CONTENT: 'utm_content'
};

function _getUrlParams$1() {
return location && location.search;
}

function getUtmData(rawCookie, query) {
// Translate the utmz cookie format into url query string format.
var cookie = rawCookie ? '?' + rawCookie.split('.').slice(-1)[0].replace(/\|/g, '&') : '';
Expand Down Expand Up @@ -2393,7 +2406,7 @@ define(function () { 'use strict';
}

function getUtm(queryParams, cookieParams) {
queryParams = _getUrlParams$1();
queryParams = _.getUrlParams();
cookieParams = _.cookie.get('__utmz');
var utmProperties = getUtmData(cookieParams, queryParams);
return utmProperties;
Expand Down Expand Up @@ -2512,10 +2525,6 @@ define(function () { 'use strict';

var logger$4 = console_with_prefix('campaign');

function _getUrlParams() {
return location && location.search;
}

function getGclid(urlParams) {
var gclid = _.getQueryParamByName('gclid', urlParams);
if (_.isEmptyString(gclid)) {
Expand All @@ -2540,7 +2549,7 @@ define(function () { 'use strict';
}
}
if (!opt.disableRGclid) {
var gclid = getGclid(_getUrlParams());
var gclid = getGclid(_.getUrlParams());
if (gclid) {
result['gclid'] = gclid;
}
Expand Down
31 changes: 20 additions & 11 deletions build/moesif.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

var Config = {
DEBUG: false,
LIB_VERSION: '1.8.3'
LIB_VERSION: '1.8.5'
};

// since es6 imports are static and we run unit tests from the console, window won't be defined when importing this file
Expand Down Expand Up @@ -971,6 +971,21 @@ _.HTTPBuildQuery = function(formdata, arg_separator) {
return tmp_arr.join(arg_separator);
};

function splitFromQuestionMark(myHref) {
if (myHref) {
var startOfQuery = myHref.indexOf('?');
if (startOfQuery >= 0) {
var res = myHref.substring(startOfQuery);
return res;
}
}
return '';
}

_.getUrlParams = function() {
return location && (location.search || splitFromQuestionMark(location.href));
};

_.getQueryParamByName = function(name, query) {
// expects a name
// and a query string. aka location part.
Expand Down Expand Up @@ -2303,6 +2318,8 @@ function patch(recorder, env) {
}
}

// eslint-disable-line

var logger$5 = console_with_prefix('referrer');

function _getReferrerStr() {
Expand Down Expand Up @@ -2354,10 +2371,6 @@ var UTMConstants = { // UTM Params
UTM_CONTENT: 'utm_content'
};

function _getUrlParams$1() {
return location && location.search;
}

function getUtmData(rawCookie, query) {
// Translate the utmz cookie format into url query string format.
var cookie = rawCookie ? '?' + rawCookie.split('.').slice(-1)[0].replace(/\|/g, '&') : '';
Expand Down Expand Up @@ -2393,7 +2406,7 @@ function getUtmData(rawCookie, query) {
}

function getUtm(queryParams, cookieParams) {
queryParams = _getUrlParams$1();
queryParams = _.getUrlParams();
cookieParams = _.cookie.get('__utmz');
var utmProperties = getUtmData(cookieParams, queryParams);
return utmProperties;
Expand Down Expand Up @@ -2512,10 +2525,6 @@ function clearLocalStorage(opt) {

var logger$4 = console_with_prefix('campaign');

function _getUrlParams() {
return location && location.search;
}

function getGclid(urlParams) {
var gclid = _.getQueryParamByName('gclid', urlParams);
if (_.isEmptyString(gclid)) {
Expand All @@ -2540,7 +2549,7 @@ function getCampaignDataFromUrlOrCookie(opt) {
}
}
if (!opt.disableRGclid) {
var gclid = getGclid(_getUrlParams());
var gclid = getGclid(_.getUrlParams());
if (gclid) {
result['gclid'] = gclid;
}
Expand Down
31 changes: 20 additions & 11 deletions build/moesif.globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

var Config = {
DEBUG: false,
LIB_VERSION: '1.8.3'
LIB_VERSION: '1.8.5'
};

// since es6 imports are static and we run unit tests from the console, window won't be defined when importing this file
Expand Down Expand Up @@ -972,6 +972,21 @@
return tmp_arr.join(arg_separator);
};

function splitFromQuestionMark(myHref) {
if (myHref) {
var startOfQuery = myHref.indexOf('?');
if (startOfQuery >= 0) {
var res = myHref.substring(startOfQuery);
return res;
}
}
return '';
}

_.getUrlParams = function() {
return location && (location.search || splitFromQuestionMark(location.href));
};

_.getQueryParamByName = function(name, query) {
// expects a name
// and a query string. aka location part.
Expand Down Expand Up @@ -2304,6 +2319,8 @@
}
}

// eslint-disable-line

var logger$5 = console_with_prefix('referrer');

function _getReferrerStr() {
Expand Down Expand Up @@ -2355,10 +2372,6 @@
UTM_CONTENT: 'utm_content'
};

function _getUrlParams$1() {
return location && location.search;
}

function getUtmData(rawCookie, query) {
// Translate the utmz cookie format into url query string format.
var cookie = rawCookie ? '?' + rawCookie.split('.').slice(-1)[0].replace(/\|/g, '&') : '';
Expand Down Expand Up @@ -2394,7 +2407,7 @@
}

function getUtm(queryParams, cookieParams) {
queryParams = _getUrlParams$1();
queryParams = _.getUrlParams();
cookieParams = _.cookie.get('__utmz');
var utmProperties = getUtmData(cookieParams, queryParams);
return utmProperties;
Expand Down Expand Up @@ -2513,10 +2526,6 @@

var logger$4 = console_with_prefix('campaign');

function _getUrlParams() {
return location && location.search;
}

function getGclid(urlParams) {
var gclid = _.getQueryParamByName('gclid', urlParams);
if (_.isEmptyString(gclid)) {
Expand All @@ -2541,7 +2550,7 @@
}
}
if (!opt.disableRGclid) {
var gclid = getGclid(_getUrlParams());
var gclid = getGclid(_.getUrlParams());
if (gclid) {
result['gclid'] = gclid;
}
Expand Down
31 changes: 20 additions & 11 deletions build/moesif.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

var Config = {
DEBUG: false,
LIB_VERSION: '1.8.3'
LIB_VERSION: '1.8.5'
};

// since es6 imports are static and we run unit tests from the console, window won't be defined when importing this file
Expand Down Expand Up @@ -975,6 +975,21 @@
return tmp_arr.join(arg_separator);
};

function splitFromQuestionMark(myHref) {
if (myHref) {
var startOfQuery = myHref.indexOf('?');
if (startOfQuery >= 0) {
var res = myHref.substring(startOfQuery);
return res;
}
}
return '';
}

_.getUrlParams = function() {
return location && (location.search || splitFromQuestionMark(location.href));
};

_.getQueryParamByName = function(name, query) {
// expects a name
// and a query string. aka location part.
Expand Down Expand Up @@ -2307,6 +2322,8 @@
}
}

// eslint-disable-line

var logger$5 = console_with_prefix('referrer');

function _getReferrerStr() {
Expand Down Expand Up @@ -2358,10 +2375,6 @@
UTM_CONTENT: 'utm_content'
};

function _getUrlParams$1() {
return location && location.search;
}

function getUtmData(rawCookie, query) {
// Translate the utmz cookie format into url query string format.
var cookie = rawCookie ? '?' + rawCookie.split('.').slice(-1)[0].replace(/\|/g, '&') : '';
Expand Down Expand Up @@ -2397,7 +2410,7 @@
}

function getUtm(queryParams, cookieParams) {
queryParams = _getUrlParams$1();
queryParams = _.getUrlParams();
cookieParams = _.cookie.get('__utmz');
var utmProperties = getUtmData(cookieParams, queryParams);
return utmProperties;
Expand Down Expand Up @@ -2516,10 +2529,6 @@

var logger$4 = console_with_prefix('campaign');

function _getUrlParams() {
return location && location.search;
}

function getGclid(urlParams) {
var gclid = _.getQueryParamByName('gclid', urlParams);
if (_.isEmptyString(gclid)) {
Expand All @@ -2544,7 +2553,7 @@
}
}
if (!opt.disableRGclid) {
var gclid = getGclid(_getUrlParams());
var gclid = getGclid(_.getUrlParams());
if (gclid) {
result['gclid'] = gclid;
}
Expand Down
31 changes: 20 additions & 11 deletions examples/commonjs-browserify/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

var Config = {
DEBUG: false,
LIB_VERSION: '1.8.3'
LIB_VERSION: '1.8.5'
};

// since es6 imports are static and we run unit tests from the console, window won't be defined when importing this file
Expand Down Expand Up @@ -972,6 +972,21 @@ _.HTTPBuildQuery = function(formdata, arg_separator) {
return tmp_arr.join(arg_separator);
};

function splitFromQuestionMark(myHref) {
if (myHref) {
var startOfQuery = myHref.indexOf('?');
if (startOfQuery >= 0) {
var res = myHref.substring(startOfQuery);
return res;
}
}
return '';
}

_.getUrlParams = function() {
return location && (location.search || splitFromQuestionMark(location.href));
};

_.getQueryParamByName = function(name, query) {
// expects a name
// and a query string. aka location part.
Expand Down Expand Up @@ -2304,6 +2319,8 @@ function patch(recorder, env) {
}
}

// eslint-disable-line

var logger$5 = console_with_prefix('referrer');

function _getReferrerStr() {
Expand Down Expand Up @@ -2355,10 +2372,6 @@ var UTMConstants = { // UTM Params
UTM_CONTENT: 'utm_content'
};

function _getUrlParams$1() {
return location && location.search;
}

function getUtmData(rawCookie, query) {
// Translate the utmz cookie format into url query string format.
var cookie = rawCookie ? '?' + rawCookie.split('.').slice(-1)[0].replace(/\|/g, '&') : '';
Expand Down Expand Up @@ -2394,7 +2407,7 @@ function getUtmData(rawCookie, query) {
}

function getUtm(queryParams, cookieParams) {
queryParams = _getUrlParams$1();
queryParams = _.getUrlParams();
cookieParams = _.cookie.get('__utmz');
var utmProperties = getUtmData(cookieParams, queryParams);
return utmProperties;
Expand Down Expand Up @@ -2513,10 +2526,6 @@ function clearLocalStorage(opt) {

var logger$4 = console_with_prefix('campaign');

function _getUrlParams() {
return location && location.search;
}

function getGclid(urlParams) {
var gclid = _.getQueryParamByName('gclid', urlParams);
if (_.isEmptyString(gclid)) {
Expand All @@ -2541,7 +2550,7 @@ function getCampaignDataFromUrlOrCookie(opt) {
}
}
if (!opt.disableRGclid) {
var gclid = getGclid(_getUrlParams());
var gclid = getGclid(_.getUrlParams());
if (gclid) {
result['gclid'] = gclid;
}
Expand Down
Loading

0 comments on commit 391afd2

Please sign in to comment.