snowplow-tracker-core
Advanced tools
Comparing version 0.7.2 to 0.8.0
/* | ||
* JavaScript tracker core for Snowplow: index.js | ||
* | ||
* Copyright (c) 2014-2016 Snowplow Analytics Ltd. All rights reserved. | ||
* Copyright (c) 2014-2020 Snowplow Analytics Ltd. All rights reserved. | ||
* | ||
@@ -6,0 +6,0 @@ * This program is licensed to you under the Apache License Version 2.0, |
/* | ||
* JavaScript tracker core for Snowplow: contexts.js | ||
* | ||
* Copyright (c) 2014-2018 Snowplow Analytics Ltd. All rights reserved. | ||
* Copyright (c) 2014-2020 Snowplow Analytics Ltd. All rights reserved. | ||
* | ||
@@ -6,0 +6,0 @@ * This program is licensed to you under the Apache License Version 2.0, |
@@ -61,3 +61,3 @@ "use strict"; | ||
} | ||
function track(sb, context, tstamp) { | ||
function track(sb, context, tstamp, afterTrack) { | ||
sb.addDict(payloadPairs); | ||
@@ -75,5 +75,11 @@ sb.add('eid', uuid.v4()); | ||
} | ||
try { | ||
afterTrack && afterTrack(sb.build()); | ||
} | ||
catch (ex) { | ||
console.warn("Snowplow: error running custom callback"); | ||
} | ||
return sb; | ||
} | ||
function trackSelfDescribingEvent(properties, context, tstamp) { | ||
function trackSelfDescribingEvent(properties, context, tstamp, afterTrack) { | ||
var sb = payload.payloadBuilder(base64); | ||
@@ -86,3 +92,3 @@ var ueJson = { | ||
sb.addJson('ue_px', 'ue_pr', ueJson); | ||
return track(sb, context, tstamp); | ||
return track(sb, context, tstamp, afterTrack); | ||
} | ||
@@ -142,3 +148,3 @@ return { | ||
trackSelfDescribingEvent: trackSelfDescribingEvent, | ||
trackPageView: function (pageUrl, pageTitle, referrer, context, tstamp) { | ||
trackPageView: function (pageUrl, pageTitle, referrer, context, tstamp, afterTrack) { | ||
var sb = payload.payloadBuilder(base64); | ||
@@ -149,5 +155,5 @@ sb.add('e', 'pv'); | ||
sb.add('refr', referrer); | ||
return track(sb, context, tstamp); | ||
return track(sb, context, tstamp, afterTrack); | ||
}, | ||
trackPagePing: function (pageUrl, pageTitle, referrer, minXOffset, maxXOffset, minYOffset, maxYOffset, context, tstamp) { | ||
trackPagePing: function (pageUrl, pageTitle, referrer, minXOffset, maxXOffset, minYOffset, maxYOffset, context, tstamp, afterTrack) { | ||
var sb = payload.payloadBuilder(base64); | ||
@@ -162,5 +168,5 @@ sb.add('e', 'pp'); | ||
sb.add('pp_may', maxYOffset.toString()); | ||
return track(sb, context, tstamp); | ||
return track(sb, context, tstamp, afterTrack); | ||
}, | ||
trackStructEvent: function (category, action, label, property, value, context, tstamp) { | ||
trackStructEvent: function (category, action, label, property, value, context, tstamp, afterTrack) { | ||
var sb = payload.payloadBuilder(base64); | ||
@@ -173,5 +179,5 @@ sb.add('e', 'se'); | ||
sb.add('se_va', (value == null ? undefined : value.toString())); | ||
return track(sb, context, tstamp); | ||
return track(sb, context, tstamp, afterTrack); | ||
}, | ||
trackEcommerceTransaction: function (orderId, affiliation, totalValue, taxValue, shipping, city, state, country, currency, context, tstamp) { | ||
trackEcommerceTransaction: function (orderId, affiliation, totalValue, taxValue, shipping, city, state, country, currency, context, tstamp, afterTrack) { | ||
var sb = payload.payloadBuilder(base64); | ||
@@ -188,5 +194,5 @@ sb.add('e', 'tr'); | ||
sb.add("tr_cu", currency); | ||
return track(sb, context, tstamp); | ||
return track(sb, context, tstamp, afterTrack); | ||
}, | ||
trackEcommerceTransactionItem: function (orderId, sku, name, category, price, quantity, currency, context, tstamp) { | ||
trackEcommerceTransactionItem: function (orderId, sku, name, category, price, quantity, currency, context, tstamp, afterTrack) { | ||
var sb = payload.payloadBuilder(base64); | ||
@@ -201,5 +207,5 @@ sb.add("e", "ti"); | ||
sb.add("ti_cu", currency); | ||
return track(sb, context, tstamp); | ||
return track(sb, context, tstamp, afterTrack); | ||
}, | ||
trackScreenView: function (name, id, context, tstamp) { | ||
trackScreenView: function (name, id, context, tstamp, afterTrack) { | ||
return trackSelfDescribingEvent({ | ||
@@ -211,5 +217,5 @@ schema: 'iglu:com.snowplowanalytics.snowplow/screen_view/jsonschema/1-0-0', | ||
}) | ||
}, context, tstamp); | ||
}, context, tstamp, afterTrack); | ||
}, | ||
trackLinkClick: function (targetUrl, elementId, elementClasses, elementTarget, elementContent, context, tstamp) { | ||
trackLinkClick: function (targetUrl, elementId, elementClasses, elementTarget, elementContent, context, tstamp, afterTrack) { | ||
var eventJson = { | ||
@@ -225,5 +231,5 @@ schema: 'iglu:com.snowplowanalytics.snowplow/link_click/jsonschema/1-0-1', | ||
}; | ||
return trackSelfDescribingEvent(eventJson, context, tstamp); | ||
return trackSelfDescribingEvent(eventJson, context, tstamp, afterTrack); | ||
}, | ||
trackAdImpression: function (impressionId, costModel, cost, targetUrl, bannerId, zoneId, advertiserId, campaignId, context, tstamp) { | ||
trackAdImpression: function (impressionId, costModel, cost, targetUrl, bannerId, zoneId, advertiserId, campaignId, context, tstamp, afterTrack) { | ||
var eventJson = { | ||
@@ -242,5 +248,5 @@ schema: 'iglu:com.snowplowanalytics.snowplow/ad_impression/jsonschema/1-0-0', | ||
}; | ||
return trackSelfDescribingEvent(eventJson, context, tstamp); | ||
return trackSelfDescribingEvent(eventJson, context, tstamp, afterTrack); | ||
}, | ||
trackAdClick: function (targetUrl, clickId, costModel, cost, bannerId, zoneId, impressionId, advertiserId, campaignId, context, tstamp) { | ||
trackAdClick: function (targetUrl, clickId, costModel, cost, bannerId, zoneId, impressionId, advertiserId, campaignId, context, tstamp, afterTrack) { | ||
var eventJson = { | ||
@@ -260,5 +266,5 @@ schema: 'iglu:com.snowplowanalytics.snowplow/ad_click/jsonschema/1-0-0', | ||
}; | ||
return trackSelfDescribingEvent(eventJson, context, tstamp); | ||
return trackSelfDescribingEvent(eventJson, context, tstamp, afterTrack); | ||
}, | ||
trackAdConversion: function (conversionId, costModel, cost, category, action, property, initialValue, advertiserId, campaignId, context, tstamp) { | ||
trackAdConversion: function (conversionId, costModel, cost, category, action, property, initialValue, advertiserId, campaignId, context, tstamp, afterTrack) { | ||
var eventJson = { | ||
@@ -278,5 +284,5 @@ schema: 'iglu:com.snowplowanalytics.snowplow/ad_conversion/jsonschema/1-0-0', | ||
}; | ||
return trackSelfDescribingEvent(eventJson, context, tstamp); | ||
return trackSelfDescribingEvent(eventJson, context, tstamp, afterTrack); | ||
}, | ||
trackSocialInteraction: function (action, network, target, context, tstamp) { | ||
trackSocialInteraction: function (action, network, target, context, tstamp, afterTrack) { | ||
var eventJson = { | ||
@@ -290,5 +296,5 @@ schema: 'iglu:com.snowplowanalytics.snowplow/social_interaction/jsonschema/1-0-0', | ||
}; | ||
return trackSelfDescribingEvent(eventJson, context, tstamp); | ||
return trackSelfDescribingEvent(eventJson, context, tstamp, afterTrack); | ||
}, | ||
trackAddToCart: function (sku, name, category, unitPrice, quantity, currency, context, tstamp) { | ||
trackAddToCart: function (sku, name, category, unitPrice, quantity, currency, context, tstamp, afterTrack) { | ||
return trackSelfDescribingEvent({ | ||
@@ -304,5 +310,5 @@ schema: 'iglu:com.snowplowanalytics.snowplow/add_to_cart/jsonschema/1-0-0', | ||
}) | ||
}, context, tstamp); | ||
}, context, tstamp, afterTrack); | ||
}, | ||
trackRemoveFromCart: function (sku, name, category, unitPrice, quantity, currency, context, tstamp) { | ||
trackRemoveFromCart: function (sku, name, category, unitPrice, quantity, currency, context, tstamp, afterTrack) { | ||
return trackSelfDescribingEvent({ | ||
@@ -318,5 +324,5 @@ schema: 'iglu:com.snowplowanalytics.snowplow/remove_from_cart/jsonschema/1-0-0', | ||
}) | ||
}, context, tstamp); | ||
}, context, tstamp, afterTrack); | ||
}, | ||
trackFormFocusOrChange: function (schema, formId, elementId, nodeName, type, elementClasses, value, context, tstamp) { | ||
trackFormFocusOrChange: function (schema, formId, elementId, nodeName, type, elementClasses, value, context, tstamp, afterTrack) { | ||
var event_schema = ''; | ||
@@ -335,5 +341,5 @@ var event_data = { formId: formId, elementId: elementId, nodeName: nodeName, elementClasses: elementClasses, value: value }; | ||
data: removeEmptyProperties(event_data, { value: true }) | ||
}, context, tstamp); | ||
}, context, tstamp, afterTrack); | ||
}, | ||
trackFormSubmission: function (formId, formClasses, elements, context, tstamp) { | ||
trackFormSubmission: function (formId, formClasses, elements, context, tstamp, afterTrack) { | ||
return trackSelfDescribingEvent({ | ||
@@ -346,5 +352,5 @@ schema: 'iglu:com.snowplowanalytics.snowplow/submit_form/jsonschema/1-0-0', | ||
}) | ||
}, context, tstamp); | ||
}, context, tstamp, afterTrack); | ||
}, | ||
trackSiteSearch: function (terms, filters, totalResults, pageResults, context, tstamp) { | ||
trackSiteSearch: function (terms, filters, totalResults, pageResults, context, tstamp, afterTrack) { | ||
return trackSelfDescribingEvent({ | ||
@@ -358,5 +364,5 @@ schema: 'iglu:com.snowplowanalytics.snowplow/site_search/jsonschema/1-0-0', | ||
}) | ||
}, context, tstamp); | ||
}, context, tstamp, afterTrack); | ||
}, | ||
trackConsentWithdrawn: function (all, id, version, name, description, context, tstamp) { | ||
trackConsentWithdrawn: function (all, id, version, name, description, context, tstamp, afterTrack) { | ||
var documentJson = { | ||
@@ -376,5 +382,5 @@ schema: 'iglu:com.snowplowanalytics.snowplow/consent_document/jsonschema/1-0-0', | ||
}) | ||
}, documentJson.data && context ? context.concat([documentJson]) : context, tstamp); | ||
}, documentJson.data && context ? context.concat([documentJson]) : context, tstamp, afterTrack); | ||
}, | ||
trackConsentGranted: function (id, version, name, description, expiry, context, tstamp) { | ||
trackConsentGranted: function (id, version, name, description, expiry, context, tstamp, afterTrack) { | ||
var documentJson = { | ||
@@ -394,3 +400,3 @@ schema: 'iglu:com.snowplowanalytics.snowplow/consent_document/jsonschema/1-0-0', | ||
}) | ||
}, context ? context.concat([documentJson]) : [documentJson], tstamp); | ||
}, context ? context.concat([documentJson]) : [documentJson], tstamp, afterTrack); | ||
}, | ||
@@ -397,0 +403,0 @@ addGlobalContexts: function (contexts) { |
126
lib/core.ts
/* | ||
* JavaScript tracker core for Snowplow: core.js | ||
* | ||
* Copyright (c) 2014-2016 Snowplow Analytics Ltd. All rights reserved. | ||
* Copyright (c) 2014-2020 Snowplow Analytics Ltd. All rights reserved. | ||
* | ||
@@ -148,3 +148,3 @@ * This program is licensed to you under the Apache License Version 2.0, | ||
} | ||
if (globalContexts && globalContexts.length) { | ||
if (globalContexts && globalContexts.length) { | ||
returnedContexts.push(...globalContexts); | ||
@@ -163,5 +163,6 @@ } | ||
* @param tstamp TrackerTimestamp of the event | ||
* @param function afterTrack A callback function triggered after event is tracked | ||
* @return Payload after the callback is applied | ||
*/ | ||
function track(sb: PayloadData, context?: Array<SelfDescribingJson>, tstamp?: Timestamp): PayloadData { | ||
function track(sb: PayloadData, context?: Array<SelfDescribingJson>, tstamp?: Timestamp, afterTrack?: (PayloadData) => void): PayloadData { | ||
sb.addDict(payloadPairs); | ||
@@ -181,2 +182,8 @@ sb.add('eid', uuid.v4()); | ||
try { | ||
afterTrack && afterTrack(sb.build()); | ||
} catch (ex) { | ||
console.warn("Snowplow: error running custom callback") | ||
} | ||
return sb; | ||
@@ -191,5 +198,6 @@ } | ||
* @param tstamp TrackerTimestamp of the event | ||
* @param function afterTrack A callback function triggered after event is tracked | ||
* @return Payload | ||
*/ | ||
function trackSelfDescribingEvent(properties: Object, context?: Array<SelfDescribingJson>, tstamp?: Timestamp): PayloadData { | ||
function trackSelfDescribingEvent(properties: Object, context?: Array<SelfDescribingJson>, tstamp?: Timestamp, afterTrack?: (PayloadData) => void): PayloadData { | ||
var sb = payload.payloadBuilder(base64); | ||
@@ -204,3 +212,3 @@ var ueJson = { | ||
return track(sb, context, tstamp); | ||
return track(sb, context, tstamp, afterTrack); | ||
} | ||
@@ -365,2 +373,3 @@ | ||
* @param tstamp TrackerTimestamp of the event | ||
* @param function afterTrack A callback function triggered after event is tracked | ||
* @return Payload | ||
@@ -373,3 +382,4 @@ */ | ||
context?: Array<SelfDescribingJson>, | ||
tstamp?: Timestamp): PayloadData { | ||
tstamp?: Timestamp, | ||
afterTrack?: (PayloadData) => void): PayloadData { | ||
@@ -382,3 +392,3 @@ var sb = payload.payloadBuilder(base64); | ||
return track(sb, context, tstamp); | ||
return track(sb, context, tstamp, afterTrack); | ||
}, | ||
@@ -398,2 +408,3 @@ /** | ||
* @param tstamp TrackerTimestamp of the event | ||
* @param function afterTrack A callback function triggered after event is tracked | ||
* @return object Payload | ||
@@ -410,3 +421,4 @@ */ | ||
context?: Array<SelfDescribingJson>, | ||
tstamp?: Timestamp): PayloadData { | ||
tstamp?: Timestamp, | ||
afterTrack?: (PayloadData) => void): PayloadData { | ||
@@ -423,3 +435,3 @@ var sb = payload.payloadBuilder(base64); | ||
return track(sb, context, tstamp); | ||
return track(sb, context, tstamp, afterTrack); | ||
}, | ||
@@ -436,2 +448,3 @@ /** | ||
* @param tstamp TrackerTimestamp of the event | ||
* @param function afterTrack A callback function triggered after event is tracked | ||
* @return Payload | ||
@@ -446,3 +459,4 @@ */ | ||
context?: Array<SelfDescribingJson>, | ||
tstamp?: Timestamp): PayloadData { | ||
tstamp?: Timestamp, | ||
afterTrack?: (PayloadData) => void): PayloadData { | ||
@@ -457,3 +471,3 @@ var sb = payload.payloadBuilder(base64); | ||
return track(sb, context, tstamp); | ||
return track(sb, context, tstamp, afterTrack); | ||
}, | ||
@@ -475,2 +489,3 @@ | ||
* @param tstamp Optional. TrackerTimestamp of the event | ||
* @param function afterTrack A callback function triggered after event is tracked | ||
* @return Payload | ||
@@ -489,3 +504,4 @@ */ | ||
context?: Array<SelfDescribingJson>, | ||
tstamp?: Timestamp): PayloadData { | ||
tstamp?: Timestamp, | ||
afterTrack?: (PayloadData) => void): PayloadData { | ||
@@ -504,3 +520,3 @@ var sb = payload.payloadBuilder(base64); | ||
return track(sb, context, tstamp); | ||
return track(sb, context, tstamp, afterTrack); | ||
}, | ||
@@ -520,2 +536,3 @@ | ||
* @param tstamp Optional. TrackerTimestamp of the event | ||
* @param function afterTrack A callback function triggered after event is tracked | ||
* @return object Payload | ||
@@ -532,3 +549,4 @@ */ | ||
context?: Array<SelfDescribingJson>, | ||
tstamp?: Timestamp): PayloadData { | ||
tstamp?: Timestamp, | ||
afterTrack?: (PayloadData) => void): PayloadData { | ||
@@ -545,3 +563,3 @@ var sb = payload.payloadBuilder(base64); | ||
return track(sb, context, tstamp); | ||
return track(sb, context, tstamp, afterTrack); | ||
}, | ||
@@ -556,2 +574,3 @@ | ||
* @param tstamp TrackerTimestamp of the event | ||
* @param function afterTrack A callback function triggered after event is tracked | ||
* @return Payload | ||
@@ -563,3 +582,4 @@ */ | ||
context?: Array<SelfDescribingJson>, | ||
tstamp?: Timestamp): PayloadData { | ||
tstamp?: Timestamp, | ||
afterTrack?: (PayloadData) => void): PayloadData { | ||
@@ -572,3 +592,3 @@ return trackSelfDescribingEvent({ | ||
}) | ||
}, context, tstamp); | ||
}, context, tstamp, afterTrack); | ||
}, | ||
@@ -586,2 +606,3 @@ | ||
* @param tstamp TrackerTimestamp of the event | ||
* @param function afterTrack A callback function triggered after event is tracked | ||
* @return Payload | ||
@@ -596,3 +617,4 @@ */ | ||
context?: Array<SelfDescribingJson>, | ||
tstamp?: Timestamp) { | ||
tstamp?: Timestamp, | ||
afterTrack?: (PayloadData) => void) { | ||
@@ -610,3 +632,3 @@ var eventJson = { | ||
return trackSelfDescribingEvent(eventJson, context, tstamp); | ||
return trackSelfDescribingEvent(eventJson, context, tstamp, afterTrack); | ||
}, | ||
@@ -627,2 +649,3 @@ | ||
* @param tstamp TrackerTimestamp of the event | ||
* @param function afterTrack A callback function triggered after event is tracked | ||
* @return object Payload | ||
@@ -640,3 +663,4 @@ */ | ||
context?: Array<SelfDescribingJson>, | ||
tstamp?: Timestamp): PayloadData { | ||
tstamp?: Timestamp, | ||
afterTrack?: (PayloadData) => void): PayloadData { | ||
@@ -657,3 +681,3 @@ var eventJson = { | ||
return trackSelfDescribingEvent(eventJson, context, tstamp); | ||
return trackSelfDescribingEvent(eventJson, context, tstamp, afterTrack); | ||
}, | ||
@@ -675,2 +699,3 @@ | ||
* @param tstamp TrackerTimestamp of the event | ||
* @param function afterTrack A callback function triggered after event is tracked | ||
* @return object Payload | ||
@@ -689,3 +714,4 @@ */ | ||
context?: Array<SelfDescribingJson>, | ||
tstamp?: Timestamp): PayloadData { | ||
tstamp?: Timestamp, | ||
afterTrack?: (PayloadData) => void): PayloadData { | ||
@@ -707,3 +733,3 @@ var eventJson = { | ||
return trackSelfDescribingEvent(eventJson, context, tstamp); | ||
return trackSelfDescribingEvent(eventJson, context, tstamp, afterTrack); | ||
}, | ||
@@ -725,2 +751,3 @@ | ||
* @param tstamp TrackerTimestamp of the event | ||
* @param function afterTrack A callback function triggered after event is tracked | ||
* @return object Payload | ||
@@ -741,3 +768,4 @@ * | ||
context?: Array<SelfDescribingJson>, | ||
tstamp?: Timestamp): PayloadData { | ||
tstamp?: Timestamp, | ||
afterTrack?: (PayloadData) => void): PayloadData { | ||
@@ -759,3 +787,3 @@ var eventJson = { | ||
return trackSelfDescribingEvent(eventJson, context, tstamp); | ||
return trackSelfDescribingEvent(eventJson, context, tstamp, afterTrack); | ||
}, | ||
@@ -771,2 +799,3 @@ | ||
* @param tstamp TrackerTimestamp of the event | ||
* @param function afterTrack A callback function triggered after event is tracked | ||
* @return Payload | ||
@@ -779,3 +808,4 @@ */ | ||
context?: Array<SelfDescribingJson>, | ||
tstamp?: Timestamp): PayloadData { | ||
tstamp?: Timestamp, | ||
afterTrack?: (PayloadData) => void): PayloadData { | ||
@@ -791,3 +821,3 @@ var eventJson = { | ||
return trackSelfDescribingEvent(eventJson, context, tstamp); | ||
return trackSelfDescribingEvent(eventJson, context, tstamp, afterTrack); | ||
}, | ||
@@ -806,2 +836,3 @@ | ||
* @param tstamp Optional. TrackerTimestamp of the event | ||
* @param function afterTrack A callback function triggered after event is tracked | ||
* @return Payload | ||
@@ -817,4 +848,4 @@ */ | ||
context?: Array<SelfDescribingJson>, | ||
tstamp?: Timestamp): PayloadData { | ||
tstamp?: Timestamp, | ||
afterTrack?: (PayloadData) => void): PayloadData { | ||
return trackSelfDescribingEvent({ | ||
@@ -830,3 +861,3 @@ schema: 'iglu:com.snowplowanalytics.snowplow/add_to_cart/jsonschema/1-0-0', | ||
}) | ||
}, context, tstamp); | ||
}, context, tstamp, afterTrack); | ||
}, | ||
@@ -845,2 +876,3 @@ | ||
* @param tstamp Optional. TrackerTimestamp of the event | ||
* @param function afterTrack A callback function triggered after event is tracked | ||
* @return Payload | ||
@@ -856,3 +888,4 @@ */ | ||
context?: Array<SelfDescribingJson>, | ||
tstamp?: Timestamp): PayloadData { | ||
tstamp?: Timestamp, | ||
afterTrack?: (PayloadData) => void): PayloadData { | ||
@@ -869,3 +902,3 @@ return trackSelfDescribingEvent({ | ||
}) | ||
}, context, tstamp); | ||
}, context, tstamp, afterTrack); | ||
}, | ||
@@ -885,2 +918,3 @@ | ||
* @param tstamp Optional. TrackerTimestamp of the event | ||
* @param function afterTrack A callback function triggered after event is tracked | ||
* @return Payload | ||
@@ -899,3 +933,4 @@ * | ||
context?: Array<SelfDescribingJson>, | ||
tstamp?: Timestamp): PayloadData { | ||
tstamp?: Timestamp, | ||
afterTrack?: (PayloadData) => void): PayloadData { | ||
@@ -914,3 +949,3 @@ let event_schema = ''; | ||
data: removeEmptyProperties(event_data, {value: true}) | ||
}, context, tstamp); | ||
}, context, tstamp, afterTrack); | ||
}, | ||
@@ -926,2 +961,3 @@ | ||
* @param tstamp Optional. TrackerTimestamp of the event | ||
* @param function afterTrack A callback function triggered after event is tracked | ||
* @return Payload | ||
@@ -934,3 +970,4 @@ */ | ||
context?: Array<SelfDescribingJson>, | ||
tstamp?: Timestamp): PayloadData { | ||
tstamp?: Timestamp, | ||
afterTrack?: (PayloadData) => void): PayloadData { | ||
@@ -944,3 +981,3 @@ return trackSelfDescribingEvent({ | ||
}) | ||
}, context, tstamp); | ||
}, context, tstamp, afterTrack); | ||
}, | ||
@@ -965,3 +1002,4 @@ | ||
context?: Array<SelfDescribingJson>, | ||
tstamp?: Timestamp): PayloadData { | ||
tstamp?: Timestamp, | ||
afterTrack?: (PayloadData) => void): PayloadData { | ||
@@ -976,3 +1014,3 @@ return trackSelfDescribingEvent({ | ||
}) | ||
}, context, tstamp); | ||
}, context, tstamp, afterTrack); | ||
}, | ||
@@ -990,2 +1028,3 @@ | ||
* @param {Timestamp} [tstamp] - TrackerTimestamp of the event. | ||
* @param {function} [afterTrack] A callback function triggered after event is tracked | ||
* @return Payload | ||
@@ -1000,3 +1039,4 @@ */ | ||
context?: Array<SelfDescribingJson>, | ||
tstamp?: Timestamp): PayloadData { | ||
tstamp?: Timestamp, | ||
afterTrack?: (PayloadData) => void): PayloadData { | ||
@@ -1018,3 +1058,3 @@ let documentJson = { | ||
}) | ||
}, documentJson.data && context ? context.concat([documentJson]) : context, tstamp); | ||
}, documentJson.data && context ? context.concat([documentJson]) : context, tstamp, afterTrack); | ||
}, | ||
@@ -1032,2 +1072,3 @@ | ||
* @param {Timestamp} [tstamp] - TrackerTimestamp of the event. | ||
* @param {function} [afterTrack] A callback function triggered after event is tracked | ||
* @return Payload | ||
@@ -1042,3 +1083,4 @@ */ | ||
context?: Array<SelfDescribingJson>, | ||
tstamp?: Timestamp): PayloadData { | ||
tstamp?: Timestamp, | ||
afterTrack?: (PayloadData) => void): PayloadData { | ||
@@ -1060,3 +1102,3 @@ let documentJson = { | ||
}) | ||
}, context ? context.concat([documentJson]) : [documentJson], tstamp); | ||
}, context ? context.concat([documentJson]) : [documentJson], tstamp, afterTrack); | ||
}, | ||
@@ -1063,0 +1105,0 @@ |
/* | ||
* JavaScript tracker core for Snowplow: payload.js | ||
* | ||
* Copyright (c) 2014-2016 Snowplow Analytics Ltd. All rights reserved. | ||
* Copyright (c) 2014-2020 Snowplow Analytics Ltd. All rights reserved. | ||
* | ||
@@ -6,0 +6,0 @@ * This program is licensed to you under the Apache License Version 2.0, |
@@ -103,22 +103,22 @@ declare module 'snowplow-tracker/lib/base64' { | ||
setUseragent: (useragent: string) => void; | ||
trackUnstructEvent: (properties: Object, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined) => payload.PayloadData; | ||
trackSelfDescribingEvent: (properties: Object, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined) => payload.PayloadData; | ||
trackPageView: (pageUrl: string, pageTitle: string, referrer: string, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined) => payload.PayloadData; | ||
trackPagePing: (pageUrl: string, pageTitle: string, referrer: string, minXOffset: number, maxXOffset: number, minYOffset: number, maxYOffset: number, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined) => payload.PayloadData; | ||
trackStructEvent: (category: string, action: string, label: string, property: string, value?: number | undefined, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined) => payload.PayloadData; | ||
trackEcommerceTransaction: (orderId: string, affiliation: string, totalValue: string, taxValue?: string | undefined, shipping?: string | undefined, city?: string | undefined, state?: string | undefined, country?: string | undefined, currency?: string | undefined, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined) => payload.PayloadData; | ||
trackEcommerceTransactionItem: (orderId: string, sku: string, name: string, category: string, price: string, quantity: string, currency?: string | undefined, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined) => payload.PayloadData; | ||
trackScreenView: (name: string, id: string, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined) => payload.PayloadData; | ||
trackLinkClick: (targetUrl: string, elementId: string, elementClasses: string[], elementTarget: string, elementContent: string, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined) => payload.PayloadData; | ||
trackAdImpression: (impressionId: string, costModel: string, cost: number, targetUrl: string, bannerId: string, zoneId: string, advertiserId: string, campaignId: string, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined) => payload.PayloadData; | ||
trackAdClick: (targetUrl: string, clickId: string, costModel: string, cost: number, bannerId: string, zoneId: string, impressionId: string, advertiserId: string, campaignId: string, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined) => payload.PayloadData; | ||
trackAdConversion: (conversionId: string, costModel: string, cost: number, category: string, action: string, property: string, initialValue: number, advertiserId: string, campaignId: string, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined) => payload.PayloadData; | ||
trackSocialInteraction: (action: string, network: string, target: string, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined) => payload.PayloadData; | ||
trackAddToCart: (sku: string, name: string, category: string, unitPrice: string, quantity: string, currency?: string | undefined, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined) => payload.PayloadData; | ||
trackRemoveFromCart: (sku: string, name: string, category: string, unitPrice: string, quantity: string, currency?: string | undefined, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined) => payload.PayloadData; | ||
trackFormFocusOrChange: (schema: string, formId: string, elementId: string, nodeName: string, type: string, elementClasses: string[], value: string, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined) => payload.PayloadData; | ||
trackFormSubmission: (formId: string, formClasses: string[], elements: string[], context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined) => payload.PayloadData; | ||
trackSiteSearch: (terms: string[], filters: Object, totalResults: number, pageResults: number, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined) => payload.PayloadData; | ||
trackConsentWithdrawn: (all: boolean, id?: string | undefined, version?: string | undefined, name?: string | undefined, description?: string | undefined, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined) => payload.PayloadData; | ||
trackConsentGranted: (id: string, version: string, name?: string | undefined, description?: string | undefined, expiry?: string | undefined, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined) => payload.PayloadData; | ||
trackUnstructEvent: (properties: Object, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined, afterTrack?: ((PayloadData: any) => void) | undefined) => payload.PayloadData; | ||
trackSelfDescribingEvent: (properties: Object, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined, afterTrack?: ((PayloadData: any) => void) | undefined) => payload.PayloadData; | ||
trackPageView: (pageUrl: string, pageTitle: string, referrer: string, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined, afterTrack?: ((PayloadData: any) => void) | undefined) => payload.PayloadData; | ||
trackPagePing: (pageUrl: string, pageTitle: string, referrer: string, minXOffset: number, maxXOffset: number, minYOffset: number, maxYOffset: number, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined, afterTrack?: ((PayloadData: any) => void) | undefined) => payload.PayloadData; | ||
trackStructEvent: (category: string, action: string, label: string, property: string, value?: number | undefined, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined, afterTrack?: ((PayloadData: any) => void) | undefined) => payload.PayloadData; | ||
trackEcommerceTransaction: (orderId: string, affiliation: string, totalValue: string, taxValue?: string | undefined, shipping?: string | undefined, city?: string | undefined, state?: string | undefined, country?: string | undefined, currency?: string | undefined, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined, afterTrack?: ((PayloadData: any) => void) | undefined) => payload.PayloadData; | ||
trackEcommerceTransactionItem: (orderId: string, sku: string, name: string, category: string, price: string, quantity: string, currency?: string | undefined, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined, afterTrack?: ((PayloadData: any) => void) | undefined) => payload.PayloadData; | ||
trackScreenView: (name: string, id: string, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined, afterTrack?: ((PayloadData: any) => void) | undefined) => payload.PayloadData; | ||
trackLinkClick: (targetUrl: string, elementId: string, elementClasses: string[], elementTarget: string, elementContent: string, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined, afterTrack?: ((PayloadData: any) => void) | undefined) => payload.PayloadData; | ||
trackAdImpression: (impressionId: string, costModel: string, cost: number, targetUrl: string, bannerId: string, zoneId: string, advertiserId: string, campaignId: string, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined, afterTrack?: ((PayloadData: any) => void) | undefined) => payload.PayloadData; | ||
trackAdClick: (targetUrl: string, clickId: string, costModel: string, cost: number, bannerId: string, zoneId: string, impressionId: string, advertiserId: string, campaignId: string, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined, afterTrack?: ((PayloadData: any) => void) | undefined) => payload.PayloadData; | ||
trackAdConversion: (conversionId: string, costModel: string, cost: number, category: string, action: string, property: string, initialValue: number, advertiserId: string, campaignId: string, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined, afterTrack?: ((PayloadData: any) => void) | undefined) => payload.PayloadData; | ||
trackSocialInteraction: (action: string, network: string, target: string, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined, afterTrack?: ((PayloadData: any) => void) | undefined) => payload.PayloadData; | ||
trackAddToCart: (sku: string, name: string, category: string, unitPrice: string, quantity: string, currency?: string | undefined, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined, afterTrack?: ((PayloadData: any) => void) | undefined) => payload.PayloadData; | ||
trackRemoveFromCart: (sku: string, name: string, category: string, unitPrice: string, quantity: string, currency?: string | undefined, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined, afterTrack?: ((PayloadData: any) => void) | undefined) => payload.PayloadData; | ||
trackFormFocusOrChange: (schema: string, formId: string, elementId: string, nodeName: string, type: string, elementClasses: string[], value: string, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined, afterTrack?: ((PayloadData: any) => void) | undefined) => payload.PayloadData; | ||
trackFormSubmission: (formId: string, formClasses: string[], elements: string[], context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined, afterTrack?: ((PayloadData: any) => void) | undefined) => payload.PayloadData; | ||
trackSiteSearch: (terms: string[], filters: Object, totalResults: number, pageResults: number, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined, afterTrack?: ((PayloadData: any) => void) | undefined) => payload.PayloadData; | ||
trackConsentWithdrawn: (all: boolean, id?: string | undefined, version?: string | undefined, name?: string | undefined, description?: string | undefined, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined, afterTrack?: ((PayloadData: any) => void) | undefined) => payload.PayloadData; | ||
trackConsentGranted: (id: string, version: string, name?: string | undefined, description?: string | undefined, expiry?: string | undefined, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined, afterTrack?: ((PayloadData: any) => void) | undefined) => payload.PayloadData; | ||
addGlobalContexts: (contexts: Object[]) => void; | ||
@@ -125,0 +125,0 @@ clearGlobalContexts: () => void; |
{ | ||
"name": "snowplow-tracker-core", | ||
"version": "0.7.2", | ||
"version": "0.8.0", | ||
"devDependencies": { | ||
@@ -5,0 +5,0 @@ "@types/es6-shim": "0.31.34", |
@@ -119,3 +119,3 @@ # Snowplow JavaScript Tracker Core [![npm version][npm-image]][npm-url] | ||
The Snowplow JavaScript Tracker Core is copyright 2014 Snowplow Analytics Ltd. | ||
The Snowplow JavaScript Tracker Core is copyright 2014-2020 Snowplow Analytics Ltd. | ||
@@ -122,0 +122,0 @@ Licensed under the [Apache License, Version 2.0][apache-license] (the "License"); |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
NPM Shrinkwrap
Supply chain riskPackage contains a shrinkwrap file. This may allow the package to bypass normal install procedures.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
261621
30
5696
1