Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@snowplow/browser-plugin-debugger

Package Overview
Dependencies
Maintainers
0
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@snowplow/browser-plugin-debugger - npm Package Compare versions

Comparing version 3.24.2 to 3.24.3

2

dist/index.module.js
/*!
* Debugger for Snowplow v3.24.2 (http://bit.ly/sp-js)
* Debugger for Snowplow v3.24.3 (http://bit.ly/sp-js)
* Copyright 2022 Snowplow Analytics Ltd, 2010 Anthon Pang

@@ -4,0 +4,0 @@ * Licensed under BSD-3-Clause

/*!
* Debugger for Snowplow v3.24.2 (http://bit.ly/sp-js)
* Debugger for Snowplow v3.24.3 (http://bit.ly/sp-js)
* Copyright 2022 Snowplow Analytics Ltd, 2010 Anthon Pang

@@ -8,988 +8,993 @@ * Licensed under BSD-3-Clause

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.snowplowDebugger = {}));
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.snowplowDebugger = {}));
})(this, (function (exports) { 'use strict';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
/******************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
function __spreadArray(to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
function __spreadArray(to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
return to.concat(ar || Array.prototype.slice.call(from));
}
return to.concat(ar || Array.prototype.slice.call(from));
}
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
var e = new Error(message);
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
};
/*!
* Core functionality for Snowplow JavaScript trackers v3.24.2 (http://bit.ly/sp-js)
* Copyright 2022 Snowplow Analytics Ltd, 2010 Anthon Pang
* Licensed under BSD-3-Clause
*/
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
var version$1 = "3.24.2";
/*!
* Core functionality for Snowplow JavaScript trackers v3.24.3 (http://bit.ly/sp-js)
* Copyright 2022 Snowplow Analytics Ltd, 2010 Anthon Pang
* Licensed under BSD-3-Clause
*/
/*
* Copyright (c) 2013 Kevin van Zonneveld (http://kvz.io)
* and Contributors (http://phpjs.org/authors)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/**
* Decodes a url safe Base 64 encoded string
* @remarks See: {@link http://tools.ietf.org/html/rfc4648#page-7}
* @param data - String to decode
* @returns The decoded string
*/
function base64urldecode(data) {
if (!data) {
return data;
}
var padding = 4 - (data.length % 4);
switch (padding) {
case 2:
data += '==';
break;
case 3:
data += '=';
break;
}
var b64Data = data.replace(/-/g, '+').replace(/_/g, '/');
return base64decode(b64Data);
}
/**
* Encodes a string into a url safe Base 64 encoded string
* @remarks See: {@link http://tools.ietf.org/html/rfc4648#page-7}
* @param data - String to encode
* @returns The url safe Base 64 string
*/
function base64urlencode(data) {
if (!data) {
return data;
}
var enc = base64encode(data);
return enc.replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_');
}
var b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
/**
* Encode string as base64.
* Any type can be passed, but will be stringified
*
* @param data - string to encode
* @returns base64-encoded string
*/
function base64encode(data) {
// discuss at: http://phpjs.org/functions/base64_encode/
// original by: Tyler Akins (http://rumkin.com)
// improved by: Bayron Guevara
// improved by: Thunder.m
// improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// improved by: Rafał Kukawski (http://kukawski.pl)
// bugfixed by: Pellentesque Malesuada
// example 1: base64_encode('Kevin van Zonneveld');
// returns 1: 'S2V2aW4gdmFuIFpvbm5ldmVsZA=='
// example 2: base64_encode('a');
// returns 2: 'YQ=='
// example 3: base64_encode('✓ à la mode');
// returns 3: '4pyTIMOgIGxhIG1vZGU='
var o1, o2, o3, h1, h2, h3, h4, bits, i = 0, ac = 0;
var tmp_arr = [];
if (!data) {
return data;
}
data = unescape(encodeURIComponent(data));
do {
// pack three octets into four hexets
o1 = data.charCodeAt(i++);
o2 = data.charCodeAt(i++);
o3 = data.charCodeAt(i++);
bits = (o1 << 16) | (o2 << 8) | o3;
h1 = (bits >> 18) & 0x3f;
h2 = (bits >> 12) & 0x3f;
h3 = (bits >> 6) & 0x3f;
h4 = bits & 0x3f;
// use hexets to index into b64, and append result to encoded string
tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
} while (i < data.length);
var enc = tmp_arr.join('');
var r = data.length % 3;
return (r ? enc.slice(0, r - 3) : enc) + '==='.slice(r || 3);
}
/**
* Decode base64 to string
*
* @param data - base64 to string
* @returns decoded string
*/
function base64decode(encodedData) {
// discuss at: http://locutus.io/php/base64_decode/
// original by: Tyler Akins (http://rumkin.com)
// improved by: Thunder.m
// improved by: Kevin van Zonneveld (http://kvz.io)
// improved by: Kevin van Zonneveld (http://kvz.io)
// input by: Aman Gupta
// input by: Brett Zamir (http://brett-zamir.me)
// bugfixed by: Onno Marsman (https://twitter.com/onnomarsman)
// bugfixed by: Pellentesque Malesuada
// bugfixed by: Kevin van Zonneveld (http://kvz.io)
// improved by: Indigo744
// example 1: base64_decode('S2V2aW4gdmFuIFpvbm5ldmVsZA==')
// returns 1: 'Kevin van Zonneveld'
// example 2: base64_decode('YQ==')
// returns 2: 'a'
// example 3: base64_decode('4pyTIMOgIGxhIG1vZGU=')
// returns 3: '✓ à la mode'
// decodeUTF8string()
// Internal function to decode properly UTF8 string
// Adapted from Solution #1 at https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding
var decodeUTF8string = function (str) {
// Going backwards: from bytestream, to percent-encoding, to original string.
return decodeURIComponent(str
.split('')
.map(function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
})
.join(''));
};
var o1, o2, o3, h1, h2, h3, h4, bits, i = 0, ac = 0, dec = '';
var tmpArr = [];
if (!encodedData) {
return encodedData;
}
encodedData += '';
do {
// unpack four hexets into three octets using index points in b64
h1 = b64.indexOf(encodedData.charAt(i++));
h2 = b64.indexOf(encodedData.charAt(i++));
h3 = b64.indexOf(encodedData.charAt(i++));
h4 = b64.indexOf(encodedData.charAt(i++));
bits = (h1 << 18) | (h2 << 12) | (h3 << 6) | h4;
o1 = (bits >> 16) & 0xff;
o2 = (bits >> 8) & 0xff;
o3 = bits & 0xff;
if (h3 === 64) {
tmpArr[ac++] = String.fromCharCode(o1);
}
else if (h4 === 64) {
tmpArr[ac++] = String.fromCharCode(o1, o2);
}
else {
tmpArr[ac++] = String.fromCharCode(o1, o2, o3);
}
} while (i < encodedData.length);
dec = tmpArr.join('');
return decodeUTF8string(dec.replace(/\0+$/, ''));
}
/**
* A helper to build a Snowplow request from a set of name-value pairs, provided using the add methods.
* Will base64 encode JSON, if desired, on build
*
* @returns The request builder, with add and build methods
*/
function payloadJsonProcessor(encodeBase64) {
return function (payloadBuilder, jsonForProcessing, contextEntitiesForProcessing) {
var add = function (json, keyIfEncoded, keyIfNotEncoded) {
var str = JSON.stringify(json);
if (encodeBase64) {
payloadBuilder.add(keyIfEncoded, base64urlencode(str));
}
else {
payloadBuilder.add(keyIfNotEncoded, str);
}
};
var getContextFromPayload = function () {
var payload = payloadBuilder.getPayload();
if (encodeBase64 ? payload.cx : payload.co) {
return JSON.parse(encodeBase64 ? base64urldecode(payload.cx) : payload.co);
}
return undefined;
};
var combineContexts = function (originalContext, newContext) {
var context = originalContext || getContextFromPayload();
if (context) {
context.data = context.data.concat(newContext.data);
}
else {
context = newContext;
}
return context;
};
var context = undefined;
for (var _i = 0, jsonForProcessing_1 = jsonForProcessing; _i < jsonForProcessing_1.length; _i++) {
var json = jsonForProcessing_1[_i];
if (json.keyIfEncoded === 'cx') {
context = combineContexts(context, json.json);
}
else {
add(json.json, json.keyIfEncoded, json.keyIfNotEncoded);
}
}
jsonForProcessing.length = 0;
if (contextEntitiesForProcessing.length) {
var newContext = {
schema: 'iglu:com.snowplowanalytics.snowplow/contexts/jsonschema/1-0-0',
data: __spreadArray([], contextEntitiesForProcessing, true)
};
context = combineContexts(context, newContext);
contextEntitiesForProcessing.length = 0;
}
if (context) {
add(context, 'cx', 'co');
}
};
}
var LOG_LEVEL;
(function (LOG_LEVEL) {
LOG_LEVEL[LOG_LEVEL["none"] = 0] = "none";
LOG_LEVEL[LOG_LEVEL["error"] = 1] = "error";
LOG_LEVEL[LOG_LEVEL["warn"] = 2] = "warn";
LOG_LEVEL[LOG_LEVEL["debug"] = 3] = "debug";
LOG_LEVEL[LOG_LEVEL["info"] = 4] = "info";
})(LOG_LEVEL || (LOG_LEVEL = {}));
/**
* Slices a schema into its composite parts. Useful for ruleset filtering.
* @param input - A schema string
* @returns The vendor, schema name, major, minor and patch information of a schema string
*/
function getSchemaParts(input) {
var re = new RegExp('^iglu:([a-zA-Z0-9-_.]+)/([a-zA-Z0-9-_]+)/jsonschema/([1-9][0-9]*)-(0|[1-9][0-9]*)-(0|[1-9][0-9]*)$');
var matches = re.exec(input);
if (matches !== null)
return matches.slice(1, 6);
return undefined;
}
var version$1 = "3.24.3";
/*
* Copyright (c) 2022 Snowplow Analytics Ltd, 2010 Anthon Pang
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
var version = version$1;
/*
* Copyright (c) 2013 Kevin van Zonneveld (http://kvz.io)
* and Contributors (http://phpjs.org/authors)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/**
* Decodes a url safe Base 64 encoded string
* @remarks See: {@link http://tools.ietf.org/html/rfc4648#page-7}
* @param data - String to decode
* @returns The decoded string
*/
function base64urldecode(data) {
if (!data) {
return data;
}
var padding = 4 - (data.length % 4);
switch (padding) {
case 2:
data += '==';
break;
case 3:
data += '=';
break;
}
var b64Data = data.replace(/-/g, '+').replace(/_/g, '/');
return base64decode(b64Data);
}
/**
* Encodes a string into a url safe Base 64 encoded string
* @remarks See: {@link http://tools.ietf.org/html/rfc4648#page-7}
* @param data - String to encode
* @returns The url safe Base 64 string
*/
function base64urlencode(data) {
if (!data) {
return data;
}
var enc = base64encode(data);
return enc.replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_');
}
var b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
/**
* Encode string as base64.
* Any type can be passed, but will be stringified
*
* @param data - string to encode
* @returns base64-encoded string
*/
function base64encode(data) {
// discuss at: http://phpjs.org/functions/base64_encode/
// original by: Tyler Akins (http://rumkin.com)
// improved by: Bayron Guevara
// improved by: Thunder.m
// improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// improved by: Rafał Kukawski (http://kukawski.pl)
// bugfixed by: Pellentesque Malesuada
// example 1: base64_encode('Kevin van Zonneveld');
// returns 1: 'S2V2aW4gdmFuIFpvbm5ldmVsZA=='
// example 2: base64_encode('a');
// returns 2: 'YQ=='
// example 3: base64_encode('✓ à la mode');
// returns 3: '4pyTIMOgIGxhIG1vZGU='
var o1, o2, o3, h1, h2, h3, h4, bits, i = 0, ac = 0;
var tmp_arr = [];
if (!data) {
return data;
}
data = unescape(encodeURIComponent(data));
do {
// pack three octets into four hexets
o1 = data.charCodeAt(i++);
o2 = data.charCodeAt(i++);
o3 = data.charCodeAt(i++);
bits = (o1 << 16) | (o2 << 8) | o3;
h1 = (bits >> 18) & 0x3f;
h2 = (bits >> 12) & 0x3f;
h3 = (bits >> 6) & 0x3f;
h4 = bits & 0x3f;
// use hexets to index into b64, and append result to encoded string
tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
} while (i < data.length);
var enc = tmp_arr.join('');
var r = data.length % 3;
return (r ? enc.slice(0, r - 3) : enc) + '==='.slice(r || 3);
}
/**
* Decode base64 to string
*
* @param data - base64 to string
* @returns decoded string
*/
function base64decode(encodedData) {
// discuss at: http://locutus.io/php/base64_decode/
// original by: Tyler Akins (http://rumkin.com)
// improved by: Thunder.m
// improved by: Kevin van Zonneveld (http://kvz.io)
// improved by: Kevin van Zonneveld (http://kvz.io)
// input by: Aman Gupta
// input by: Brett Zamir (http://brett-zamir.me)
// bugfixed by: Onno Marsman (https://twitter.com/onnomarsman)
// bugfixed by: Pellentesque Malesuada
// bugfixed by: Kevin van Zonneveld (http://kvz.io)
// improved by: Indigo744
// example 1: base64_decode('S2V2aW4gdmFuIFpvbm5ldmVsZA==')
// returns 1: 'Kevin van Zonneveld'
// example 2: base64_decode('YQ==')
// returns 2: 'a'
// example 3: base64_decode('4pyTIMOgIGxhIG1vZGU=')
// returns 3: '✓ à la mode'
// decodeUTF8string()
// Internal function to decode properly UTF8 string
// Adapted from Solution #1 at https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding
var decodeUTF8string = function (str) {
// Going backwards: from bytestream, to percent-encoding, to original string.
return decodeURIComponent(str
.split('')
.map(function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
})
.join(''));
};
var o1, o2, o3, h1, h2, h3, h4, bits, i = 0, ac = 0, dec = '';
var tmpArr = [];
if (!encodedData) {
return encodedData;
}
encodedData += '';
do {
// unpack four hexets into three octets using index points in b64
h1 = b64.indexOf(encodedData.charAt(i++));
h2 = b64.indexOf(encodedData.charAt(i++));
h3 = b64.indexOf(encodedData.charAt(i++));
h4 = b64.indexOf(encodedData.charAt(i++));
bits = (h1 << 18) | (h2 << 12) | (h3 << 6) | h4;
o1 = (bits >> 16) & 0xff;
o2 = (bits >> 8) & 0xff;
o3 = bits & 0xff;
if (h3 === 64) {
tmpArr[ac++] = String.fromCharCode(o1);
}
else if (h4 === 64) {
tmpArr[ac++] = String.fromCharCode(o1, o2);
}
else {
tmpArr[ac++] = String.fromCharCode(o1, o2, o3);
}
} while (i < encodedData.length);
dec = tmpArr.join('');
return decodeUTF8string(dec.replace(/\0+$/, ''));
}
/**
* A helper to build a Snowplow request from a set of name-value pairs, provided using the add methods.
* Will base64 encode JSON, if desired, on build
*
* @returns The request builder, with add and build methods
*/
function payloadJsonProcessor(encodeBase64) {
return function (payloadBuilder, jsonForProcessing, contextEntitiesForProcessing) {
var add = function (json, keyIfEncoded, keyIfNotEncoded) {
var str = JSON.stringify(json);
if (encodeBase64) {
payloadBuilder.add(keyIfEncoded, base64urlencode(str));
}
else {
payloadBuilder.add(keyIfNotEncoded, str);
}
};
var getContextFromPayload = function () {
var payload = payloadBuilder.getPayload();
if (encodeBase64 ? payload.cx : payload.co) {
return JSON.parse(encodeBase64 ? base64urldecode(payload.cx) : payload.co);
}
return undefined;
};
var combineContexts = function (originalContext, newContext) {
var context = originalContext || getContextFromPayload();
if (context) {
context.data = context.data.concat(newContext.data);
}
else {
context = newContext;
}
return context;
};
var context = undefined;
for (var _i = 0, jsonForProcessing_1 = jsonForProcessing; _i < jsonForProcessing_1.length; _i++) {
var json = jsonForProcessing_1[_i];
if (json.keyIfEncoded === 'cx') {
context = combineContexts(context, json.json);
}
else {
add(json.json, json.keyIfEncoded, json.keyIfNotEncoded);
}
}
jsonForProcessing.length = 0;
if (contextEntitiesForProcessing.length) {
var newContext = {
schema: 'iglu:com.snowplowanalytics.snowplow/contexts/jsonschema/1-0-0',
data: __spreadArray([], contextEntitiesForProcessing, true)
};
context = combineContexts(context, newContext);
contextEntitiesForProcessing.length = 0;
}
if (context) {
add(context, 'cx', 'co');
}
};
}
var LOG_LEVEL;
(function (LOG_LEVEL) {
LOG_LEVEL[LOG_LEVEL["none"] = 0] = "none";
LOG_LEVEL[LOG_LEVEL["error"] = 1] = "error";
LOG_LEVEL[LOG_LEVEL["warn"] = 2] = "warn";
LOG_LEVEL[LOG_LEVEL["debug"] = 3] = "debug";
LOG_LEVEL[LOG_LEVEL["info"] = 4] = "info";
})(LOG_LEVEL || (LOG_LEVEL = {}));
/**
* Slices a schema into its composite parts. Useful for ruleset filtering.
* @param input - A schema string
* @returns The vendor, schema name, major, minor and patch information of a schema string
*/
function getSchemaParts(input) {
var re = new RegExp('^iglu:([a-zA-Z0-9-_.]+)/([a-zA-Z0-9-_]+)/jsonschema/([1-9][0-9]*)-(0|[1-9][0-9]*)-(0|[1-9][0-9]*)$');
var matches = re.exec(input);
if (matches !== null)
return matches.slice(1, 6);
return undefined;
}
var randomColor = {exports: {}};
/*
* Copyright (c) 2022 Snowplow Analytics Ltd, 2010 Anthon Pang
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
var version = version$1;
(function (module, exports) {
(function(root, factory) {
var randomColor = {exports: {}};
// Support CommonJS
{
var randomColor = factory();
(function (module, exports) {
(function(root, factory) {
// Support NodeJS & Component, which allow module.exports to be a function
if (module && module.exports) {
exports = module.exports = randomColor;
}
// Support CommonJS
{
var randomColor = factory();
// Support CommonJS 1.1.1 spec
exports.randomColor = randomColor;
// Support AMD
// Support NodeJS & Component, which allow module.exports to be a function
if (module && module.exports) {
exports = module.exports = randomColor;
}
}(commonjsGlobal, function() {
// Support CommonJS 1.1.1 spec
exports.randomColor = randomColor;
// Seed to get repeatable colors
var seed = null;
// Support AMD
}
// Shared color dictionary
var colorDictionary = {};
}(commonjsGlobal, function() {
// Populate the color dictionary
loadColorBounds();
// Seed to get repeatable colors
var seed = null;
// check if a range is taken
var colorRanges = [];
// Shared color dictionary
var colorDictionary = {};
var randomColor = function (options) {
// Populate the color dictionary
loadColorBounds();
options = options || {};
// check if a range is taken
var colorRanges = [];
// Check if there is a seed and ensure it's an
// integer. Otherwise, reset the seed value.
if (options.seed !== undefined && options.seed !== null && options.seed === parseInt(options.seed, 10)) {
seed = options.seed;
var randomColor = function (options) {
// A string was passed as a seed
} else if (typeof options.seed === 'string') {
seed = stringToInteger(options.seed);
options = options || {};
// Something was passed as a seed but it wasn't an integer or string
} else if (options.seed !== undefined && options.seed !== null) {
throw new TypeError('The seed value must be an integer or string');
// Check if there is a seed and ensure it's an
// integer. Otherwise, reset the seed value.
if (options.seed !== undefined && options.seed !== null && options.seed === parseInt(options.seed, 10)) {
seed = options.seed;
// No seed, reset the value outside.
} else {
seed = null;
}
// A string was passed as a seed
} else if (typeof options.seed === 'string') {
seed = stringToInteger(options.seed);
var H,S,B;
// Something was passed as a seed but it wasn't an integer or string
} else if (options.seed !== undefined && options.seed !== null) {
throw new TypeError('The seed value must be an integer or string');
// Check if we need to generate multiple colors
if (options.count !== null && options.count !== undefined) {
// No seed, reset the value outside.
} else {
seed = null;
}
var totalColors = options.count,
colors = [];
// Value false at index i means the range i is not taken yet.
for (var i = 0; i < options.count; i++) {
colorRanges.push(false);
}
options.count = null;
var H,S,B;
while (totalColors > colors.length) {
// Check if we need to generate multiple colors
if (options.count !== null && options.count !== undefined) {
var color = randomColor(options);
var totalColors = options.count,
colors = [];
// Value false at index i means the range i is not taken yet.
for (var i = 0; i < options.count; i++) {
colorRanges.push(false);
}
options.count = null;
if (seed !== null) {
options.seed = seed;
}
while (totalColors > colors.length) {
colors.push(color);
var color = randomColor(options);
if (seed !== null) {
options.seed = seed;
}
options.count = totalColors;
return colors;
colors.push(color);
}
// First we pick a hue (H)
H = pickHue(options);
options.count = totalColors;
// Then use H to determine saturation (S)
S = pickSaturation(H, options);
return colors;
}
// Then use S and H to determine brightness (B).
B = pickBrightness(H, S, options);
// First we pick a hue (H)
H = pickHue(options);
// Then we return the HSB color in the desired format
return setFormat([H,S,B], options);
};
// Then use H to determine saturation (S)
S = pickSaturation(H, options);
function pickHue(options) {
if (colorRanges.length > 0) {
var hueRange = getRealHueRange(options.hue);
// Then use S and H to determine brightness (B).
B = pickBrightness(H, S, options);
var hue = randomWithin(hueRange);
// Then we return the HSB color in the desired format
return setFormat([H,S,B], options);
};
//Each of colorRanges.length ranges has a length equal approximatelly one step
var step = (hueRange[1] - hueRange[0]) / colorRanges.length;
function pickHue(options) {
if (colorRanges.length > 0) {
var hueRange = getRealHueRange(options.hue);
var j = parseInt((hue - hueRange[0]) / step);
var hue = randomWithin(hueRange);
//Check if the range j is taken
if (colorRanges[j] === true) {
j = (j + 2) % colorRanges.length;
}
else {
colorRanges[j] = true;
}
//Each of colorRanges.length ranges has a length equal approximatelly one step
var step = (hueRange[1] - hueRange[0]) / colorRanges.length;
var min = (hueRange[0] + j * step) % 359,
max = (hueRange[0] + (j + 1) * step) % 359;
var j = parseInt((hue - hueRange[0]) / step);
hueRange = [min, max];
hue = randomWithin(hueRange);
if (hue < 0) {hue = 360 + hue;}
return hue
//Check if the range j is taken
if (colorRanges[j] === true) {
j = (j + 2) % colorRanges.length;
}
else {
var hueRange = getHueRange(options.hue);
colorRanges[j] = true;
}
hue = randomWithin(hueRange);
// Instead of storing red as two seperate ranges,
// we group them, using negative numbers
if (hue < 0) {
hue = 360 + hue;
}
var min = (hueRange[0] + j * step) % 359,
max = (hueRange[0] + (j + 1) * step) % 359;
return hue;
hueRange = [min, max];
hue = randomWithin(hueRange);
if (hue < 0) {hue = 360 + hue;}
return hue
}
else {
var hueRange = getHueRange(options.hue);
hue = randomWithin(hueRange);
// Instead of storing red as two seperate ranges,
// we group them, using negative numbers
if (hue < 0) {
hue = 360 + hue;
}
return hue;
}
}
function pickSaturation (hue, options) {
function pickSaturation (hue, options) {
if (options.hue === 'monochrome') {
return 0;
}
if (options.hue === 'monochrome') {
return 0;
}
if (options.luminosity === 'random') {
return randomWithin([0,100]);
}
if (options.luminosity === 'random') {
return randomWithin([0,100]);
}
var saturationRange = getSaturationRange(hue);
var saturationRange = getSaturationRange(hue);
var sMin = saturationRange[0],
sMax = saturationRange[1];
var sMin = saturationRange[0],
sMax = saturationRange[1];
switch (options.luminosity) {
switch (options.luminosity) {
case 'bright':
sMin = 55;
break;
case 'bright':
sMin = 55;
break;
case 'dark':
sMin = sMax - 10;
break;
case 'dark':
sMin = sMax - 10;
break;
case 'light':
sMax = 55;
break;
}
case 'light':
sMax = 55;
break;
}
return randomWithin([sMin, sMax]);
return randomWithin([sMin, sMax]);
}
}
function pickBrightness (H, S, options) {
function pickBrightness (H, S, options) {
var bMin = getMinimumBrightness(H, S),
bMax = 100;
var bMin = getMinimumBrightness(H, S),
bMax = 100;
switch (options.luminosity) {
switch (options.luminosity) {
case 'dark':
bMax = bMin + 20;
break;
case 'dark':
bMax = bMin + 20;
break;
case 'light':
bMin = (bMax + bMin)/2;
break;
case 'light':
bMin = (bMax + bMin)/2;
break;
case 'random':
bMin = 0;
bMax = 100;
break;
}
return randomWithin([bMin, bMax]);
case 'random':
bMin = 0;
bMax = 100;
break;
}
function setFormat (hsv, options) {
return randomWithin([bMin, bMax]);
}
switch (options.format) {
function setFormat (hsv, options) {
case 'hsvArray':
return hsv;
switch (options.format) {
case 'hslArray':
return HSVtoHSL(hsv);
case 'hsvArray':
return hsv;
case 'hsl':
var hsl = HSVtoHSL(hsv);
return 'hsl('+hsl[0]+', '+hsl[1]+'%, '+hsl[2]+'%)';
case 'hslArray':
return HSVtoHSL(hsv);
case 'hsla':
var hslColor = HSVtoHSL(hsv);
var alpha = options.alpha || Math.random();
return 'hsla('+hslColor[0]+', '+hslColor[1]+'%, '+hslColor[2]+'%, ' + alpha + ')';
case 'hsl':
var hsl = HSVtoHSL(hsv);
return 'hsl('+hsl[0]+', '+hsl[1]+'%, '+hsl[2]+'%)';
case 'rgbArray':
return HSVtoRGB(hsv);
case 'hsla':
var hslColor = HSVtoHSL(hsv);
var alpha = options.alpha || Math.random();
return 'hsla('+hslColor[0]+', '+hslColor[1]+'%, '+hslColor[2]+'%, ' + alpha + ')';
case 'rgb':
var rgb = HSVtoRGB(hsv);
return 'rgb(' + rgb.join(', ') + ')';
case 'rgbArray':
return HSVtoRGB(hsv);
case 'rgba':
var rgbColor = HSVtoRGB(hsv);
var alpha = options.alpha || Math.random();
return 'rgba(' + rgbColor.join(', ') + ', ' + alpha + ')';
case 'rgb':
var rgb = HSVtoRGB(hsv);
return 'rgb(' + rgb.join(', ') + ')';
default:
return HSVtoHex(hsv);
}
case 'rgba':
var rgbColor = HSVtoRGB(hsv);
var alpha = options.alpha || Math.random();
return 'rgba(' + rgbColor.join(', ') + ', ' + alpha + ')';
default:
return HSVtoHex(hsv);
}
function getMinimumBrightness(H, S) {
}
var lowerBounds = getColorInfo(H).lowerBounds;
function getMinimumBrightness(H, S) {
for (var i = 0; i < lowerBounds.length - 1; i++) {
var lowerBounds = getColorInfo(H).lowerBounds;
var s1 = lowerBounds[i][0],
v1 = lowerBounds[i][1];
for (var i = 0; i < lowerBounds.length - 1; i++) {
var s2 = lowerBounds[i+1][0],
v2 = lowerBounds[i+1][1];
var s1 = lowerBounds[i][0],
v1 = lowerBounds[i][1];
if (S >= s1 && S <= s2) {
var s2 = lowerBounds[i+1][0],
v2 = lowerBounds[i+1][1];
var m = (v2 - v1)/(s2 - s1),
b = v1 - m*s1;
if (S >= s1 && S <= s2) {
return m*S + b;
}
var m = (v2 - v1)/(s2 - s1),
b = v1 - m*s1;
return m*S + b;
}
return 0;
}
function getHueRange (colorInput) {
return 0;
}
if (typeof parseInt(colorInput) === 'number') {
function getHueRange (colorInput) {
var number = parseInt(colorInput);
if (typeof parseInt(colorInput) === 'number') {
if (number < 360 && number > 0) {
return [number, number];
}
var number = parseInt(colorInput);
if (number < 360 && number > 0) {
return [number, number];
}
if (typeof colorInput === 'string') {
}
if (colorDictionary[colorInput]) {
var color = colorDictionary[colorInput];
if (color.hueRange) {return color.hueRange;}
} else if (colorInput.match(/^#?([0-9A-F]{3}|[0-9A-F]{6})$/i)) {
var hue = HexToHSB(colorInput)[0];
return [ hue, hue ];
}
if (typeof colorInput === 'string') {
if (colorDictionary[colorInput]) {
var color = colorDictionary[colorInput];
if (color.hueRange) {return color.hueRange;}
} else if (colorInput.match(/^#?([0-9A-F]{3}|[0-9A-F]{6})$/i)) {
var hue = HexToHSB(colorInput)[0];
return [ hue, hue ];
}
}
return [0,360];
return [0,360];
}
}
function getSaturationRange (hue) {
return getColorInfo(hue).saturationRange;
}
function getSaturationRange (hue) {
return getColorInfo(hue).saturationRange;
}
function getColorInfo (hue) {
function getColorInfo (hue) {
// Maps red colors to make picking hue easier
if (hue >= 334 && hue <= 360) {
hue-= 360;
}
for (var colorName in colorDictionary) {
var color = colorDictionary[colorName];
if (color.hueRange &&
hue >= color.hueRange[0] &&
hue <= color.hueRange[1]) {
return colorDictionary[colorName];
}
} return 'Color not found';
// Maps red colors to make picking hue easier
if (hue >= 334 && hue <= 360) {
hue-= 360;
}
function randomWithin (range) {
if (seed === null) {
//generate random evenly destinct number from : https://martin.ankerl.com/2009/12/09/how-to-create-random-colors-programmatically/
var golden_ratio = 0.618033988749895;
var r=Math.random();
r += golden_ratio;
r %= 1;
return Math.floor(range[0] + r*(range[1] + 1 - range[0]));
} else {
//Seeded random algorithm from http://indiegamr.com/generate-repeatable-random-numbers-in-js/
var max = range[1] || 1;
var min = range[0] || 0;
seed = (seed * 9301 + 49297) % 233280;
var rnd = seed / 233280.0;
return Math.floor(min + rnd * (max - min));
for (var colorName in colorDictionary) {
var color = colorDictionary[colorName];
if (color.hueRange &&
hue >= color.hueRange[0] &&
hue <= color.hueRange[1]) {
return colorDictionary[colorName];
}
} return 'Color not found';
}
}
function HSVtoHex (hsv){
function randomWithin (range) {
if (seed === null) {
//generate random evenly destinct number from : https://martin.ankerl.com/2009/12/09/how-to-create-random-colors-programmatically/
var golden_ratio = 0.618033988749895;
var r=Math.random();
r += golden_ratio;
r %= 1;
return Math.floor(range[0] + r*(range[1] + 1 - range[0]));
} else {
//Seeded random algorithm from http://indiegamr.com/generate-repeatable-random-numbers-in-js/
var max = range[1] || 1;
var min = range[0] || 0;
seed = (seed * 9301 + 49297) % 233280;
var rnd = seed / 233280.0;
return Math.floor(min + rnd * (max - min));
}
}
var rgb = HSVtoRGB(hsv);
function HSVtoHex (hsv){
function componentToHex(c) {
var hex = c.toString(16);
return hex.length == 1 ? '0' + hex : hex;
}
var rgb = HSVtoRGB(hsv);
var hex = '#' + componentToHex(rgb[0]) + componentToHex(rgb[1]) + componentToHex(rgb[2]);
function componentToHex(c) {
var hex = c.toString(16);
return hex.length == 1 ? '0' + hex : hex;
}
return hex;
var hex = '#' + componentToHex(rgb[0]) + componentToHex(rgb[1]) + componentToHex(rgb[2]);
}
return hex;
function defineColor (name, hueRange, lowerBounds) {
}
var sMin = lowerBounds[0][0],
sMax = lowerBounds[lowerBounds.length - 1][0],
function defineColor (name, hueRange, lowerBounds) {
bMin = lowerBounds[lowerBounds.length - 1][1],
bMax = lowerBounds[0][1];
var sMin = lowerBounds[0][0],
sMax = lowerBounds[lowerBounds.length - 1][0],
colorDictionary[name] = {
hueRange: hueRange,
lowerBounds: lowerBounds,
saturationRange: [sMin, sMax],
brightnessRange: [bMin, bMax]
};
bMin = lowerBounds[lowerBounds.length - 1][1],
bMax = lowerBounds[0][1];
}
colorDictionary[name] = {
hueRange: hueRange,
lowerBounds: lowerBounds,
saturationRange: [sMin, sMax],
brightnessRange: [bMin, bMax]
};
function loadColorBounds () {
}
defineColor(
'monochrome',
null,
[[0,0],[100,0]]
);
function loadColorBounds () {
defineColor(
'red',
[-26,18],
[[20,100],[30,92],[40,89],[50,85],[60,78],[70,70],[80,60],[90,55],[100,50]]
);
defineColor(
'monochrome',
null,
[[0,0],[100,0]]
);
defineColor(
'orange',
[18,46],
[[20,100],[30,93],[40,88],[50,86],[60,85],[70,70],[100,70]]
);
defineColor(
'red',
[-26,18],
[[20,100],[30,92],[40,89],[50,85],[60,78],[70,70],[80,60],[90,55],[100,50]]
);
defineColor(
'yellow',
[46,62],
[[25,100],[40,94],[50,89],[60,86],[70,84],[80,82],[90,80],[100,75]]
);
defineColor(
'orange',
[18,46],
[[20,100],[30,93],[40,88],[50,86],[60,85],[70,70],[100,70]]
);
defineColor(
'green',
[62,178],
[[30,100],[40,90],[50,85],[60,81],[70,74],[80,64],[90,50],[100,40]]
);
defineColor(
'yellow',
[46,62],
[[25,100],[40,94],[50,89],[60,86],[70,84],[80,82],[90,80],[100,75]]
);
defineColor(
'blue',
[178, 257],
[[20,100],[30,86],[40,80],[50,74],[60,60],[70,52],[80,44],[90,39],[100,35]]
);
defineColor(
'green',
[62,178],
[[30,100],[40,90],[50,85],[60,81],[70,74],[80,64],[90,50],[100,40]]
);
defineColor(
'purple',
[257, 282],
[[20,100],[30,87],[40,79],[50,70],[60,65],[70,59],[80,52],[90,45],[100,42]]
);
defineColor(
'blue',
[178, 257],
[[20,100],[30,86],[40,80],[50,74],[60,60],[70,52],[80,44],[90,39],[100,35]]
);
defineColor(
'pink',
[282, 334],
[[20,100],[30,90],[40,86],[60,84],[80,80],[90,75],[100,73]]
);
defineColor(
'purple',
[257, 282],
[[20,100],[30,87],[40,79],[50,70],[60,65],[70,59],[80,52],[90,45],[100,42]]
);
}
defineColor(
'pink',
[282, 334],
[[20,100],[30,90],[40,86],[60,84],[80,80],[90,75],[100,73]]
);
function HSVtoRGB (hsv) {
}
// this doesn't work for the values of 0 and 360
// here's the hacky fix
var h = hsv[0];
if (h === 0) {h = 1;}
if (h === 360) {h = 359;}
function HSVtoRGB (hsv) {
// Rebase the h,s,v values
h = h/360;
var s = hsv[1]/100,
v = hsv[2]/100;
// this doesn't work for the values of 0 and 360
// here's the hacky fix
var h = hsv[0];
if (h === 0) {h = 1;}
if (h === 360) {h = 359;}
var h_i = Math.floor(h*6),
f = h * 6 - h_i,
p = v * (1 - s),
q = v * (1 - f*s),
t = v * (1 - (1 - f)*s),
r = 256,
g = 256,
b = 256;
// Rebase the h,s,v values
h = h/360;
var s = hsv[1]/100,
v = hsv[2]/100;
switch(h_i) {
case 0: r = v; g = t; b = p; break;
case 1: r = q; g = v; b = p; break;
case 2: r = p; g = v; b = t; break;
case 3: r = p; g = q; b = v; break;
case 4: r = t; g = p; b = v; break;
case 5: r = v; g = p; b = q; break;
}
var h_i = Math.floor(h*6),
f = h * 6 - h_i,
p = v * (1 - s),
q = v * (1 - f*s),
t = v * (1 - (1 - f)*s),
r = 256,
g = 256,
b = 256;
var result = [Math.floor(r*255), Math.floor(g*255), Math.floor(b*255)];
return result;
switch(h_i) {
case 0: r = v; g = t; b = p; break;
case 1: r = q; g = v; b = p; break;
case 2: r = p; g = v; b = t; break;
case 3: r = p; g = q; b = v; break;
case 4: r = t; g = p; b = v; break;
case 5: r = v; g = p; b = q; break;
}
function HexToHSB (hex) {
hex = hex.replace(/^#/, '');
hex = hex.length === 3 ? hex.replace(/(.)/g, '$1$1') : hex;
var result = [Math.floor(r*255), Math.floor(g*255), Math.floor(b*255)];
return result;
}
var red = parseInt(hex.substr(0, 2), 16) / 255,
green = parseInt(hex.substr(2, 2), 16) / 255,
blue = parseInt(hex.substr(4, 2), 16) / 255;
function HexToHSB (hex) {
hex = hex.replace(/^#/, '');
hex = hex.length === 3 ? hex.replace(/(.)/g, '$1$1') : hex;
var cMax = Math.max(red, green, blue),
delta = cMax - Math.min(red, green, blue),
saturation = cMax ? (delta / cMax) : 0;
var red = parseInt(hex.substr(0, 2), 16) / 255,
green = parseInt(hex.substr(2, 2), 16) / 255,
blue = parseInt(hex.substr(4, 2), 16) / 255;
switch (cMax) {
case red: return [ 60 * (((green - blue) / delta) % 6) || 0, saturation, cMax ];
case green: return [ 60 * (((blue - red) / delta) + 2) || 0, saturation, cMax ];
case blue: return [ 60 * (((red - green) / delta) + 4) || 0, saturation, cMax ];
}
var cMax = Math.max(red, green, blue),
delta = cMax - Math.min(red, green, blue),
saturation = cMax ? (delta / cMax) : 0;
switch (cMax) {
case red: return [ 60 * (((green - blue) / delta) % 6) || 0, saturation, cMax ];
case green: return [ 60 * (((blue - red) / delta) + 2) || 0, saturation, cMax ];
case blue: return [ 60 * (((red - green) / delta) + 4) || 0, saturation, cMax ];
}
}
function HSVtoHSL (hsv) {
var h = hsv[0],
s = hsv[1]/100,
v = hsv[2]/100,
k = (2-s)*v;
function HSVtoHSL (hsv) {
var h = hsv[0],
s = hsv[1]/100,
v = hsv[2]/100,
k = (2-s)*v;
return [
h,
Math.round(s*v / (k<1 ? k : 2-k) * 10000) / 100,
k/2 * 100
];
}
return [
h,
Math.round(s*v / (k<1 ? k : 2-k) * 10000) / 100,
k/2 * 100
];
}
function stringToInteger (string) {
var total = 0;
for (var i = 0; i !== string.length; i++) {
if (total >= Number.MAX_SAFE_INTEGER) break;
total += string.charCodeAt(i);
}
return total
function stringToInteger (string) {
var total = 0;
for (var i = 0; i !== string.length; i++) {
if (total >= Number.MAX_SAFE_INTEGER) break;
total += string.charCodeAt(i);
}
return total
}
// get The range of given hue when options.count!=0
function getRealHueRange(colorHue)
{ if (!isNaN(colorHue)) {
var number = parseInt(colorHue);
// get The range of given hue when options.count!=0
function getRealHueRange(colorHue)
{ if (!isNaN(colorHue)) {
var number = parseInt(colorHue);
if (number < 360 && number > 0) {
return getColorInfo(colorHue).hueRange
}
if (number < 360 && number > 0) {
return getColorInfo(colorHue).hueRange
}
else if (typeof colorHue === 'string') {
}
else if (typeof colorHue === 'string') {
if (colorDictionary[colorHue]) {
var color = colorDictionary[colorHue];
if (colorDictionary[colorHue]) {
var color = colorDictionary[colorHue];
if (color.hueRange) {
return color.hueRange
}
} else if (colorHue.match(/^#?([0-9A-F]{3}|[0-9A-F]{6})$/i)) {
var hue = HexToHSB(colorHue)[0];
return getColorInfo(hue).hueRange
}
if (color.hueRange) {
return color.hueRange
}
} else if (colorHue.match(/^#?([0-9A-F]{3}|[0-9A-F]{6})$/i)) {
var hue = HexToHSB(colorHue)[0];
return getColorInfo(hue).hueRange
}
return [0,360]
}
return randomColor;
}));
}(randomColor, randomColor.exports));
var randomcolor = randomColor.exports;
return [0,360]
}
return randomColor;
}));
}(randomColor, randomColor.exports));
/*
* Copyright (c) 2022 Snowplow Analytics Ltd, 2010 Anthon Pang
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* Adds advertisement tracking functions
*/
function DebuggerPlugin(logLevel) {
if (logLevel === void 0) { logLevel = LOG_LEVEL.debug; }
var LOG;
var tracker;
var eventColour;
var colours = {
event: function () { return "color: White; background: ".concat(eventColour, "; font-weight: bold; padding: 1px 4px; border-radius: 2px;"); },
snowplowPurple: 'color: White; background: #6638B8; font-weight: bold; padding: 1px 4px; border-radius: 2px;',
activated: 'color: White; background: #9E62DD; font-weight: bold; padding: 1px 4px; border-radius: 2px;',
payload: 'color: White; background: #3748B8; font-weight: bold; padding: 1px 4px; border-radius: 2px;',
json: 'color: White; background: #388AB8; font-weight: bold; padding: 1px 4px; border-radius: 2px;',
schema: 'color: White; background: #268047; font-weight: bold; padding: 1px 4px; border-radius: 2px;',
schemaVersion: 'color: White; background: #80265F; font-weight: bold; padding: 1px 4px; border-radius: 2px;'
};
var debug = function (style, message, extra) {
var _a = extra !== null && extra !== void 0 ? extra : [''], extraMessage = _a[0], rest = _a.slice(1);
LOG.debug.apply(LOG, __spreadArray(["v".concat(version, " %c").concat(tracker.namespace, "%c %c%s") + extraMessage,
colours.snowplowPurple,
'',
style,
message], rest, false));
};
function jsonInterceptor(encodeBase64) {
var log = function (jsonType, data) {
var schemaParts = getSchemaParts(data['schema']);
debug(colours.event(), 'Event', [
'%c%s%c%s%c%s\n%o',
colours.json,
"".concat(jsonType, ": ").concat(schemaParts ? schemaParts[1] : 'Unknown Schema'),
colours.schemaVersion,
schemaParts ? "Version: ".concat(schemaParts[2], "-").concat(schemaParts[3], "-").concat(schemaParts[4]) : 'Unknown Schema Version',
colours.schema,
schemaParts ? "Vendor: ".concat(schemaParts[0]) : 'Unknown Vendor',
data['data'],
]);
};
return function (payloadBuilder, jsonForProcessing, contextEntitiesForProcessing) {
if (jsonForProcessing.length) {
var _loop_1 = function (json) {
var data = json.json['data'];
if (Array.isArray(data)) {
data.forEach(function (d) {
log(getJsonType(json), d);
});
}
else {
log(getJsonType(json), data);
}
};
for (var _i = 0, jsonForProcessing_1 = jsonForProcessing; _i < jsonForProcessing_1.length; _i++) {
var json = jsonForProcessing_1[_i];
_loop_1(json);
}
}
if (contextEntitiesForProcessing.length) {
for (var _a = 0, contextEntitiesForProcessing_1 = contextEntitiesForProcessing; _a < contextEntitiesForProcessing_1.length; _a++) {
var entity = contextEntitiesForProcessing_1[_a];
log('Context', entity);
}
}
return payloadJsonProcessor(encodeBase64)(payloadBuilder, jsonForProcessing, contextEntitiesForProcessing);
};
}
return {
logger: function (logger) {
LOG = logger;
logger.setLogLevel(logLevel);
},
activateBrowserPlugin: function (t) {
tracker = t;
debug(colours.activated, 'Tracker Activated');
},
beforeTrack: function (payloadBuilder) {
eventColour = randomcolor({ luminosity: 'dark' });
payloadBuilder.withJsonProcessor(jsonInterceptor(tracker.core.getBase64Encoding()));
debug(colours.event(), 'Event', ['%c%s', colours.snowplowPurple, getEventType(payloadBuilder)]);
payloadBuilder.build();
},
afterTrack: function (payload) {
debug(colours.event(), 'Event', ['%c%s\n%o', colours.payload, 'Payload', payload]);
}
};
}
function getJsonType(json) {
switch (json.keyIfEncoded) {
case 'cx':
return 'Context';
case 'ue_px':
return 'Self Describing';
default:
return "".concat(json.keyIfEncoded, ", ").concat(json.keyIfNotEncoded);
}
}
function getEventType(payloadBuilder) {
var payload = payloadBuilder.getPayload();
switch (payload['e']) {
case 'pv':
return 'Page View';
case 'pp':
return 'Page Ping';
case 'tr':
return 'Ecommerce Transaction';
case 'ti':
return 'Ecommerce Transaction Item';
case 'se':
return 'Structured Event';
case 'ue':
return 'Self Describing';
default:
return typeof payload['e'] === 'string' ? payload['e'] : 'Invalid';
}
}
var randomcolor = randomColor.exports;
exports.DebuggerPlugin = DebuggerPlugin;
/*
* Copyright (c) 2022 Snowplow Analytics Ltd, 2010 Anthon Pang
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* Adds advertisement tracking functions
*/
function DebuggerPlugin(logLevel) {
if (logLevel === void 0) { logLevel = LOG_LEVEL.debug; }
var LOG;
var tracker;
var eventColour;
var colours = {
event: function () { return "color: White; background: ".concat(eventColour, "; font-weight: bold; padding: 1px 4px; border-radius: 2px;"); },
snowplowPurple: 'color: White; background: #6638B8; font-weight: bold; padding: 1px 4px; border-radius: 2px;',
activated: 'color: White; background: #9E62DD; font-weight: bold; padding: 1px 4px; border-radius: 2px;',
payload: 'color: White; background: #3748B8; font-weight: bold; padding: 1px 4px; border-radius: 2px;',
json: 'color: White; background: #388AB8; font-weight: bold; padding: 1px 4px; border-radius: 2px;',
schema: 'color: White; background: #268047; font-weight: bold; padding: 1px 4px; border-radius: 2px;',
schemaVersion: 'color: White; background: #80265F; font-weight: bold; padding: 1px 4px; border-radius: 2px;'
};
var debug = function (style, message, extra) {
var _a = extra !== null && extra !== void 0 ? extra : [''], extraMessage = _a[0], rest = _a.slice(1);
LOG.debug.apply(LOG, __spreadArray(["v".concat(version, " %c").concat(tracker.namespace, "%c %c%s") + extraMessage,
colours.snowplowPurple,
'',
style,
message], rest, false));
};
function jsonInterceptor(encodeBase64) {
var log = function (jsonType, data) {
var schemaParts = getSchemaParts(data['schema']);
debug(colours.event(), 'Event', [
'%c%s%c%s%c%s\n%o',
colours.json,
"".concat(jsonType, ": ").concat(schemaParts ? schemaParts[1] : 'Unknown Schema'),
colours.schemaVersion,
schemaParts ? "Version: ".concat(schemaParts[2], "-").concat(schemaParts[3], "-").concat(schemaParts[4]) : 'Unknown Schema Version',
colours.schema,
schemaParts ? "Vendor: ".concat(schemaParts[0]) : 'Unknown Vendor',
data['data'],
]);
};
return function (payloadBuilder, jsonForProcessing, contextEntitiesForProcessing) {
if (jsonForProcessing.length) {
var _loop_1 = function (json) {
var data = json.json['data'];
if (Array.isArray(data)) {
data.forEach(function (d) {
log(getJsonType(json), d);
});
}
else {
log(getJsonType(json), data);
}
};
for (var _i = 0, jsonForProcessing_1 = jsonForProcessing; _i < jsonForProcessing_1.length; _i++) {
var json = jsonForProcessing_1[_i];
_loop_1(json);
}
}
if (contextEntitiesForProcessing.length) {
for (var _a = 0, contextEntitiesForProcessing_1 = contextEntitiesForProcessing; _a < contextEntitiesForProcessing_1.length; _a++) {
var entity = contextEntitiesForProcessing_1[_a];
log('Context', entity);
}
}
return payloadJsonProcessor(encodeBase64)(payloadBuilder, jsonForProcessing, contextEntitiesForProcessing);
};
}
return {
logger: function (logger) {
LOG = logger;
logger.setLogLevel(logLevel);
},
activateBrowserPlugin: function (t) {
tracker = t;
debug(colours.activated, 'Tracker Activated');
},
beforeTrack: function (payloadBuilder) {
eventColour = randomcolor({ luminosity: 'dark' });
payloadBuilder.withJsonProcessor(jsonInterceptor(tracker.core.getBase64Encoding()));
debug(colours.event(), 'Event', ['%c%s', colours.snowplowPurple, getEventType(payloadBuilder)]);
payloadBuilder.build();
},
afterTrack: function (payload) {
debug(colours.event(), 'Event', ['%c%s\n%o', colours.payload, 'Payload', payload]);
}
};
}
function getJsonType(json) {
switch (json.keyIfEncoded) {
case 'cx':
return 'Context';
case 'ue_px':
return 'Self Describing';
default:
return "".concat(json.keyIfEncoded, ", ").concat(json.keyIfNotEncoded);
}
}
function getEventType(payloadBuilder) {
var payload = payloadBuilder.getPayload();
switch (payload['e']) {
case 'pv':
return 'Page View';
case 'pp':
return 'Page Ping';
case 'tr':
return 'Ecommerce Transaction';
case 'ti':
return 'Ecommerce Transaction Item';
case 'se':
return 'Structured Event';
case 'ue':
return 'Self Describing';
default:
return typeof payload['e'] === 'string' ? payload['e'] : 'Invalid';
}
}
Object.defineProperty(exports, '__esModule', { value: true });
exports.DebuggerPlugin = DebuggerPlugin;
Object.defineProperty(exports, '__esModule', { value: true });
}));
//# sourceMappingURL=index.umd.js.map
/*!
* Debugger for Snowplow v3.24.2 (http://bit.ly/sp-js)
* Debugger for Snowplow v3.24.3 (http://bit.ly/sp-js)
* Copyright 2022 Snowplow Analytics Ltd, 2010 Anthon Pang

@@ -7,3 +7,3 @@ * Licensed under BSD-3-Clause

"use strict";!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).snowplowDebugger={})}(this,(function(e){function n(e,n,r){if(r||2===arguments.length)for(var t,o=0,a=n.length;o<a;o++)!t&&o in n||(t||(t=Array.prototype.slice.call(n,0,o)),t[o]=n[o]);return e.concat(t||Array.prototype.slice.call(n))}function r(e){return function(r,t,o){for(var a=function(n,t,o){if(n=JSON.stringify(n),e){if(o=r.add,n){var a=0,c=0,i=[];if(n){n=unescape(encodeURIComponent(n));do{var s=n.charCodeAt(a++),l=n.charCodeAt(a++),d=n.charCodeAt(a++),f=s<<16|l<<8|d;s=f>>18&63,l=f>>12&63,d=f>>6&63,f&=63,i[c++]=u.charAt(s)+u.charAt(l)+u.charAt(d)+u.charAt(f)}while(a<n.length);a=i.join(""),n=((n=n.length%3)?a.slice(0,n-3):a)+"===".slice(n||3)}n=n.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}o.call(r,t,n)}else r.add(o,n)},c=function(n,t){if(!n){var o=r.getPayload();if(e?o.cx:o.co){var a=(n=JSON).parse;if(e){if(o=o.cx){switch(4-o.length%4){case 2:o+="==";break;case 3:o+="="}o=function(e){var n,r=0,t=0,o="",a=[];if(!e)return e;e+="";do{var c=u.indexOf(e.charAt(r++)),i=u.indexOf(e.charAt(r++));o=u.indexOf(e.charAt(r++));var s=u.indexOf(e.charAt(r++)),l=c<<18|i<<12|o<<6|s;c=l>>16&255,i=l>>8&255,l&=255,a[t++]=64===o?String.fromCharCode(c):64===s?String.fromCharCode(c,i):String.fromCharCode(c,i,l)}while(r<e.length);return o=a.join(""),n=o.replace(/\0+$/,""),decodeURIComponent(n.split("").map((function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)})).join(""))}(o=o.replace(/-/g,"+").replace(/_/g,"/"))}}else o=o.co;n=a.call(n,o)}else n=void 0}return n?n.data=n.data.concat(t.data):n=t,n},i=void 0,s=0;s<t.length;s++){var l=t[s];"cx"===l.keyIfEncoded?i=c(i,l.json):a(l.json,l.keyIfEncoded,l.keyIfNotEncoded)}t.length=0,o.length&&(i=c(i,t={schema:"iglu:com.snowplowanalytics.snowplow/contexts/jsonschema/1-0-0",data:n([],o,!0)}),o.length=0),i&&a(i,"cx","co")}}function t(e){switch(e.keyIfEncoded){case"cx":return"Context";case"ue_px":return"Self Describing";default:return"".concat(e.keyIfEncoded,", ").concat(e.keyIfNotEncoded)}}function o(e){switch((e=e.getPayload()).e){case"pv":return"Page View";case"pp":return"Page Ping";case"tr":return"Ecommerce Transaction";case"ti":return"Ecommerce Transaction Item";case"se":return"Structured Event";case"ue":return"Self Describing";default:return"string"==typeof e.e?e.e:"Invalid"}}var a,c,i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";(c=a||(a={}))[c.none=0]="none",c[c.error=1]="error",c[c.warn=2]="warn",c[c.debug=3]="debug",c[c.info=4]="info";var s={exports:{}};!function(e,n){var r;r=i,r=function(){function e(e,n){switch(n.format){case"hsvArray":return e;case"hslArray":return u(e);case"hsl":return"hsl("+(n=u(e))[0]+", "+n[1]+"%, "+n[2]+"%)";case"hsla":return e=u(e),n=n.alpha||Math.random(),"hsla("+e[0]+", "+e[1]+"%, "+e[2]+"%, "+n+")";case"rgbArray":return c(e);case"rgb":return"rgb("+c(e).join(", ")+")";case"rgba":return e=c(e),n=n.alpha||Math.random(),"rgba("+e.join(", ")+", "+n+")";default:return o(e)}}function n(e){if("number"==typeof parseInt(e)){var n=parseInt(e);if(360>n&&0<n)return[n,n]}if("string"==typeof e)if(d[e]){if((e=d[e]).hueRange)return e.hueRange}else if(e.match(/^#?([0-9A-F]{3}|[0-9A-F]{6})$/i))return[e=i(e)[0],e];return[0,360]}function r(e){for(var n in 334<=e&&360>=e&&(e-=360),d){var r=d[n];if(r.hueRange&&e>=r.hueRange[0]&&e<=r.hueRange[1])return d[n]}return"Color not found"}function t(e){if(null===l){var n=Math.random();return Math.floor(e[0]+(n+.618033988749895)%1*(e[1]+1-e[0]))}return n=e[1]||1,e=e[0]||0,l=(9301*l+49297)%233280,Math.floor(e+l/233280*(n-e))}function o(e){function n(e){return 1==(e=e.toString(16)).length?"0"+e:e}return"#"+n((e=c(e))[0])+n(e[1])+n(e[2])}function a(e,n,r){d[e]={hueRange:n,lowerBounds:r,saturationRange:[r[0][0],r[r.length-1][0]],brightnessRange:[r[r.length-1][1],r[0][1]]}}function c(e){var n=e[0];0===n&&(n=1),360===n&&(n=359),n/=360;var r=e[1]/100;e=e[2]/100;var t=Math.floor(6*n),o=6*n-t;n=e*(1-r);var a=e*(1-o*r);r=e*(1-(1-o)*r);var c=o=256,i=256;switch(t){case 0:o=e,c=r,i=n;break;case 1:o=a,c=e,i=n;break;case 2:o=n,c=e,i=r;break;case 3:o=n,c=a,i=e;break;case 4:o=r,c=n,i=e;break;case 5:o=e,c=n,i=a}return[Math.floor(255*o),Math.floor(255*c),Math.floor(255*i)]}function i(e){e=3===(e=e.replace(/^#/,"")).length?e.replace(/(.)/g,"$1$1"):e;var n=parseInt(e.substr(0,2),16)/255,r=parseInt(e.substr(2,2),16)/255;e=parseInt(e.substr(4,2),16)/255;var t=Math.max(n,r,e),o=t-Math.min(n,r,e),a=t?o/t:0;switch(t){case n:return[(r-e)/o%6*60||0,a,t];case r:return[60*((e-n)/o+2)||0,a,t];case e:return[60*((n-r)/o+4)||0,a,t]}}function u(e){var n=e[1]/100,r=e[2]/100,t=(2-n)*r;return[e[0],Math.round(n*r/(1>t?t:2-t)*1e4)/100,t/2*100]}function s(e){if(isNaN(e)){if("string"==typeof e)if(d[e]){if((e=d[e]).hueRange)return e.hueRange}else if(e.match(/^#?([0-9A-F]{3}|[0-9A-F]{6})$/i))return r(e=i(e)[0]).hueRange}else{var n=parseInt(e);if(360>n&&0<n)return r(e).hueRange}return[0,360]}var l=null,d={};a("monochrome",null,[[0,0],[100,0]]),a("red",[-26,18],[[20,100],[30,92],[40,89],[50,85],[60,78],[70,70],[80,60],[90,55],[100,50]]),a("orange",[18,46],[[20,100],[30,93],[40,88],[50,86],[60,85],[70,70],[100,70]]),a("yellow",[46,62],[[25,100],[40,94],[50,89],[60,86],[70,84],[80,82],[90,80],[100,75]]),a("green",[62,178],[[30,100],[40,90],[50,85],[60,81],[70,74],[80,64],[90,50],[100,40]]),a("blue",[178,257],[[20,100],[30,86],[40,80],[50,74],[60,60],[70,52],[80,44],[90,39],[100,35]]),a("purple",[257,282],[[20,100],[30,87],[40,79],[50,70],[60,65],[70,59],[80,52],[90,45],[100,42]]),a("pink",[282,334],[[20,100],[30,90],[40,86],[60,84],[80,80],[90,75],[100,73]]);var f=[],h=function(o){if(void 0!==(o=o||{}).seed&&null!==o.seed&&o.seed===parseInt(o.seed,10))l=o.seed;else if("string"==typeof o.seed){for(var a=o.seed,c=0,i=0;i!==a.length&&!(c>=Number.MAX_SAFE_INTEGER);i++)c+=a.charCodeAt(i);l=c}else{if(void 0!==o.seed&&null!==o.seed)throw new TypeError("The seed value must be an integer or string");l=null}if(null!==o.count&&void 0!==o.count){for(a=o.count,c=[],i=0;i<o.count;i++)f.push(!1);for(o.count=null;a>c.length;)i=h(o),null!==l&&(o.seed=l),c.push(i);return o.count=a,c}if(a=o,0<f.length?(i=t(a=s(a.hue)),c=(a[1]-a[0])/f.length,i=parseInt((i-a[0])/c),!0===f[i]?i=(i+2)%f.length:f[i]=!0,a=[(a[0]+i*c)%359,(a[0]+(i+1)*c)%359]):a=n(a.hue),0>(i=t(a))&&(i=360+i),a=i,"monochrome"===(c=o).hue)c=0;else if("random"===c.luminosity)c=t([0,100]);else{var u=r(a).saturationRange;switch(i=u[0],u=u[1],c.luminosity){case"bright":i=55;break;case"dark":i=u-10;break;case"light":u=55}c=t([i,u])}i=o;e:{u=c;for(var d=r(a).lowerBounds,g=0;g<d.length-1;g++){var p=d[g][0],v=d[g][1],b=d[g+1][0],m=d[g+1][1];if(u>=p&&u<=b){u=(d=(m-v)/(b-p))*u+(v-d*p);break e}}u=0}switch(p=100,i.luminosity){case"dark":p=u+20;break;case"light":u=(p+u)/2;break;case"random":u=0,p=100}return e([a,c,i=t([u,p])],o)};return h}(),e&&e.exports&&(n=e.exports=r),n.randomColor=r}(s,s.exports);var l=s.exports;e.DebuggerPlugin=function(e){void 0===e&&(e=a.debug);var c,i,u,s={event:function(){return"color: White; background: ".concat(u,"; font-weight: bold; padding: 1px 4px; border-radius: 2px;")},snowplowPurple:"color: White; background: #6638B8; font-weight: bold; padding: 1px 4px; border-radius: 2px;",activated:"color: White; background: #9E62DD; font-weight: bold; padding: 1px 4px; border-radius: 2px;",payload:"color: White; background: #3748B8; font-weight: bold; padding: 1px 4px; border-radius: 2px;",json:"color: White; background: #388AB8; font-weight: bold; padding: 1px 4px; border-radius: 2px;",schema:"color: White; background: #268047; font-weight: bold; padding: 1px 4px; border-radius: 2px;",schemaVersion:"color: White; background: #80265F; font-weight: bold; padding: 1px 4px; border-radius: 2px;"},d=function(e,r,t){var o=null!=t?t:[""];t=o[0],o=o.slice(1),c.debug.apply(c,n(["v".concat("3.24.2"," %c").concat(i.namespace,"%c %c%s")+t,s.snowplowPurple,"",e,r],o,!1))};return{logger:function(n){c=n,n.setLogLevel(e)},activateBrowserPlugin:function(e){i=e,d(s.activated,"Tracker Activated")},beforeTrack:function(e){u=l({luminosity:"dark"}),e.withJsonProcessor(function(e){var n=function(e,n){var r=/^iglu:([a-zA-Z0-9-_.]+)\/([a-zA-Z0-9-_]+)\/jsonschema\/([1-9][0-9]*)-(0|[1-9][0-9]*)-(0|[1-9][0-9]*)$/.exec(n.schema);r=null!==r?r.slice(1,6):void 0,d(s.event(),"Event",["%c%s%c%s%c%s\n%o",s.json,"".concat(e,": ").concat(r?r[1]:"Unknown Schema"),s.schemaVersion,r?"Version: ".concat(r[2],"-").concat(r[3],"-").concat(r[4]):"Unknown Schema Version",s.schema,r?"Vendor: ".concat(r[0]):"Unknown Vendor",n.data])};return function(o,a,c){if(a.length)for(var i=function(e){var r=e.json.data;Array.isArray(r)?r.forEach((function(r){n(t(e),r)})):n(t(e),r)},u=0;u<a.length;u++)i(a[u]);if(c.length)for(i=0;i<c.length;i++)n("Context",c[i]);return r(e)(o,a,c)}}(i.core.getBase64Encoding())),d(s.event(),"Event",["%c%s",s.snowplowPurple,o(e)]),e.build()},afterTrack:function(e){d(s.event(),"Event",["%c%s\n%o",s.payload,"Payload",e])}}},Object.defineProperty(e,"__esModule",{value:!0})}));
"use strict";!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).snowplowDebugger={})}(this,(function(e){function n(e,n,r){if(r||2===arguments.length)for(var t,o=0,a=n.length;o<a;o++)!t&&o in n||(t||(t=Array.prototype.slice.call(n,0,o)),t[o]=n[o]);return e.concat(t||Array.prototype.slice.call(n))}function r(e){return function(r,t,o){for(var a=function(n,t,o){if(n=JSON.stringify(n),e){if(o=r.add,n){var a=0,c=0,i=[];if(n){n=unescape(encodeURIComponent(n));do{var s=n.charCodeAt(a++),l=n.charCodeAt(a++),d=n.charCodeAt(a++),f=s<<16|l<<8|d;s=f>>18&63,l=f>>12&63,d=f>>6&63,f&=63,i[c++]=u.charAt(s)+u.charAt(l)+u.charAt(d)+u.charAt(f)}while(a<n.length);a=i.join(""),n=((n=n.length%3)?a.slice(0,n-3):a)+"===".slice(n||3)}n=n.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}o.call(r,t,n)}else r.add(o,n)},c=function(n,t){if(!n){var o=r.getPayload();if(e?o.cx:o.co){var a=(n=JSON).parse;if(e){if(o=o.cx){switch(4-o.length%4){case 2:o+="==";break;case 3:o+="="}o=function(e){var n,r=0,t=0,o="",a=[];if(!e)return e;e+="";do{var c=u.indexOf(e.charAt(r++)),i=u.indexOf(e.charAt(r++));o=u.indexOf(e.charAt(r++));var s=u.indexOf(e.charAt(r++)),l=c<<18|i<<12|o<<6|s;c=l>>16&255,i=l>>8&255,l&=255,a[t++]=64===o?String.fromCharCode(c):64===s?String.fromCharCode(c,i):String.fromCharCode(c,i,l)}while(r<e.length);return o=a.join(""),n=o.replace(/\0+$/,""),decodeURIComponent(n.split("").map((function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)})).join(""))}(o=o.replace(/-/g,"+").replace(/_/g,"/"))}}else o=o.co;n=a.call(n,o)}else n=void 0}return n?n.data=n.data.concat(t.data):n=t,n},i=void 0,s=0;s<t.length;s++){var l=t[s];"cx"===l.keyIfEncoded?i=c(i,l.json):a(l.json,l.keyIfEncoded,l.keyIfNotEncoded)}t.length=0,o.length&&(i=c(i,t={schema:"iglu:com.snowplowanalytics.snowplow/contexts/jsonschema/1-0-0",data:n([],o,!0)}),o.length=0),i&&a(i,"cx","co")}}function t(e){switch(e.keyIfEncoded){case"cx":return"Context";case"ue_px":return"Self Describing";default:return"".concat(e.keyIfEncoded,", ").concat(e.keyIfNotEncoded)}}function o(e){switch((e=e.getPayload()).e){case"pv":return"Page View";case"pp":return"Page Ping";case"tr":return"Ecommerce Transaction";case"ti":return"Ecommerce Transaction Item";case"se":return"Structured Event";case"ue":return"Self Describing";default:return"string"==typeof e.e?e.e:"Invalid"}}"function"==typeof SuppressedError&&SuppressedError;var a,c,i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";(c=a||(a={}))[c.none=0]="none",c[c.error=1]="error",c[c.warn=2]="warn",c[c.debug=3]="debug",c[c.info=4]="info";var s={exports:{}};!function(e,n){var r;r=i,r=function(){function e(e,n){switch(n.format){case"hsvArray":return e;case"hslArray":return u(e);case"hsl":return"hsl("+(n=u(e))[0]+", "+n[1]+"%, "+n[2]+"%)";case"hsla":return e=u(e),n=n.alpha||Math.random(),"hsla("+e[0]+", "+e[1]+"%, "+e[2]+"%, "+n+")";case"rgbArray":return c(e);case"rgb":return"rgb("+c(e).join(", ")+")";case"rgba":return e=c(e),n=n.alpha||Math.random(),"rgba("+e.join(", ")+", "+n+")";default:return o(e)}}function n(e){if("number"==typeof parseInt(e)){var n=parseInt(e);if(360>n&&0<n)return[n,n]}if("string"==typeof e)if(d[e]){if((e=d[e]).hueRange)return e.hueRange}else if(e.match(/^#?([0-9A-F]{3}|[0-9A-F]{6})$/i))return[e=i(e)[0],e];return[0,360]}function r(e){for(var n in 334<=e&&360>=e&&(e-=360),d){var r=d[n];if(r.hueRange&&e>=r.hueRange[0]&&e<=r.hueRange[1])return d[n]}return"Color not found"}function t(e){if(null===l){var n=Math.random();return Math.floor(e[0]+(n+.618033988749895)%1*(e[1]+1-e[0]))}return n=e[1]||1,e=e[0]||0,l=(9301*l+49297)%233280,Math.floor(e+l/233280*(n-e))}function o(e){function n(e){return 1==(e=e.toString(16)).length?"0"+e:e}return"#"+n((e=c(e))[0])+n(e[1])+n(e[2])}function a(e,n,r){d[e]={hueRange:n,lowerBounds:r,saturationRange:[r[0][0],r[r.length-1][0]],brightnessRange:[r[r.length-1][1],r[0][1]]}}function c(e){var n=e[0];0===n&&(n=1),360===n&&(n=359),n/=360;var r=e[1]/100;e=e[2]/100;var t=Math.floor(6*n),o=6*n-t;n=e*(1-r);var a=e*(1-o*r);r=e*(1-(1-o)*r);var c=o=256,i=256;switch(t){case 0:o=e,c=r,i=n;break;case 1:o=a,c=e,i=n;break;case 2:o=n,c=e,i=r;break;case 3:o=n,c=a,i=e;break;case 4:o=r,c=n,i=e;break;case 5:o=e,c=n,i=a}return[Math.floor(255*o),Math.floor(255*c),Math.floor(255*i)]}function i(e){e=3===(e=e.replace(/^#/,"")).length?e.replace(/(.)/g,"$1$1"):e;var n=parseInt(e.substr(0,2),16)/255,r=parseInt(e.substr(2,2),16)/255;e=parseInt(e.substr(4,2),16)/255;var t=Math.max(n,r,e),o=t-Math.min(n,r,e),a=t?o/t:0;switch(t){case n:return[(r-e)/o%6*60||0,a,t];case r:return[60*((e-n)/o+2)||0,a,t];case e:return[60*((n-r)/o+4)||0,a,t]}}function u(e){var n=e[1]/100,r=e[2]/100,t=(2-n)*r;return[e[0],Math.round(n*r/(1>t?t:2-t)*1e4)/100,t/2*100]}function s(e){if(isNaN(e)){if("string"==typeof e)if(d[e]){if((e=d[e]).hueRange)return e.hueRange}else if(e.match(/^#?([0-9A-F]{3}|[0-9A-F]{6})$/i))return r(e=i(e)[0]).hueRange}else{var n=parseInt(e);if(360>n&&0<n)return r(e).hueRange}return[0,360]}var l=null,d={};a("monochrome",null,[[0,0],[100,0]]),a("red",[-26,18],[[20,100],[30,92],[40,89],[50,85],[60,78],[70,70],[80,60],[90,55],[100,50]]),a("orange",[18,46],[[20,100],[30,93],[40,88],[50,86],[60,85],[70,70],[100,70]]),a("yellow",[46,62],[[25,100],[40,94],[50,89],[60,86],[70,84],[80,82],[90,80],[100,75]]),a("green",[62,178],[[30,100],[40,90],[50,85],[60,81],[70,74],[80,64],[90,50],[100,40]]),a("blue",[178,257],[[20,100],[30,86],[40,80],[50,74],[60,60],[70,52],[80,44],[90,39],[100,35]]),a("purple",[257,282],[[20,100],[30,87],[40,79],[50,70],[60,65],[70,59],[80,52],[90,45],[100,42]]),a("pink",[282,334],[[20,100],[30,90],[40,86],[60,84],[80,80],[90,75],[100,73]]);var f=[],h=function(o){if(void 0!==(o=o||{}).seed&&null!==o.seed&&o.seed===parseInt(o.seed,10))l=o.seed;else if("string"==typeof o.seed){for(var a=o.seed,c=0,i=0;i!==a.length&&!(c>=Number.MAX_SAFE_INTEGER);i++)c+=a.charCodeAt(i);l=c}else{if(void 0!==o.seed&&null!==o.seed)throw new TypeError("The seed value must be an integer or string");l=null}if(null!==o.count&&void 0!==o.count){for(a=o.count,c=[],i=0;i<o.count;i++)f.push(!1);for(o.count=null;a>c.length;)i=h(o),null!==l&&(o.seed=l),c.push(i);return o.count=a,c}if(a=o,0<f.length?(i=t(a=s(a.hue)),c=(a[1]-a[0])/f.length,i=parseInt((i-a[0])/c),!0===f[i]?i=(i+2)%f.length:f[i]=!0,a=[(a[0]+i*c)%359,(a[0]+(i+1)*c)%359]):a=n(a.hue),0>(i=t(a))&&(i=360+i),a=i,"monochrome"===(c=o).hue)c=0;else if("random"===c.luminosity)c=t([0,100]);else{var u=r(a).saturationRange;switch(i=u[0],u=u[1],c.luminosity){case"bright":i=55;break;case"dark":i=u-10;break;case"light":u=55}c=t([i,u])}i=o;e:{u=c;for(var d=r(a).lowerBounds,g=0;g<d.length-1;g++){var p=d[g][0],v=d[g][1],b=d[g+1][0],m=d[g+1][1];if(u>=p&&u<=b){u=(d=(m-v)/(b-p))*u+(v-d*p);break e}}u=0}switch(p=100,i.luminosity){case"dark":p=u+20;break;case"light":u=(p+u)/2;break;case"random":u=0,p=100}return e([a,c,i=t([u,p])],o)};return h}(),e&&e.exports&&(n=e.exports=r),n.randomColor=r}(s,s.exports);var l=s.exports;e.DebuggerPlugin=function(e){void 0===e&&(e=a.debug);var c,i,u,s={event:function(){return"color: White; background: ".concat(u,"; font-weight: bold; padding: 1px 4px; border-radius: 2px;")},snowplowPurple:"color: White; background: #6638B8; font-weight: bold; padding: 1px 4px; border-radius: 2px;",activated:"color: White; background: #9E62DD; font-weight: bold; padding: 1px 4px; border-radius: 2px;",payload:"color: White; background: #3748B8; font-weight: bold; padding: 1px 4px; border-radius: 2px;",json:"color: White; background: #388AB8; font-weight: bold; padding: 1px 4px; border-radius: 2px;",schema:"color: White; background: #268047; font-weight: bold; padding: 1px 4px; border-radius: 2px;",schemaVersion:"color: White; background: #80265F; font-weight: bold; padding: 1px 4px; border-radius: 2px;"},d=function(e,r,t){var o=null!=t?t:[""];t=o[0],o=o.slice(1),c.debug.apply(c,n(["v".concat("3.24.3"," %c").concat(i.namespace,"%c %c%s")+t,s.snowplowPurple,"",e,r],o,!1))};return{logger:function(n){c=n,n.setLogLevel(e)},activateBrowserPlugin:function(e){i=e,d(s.activated,"Tracker Activated")},beforeTrack:function(e){u=l({luminosity:"dark"}),e.withJsonProcessor(function(e){var n=function(e,n){var r=/^iglu:([a-zA-Z0-9-_.]+)\/([a-zA-Z0-9-_]+)\/jsonschema\/([1-9][0-9]*)-(0|[1-9][0-9]*)-(0|[1-9][0-9]*)$/.exec(n.schema);r=null!==r?r.slice(1,6):void 0,d(s.event(),"Event",["%c%s%c%s%c%s\n%o",s.json,"".concat(e,": ").concat(r?r[1]:"Unknown Schema"),s.schemaVersion,r?"Version: ".concat(r[2],"-").concat(r[3],"-").concat(r[4]):"Unknown Schema Version",s.schema,r?"Vendor: ".concat(r[0]):"Unknown Vendor",n.data])};return function(o,a,c){if(a.length)for(var i=function(e){var r=e.json.data;Array.isArray(r)?r.forEach((function(r){n(t(e),r)})):n(t(e),r)},u=0;u<a.length;u++)i(a[u]);if(c.length)for(i=0;i<c.length;i++)n("Context",c[i]);return r(e)(o,a,c)}}(i.core.getBase64Encoding())),d(s.event(),"Event",["%c%s",s.snowplowPurple,o(e)]),e.build()},afterTrack:function(e){d(s.event(),"Event",["%c%s\n%o",s.payload,"Payload",e])}}},Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=index.umd.min.js.map
{
"name": "@snowplow/browser-plugin-debugger",
"version": "3.24.2",
"version": "3.24.3",
"description": "Debugger for Snowplow",

@@ -21,6 +21,6 @@ "homepage": "http://bit.ly/sp-js",

"dependencies": {
"@snowplow/browser-tracker-core": "3.24.2",
"@snowplow/tracker-core": "3.24.2",
"randomcolor": "^0.6.2",
"tslib": "^2.3.1"
"tslib": "^2.3.1",
"@snowplow/browser-tracker-core": "3.24.3",
"@snowplow/tracker-core": "3.24.3"
},

@@ -50,3 +50,3 @@ "devDependencies": {

"peerDependencies": {
"@snowplow/browser-tracker": "~3.24.2"
"@snowplow/browser-tracker": "~3.24.3"
},

@@ -56,4 +56,3 @@ "scripts": {

"test": ""
},
"readme": "# Snowplow Advertising Tracking\n\n[![npm version][npm-image]][npm-url]\n[![License][license-image]](LICENSE)\n\nBrowser Plugin to be used with `@snowplow/browser-tracker`.\n\nAdds debugging to your Snowplow tracking.\n\n## Maintainer quick start\n\nPart of the Snowplow JavaScript Tracker monorepo. \nBuild with [Node.js](https://nodejs.org/en/) (14 or 16) and [Rush](https://rushjs.io/).\n\n### Setup repository\n\n```bash\nnpm install -g @microsoft/rush \ngit clone https://github.com/snowplow/snowplow-javascript-tracker.git\nrush update\n```\n\n## Package Installation\n\nWith npm:\n\n```bash\nnpm install @snowplow/browser-plugin-debugger\n```\n\n## Usage\n\nInitialize your tracker with the DebuggerPlugin:\n\n```js\nimport { newTracker } from '@snowplow/browser-tracker';\nimport { DebuggerPlugin } from '@snowplow/browser-plugin-debugger';\n\nnewTracker('sp1', '{{collector}}', { plugins: [ DebuggerPlugin() ] }); // Also stores reference at module level\n```\n\nThen additional debugging information will be available in your browsers Developer Tools.\n\n## Copyright and license\n\nLicensed and distributed under the [BSD 3-Clause License](LICENSE) ([An OSI Approved License][osi]).\n\nCopyright (c) 2022 Snowplow Analytics Ltd, 2010 Anthon Pang.\n\nAll rights reserved.\n\n[npm-url]: https://www.npmjs.com/package/@snowplow/browser-plugin-ad-tracking\n[npm-image]: https://img.shields.io/npm/v/@snowplow/browser-plugin-ad-tracking\n[docs]: https://docs.snowplowanalytics.com/docs/collecting-data/collecting-from-own-applications/javascript-tracker/\n[osi]: https://opensource.org/licenses/BSD-3-Clause\n[license-image]: https://img.shields.io/npm/l/@snowplow/browser-plugin-ad-tracking\n"
}
}

@@ -13,3 +13,3 @@ # Snowplow Advertising Tracking

Part of the Snowplow JavaScript Tracker monorepo.
Build with [Node.js](https://nodejs.org/en/) (14 or 16) and [Rush](https://rushjs.io/).
Build with [Node.js](https://nodejs.org/en/) (18 - 20) and [Rush](https://rushjs.io/).

@@ -16,0 +16,0 @@ ### Setup repository

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc