react-ga-gtm
Version:
React Google Analytics Module.
1,235 lines (994 loc) • 38.6 kB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("react"), require("prop-types"));
else if(typeof define === 'function' && define.amd)
define(["react", "prop-types"], factory);
else {
var a = typeof exports === 'object' ? factory(require("react"), require("prop-types")) : factory(root["react"], root["prop-types"]);
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
}
})(typeof self !== 'undefined' ? self : this, function(__WEBPACK_EXTERNAL_MODULE_1__, __WEBPACK_EXTERNAL_MODULE_2__) {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 4);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = warn;
function warn(s) {
console.warn('[react-ga]', s);
}
/***/ }),
/* 1 */
/***/ (function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE_1__;
/***/ }),
/* 2 */
/***/ (function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE_2__;
/***/ }),
/* 3 */
/***/ (function(module, exports, __webpack_require__) {
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = trim;
// GA strings need to have leading/trailing whitespace trimmed, and not all
// browsers have String.prototoype.trim().
function trim(s) {
return s.replace(/^\s+|\s+$/g, '');
}
/***/ }),
/* 4 */
/***/ (function(module, exports, __webpack_require__) {
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.GoogleTagManagerScript = exports.GoogleTagManagerIframe = exports.testModeAPI = exports.OutboundLink = exports.plugin = undefined;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
exports.initialize = initialize;
exports.ga = ga;
exports.set = set;
exports.send = send;
exports.pageview = pageview;
exports.modalview = modalview;
exports.timing = timing;
exports.event = event;
exports.exception = exception;
exports.outboundLink = outboundLink;
var _format2 = __webpack_require__(5);
var _format3 = _interopRequireDefault(_format2);
var _removeLeadingSlash = __webpack_require__(8);
var _removeLeadingSlash2 = _interopRequireDefault(_removeLeadingSlash);
var _trim = __webpack_require__(3);
var _trim2 = _interopRequireDefault(_trim);
var _loadGA = __webpack_require__(9);
var _loadGA2 = _interopRequireDefault(_loadGA);
var _loadGTM = __webpack_require__(10);
var _loadGTM2 = _interopRequireDefault(_loadGTM);
var _warn = __webpack_require__(0);
var _warn2 = _interopRequireDefault(_warn);
var _log = __webpack_require__(11);
var _log2 = _interopRequireDefault(_log);
var _testModeAPI = __webpack_require__(12);
var _testModeAPI2 = _interopRequireDefault(_testModeAPI);
var _OutboundLink = __webpack_require__(13);
var _OutboundLink2 = _interopRequireDefault(_OutboundLink);
var _GoogleTagManagerIframe = __webpack_require__(14);
var _GoogleTagManagerIframe2 = _interopRequireDefault(_GoogleTagManagerIframe);
var _GoogleTagManagerScript = __webpack_require__(15);
var _GoogleTagManagerScript2 = _interopRequireDefault(_GoogleTagManagerScript);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } /**
* React Google Analytics Module
*
* @package react-ga
* @author Adam Lofting <adam@mozillafoundation.org>
* Atul Varma <atul@mozillafoundation.org>
*/
/**
* Utilities
*/
var _debug = false;
var _titleCase = true;
var _testMode = false;
var _alwaysSendToDefaultTracker = true;
var savedEvents = [];
var internalGa = function internalGa() {
var _window2;
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
if (_testMode) return _testModeAPI2.default.ga.apply(_testModeAPI2.default, args);
if (!window.ga) {
savedEvents.push(args);
return null;
}
if (savedEvents.length) {
savedEvents.map(function (savedArgs) {
var _window;
return (_window = window).ga.apply(_window, _toConsumableArray(savedArgs));
});
savedEvents = [];
}
return (_window2 = window).ga.apply(_window2, args);
};
function _format(s) {
return (0, _format3.default)(s, _titleCase);
}
function _gaCommand(trackerNames) {
for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
args[_key2 - 1] = arguments[_key2];
}
var command = args[0];
if (typeof internalGa === 'function') {
if (typeof command !== 'string') {
(0, _warn2.default)('ga command must be a string');
return;
}
if (_alwaysSendToDefaultTracker || !Array.isArray(trackerNames)) internalGa.apply(undefined, args);
if (Array.isArray(trackerNames)) {
trackerNames.forEach(function (name) {
internalGa.apply(undefined, _toConsumableArray([name + '.' + command].concat(args.slice(1))));
});
}
}
}
function _initialize(gaTrackingID, options) {
if (!gaTrackingID) {
(0, _warn2.default)('gaTrackingID is required in initialize()');
return;
}
if (options && (typeof options === 'undefined' ? 'undefined' : _typeof(options)) === 'object' && options.gtmTrackingId) {
(0, _warn2.default)('GTM initializes the GA');
return;
}
if (options) {
if (options.debug && options.debug === true) {
_debug = true;
}
if (options.titleCase === false) {
_titleCase = false;
}
}
if (options && options.gaOptions) {
internalGa('create', gaTrackingID, options.gaOptions);
} else {
internalGa('create', gaTrackingID, 'auto');
}
}
function getTrackingId(configsOrTrackingId) {
if (typeof configsOrTrackingId === 'string') {
return configsOrTrackingId;
}
if (Array.isArray(configsOrTrackingId) && configsOrTrackingId.length) {
var config = configsOrTrackingId.find(function (item) {
return item.trackingId;
});
if (config && (typeof config === 'undefined' ? 'undefined' : _typeof(config)) !== 'object') {
return config.trackingId;
}
}
return null;
}
function initialize(configsOrTrackingId, options) {
if (options && options.testMode === true) {
_testMode = true;
} else {
if (typeof window === 'undefined') {
return false;
}
var trackingId = getTrackingId(configsOrTrackingId);
if (options && (typeof options === 'undefined' ? 'undefined' : _typeof(options)) === 'object' && options.gtmTrackingId) {
(0, _loadGTM2.default)(trackingId, options);
} else {
(0, _loadGA2.default)(options);
}
}
_alwaysSendToDefaultTracker = options && typeof options.alwaysSendToDefaultTracker === 'boolean' ? options.alwaysSendToDefaultTracker : true;
if (Array.isArray(configsOrTrackingId)) {
configsOrTrackingId.forEach(function (config) {
if ((typeof config === 'undefined' ? 'undefined' : _typeof(config)) !== 'object') {
(0, _warn2.default)('All configs must be an object');
return;
}
_initialize(config.trackingId, config);
});
} else {
_initialize(configsOrTrackingId, options);
}
return true;
}
/**
* ga:
* Returns the original GA object.
*/
function ga() {
for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
args[_key3] = arguments[_key3];
}
if (args.length > 0) {
internalGa.apply(undefined, args);
if (_debug) {
(0, _log2.default)('called ga(\'arguments\');');
(0, _log2.default)('with arguments: ' + JSON.stringify(args));
}
}
return window.ga;
}
/**
* set:
* GA tracker set method
* @param {Object} fieldsObject - a field/value pair or a group of field/value pairs on the tracker
* @param {Array} trackerNames - (optional) a list of extra trackers to run the command on
*/
function set(fieldsObject, trackerNames) {
if (!fieldsObject) {
(0, _warn2.default)('`fieldsObject` is required in .set()');
return;
}
if ((typeof fieldsObject === 'undefined' ? 'undefined' : _typeof(fieldsObject)) !== 'object') {
(0, _warn2.default)('Expected `fieldsObject` arg to be an Object');
return;
}
if (Object.keys(fieldsObject).length === 0) {
(0, _warn2.default)('empty `fieldsObject` given to .set()');
}
_gaCommand(trackerNames, 'set', fieldsObject);
if (_debug) {
(0, _log2.default)('called ga(\'set\', fieldsObject);');
(0, _log2.default)('with fieldsObject: ' + JSON.stringify(fieldsObject));
}
}
/**
* send:
* Clone of the low level `ga.send` method
* WARNING: No validations will be applied to this
* @param {Object} fieldObject - field object for tracking different analytics
* @param {Array} trackerNames - trackers to send the command to
* @param {Array} trackerNames - (optional) a list of extra trackers to run the command on
*/
function send(fieldObject, trackerNames) {
_gaCommand(trackerNames, 'send', fieldObject);
if (_debug) {
(0, _log2.default)('called ga(\'send\', fieldObject);');
(0, _log2.default)('with fieldObject: ' + JSON.stringify(fieldObject));
(0, _log2.default)('with trackers: ' + JSON.stringify(trackerNames));
}
}
/**
* pageview:
* Basic GA pageview tracking
* @param {String} path - the current page page e.g. '/about'
* @param {Array} trackerNames - (optional) a list of extra trackers to run the command on
* @param {String} title - (optional) the page title e. g. 'My Website'
*/
function pageview(rawPath, trackerNames, title) {
if (!rawPath) {
(0, _warn2.default)('path is required in .pageview()');
return;
}
var path = (0, _trim2.default)(rawPath);
if (path === '') {
(0, _warn2.default)('path cannot be an empty string in .pageview()');
return;
}
var extraFields = {};
if (title) {
extraFields.title = title;
}
if (typeof ga === 'function') {
_gaCommand(trackerNames, 'send', _extends({
hitType: 'pageview',
page: path
}, extraFields));
if (_debug) {
(0, _log2.default)('called ga(\'send\', \'pageview\', path);');
var extraLog = '';
if (title) {
extraLog = ' and title: ' + title;
}
(0, _log2.default)('with path: ' + path + extraLog);
}
}
}
/**
* modalview:
* a proxy to basic GA pageview tracking to consistently track
* modal views that are an equivalent UX to a traditional pageview
* @param {String} modalName e.g. 'add-or-edit-club'
* @param {Array} trackerNames - (optional) a list of extra trackers to run the command on
*/
function modalview(rawModalName, trackerNames) {
if (!rawModalName) {
(0, _warn2.default)('modalName is required in .modalview(modalName)');
return;
}
var modalName = (0, _removeLeadingSlash2.default)((0, _trim2.default)(rawModalName));
if (modalName === '') {
(0, _warn2.default)('modalName cannot be an empty string or a single / in .modalview()');
return;
}
if (typeof ga === 'function') {
var path = '/modal/' + modalName;
_gaCommand(trackerNames, 'send', 'pageview', path);
if (_debug) {
(0, _log2.default)('called ga(\'send\', \'pageview\', path);');
(0, _log2.default)('with path: ' + path);
}
}
}
/**
* timing:
* GA timing
* @param args.category {String} required
* @param args.variable {String} required
* @param args.value {Int} required
* @param args.label {String} required
* @param {Array} trackerNames - (optional) a list of extra trackers to run the command on
*/
function timing() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
category = _ref.category,
variable = _ref.variable,
value = _ref.value,
label = _ref.label;
var trackerNames = arguments[1];
if (typeof ga === 'function') {
if (!category || !variable || !value || typeof value !== 'number') {
(0, _warn2.default)('args.category, args.variable ' + 'AND args.value are required in timing() ' + 'AND args.value has to be a number');
return;
}
// Required Fields
var fieldObject = {
hitType: 'timing',
timingCategory: _format(category),
timingVar: _format(variable),
timingValue: value
};
if (label) {
fieldObject.timingLabel = _format(label);
}
send(fieldObject, trackerNames);
}
}
/**
* event:
* GA event tracking
* @param args.category {String} required
* @param args.action {String} required
* @param args.label {String} optional
* @param args.value {Int} optional
* @param args.nonInteraction {boolean} optional
* @param args.transport {string} optional
* @param {Array} trackerNames - (optional) a list of extra trackers to run the command on
*/
function event() {
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var trackerNames = arguments[1];
var category = _ref2.category,
action = _ref2.action,
label = _ref2.label,
value = _ref2.value,
nonInteraction = _ref2.nonInteraction,
transport = _ref2.transport,
args = _objectWithoutProperties(_ref2, ['category', 'action', 'label', 'value', 'nonInteraction', 'transport']);
if (typeof ga === 'function') {
// Simple Validation
if (!category || !action) {
(0, _warn2.default)('args.category AND args.action are required in event()');
return;
}
// Required Fields
var fieldObject = {
hitType: 'event',
eventCategory: _format(category),
eventAction: _format(action)
};
// Optional Fields
if (label) {
fieldObject.eventLabel = _format(label);
}
if (typeof value !== 'undefined') {
if (typeof value !== 'number') {
(0, _warn2.default)('Expected `args.value` arg to be a Number.');
} else {
fieldObject.eventValue = value;
}
}
if (typeof nonInteraction !== 'undefined') {
if (typeof nonInteraction !== 'boolean') {
(0, _warn2.default)('`args.nonInteraction` must be a boolean.');
} else {
fieldObject.nonInteraction = nonInteraction;
}
}
if (typeof transport !== 'undefined') {
if (typeof transport !== 'string') {
(0, _warn2.default)('`args.transport` must be a string.');
} else {
if (['beacon', 'xhr', 'image'].indexOf(transport) === -1) {
(0, _warn2.default)('`args.transport` must be either one of these values: `beacon`, `xhr` or `image`');
}
fieldObject.transport = transport;
}
}
Object.keys(args).filter(function (key) {
return key.substr(0, 'dimension'.length) === 'dimension';
}).forEach(function (key) {
fieldObject[key] = args[key];
});
Object.keys(args).filter(function (key) {
return key.substr(0, 'metric'.length) === 'metric';
}).forEach(function (key) {
fieldObject[key] = args[key];
});
// Send to GA
send(fieldObject, trackerNames);
}
}
/**
* exception:
* GA exception tracking
* @param args.description {String} optional
* @param args.fatal {boolean} optional
* @param {Array} trackerNames - (optional) a list of extra trackers to run the command on
*/
function exception(_ref3, trackerNames) {
var description = _ref3.description,
fatal = _ref3.fatal;
if (typeof ga === 'function') {
// Required Fields
var fieldObject = {
hitType: 'exception'
};
// Optional Fields
if (description) {
fieldObject.exDescription = _format(description);
}
if (typeof fatal !== 'undefined') {
if (typeof fatal !== 'boolean') {
(0, _warn2.default)('`args.fatal` must be a boolean.');
} else {
fieldObject.exFatal = fatal;
}
}
// Send to GA
send(fieldObject, trackerNames);
}
}
var plugin = exports.plugin = {
/**
* require:
* GA requires a plugin
* @param name {String} e.g. 'ecommerce' or 'myplugin'
* @param options {Object} optional e.g {path: '/log', debug: true}
*/
require: function require(rawName, options) {
if (typeof ga === 'function') {
// Required Fields
if (!rawName) {
(0, _warn2.default)('`name` is required in .require()');
return;
}
var name = (0, _trim2.default)(rawName);
if (name === '') {
(0, _warn2.default)('`name` cannot be an empty string in .require()');
return;
}
// Optional Fields
if (options) {
if ((typeof options === 'undefined' ? 'undefined' : _typeof(options)) !== 'object') {
(0, _warn2.default)('Expected `options` arg to be an Object');
return;
}
if (Object.keys(options).length === 0) {
(0, _warn2.default)('Empty `options` given to .require()');
}
ga('require', name, options);
if (_debug) {
(0, _log2.default)('called ga(\'require\', \'' + name + '\', ' + JSON.stringify(options));
}
} else {
ga('require', name);
if (_debug) {
(0, _log2.default)('called ga(\'require\', \'' + name + '\');');
}
}
}
},
/**
* execute:
* GA execute action for plugin
* Takes variable number of arguments
* @param pluginName {String} e.g. 'ecommerce' or 'myplugin'
* @param action {String} e.g. 'addItem' or 'myCustomAction'
* @param actionType {String} optional e.g. 'detail'
* @param payload {Object} optional e.g { id: '1x5e', name : 'My product to track' }
*/
execute: function execute(pluginName, action) {
var payload = void 0;
var actionType = void 0;
if ((arguments.length <= 2 ? 0 : arguments.length - 2) === 1) {
payload = arguments.length <= 2 ? undefined : arguments[2];
} else {
actionType = arguments.length <= 2 ? undefined : arguments[2];
payload = arguments.length <= 3 ? undefined : arguments[3];
}
if (typeof ga === 'function') {
if (typeof pluginName !== 'string') {
(0, _warn2.default)('Expected `pluginName` arg to be a String.');
} else if (typeof action !== 'string') {
(0, _warn2.default)('Expected `action` arg to be a String.');
} else {
var command = pluginName + ':' + action;
payload = payload || null;
if (actionType && payload) {
ga(command, actionType, payload);
if (_debug) {
(0, _log2.default)('called ga(\'' + command + '\');');
(0, _log2.default)('actionType: "' + actionType + '" with payload: ' + JSON.stringify(payload));
}
} else if (payload) {
ga(command, payload);
if (_debug) {
(0, _log2.default)('called ga(\'' + command + '\');');
(0, _log2.default)('with payload: ' + JSON.stringify(payload));
}
} else {
ga(command);
if (_debug) {
(0, _log2.default)('called ga(\'' + command + '\');');
}
}
}
}
}
};
/**
* outboundLink:
* GA outboundLink tracking
* @param args.label {String} e.g. url, or 'Create an Account'
* @param {function} hitCallback - Called after processing a hit.
*/
function outboundLink(args, hitCallback, trackerNames) {
if (typeof hitCallback !== 'function') {
(0, _warn2.default)('hitCallback function is required');
return;
}
if (typeof ga === 'function') {
// Simple Validation
if (!args || !args.label) {
(0, _warn2.default)('args.label is required in outboundLink()');
return;
}
// Required Fields
var fieldObject = {
hitType: 'event',
eventCategory: 'Outbound',
eventAction: 'Click',
eventLabel: _format(args.label)
};
var safetyCallbackCalled = false;
var safetyCallback = function safetyCallback() {
// This prevents a delayed response from GA
// causing hitCallback from being fired twice
safetyCallbackCalled = true;
hitCallback();
};
// Using a timeout to ensure the execution of critical application code
// in the case when the GA server might be down
// or an ad blocker prevents sending the data
// register safety net timeout:
var t = setTimeout(safetyCallback, 250);
var clearableCallbackForGA = function clearableCallbackForGA() {
clearTimeout(t);
if (!safetyCallbackCalled) {
hitCallback();
}
};
fieldObject.hitCallback = clearableCallbackForGA;
// Send to GA
send(fieldObject, trackerNames);
} else {
// if ga is not defined, return the callback so the application
// continues to work as expected
setTimeout(hitCallback, 0);
}
}
_OutboundLink2.default.origTrackLink = _OutboundLink2.default.trackLink;
_OutboundLink2.default.trackLink = outboundLink;
var OutboundLink = exports.OutboundLink = _OutboundLink2.default;
var testModeAPI = exports.testModeAPI = _testModeAPI2.default;
var GoogleTagManagerIframe = exports.GoogleTagManagerIframe = _GoogleTagManagerIframe2.default;
var GoogleTagManagerScript = exports.GoogleTagManagerScript = _GoogleTagManagerScript2.default;
exports.default = {
initialize: initialize,
ga: ga,
set: set,
send: send,
pageview: pageview,
modalview: modalview,
timing: timing,
event: event,
exception: exception,
plugin: plugin,
outboundLink: outboundLink,
OutboundLink: OutboundLink,
GoogleTagManagerIframe: GoogleTagManagerIframe,
GoogleTagManagerScript: GoogleTagManagerScript,
testModeAPI: _testModeAPI2.default
};
/***/ }),
/* 5 */
/***/ (function(module, exports, __webpack_require__) {
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = format;
var _mightBeEmail = __webpack_require__(6);
var _mightBeEmail2 = _interopRequireDefault(_mightBeEmail);
var _toTitleCase = __webpack_require__(7);
var _toTitleCase2 = _interopRequireDefault(_toTitleCase);
var _warn = __webpack_require__(0);
var _warn2 = _interopRequireDefault(_warn);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var redacted = 'REDACTED (Potential Email Address)';
function format(s, titleCase) {
if ((0, _mightBeEmail2.default)(s)) {
(0, _warn2.default)('This arg looks like an email address, redacting.');
return redacted;
}
if (titleCase) {
return (0, _toTitleCase2.default)(s);
}
return s;
}
/***/ }),
/* 6 */
/***/ (function(module, exports, __webpack_require__) {
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = mightBeEmail;
// See if s could be an email address. We don't want to send personal data like email.
// https://support.google.com/analytics/answer/2795983?hl=en
function mightBeEmail(s) {
// There's no point trying to validate rfc822 fully, just look for ...@...
return (/[^@]+@[^@]+/.test(s)
);
}
/***/ }),
/* 7 */
/***/ (function(module, exports, __webpack_require__) {
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = toTitleCase;
var _trim = __webpack_require__(3);
var _trim2 = _interopRequireDefault(_trim);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var smallWords = /^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|vs?\.?|via)$/i; /**
* To Title Case 2.1 - http://individed.com/code/to-title-case/
* Copyright 2008-2013 David Gouch. Licensed under the MIT License.
* https://github.com/gouch/to-title-case
*/
function toTitleCase(string) {
return (0, _trim2.default)(string).replace(/[A-Za-z0-9\u00C0-\u00FF]+[^\s-]*/g, function (match, index, title) {
if (index > 0 && index + match.length !== title.length && match.search(smallWords) > -1 && title.charAt(index - 2) !== ':' && (title.charAt(index + match.length) !== '-' || title.charAt(index - 1) === '-') && title.charAt(index - 1).search(/[^\s-]/) < 0) {
return match.toLowerCase();
}
if (match.substr(1).search(/[A-Z]|\../) > -1) {
return match;
}
return match.charAt(0).toUpperCase() + match.substr(1);
});
}
/***/ }),
/* 8 */
/***/ (function(module, exports, __webpack_require__) {
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = removeLeadingSlash;
function removeLeadingSlash(string) {
if (string.substring(0, 1) === '/') {
return string.substring(1);
}
return string;
}
/***/ }),
/* 9 */
/***/ (function(module, exports, __webpack_require__) {
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = function (options) {
// https://developers.google.com/analytics/devguides/collection/analyticsjs/
/* eslint-disable */
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments);
}, i[r].l = 1 * new Date();
a = s.createElement(o), m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m);
})(window, document, 'script', options && options.gaAddress ? options.gaAddress : 'https://www.google-analytics.com/analytics.js', 'ga');
/* eslint-enable */
};
/***/ }),
/* 10 */
/***/ (function(module, exports, __webpack_require__) {
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = function (gaTrackingId, options) {
// https://developers.google.com/analytics/devguides/collection/gtagjs/
/* eslint-disable */
(function (w, d, s, l, i, k, m, g) {
w[l] = w[l] || [];
w[g] = function () {
w[l].push(arguments);
};
w[g]({ 'gtm.start': new Date().getTime(), event: 'gtm.js' });
w[g]('config', k);
var f = d.getElementsByTagName(s)[0],
j = d.createElement(s),
dl = l != 'dataLayer' ? '&l=' + l : '';
j.async = true;
j.src = m + '?id=' + i + dl;
f.parentNode.insertBefore(j, f);
})(window, document, 'script', 'dataLayer', options && options.gtmTrackingId, gaTrackingId, options && options.gtmAddress ? options.gtmAddress : 'https://www.googletagmanager.com/gtm.js', 'gtag');
/* eslint-enable */
};
/***/ }),
/* 11 */
/***/ (function(module, exports, __webpack_require__) {
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = log;
function log(s) {
console.info('[react-ga]', s);
}
/***/ }),
/* 12 */
/***/ (function(module, exports, __webpack_require__) {
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var gaCalls = exports.gaCalls = [];
exports.default = {
calls: gaCalls,
ga: function ga() {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
gaCalls.push([].concat(args));
}
};
/***/ }),
/* 13 */
/***/ (function(module, exports, __webpack_require__) {
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _react = __webpack_require__(1);
var _react2 = _interopRequireDefault(_react);
var _propTypes = __webpack_require__(2);
var _propTypes2 = _interopRequireDefault(_propTypes);
var _warn = __webpack_require__(0);
var _warn2 = _interopRequireDefault(_warn);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var NEWTAB = '_blank';
var MIDDLECLICK = 1;
var OutboundLink = function (_Component) {
_inherits(OutboundLink, _Component);
function OutboundLink() {
var _ref;
var _temp, _this, _ret;
_classCallCheck(this, OutboundLink);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = OutboundLink.__proto__ || Object.getPrototypeOf(OutboundLink)).call.apply(_ref, [this].concat(args))), _this), _this.handleClick = function (event) {
var _this$props = _this.props,
target = _this$props.target,
eventLabel = _this$props.eventLabel,
to = _this$props.to,
onClick = _this$props.onClick;
var eventMeta = { label: eventLabel };
var sameTarget = target !== NEWTAB;
var normalClick = !(event.ctrlKey || event.shiftKey || event.metaKey || event.button === MIDDLECLICK);
if (sameTarget && normalClick) {
event.preventDefault();
OutboundLink.trackLink(eventMeta, function () {
window.location.href = to;
});
} else {
OutboundLink.trackLink(eventMeta, function () {});
}
if (onClick) {
onClick(event);
}
}, _temp), _possibleConstructorReturn(_this, _ret);
}
_createClass(OutboundLink, [{
key: 'render',
value: function render() {
var props = _extends({}, this.props, {
href: this.props.to,
onClick: this.handleClick
});
delete props.eventLabel;
return _react2.default.createElement('a', props);
}
}]);
return OutboundLink;
}(_react.Component);
OutboundLink.propTypes = {
eventLabel: _propTypes2.default.string.isRequired,
target: _propTypes2.default.string,
to: _propTypes2.default.string,
onClick: _propTypes2.default.func
};
OutboundLink.defaultProps = {
target: null,
to: null,
onClick: null
};
OutboundLink.trackLink = function () {
(0, _warn2.default)('ga tracking not enabled');
};
exports.default = OutboundLink;
/***/ }),
/* 14 */
/***/ (function(module, exports, __webpack_require__) {
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = GoogleTagManagerIframe;
var _react = __webpack_require__(1);
var _react2 = _interopRequireDefault(_react);
var _propTypes = __webpack_require__(2);
var _propTypes2 = _interopRequireDefault(_propTypes);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/* eslint-disable react/jsx-filename-extension */
function GoogleTagManagerIframe(props) {
return _react2.default.createElement(
'noscript',
null,
_react2.default.createElement('iframe', {
title: 'googleTagManagerIframe',
src: 'https://' + props.gtmHost + '/ns.html?id=' + props.gtmTrackingId,
height: '0',
width: '0',
style: { display: 'none', visibility: 'hidden' }
})
);
}
GoogleTagManagerIframe.propTypes = {
gtmHost: _propTypes2.default.string,
gtmTrackingId: _propTypes2.default.string.isRequired
};
GoogleTagManagerIframe.defaultProps = {
gtmHost: 'www.googletagmanager.com'
};
/***/ }),
/* 15 */
/***/ (function(module, exports, __webpack_require__) {
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getGoogleTagManagerScript = undefined;
exports.default = GoogleTagManagerScript;
var _react = __webpack_require__(1);
var _react2 = _interopRequireDefault(_react);
var _propTypes = __webpack_require__(2);
var _propTypes2 = _interopRequireDefault(_propTypes);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/* eslint-disable react/jsx-filename-extension,max-len,react/no-danger */
var getGoogleTagManagerScript = exports.getGoogleTagManagerScript = function getGoogleTagManagerScript(gtmHost, gtmTrackingId) {
return '(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({\'gtm.start\':\nnew Date().getTime(),event:\'gtm.js\'});var f=d.getElementsByTagName(s)[0],\nj=d.createElement(s),dl=l!=\'dataLayer\'?\'&l=\'+l:\'\';j.async=true;j.src=\n\'https://' + gtmHost + '/gtm.js?id=\'+i+dl;f.parentNode.insertBefore(j,f);\n})(window,document,\'script\',\'dataLayer\',\'' + gtmTrackingId + '\');';
};
function GoogleTagManagerScript(props) {
return _react2.default.createElement('script', { dangerouslySetInnerHTML: { __html: getGoogleTagManagerScript(props.gtmHost, props.gtmTrackingId) } });
}
GoogleTagManagerScript.propTypes = {
gtmHost: _propTypes2.default.string,
gtmTrackingId: _propTypes2.default.string.isRequired
};
GoogleTagManagerScript.defaultProps = {
gtmHost: 'www.googletagmanager.com'
};
/***/ })
/******/ ]);
});