@snowplow/browser-plugin-ad-tracking
Advanced tools
Comparing version 3.24.2 to 3.24.3-dev.0
/*! | ||
* Ad tracking for Snowplow v3.24.2 (http://bit.ly/sp-js) | ||
* Ad tracking for Snowplow v3.24.3-dev.0 (http://bit.ly/sp-js) | ||
* Copyright 2022 Snowplow Analytics Ltd, 2010 Anthon Pang | ||
@@ -47,3 +47,3 @@ * Licensed under BSD-3-Clause | ||
_trackers[tracker.id] = tracker; | ||
} | ||
}, | ||
}; | ||
@@ -50,0 +50,0 @@ } |
/*! | ||
* Ad tracking for Snowplow v3.24.2 (http://bit.ly/sp-js) | ||
* Ad tracking for Snowplow v3.24.3-dev.0 (http://bit.ly/sp-js) | ||
* Copyright 2022 Snowplow Analytics Ltd, 2010 Anthon Pang | ||
@@ -8,483 +8,488 @@ * 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.snowplowAdTracking = {})); | ||
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.snowplowAdTracking = {})); | ||
})(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)); | ||
} | ||
/*! | ||
* 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 | ||
*/ | ||
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { | ||
var e = new Error(message); | ||
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; | ||
}; | ||
/* | ||
* 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. | ||
*/ | ||
function payloadBuilder() { | ||
var dict = {}, allJson = [], jsonForProcessing = [], contextEntitiesForProcessing = []; | ||
var processor; | ||
var add = function (key, value) { | ||
if (value != null && value !== '') { | ||
// null also checks undefined | ||
dict[key] = value; | ||
} | ||
}; | ||
var addDict = function (dict) { | ||
for (var key in dict) { | ||
if (Object.prototype.hasOwnProperty.call(dict, key)) { | ||
add(key, dict[key]); | ||
} | ||
} | ||
}; | ||
var addJson = function (keyIfEncoded, keyIfNotEncoded, json) { | ||
if (json && isNonEmptyJson(json)) { | ||
var jsonWithKeys = { keyIfEncoded: keyIfEncoded, keyIfNotEncoded: keyIfNotEncoded, json: json }; | ||
jsonForProcessing.push(jsonWithKeys); | ||
allJson.push(jsonWithKeys); | ||
} | ||
}; | ||
var addContextEntity = function (entity) { | ||
contextEntitiesForProcessing.push(entity); | ||
}; | ||
return { | ||
add: add, | ||
addDict: addDict, | ||
addJson: addJson, | ||
addContextEntity: addContextEntity, | ||
getPayload: function () { return dict; }, | ||
getJson: function () { return allJson; }, | ||
withJsonProcessor: function (jsonProcessor) { | ||
processor = jsonProcessor; | ||
}, | ||
build: function () { | ||
processor === null || processor === void 0 ? void 0 : processor(this, jsonForProcessing, contextEntitiesForProcessing); | ||
return dict; | ||
} | ||
}; | ||
} | ||
/** | ||
* Is property a non-empty JSON? | ||
* @param property - Checks if object is non-empty json | ||
*/ | ||
function isNonEmptyJson(property) { | ||
if (!isJson(property)) { | ||
return false; | ||
} | ||
for (var key in property) { | ||
if (Object.prototype.hasOwnProperty.call(property, key)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
/** | ||
* Is property a JSON? | ||
* @param property - Checks if object is json | ||
*/ | ||
function isJson(property) { | ||
return (typeof property !== 'undefined' && | ||
property !== null && | ||
(property.constructor === {}.constructor || property.constructor === [].constructor)); | ||
} | ||
/*! | ||
* Core functionality for Snowplow JavaScript trackers v3.24.3-dev.0 (http://bit.ly/sp-js) | ||
* Copyright 2022 Snowplow Analytics Ltd, 2010 Anthon Pang | ||
* Licensed under BSD-3-Clause | ||
*/ | ||
/* | ||
* 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 label = 'Snowplow: '; | ||
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 = {})); | ||
var LOG = logger(); | ||
function logger(logLevel) { | ||
if (logLevel === void 0) { logLevel = LOG_LEVEL.warn; } | ||
function setLogLevel(level) { | ||
if (LOG_LEVEL[level]) { | ||
logLevel = level; | ||
} | ||
else { | ||
logLevel = LOG_LEVEL.warn; | ||
} | ||
} | ||
/** | ||
* Log errors, with or without error object | ||
*/ | ||
function error(message, error) { | ||
var extraParams = []; | ||
for (var _i = 2; _i < arguments.length; _i++) { | ||
extraParams[_i - 2] = arguments[_i]; | ||
} | ||
if (logLevel >= LOG_LEVEL.error && typeof console !== 'undefined') { | ||
var logMsg = label + message + '\n'; | ||
if (error) { | ||
console.error.apply(console, __spreadArray([logMsg + '\n', error], extraParams, false)); | ||
} | ||
else { | ||
console.error.apply(console, __spreadArray([logMsg], extraParams, false)); | ||
} | ||
} | ||
} | ||
/** | ||
* Log warnings, with or without error object | ||
*/ | ||
function warn(message, error) { | ||
var extraParams = []; | ||
for (var _i = 2; _i < arguments.length; _i++) { | ||
extraParams[_i - 2] = arguments[_i]; | ||
} | ||
if (logLevel >= LOG_LEVEL.warn && typeof console !== 'undefined') { | ||
var logMsg = label + message; | ||
if (error) { | ||
console.warn.apply(console, __spreadArray([logMsg + '\n', error], extraParams, false)); | ||
} | ||
else { | ||
console.warn.apply(console, __spreadArray([logMsg], extraParams, false)); | ||
} | ||
} | ||
} | ||
/** | ||
* Log debug messages | ||
*/ | ||
function debug(message) { | ||
var extraParams = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
extraParams[_i - 1] = arguments[_i]; | ||
} | ||
if (logLevel >= LOG_LEVEL.debug && typeof console !== 'undefined') { | ||
console.debug.apply(console, __spreadArray([label + message], extraParams, false)); | ||
} | ||
} | ||
/** | ||
* Log info messages | ||
*/ | ||
function info(message) { | ||
var extraParams = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
extraParams[_i - 1] = arguments[_i]; | ||
} | ||
if (logLevel >= LOG_LEVEL.info && typeof console !== 'undefined') { | ||
console.info.apply(console, __spreadArray([label + message], extraParams, false)); | ||
} | ||
} | ||
return { setLogLevel: setLogLevel, warn: warn, error: error, debug: debug, info: info }; | ||
} | ||
/** | ||
* Build a self-describing event | ||
* A custom event type, allowing for an event to be tracked using your own custom schema | ||
* and a data object which conforms to the supplied schema | ||
* | ||
* @param event - Contains the properties and schema location for the event | ||
* @returns PayloadBuilder to be sent to {@link @snowplow/tracker-core#TrackerCore.track} | ||
*/ | ||
function buildSelfDescribingEvent(event) { | ||
var _a = event.event, schema = _a.schema, data = _a.data, pb = payloadBuilder(); | ||
var ueJson = { | ||
schema: 'iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0', | ||
data: { schema: schema, data: data } | ||
}; | ||
pb.add('e', 'ue'); | ||
pb.addJson('ue_px', 'ue_pr', ueJson); | ||
return pb; | ||
} | ||
/** | ||
* Build a Ad Impression Event | ||
* Used to track an advertisement impression | ||
* | ||
* @remarks | ||
* If you provide the cost field, you must also provide one of 'cpa', 'cpc', and 'cpm' for the costModel field. | ||
* | ||
* @param event - Contains the properties for the Ad Impression event | ||
* @returns PayloadBuilder to be sent to {@link @snowplow/tracker-core#TrackerCore.track} | ||
*/ | ||
function buildAdImpression(event) { | ||
var impressionId = event.impressionId, costModel = event.costModel, cost = event.cost, targetUrl = event.targetUrl, bannerId = event.bannerId, zoneId = event.zoneId, advertiserId = event.advertiserId, campaignId = event.campaignId; | ||
var eventJson = { | ||
schema: 'iglu:com.snowplowanalytics.snowplow/ad_impression/jsonschema/1-0-0', | ||
data: removeEmptyProperties({ | ||
impressionId: impressionId, | ||
costModel: costModel, | ||
cost: cost, | ||
targetUrl: targetUrl, | ||
bannerId: bannerId, | ||
zoneId: zoneId, | ||
advertiserId: advertiserId, | ||
campaignId: campaignId | ||
}) | ||
}; | ||
return buildSelfDescribingEvent({ event: eventJson }); | ||
} | ||
/** | ||
* Build a Ad Click Event | ||
* Used to track an advertisement click | ||
* | ||
* @remarks | ||
* If you provide the cost field, you must also provide one of 'cpa', 'cpc', and 'cpm' for the costModel field. | ||
* | ||
* @param event - Contains the properties for the Ad Click event | ||
* @returns PayloadBuilder to be sent to {@link @snowplow/tracker-core#TrackerCore.track} | ||
*/ | ||
function buildAdClick(event) { | ||
var targetUrl = event.targetUrl, clickId = event.clickId, costModel = event.costModel, cost = event.cost, bannerId = event.bannerId, zoneId = event.zoneId, impressionId = event.impressionId, advertiserId = event.advertiserId, campaignId = event.campaignId; | ||
var eventJson = { | ||
schema: 'iglu:com.snowplowanalytics.snowplow/ad_click/jsonschema/1-0-0', | ||
data: removeEmptyProperties({ | ||
targetUrl: targetUrl, | ||
clickId: clickId, | ||
costModel: costModel, | ||
cost: cost, | ||
bannerId: bannerId, | ||
zoneId: zoneId, | ||
impressionId: impressionId, | ||
advertiserId: advertiserId, | ||
campaignId: campaignId | ||
}) | ||
}; | ||
return buildSelfDescribingEvent({ event: eventJson }); | ||
} | ||
/** | ||
* Build a Ad Conversion Event | ||
* Used to track an advertisement click | ||
* | ||
* @remarks | ||
* If you provide the cost field, you must also provide one of 'cpa', 'cpc', and 'cpm' for the costModel field. | ||
* | ||
* @param event - Contains the properties for the Ad Conversion event | ||
* @returns PayloadBuilder to be sent to {@link @snowplow/tracker-core#TrackerCore.track} | ||
*/ | ||
function buildAdConversion(event) { | ||
var conversionId = event.conversionId, costModel = event.costModel, cost = event.cost, category = event.category, action = event.action, property = event.property, initialValue = event.initialValue, advertiserId = event.advertiserId, campaignId = event.campaignId; | ||
var eventJson = { | ||
schema: 'iglu:com.snowplowanalytics.snowplow/ad_conversion/jsonschema/1-0-0', | ||
data: removeEmptyProperties({ | ||
conversionId: conversionId, | ||
costModel: costModel, | ||
cost: cost, | ||
category: category, | ||
action: action, | ||
property: property, | ||
initialValue: initialValue, | ||
advertiserId: advertiserId, | ||
campaignId: campaignId | ||
}) | ||
}; | ||
return buildSelfDescribingEvent({ event: eventJson }); | ||
} | ||
/** | ||
* Returns a copy of a JSON with undefined and null properties removed | ||
* | ||
* @param event - JSON object to clean | ||
* @param exemptFields - Set of fields which should not be removed even if empty | ||
* @returns A cleaned copy of eventJson | ||
*/ | ||
function removeEmptyProperties(event, exemptFields) { | ||
if (exemptFields === void 0) { exemptFields = {}; } | ||
var ret = {}; | ||
for (var k in event) { | ||
if (exemptFields[k] || (event[k] !== null && typeof event[k] !== 'undefined')) { | ||
ret[k] = event[k]; | ||
} | ||
} | ||
return ret; | ||
} | ||
/* | ||
* 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. | ||
*/ | ||
function payloadBuilder() { | ||
var dict = {}, allJson = [], jsonForProcessing = [], contextEntitiesForProcessing = []; | ||
var processor; | ||
var add = function (key, value) { | ||
if (value != null && value !== '') { | ||
// null also checks undefined | ||
dict[key] = value; | ||
} | ||
}; | ||
var addDict = function (dict) { | ||
for (var key in dict) { | ||
if (Object.prototype.hasOwnProperty.call(dict, key)) { | ||
add(key, dict[key]); | ||
} | ||
} | ||
}; | ||
var addJson = function (keyIfEncoded, keyIfNotEncoded, json) { | ||
if (json && isNonEmptyJson(json)) { | ||
var jsonWithKeys = { keyIfEncoded: keyIfEncoded, keyIfNotEncoded: keyIfNotEncoded, json: json }; | ||
jsonForProcessing.push(jsonWithKeys); | ||
allJson.push(jsonWithKeys); | ||
} | ||
}; | ||
var addContextEntity = function (entity) { | ||
contextEntitiesForProcessing.push(entity); | ||
}; | ||
return { | ||
add: add, | ||
addDict: addDict, | ||
addJson: addJson, | ||
addContextEntity: addContextEntity, | ||
getPayload: function () { return dict; }, | ||
getJson: function () { return allJson; }, | ||
withJsonProcessor: function (jsonProcessor) { | ||
processor = jsonProcessor; | ||
}, | ||
build: function () { | ||
processor === null || processor === void 0 ? void 0 : processor(this, jsonForProcessing, contextEntitiesForProcessing); | ||
return dict; | ||
}, | ||
}; | ||
} | ||
/** | ||
* Is property a non-empty JSON? | ||
* @param property - Checks if object is non-empty json | ||
*/ | ||
function isNonEmptyJson(property) { | ||
if (!isJson(property)) { | ||
return false; | ||
} | ||
for (var key in property) { | ||
if (Object.prototype.hasOwnProperty.call(property, key)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
/** | ||
* Is property a JSON? | ||
* @param property - Checks if object is json | ||
*/ | ||
function isJson(property) { | ||
return (typeof property !== 'undefined' && | ||
property !== null && | ||
(property.constructor === {}.constructor || property.constructor === [].constructor)); | ||
} | ||
/*! | ||
* Core functionality for Snowplow Browser trackers v3.24.2 (http://bit.ly/sp-js) | ||
* Copyright 2022 Snowplow Analytics Ltd, 2010 Anthon Pang | ||
* Licensed under BSD-3-Clause | ||
*/ | ||
/** | ||
* Dispatch function to all specified trackers from the supplied collection | ||
* | ||
* @param trackers - An optional list of trackers to send the event to, or will send to all trackers | ||
* @param trackerCollection - The collection which the trackers will be selected from | ||
* @param fn - The function which will run against each tracker | ||
*/ | ||
function dispatchToTrackersInCollection(trackers, trackerCollection, fn) { | ||
try { | ||
getTrackersFromCollection(trackers !== null && trackers !== void 0 ? trackers : Object.keys(trackerCollection), trackerCollection).forEach(fn); | ||
} | ||
catch (ex) { | ||
LOG.error('Function failed', ex); | ||
} | ||
} | ||
function getTrackersFromCollection(trackerIds, trackerCollection) { | ||
var trackers = []; | ||
for (var _i = 0, trackerIds_1 = trackerIds; _i < trackerIds_1.length; _i++) { | ||
var id = trackerIds_1[_i]; | ||
if (trackerCollection.hasOwnProperty(id)) { | ||
trackers.push(trackerCollection[id]); | ||
} | ||
else { | ||
LOG.warn(id + ' not configured'); | ||
} | ||
} | ||
return trackers; | ||
} | ||
/* | ||
* 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 label = 'Snowplow: '; | ||
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 = {})); | ||
var LOG = logger(); | ||
function logger(logLevel) { | ||
if (logLevel === void 0) { logLevel = LOG_LEVEL.warn; } | ||
function setLogLevel(level) { | ||
if (LOG_LEVEL[level]) { | ||
logLevel = level; | ||
} | ||
else { | ||
logLevel = LOG_LEVEL.warn; | ||
} | ||
} | ||
/** | ||
* Log errors, with or without error object | ||
*/ | ||
function error(message, error) { | ||
var extraParams = []; | ||
for (var _i = 2; _i < arguments.length; _i++) { | ||
extraParams[_i - 2] = arguments[_i]; | ||
} | ||
if (logLevel >= LOG_LEVEL.error && typeof console !== 'undefined') { | ||
var logMsg = label + message + '\n'; | ||
if (error) { | ||
console.error.apply(console, __spreadArray([logMsg + '\n', error], extraParams, false)); | ||
} | ||
else { | ||
console.error.apply(console, __spreadArray([logMsg], extraParams, false)); | ||
} | ||
} | ||
} | ||
/** | ||
* Log warnings, with or without error object | ||
*/ | ||
function warn(message, error) { | ||
var extraParams = []; | ||
for (var _i = 2; _i < arguments.length; _i++) { | ||
extraParams[_i - 2] = arguments[_i]; | ||
} | ||
if (logLevel >= LOG_LEVEL.warn && typeof console !== 'undefined') { | ||
var logMsg = label + message; | ||
if (error) { | ||
console.warn.apply(console, __spreadArray([logMsg + '\n', error], extraParams, false)); | ||
} | ||
else { | ||
console.warn.apply(console, __spreadArray([logMsg], extraParams, false)); | ||
} | ||
} | ||
} | ||
/** | ||
* Log debug messages | ||
*/ | ||
function debug(message) { | ||
var extraParams = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
extraParams[_i - 1] = arguments[_i]; | ||
} | ||
if (logLevel >= LOG_LEVEL.debug && typeof console !== 'undefined') { | ||
console.debug.apply(console, __spreadArray([label + message], extraParams, false)); | ||
} | ||
} | ||
/** | ||
* Log info messages | ||
*/ | ||
function info(message) { | ||
var extraParams = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
extraParams[_i - 1] = arguments[_i]; | ||
} | ||
if (logLevel >= LOG_LEVEL.info && typeof console !== 'undefined') { | ||
console.info.apply(console, __spreadArray([label + message], extraParams, false)); | ||
} | ||
} | ||
return { setLogLevel: setLogLevel, warn: warn, error: error, debug: debug, info: info }; | ||
} | ||
/** | ||
* Build a self-describing event | ||
* A custom event type, allowing for an event to be tracked using your own custom schema | ||
* and a data object which conforms to the supplied schema | ||
* | ||
* @param event - Contains the properties and schema location for the event | ||
* @returns PayloadBuilder to be sent to {@link @snowplow/tracker-core#TrackerCore.track} | ||
*/ | ||
function buildSelfDescribingEvent(event) { | ||
var _a = event.event, schema = _a.schema, data = _a.data, pb = payloadBuilder(); | ||
var ueJson = { | ||
schema: 'iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0', | ||
data: { schema: schema, data: data }, | ||
}; | ||
pb.add('e', 'ue'); | ||
pb.addJson('ue_px', 'ue_pr', ueJson); | ||
return pb; | ||
} | ||
/** | ||
* Build a Ad Impression Event | ||
* Used to track an advertisement impression | ||
* | ||
* @remarks | ||
* If you provide the cost field, you must also provide one of 'cpa', 'cpc', and 'cpm' for the costModel field. | ||
* | ||
* @param event - Contains the properties for the Ad Impression event | ||
* @returns PayloadBuilder to be sent to {@link @snowplow/tracker-core#TrackerCore.track} | ||
*/ | ||
function buildAdImpression(event) { | ||
var impressionId = event.impressionId, costModel = event.costModel, cost = event.cost, targetUrl = event.targetUrl, bannerId = event.bannerId, zoneId = event.zoneId, advertiserId = event.advertiserId, campaignId = event.campaignId; | ||
var eventJson = { | ||
schema: 'iglu:com.snowplowanalytics.snowplow/ad_impression/jsonschema/1-0-0', | ||
data: removeEmptyProperties({ | ||
impressionId: impressionId, | ||
costModel: costModel, | ||
cost: cost, | ||
targetUrl: targetUrl, | ||
bannerId: bannerId, | ||
zoneId: zoneId, | ||
advertiserId: advertiserId, | ||
campaignId: campaignId, | ||
}), | ||
}; | ||
return buildSelfDescribingEvent({ event: eventJson }); | ||
} | ||
/** | ||
* Build a Ad Click Event | ||
* Used to track an advertisement click | ||
* | ||
* @remarks | ||
* If you provide the cost field, you must also provide one of 'cpa', 'cpc', and 'cpm' for the costModel field. | ||
* | ||
* @param event - Contains the properties for the Ad Click event | ||
* @returns PayloadBuilder to be sent to {@link @snowplow/tracker-core#TrackerCore.track} | ||
*/ | ||
function buildAdClick(event) { | ||
var targetUrl = event.targetUrl, clickId = event.clickId, costModel = event.costModel, cost = event.cost, bannerId = event.bannerId, zoneId = event.zoneId, impressionId = event.impressionId, advertiserId = event.advertiserId, campaignId = event.campaignId; | ||
var eventJson = { | ||
schema: 'iglu:com.snowplowanalytics.snowplow/ad_click/jsonschema/1-0-0', | ||
data: removeEmptyProperties({ | ||
targetUrl: targetUrl, | ||
clickId: clickId, | ||
costModel: costModel, | ||
cost: cost, | ||
bannerId: bannerId, | ||
zoneId: zoneId, | ||
impressionId: impressionId, | ||
advertiserId: advertiserId, | ||
campaignId: campaignId, | ||
}), | ||
}; | ||
return buildSelfDescribingEvent({ event: eventJson }); | ||
} | ||
/** | ||
* Build a Ad Conversion Event | ||
* Used to track an advertisement click | ||
* | ||
* @remarks | ||
* If you provide the cost field, you must also provide one of 'cpa', 'cpc', and 'cpm' for the costModel field. | ||
* | ||
* @param event - Contains the properties for the Ad Conversion event | ||
* @returns PayloadBuilder to be sent to {@link @snowplow/tracker-core#TrackerCore.track} | ||
*/ | ||
function buildAdConversion(event) { | ||
var conversionId = event.conversionId, costModel = event.costModel, cost = event.cost, category = event.category, action = event.action, property = event.property, initialValue = event.initialValue, advertiserId = event.advertiserId, campaignId = event.campaignId; | ||
var eventJson = { | ||
schema: 'iglu:com.snowplowanalytics.snowplow/ad_conversion/jsonschema/1-0-0', | ||
data: removeEmptyProperties({ | ||
conversionId: conversionId, | ||
costModel: costModel, | ||
cost: cost, | ||
category: category, | ||
action: action, | ||
property: property, | ||
initialValue: initialValue, | ||
advertiserId: advertiserId, | ||
campaignId: campaignId, | ||
}), | ||
}; | ||
return buildSelfDescribingEvent({ event: eventJson }); | ||
} | ||
/** | ||
* Returns a copy of a JSON with undefined and null properties removed | ||
* | ||
* @param event - JSON object to clean | ||
* @param exemptFields - Set of fields which should not be removed even if empty | ||
* @returns A cleaned copy of eventJson | ||
*/ | ||
function removeEmptyProperties(event, exemptFields) { | ||
if (exemptFields === void 0) { exemptFields = {}; } | ||
var ret = {}; | ||
for (var k in event) { | ||
if (exemptFields[k] || (event[k] !== null && typeof event[k] !== 'undefined')) { | ||
ret[k] = event[k]; | ||
} | ||
} | ||
return ret; | ||
} | ||
/* | ||
* 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 _trackers = {}; | ||
/** | ||
* Adds advertisement tracking functions | ||
*/ | ||
function AdTrackingPlugin() { | ||
return { | ||
activateBrowserPlugin: function (tracker) { | ||
_trackers[tracker.id] = tracker; | ||
} | ||
}; | ||
} | ||
/** | ||
* Track an ad being served | ||
* | ||
* @param event - The event information | ||
* @param trackers - The tracker identifiers which the event will be sent to | ||
*/ | ||
function trackAdImpression(event, trackers) { | ||
if (trackers === void 0) { trackers = Object.keys(_trackers); } | ||
dispatchToTrackersInCollection(trackers, _trackers, function (t) { | ||
t.core.track(buildAdImpression(event), event.context, event.timestamp); | ||
}); | ||
} | ||
/** | ||
* Track an ad being clicked | ||
* | ||
* @param event - The event information | ||
* @param trackers - The tracker identifiers which the event will be sent to | ||
*/ | ||
function trackAdClick(event, trackers) { | ||
if (trackers === void 0) { trackers = Object.keys(_trackers); } | ||
dispatchToTrackersInCollection(trackers, _trackers, function (t) { | ||
t.core.track(buildAdClick(event), event.context, event.timestamp); | ||
}); | ||
} | ||
/** | ||
* Track an ad conversion event | ||
* | ||
* @param event - The event information | ||
* @param trackers - The tracker identifiers which the event will be sent to | ||
*/ | ||
function trackAdConversion(event, trackers) { | ||
if (trackers === void 0) { trackers = Object.keys(_trackers); } | ||
dispatchToTrackersInCollection(trackers, _trackers, function (t) { | ||
t.core.track(buildAdConversion(event), event.context, event.timestamp); | ||
}); | ||
} | ||
/*! | ||
* Core functionality for Snowplow Browser trackers v3.24.3-dev.0 (http://bit.ly/sp-js) | ||
* Copyright 2022 Snowplow Analytics Ltd, 2010 Anthon Pang | ||
* Licensed under BSD-3-Clause | ||
*/ | ||
/** | ||
* Dispatch function to all specified trackers from the supplied collection | ||
* | ||
* @param trackers - An optional list of trackers to send the event to, or will send to all trackers | ||
* @param trackerCollection - The collection which the trackers will be selected from | ||
* @param fn - The function which will run against each tracker | ||
*/ | ||
function dispatchToTrackersInCollection(trackers, trackerCollection, fn) { | ||
try { | ||
getTrackersFromCollection(trackers !== null && trackers !== void 0 ? trackers : Object.keys(trackerCollection), trackerCollection).forEach(fn); | ||
} | ||
catch (ex) { | ||
LOG.error('Function failed', ex); | ||
} | ||
} | ||
function getTrackersFromCollection(trackerIds, trackerCollection) { | ||
var trackers = []; | ||
for (var _i = 0, trackerIds_1 = trackerIds; _i < trackerIds_1.length; _i++) { | ||
var id = trackerIds_1[_i]; | ||
if (trackerCollection.hasOwnProperty(id)) { | ||
trackers.push(trackerCollection[id]); | ||
} | ||
else { | ||
LOG.warn(id + ' not configured'); | ||
} | ||
} | ||
return trackers; | ||
} | ||
exports.AdTrackingPlugin = AdTrackingPlugin; | ||
exports.trackAdClick = trackAdClick; | ||
exports.trackAdConversion = trackAdConversion; | ||
exports.trackAdImpression = trackAdImpression; | ||
/* | ||
* 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 _trackers = {}; | ||
/** | ||
* Adds advertisement tracking functions | ||
*/ | ||
function AdTrackingPlugin() { | ||
return { | ||
activateBrowserPlugin: function (tracker) { | ||
_trackers[tracker.id] = tracker; | ||
}, | ||
}; | ||
} | ||
/** | ||
* Track an ad being served | ||
* | ||
* @param event - The event information | ||
* @param trackers - The tracker identifiers which the event will be sent to | ||
*/ | ||
function trackAdImpression(event, trackers) { | ||
if (trackers === void 0) { trackers = Object.keys(_trackers); } | ||
dispatchToTrackersInCollection(trackers, _trackers, function (t) { | ||
t.core.track(buildAdImpression(event), event.context, event.timestamp); | ||
}); | ||
} | ||
/** | ||
* Track an ad being clicked | ||
* | ||
* @param event - The event information | ||
* @param trackers - The tracker identifiers which the event will be sent to | ||
*/ | ||
function trackAdClick(event, trackers) { | ||
if (trackers === void 0) { trackers = Object.keys(_trackers); } | ||
dispatchToTrackersInCollection(trackers, _trackers, function (t) { | ||
t.core.track(buildAdClick(event), event.context, event.timestamp); | ||
}); | ||
} | ||
/** | ||
* Track an ad conversion event | ||
* | ||
* @param event - The event information | ||
* @param trackers - The tracker identifiers which the event will be sent to | ||
*/ | ||
function trackAdConversion(event, trackers) { | ||
if (trackers === void 0) { trackers = Object.keys(_trackers); } | ||
dispatchToTrackersInCollection(trackers, _trackers, function (t) { | ||
t.core.track(buildAdConversion(event), event.context, event.timestamp); | ||
}); | ||
} | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
exports.AdTrackingPlugin = AdTrackingPlugin; | ||
exports.trackAdClick = trackAdClick; | ||
exports.trackAdConversion = trackAdConversion; | ||
exports.trackAdImpression = trackAdImpression; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
})); | ||
//# sourceMappingURL=index.umd.js.map |
/*! | ||
* Ad tracking for Snowplow v3.24.2 (http://bit.ly/sp-js) | ||
* Ad tracking for Snowplow v3.24.3-dev.0 (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(n,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports):"function"==typeof define&&define.amd?define(["exports"],o):o((n="undefined"!=typeof globalThis?globalThis:n||self).snowplowAdTracking={})}(this,(function(n){function o(n,o,e){if(e||2===arguments.length)for(var t,r=0,c=o.length;r<c;r++)!t&&r in o||(t||(t=Array.prototype.slice.call(o,0,r)),t[r]=o[r]);return n.concat(t||Array.prototype.slice.call(o))}function e(n){var o=n.event;n=o.schema;var e=o.data;return o=function(){var n,o={},e=[],t=[],r=[],c=function(n,e){null!=e&&""!==e&&(o[n]=e)};return{add:c,addDict:function(n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&c(o,n[o])},addJson:function(n,o,r){var c;if(c=r)n:{if(null!=r&&(r.constructor==={}.constructor||r.constructor===[].constructor))for(var a in r)if(Object.prototype.hasOwnProperty.call(r,a)){c=!0;break n}c=!1}c&&(n={keyIfEncoded:n,keyIfNotEncoded:o,json:r},t.push(n),e.push(n))},addContextEntity:function(n){r.push(n)},getPayload:function(){return o},getJson:function(){return e},withJsonProcessor:function(o){n=o},build:function(){return null==n||n(this,t,r),o}}}(),n={schema:"iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0",data:{schema:n,data:e}},o.add("e","ue"),o.addJson("ue_px","ue_pr",n),o}function t(n,o){void 0===o&&(o={});var e,t={};for(e in n)(o[e]||null!==n[e]&&void 0!==n[e])&&(t[e]=n[e]);return t}function r(n,o,e){try{var t=null!=n?n:Object.keys(o);n=[];for(var r=0;r<t.length;r++){var c=t[r];o.hasOwnProperty(c)?n.push(o[c]):i.warn(c+" not configured")}n.forEach(e)}catch(n){i.error("Function failed",n)}}var c,a;(a=c||(c={}))[a.none=0]="none",a[a.error=1]="error",a[a.warn=2]="warn",a[a.debug=3]="debug",a[a.info=4]="info";var i=function(n){return void 0===n&&(n=c.warn),{setLogLevel:function(o){n=c[o]?o:c.warn},warn:function(e,t){for(var r=[],a=2;a<arguments.length;a++)r[a-2]=arguments[a];n>=c.warn&&"undefined"!=typeof console&&(a="Snowplow: "+e,t?console.warn.apply(console,o([a+"\n",t],r,!1)):console.warn.apply(console,o([a],r,!1)))},error:function(e,t){for(var r=[],a=2;a<arguments.length;a++)r[a-2]=arguments[a];n>=c.error&&"undefined"!=typeof console&&(a="Snowplow: "+e+"\n",t?console.error.apply(console,o([a+"\n",t],r,!1)):console.error.apply(console,o([a],r,!1)))},debug:function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];n>=c.debug&&"undefined"!=typeof console&&console.debug.apply(console,o(["Snowplow: "+e],t,!1))},info:function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];n>=c.info&&"undefined"!=typeof console&&console.info.apply(console,o(["Snowplow: "+e],t,!1))}}}(),s={};n.AdTrackingPlugin=function(){return{activateBrowserPlugin:function(n){s[n.id]=n}}},n.trackAdClick=function(n,o){void 0===o&&(o=Object.keys(s)),r(o,s,(function(o){var r=(o=o.core).track,c={schema:"iglu:com.snowplowanalytics.snowplow/ad_click/jsonschema/1-0-0",data:t({targetUrl:n.targetUrl,clickId:n.clickId,costModel:n.costModel,cost:n.cost,bannerId:n.bannerId,zoneId:n.zoneId,impressionId:n.impressionId,advertiserId:n.advertiserId,campaignId:n.campaignId})};c=e({event:c}),r.call(o,c,n.context,n.timestamp)}))},n.trackAdConversion=function(n,o){void 0===o&&(o=Object.keys(s)),r(o,s,(function(o){var r=(o=o.core).track,c={schema:"iglu:com.snowplowanalytics.snowplow/ad_conversion/jsonschema/1-0-0",data:t({conversionId:n.conversionId,costModel:n.costModel,cost:n.cost,category:n.category,action:n.action,property:n.property,initialValue:n.initialValue,advertiserId:n.advertiserId,campaignId:n.campaignId})};c=e({event:c}),r.call(o,c,n.context,n.timestamp)}))},n.trackAdImpression=function(n,o){void 0===o&&(o=Object.keys(s)),r(o,s,(function(o){var r=(o=o.core).track,c={schema:"iglu:com.snowplowanalytics.snowplow/ad_impression/jsonschema/1-0-0",data:t({impressionId:n.impressionId,costModel:n.costModel,cost:n.cost,targetUrl:n.targetUrl,bannerId:n.bannerId,zoneId:n.zoneId,advertiserId:n.advertiserId,campaignId:n.campaignId})};c=e({event:c}),r.call(o,c,n.context,n.timestamp)}))},Object.defineProperty(n,"__esModule",{value:!0})})); | ||
"use strict";!function(o,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((o="undefined"!=typeof globalThis?globalThis:o||self).snowplowAdTracking={})}(this,(function(o){function n(o,n,e){if(e||2===arguments.length)for(var t,r=0,c=n.length;r<c;r++)!t&&r in n||(t||(t=Array.prototype.slice.call(n,0,r)),t[r]=n[r]);return o.concat(t||Array.prototype.slice.call(n))}function e(o){var n=o.event;o=n.schema;var e=n.data;return n=function(){var o,n={},e=[],t=[],r=[],c=function(o,e){null!=e&&""!==e&&(n[o]=e)};return{add:c,addDict:function(o){for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&c(n,o[n])},addJson:function(o,n,r){var c;if(c=r)o:{if(null!=r&&(r.constructor==={}.constructor||r.constructor===[].constructor))for(var a in r)if(Object.prototype.hasOwnProperty.call(r,a)){c=!0;break o}c=!1}c&&(o={keyIfEncoded:o,keyIfNotEncoded:n,json:r},t.push(o),e.push(o))},addContextEntity:function(o){r.push(o)},getPayload:function(){return n},getJson:function(){return e},withJsonProcessor:function(n){o=n},build:function(){return null==o||o(this,t,r),n}}}(),o={schema:"iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0",data:{schema:o,data:e}},n.add("e","ue"),n.addJson("ue_px","ue_pr",o),n}function t(o,n){void 0===n&&(n={});var e,t={};for(e in o)(n[e]||null!==o[e]&&void 0!==o[e])&&(t[e]=o[e]);return t}function r(o,n,e){try{var t=null!=o?o:Object.keys(n);o=[];for(var r=0;r<t.length;r++){var c=t[r];n.hasOwnProperty(c)?o.push(n[c]):i.warn(c+" not configured")}o.forEach(e)}catch(o){i.error("Function failed",o)}}var c,a;"function"==typeof SuppressedError&&SuppressedError,(a=c||(c={}))[a.none=0]="none",a[a.error=1]="error",a[a.warn=2]="warn",a[a.debug=3]="debug",a[a.info=4]="info";var i=function(o){return void 0===o&&(o=c.warn),{setLogLevel:function(n){o=c[n]?n:c.warn},warn:function(e,t){for(var r=[],a=2;a<arguments.length;a++)r[a-2]=arguments[a];o>=c.warn&&"undefined"!=typeof console&&(a="Snowplow: "+e,t?console.warn.apply(console,n([a+"\n",t],r,!1)):console.warn.apply(console,n([a],r,!1)))},error:function(e,t){for(var r=[],a=2;a<arguments.length;a++)r[a-2]=arguments[a];o>=c.error&&"undefined"!=typeof console&&(a="Snowplow: "+e+"\n",t?console.error.apply(console,n([a+"\n",t],r,!1)):console.error.apply(console,n([a],r,!1)))},debug:function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];o>=c.debug&&"undefined"!=typeof console&&console.debug.apply(console,n(["Snowplow: "+e],t,!1))},info:function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];o>=c.info&&"undefined"!=typeof console&&console.info.apply(console,n(["Snowplow: "+e],t,!1))}}}(),s={};o.AdTrackingPlugin=function(){return{activateBrowserPlugin:function(o){s[o.id]=o}}},o.trackAdClick=function(o,n){void 0===n&&(n=Object.keys(s)),r(n,s,(function(n){var r=(n=n.core).track,c={schema:"iglu:com.snowplowanalytics.snowplow/ad_click/jsonschema/1-0-0",data:t({targetUrl:o.targetUrl,clickId:o.clickId,costModel:o.costModel,cost:o.cost,bannerId:o.bannerId,zoneId:o.zoneId,impressionId:o.impressionId,advertiserId:o.advertiserId,campaignId:o.campaignId})};c=e({event:c}),r.call(n,c,o.context,o.timestamp)}))},o.trackAdConversion=function(o,n){void 0===n&&(n=Object.keys(s)),r(n,s,(function(n){var r=(n=n.core).track,c={schema:"iglu:com.snowplowanalytics.snowplow/ad_conversion/jsonschema/1-0-0",data:t({conversionId:o.conversionId,costModel:o.costModel,cost:o.cost,category:o.category,action:o.action,property:o.property,initialValue:o.initialValue,advertiserId:o.advertiserId,campaignId:o.campaignId})};c=e({event:c}),r.call(n,c,o.context,o.timestamp)}))},o.trackAdImpression=function(o,n){void 0===n&&(n=Object.keys(s)),r(n,s,(function(n){var r=(n=n.core).track,c={schema:"iglu:com.snowplowanalytics.snowplow/ad_impression/jsonschema/1-0-0",data:t({impressionId:o.impressionId,costModel:o.costModel,cost:o.cost,targetUrl:o.targetUrl,bannerId:o.bannerId,zoneId:o.zoneId,advertiserId:o.advertiserId,campaignId:o.campaignId})};c=e({event:c}),r.call(n,c,o.context,o.timestamp)}))},Object.defineProperty(o,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=index.umd.min.js.map |
{ | ||
"name": "@snowplow/browser-plugin-ad-tracking", | ||
"version": "3.24.2", | ||
"version": "3.24.3-dev.0", | ||
"description": "Ad tracking for Snowplow", | ||
@@ -21,5 +21,5 @@ "homepage": "http://bit.ly/sp-js", | ||
"dependencies": { | ||
"@snowplow/browser-tracker-core": "3.24.2", | ||
"@snowplow/tracker-core": "3.24.2", | ||
"tslib": "^2.3.1" | ||
"tslib": "^2.3.1", | ||
"@snowplow/browser-tracker-core": "3.24.3-dev.0", | ||
"@snowplow/tracker-core": "3.24.3-dev.0" | ||
}, | ||
@@ -50,3 +50,3 @@ "devDependencies": { | ||
"peerDependencies": { | ||
"@snowplow/browser-tracker": "~3.24.2" | ||
"@snowplow/browser-tracker": "~3.24.3-dev.0" | ||
}, | ||
@@ -56,4 +56,3 @@ "scripts": { | ||
"test": "jest" | ||
}, | ||
"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 advertising based events 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-ad-tracking\n```\n\n## Usage\n\nInitialize your tracker with the AdTrackingPlugin:\n\n```js\nimport { newTracker } from '@snowplow/browser-tracker';\nimport { AdTrackingPlugin } from '@snowplow/browser-plugin-ad-tracking';\n\nnewTracker('sp1', '{{collector}}', { plugins: [ AdTrackingPlugin() ] }); // Also stores reference at module level\n```\n\nThen use the `trackX` functions from this package to track to all trackers which have been initialized with this plugin:\n\n```js\nimport { trackAdClick } from '@snowplow/browser-plugin-ad-tracking';\n\ntrackAdClick({\n targetUrl: 'http://www.example.com',\n clickId: '12243253',\n costModel: 'cpm',\n cost: 2.5,\n bannerId: '23',\n zoneId: '7',\n impressionId: '67965967893',\n advertiserId: '201',\n campaignId: '12',\n});\n```\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" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
601438
671
1
+ Added@snowplow/browser-tracker-core@3.24.3-dev.0(transitive)
+ Added@snowplow/tracker-core@3.24.3-dev.0(transitive)
+ Addeduuid@8.3.2(transitive)
- Removed@snowplow/browser-tracker-core@3.24.2(transitive)
- Removed@snowplow/tracker-core@3.24.2(transitive)