@amplitude/amplitude-js-gtm
Advanced tools
Comparing version 3.3.0 to 3.4.0
@@ -1,1 +0,1 @@ | ||
(()=>{"use strict";!function(e,t){var n=e.amplitudeGTM||{_q:[],_iq:{}};if(n.invoked)e.console&&console.error&&console.error("Amplitude snippet has been loaded.");else{var r=function(e,t){e.prototype[t]=function(){return this._q.push({name:t,args:Array.prototype.slice.call(arguments,0)}),this}},i=function(e,t,n){return function(r){e._q.push({name:t,args:Array.prototype.slice.call(n,0),resolve:r})}},s=function(e,t,n){e[t]=function(){if(n)return{promise:new Promise(i(e,t,Array.prototype.slice.call(arguments)))}}},o=function(e){for(var t=0;t<v.length;t++)s(e,v[t],!1);for(var n=0;n<g.length;n++)s(e,g[n],!0)};n.invoked=!0;var a=t.createElement("script");a.type="text/javascript",a.integrity="sha384-7x9NaHX3HxCUYCmCnbfq2CSxglcaiO7vhMln0q050owSIgqOj8bI4xWsWkxZ1nyn",a.crossOrigin="anonymous",a.async=!0,a.src="https://cdn.amplitude.com/libs/marketing-analytics-browser-gtm-0.8.0-min.js.gz",a.onload=function(){e.amplitudeGTM.runQueuedFunctions||console.log("[Amplitude] Error: could not load SDK")};var u=t.getElementsByTagName("script")[0];u.parentNode.insertBefore(a,u);for(var c=function(){return this._q=[],this},p=["add","append","clearAll","prepend","set","setOnce","unset","preInsert","postInsert","remove","getUserProperties"],d=0;d<p.length;d++)r(c,p[d]);n.Identify=c;for(var l=function(){return this._q=[],this},f=["getEventProperties","setProductId","setQuantity","setPrice","setRevenue","setRevenueType","setEventProperties"],y=0;y<f.length;y++)r(l,f[y]);n.Revenue=l;var v=["getDeviceId","setDeviceId","getSessionId","setSessionId","getUserId","setUserId","setOptOut","setTransport","reset"],g=["init","add","remove","track","logEvent","identify","groupIdentify","setGroup","revenue","flush"];o(n),n.createInstance=function(e){return n._iq[e]={_q:[]},o(n._iq[e]),n._iq[e]},e.amplitudeGTM=n,e.amplitude||(e.amplitude=e.amplitudeGTM)}}(window,document),function(e,t){const n=e.amplitudeGTM;if(n&&"function"==typeof n.init){var r=["init","track","identify","setGroup","groupIdentify","revenue","flush","getUserId","setUserId","getSessionId","setSessionId","setDeviceId","getDeviceId","reset","setOptOut","setTransport"],i=["add","append","clearAll","prepend","set","setOnce","remove","preInsert","postInsert"],s=function(e,t,r){if(t=t.shift(),Array.isArray(t)&&0!==t.length){var s=new n.Identify;if(t.forEach((function(e){if(Array.isArray(e)){var t=e.shift();-1!==i.indexOf(t)&&s[t].apply(s,e)}})),!0===r)return s;e.identify(s)}},o=function(e,t){if(!(t.length<3)&&"string"==typeof t[0]&&"string"==typeof t[1]&&Array.isArray(t[2])&&0!==t[2].length){var n=s(e,[t[2]],!0);e.groupIdentify(t[0],t[1],n)}},a=function(e,t){if((t=t.shift()).price&&t.productId){var r=(new n.Revenue).setProductId(t.productId).setQuantity(t.quantity||1).setPrice(t.price).setRevenueType(t.revenueType||"").setEventProperties(t.eventProperties||{}).setRevenue(t.revenue||t.price*(t.quantity||1));e.revenue(r)}},u=function(e,t){let n=e.init(...t).promise;return n.then((()=>e.add({name:"gtm-library-enrichment",type:"enrichment",setup:async()=>{},execute:async e=>(e.library="amplitude-ts-gtm/3.3.0",e)}))),n};e[t]=e[t]||function(){var e=[].slice.call(arguments,0),t=e.shift(),i=t?n._iq[t]:n;i||(i=n.createInstance(t));var c=e.shift();if(-1!==r.indexOf(c))return"revenue"===c?a(i,e):"identify"===c?s(i,e):"groupIdentify"===c?o(i,e):"init"===c?u(i,e):i[c].apply(this,e)}}}(window,"_amplitude")})(); | ||
(()=>{"use strict";!function(e,t){var n=e.amplitudeGTM||{_q:[],_iq:{}};if(n.invoked)e.console&&console.error&&console.error("Amplitude snippet has been loaded.");else{var r=function(e,t){e.prototype[t]=function(){return this._q.push({name:t,args:Array.prototype.slice.call(arguments,0)}),this}},i=function(e,t,n){return function(r){e._q.push({name:t,args:Array.prototype.slice.call(n,0),resolve:r})}},s=function(e,t,n){e[t]=function(){if(n)return{promise:new Promise(i(e,t,Array.prototype.slice.call(arguments)))}}},p=function(e){for(var t=0;t<f.length;t++)s(e,f[t],!1);for(var n=0;n<m.length;n++)s(e,m[n],!0)};n.invoked=!0;var o=t.createElement("script");o.type="text/javascript",o.integrity="sha384-JgGhMqE+JXsvjPMgPoI507H0dZ02IX50VHbmLsoC6hYCH5llQgn5JtEDH6O3vIrv",o.crossOrigin="anonymous",o.async=!0,o.src="https://cdn.amplitude.com/libs/analytics-browser-gtm-2.1.3-min.js.gz",o.onload=function(){e.amplitudeGTM.runQueuedFunctions||console.log("[Amplitude] Error: could not load SDK")};var a=t.getElementsByTagName("script")[0];a.parentNode.insertBefore(o,a);for(var u=function(){return this._q=[],this},d=["add","append","clearAll","prepend","set","setOnce","unset","preInsert","postInsert","remove","getUserProperties"],c=0;c<d.length;c++)r(u,d[c]);n.Identify=u;for(var l=function(){return this._q=[],this},v=["getEventProperties","setProductId","setQuantity","setPrice","setRevenue","setRevenueType","setEventProperties"],g=0;g<v.length;g++)r(l,v[g]);n.Revenue=l;var f=["getDeviceId","setDeviceId","getSessionId","setSessionId","getUserId","setUserId","setOptOut","setTransport","reset","extendSession"],m=["init","add","remove","track","logEvent","identify","groupIdentify","setGroup","revenue","flush"];p(n),n.createInstance=function(e){return n._iq[e]={_q:[]},p(n._iq[e]),n._iq[e]},e.amplitudeGTM=n,e.amplitude||(e.amplitude=e.amplitudeGTM)}}(window,document),function(e,t){const n=e.amplitudeGTM;if(n&&"function"==typeof n.init){var r=["init","track","identify","setGroup","groupIdentify","revenue","flush","getUserId","setUserId","getSessionId","setSessionId","setDeviceId","getDeviceId","reset","setOptOut","setTransport"],i=["add","append","clearAll","prepend","set","setOnce","remove","preInsert","postInsert"],s=function(e,t,r){if(t=t.shift(),Array.isArray(t)&&0!==t.length){var s=new n.Identify;if(t.forEach((function(e){if(Array.isArray(e)){var t=e.shift();-1!==i.indexOf(t)&&s[t].apply(s,e)}})),!0===r)return s;e.identify(s)}},p=function(e,t){if(!(t.length<3)&&"string"==typeof t[0]&&"string"==typeof t[1]&&Array.isArray(t[2])&&0!==t[2].length){var n=s(e,[t[2]],!0);e.groupIdentify(t[0],t[1],n)}},o=function(e,t){if((t=t.shift()).price&&t.productId){var r=(new n.Revenue).setProductId(t.productId).setQuantity(t.quantity||1).setPrice(t.price).setRevenueType(t.revenueType||"").setEventProperties(t.eventProperties||{}).setRevenue(t.revenue||t.price*(t.quantity||1));e.revenue(r)}},a=function(e,t){const n=t[t.length-1],r=n.userAgentEnrichmentOptions,i=n.pageViewLegacy;userAgentEnrichment&&e.add(userAgentEnrichmentPlugin(r)),i&&e.add({name:"page-view-plugin",type:"enrichment",setup:async()=>{},execute:async e=>("[Amplitude] Page Viewed"==e.event_type&&(e.event_type="Page View",e.event_properties.page_domain=e.event_properties["[Amplitude] Page Domain"],e.event_properties.page_location=e.event_properties["[Amplitude] Page Location"],e.event_properties.page_path=e.event_properties["[Amplitude] Page Path"],e.event_properties.page_title=e.event_properties["[Amplitude] Page Title"],e.event_properties.page_url=e.event_properties["[Amplitude] Page URL"],delete e.event_properties["[Amplitude] Page Domain"],delete e.event_properties["[Amplitude] Page Location"],delete e.event_properties["[Amplitude] Page Path"],delete e.event_properties["[Amplitude] Page Title"],delete e.event_properties["[Amplitude] Page URL"]),e)});let s=e.init(...t).promise;return s.then((()=>e.add({name:"gtm-library-enrichment",type:"enrichment",setup:async()=>{},execute:async e=>(e.library="amplitude-ts-gtm/3.4.0",e)}))),s};e[t]=e[t]||function(){var e=[].slice.call(arguments,0),t=e.shift(),i=t?n._iq[t]:n;i||(i=n.createInstance(t));var u=e.shift();if(-1!==r.indexOf(u))return"revenue"===u?o(i,e):"identify"===u?s(i,e):"groupIdentify"===u?p(i,e):"init"===u?a(i,e):i[u].apply(this,e)}}}(window,"_amplitude")})(); |
{ | ||
"name": "@amplitude/amplitude-js-gtm", | ||
"version": "3.3.0", | ||
"version": "3.4.0", | ||
"description": "Amplitude JS SDK Wrapper for use with Google Tag Manager", | ||
@@ -24,2 +24,5 @@ "main": "dist/index.js", | ||
"homepage": "https://github.com/amplitude/amplitude-js-gtm#readme", | ||
"dependencies": { | ||
"@amplitude/plugin-user-agent-enrichment-browser": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
@@ -26,0 +29,0 @@ "@amplitude/eslint-plugin-amplitude": "^1.0.1", |
import { version } from '../package.json'; | ||
/* Amplitude JavaScript SDK begin */ | ||
!function(){"use strict";!function(e,t){var n=e.amplitudeGTM||{_q:[],_iq:{}};if(n.invoked)e.console&&console.error&&console.error("Amplitude snippet has been loaded.");else{var r=function(e,t){e.prototype[t]=function(){return this._q.push({name:t,args:Array.prototype.slice.call(arguments,0)}),this}},s=function(e,t,n){return function(r){e._q.push({name:t,args:Array.prototype.slice.call(n,0),resolve:r})}},i=function(e,t,n){e[t]=function(){if(n)return{promise:new Promise(s(e,t,Array.prototype.slice.call(arguments)))}}},o=function(e){for(var t=0;t<v.length;t++)i(e,v[t],!1);for(var n=0;n<g.length;n++)i(e,g[n],!0)};n.invoked=!0;var a=t.createElement("script");a.type="text/javascript",a.integrity="sha384-7x9NaHX3HxCUYCmCnbfq2CSxglcaiO7vhMln0q050owSIgqOj8bI4xWsWkxZ1nyn",a.crossOrigin="anonymous",a.async=!0,a.src="https://cdn.amplitude.com/libs/marketing-analytics-browser-gtm-0.8.0-min.js.gz",a.onload=function(){e.amplitudeGTM.runQueuedFunctions||console.log("[Amplitude] Error: could not load SDK")};var u=t.getElementsByTagName("script")[0];u.parentNode.insertBefore(a,u);for(var c=function(){return this._q=[],this},l=["add","append","clearAll","prepend","set","setOnce","unset","preInsert","postInsert","remove","getUserProperties"],p=0;p<l.length;p++)r(c,l[p]);n.Identify=c;for(var d=function(){return this._q=[],this},f=["getEventProperties","setProductId","setQuantity","setPrice","setRevenue","setRevenueType","setEventProperties"],m=0;m<f.length;m++)r(d,f[m]);n.Revenue=d;var v=["getDeviceId","setDeviceId","getSessionId","setSessionId","getUserId","setUserId","setOptOut","setTransport","reset"],g=["init","add","remove","track","logEvent","identify","groupIdentify","setGroup","revenue","flush"];o(n),n.createInstance=function(e){return n._iq[e]={_q:[]},o(n._iq[e]),n._iq[e]},e.amplitudeGTM=n,e.amplitude||(e.amplitude=e.amplitudeGTM)}}(window,document)}(); | ||
/* Amplitude JavaScript SDK end */ | ||
/* Amplitude Browser 2.0 SDK begin */ | ||
!function(){"use strict";!function(e,t){var n=e.amplitudeGTM||{_q:[],_iq:{}};if(n.invoked)e.console&&console.error&&console.error("Amplitude snippet has been loaded.");else{var r=function(e,t){e.prototype[t]=function(){return this._q.push({name:t,args:Array.prototype.slice.call(arguments,0)}),this}},s=function(e,t,n){return function(r){e._q.push({name:t,args:Array.prototype.slice.call(n,0),resolve:r})}},o=function(e,t,n){e[t]=function(){if(n)return{promise:new Promise(s(e,t,Array.prototype.slice.call(arguments)))}}},i=function(e){for(var t=0;t<m.length;t++)o(e,m[t],!1);for(var n=0;n<g.length;n++)o(e,g[n],!0)};n.invoked=!0;var a=t.createElement("script");a.type="text/javascript",a.integrity="sha384-JgGhMqE+JXsvjPMgPoI507H0dZ02IX50VHbmLsoC6hYCH5llQgn5JtEDH6O3vIrv",a.crossOrigin="anonymous",a.async=!0,a.src="https://cdn.amplitude.com/libs/analytics-browser-gtm-2.1.3-min.js.gz",a.onload=function(){e.amplitudeGTM.runQueuedFunctions||console.log("[Amplitude] Error: could not load SDK")};var u=t.getElementsByTagName("script")[0];u.parentNode.insertBefore(a,u);for(var c=function(){return this._q=[],this},l=["add","append","clearAll","prepend","set","setOnce","unset","preInsert","postInsert","remove","getUserProperties"],p=0;p<l.length;p++)r(c,l[p]);n.Identify=c;for(var d=function(){return this._q=[],this},v=["getEventProperties","setProductId","setQuantity","setPrice","setRevenue","setRevenueType","setEventProperties"],f=0;f<v.length;f++)r(d,v[f]);n.Revenue=d;var m=["getDeviceId","setDeviceId","getSessionId","setSessionId","getUserId","setUserId","setOptOut","setTransport","reset","extendSession"],g=["init","add","remove","track","logEvent","identify","groupIdentify","setGroup","revenue","flush"];i(n),n.createInstance=function(e){return n._iq[e]={_q:[]},i(n._iq[e]),n._iq[e]},e.amplitudeGTM=n,e.amplitude||(e.amplitude=e.amplitudeGTM)}}(window,document)}(); | ||
/* Amplitude Browser 2.0 SDK end */ | ||
@@ -146,3 +146,39 @@ /* Amplitude Wrapper begin */ | ||
var pageViewPlugin = () => { | ||
return { | ||
name: 'page-view-plugin', | ||
type: 'enrichment', | ||
setup: async () => undefined, | ||
execute: async (event) => { | ||
if (event.event_type == '[Amplitude] Page Viewed') { | ||
event.event_type = 'Page View'; | ||
event.event_properties.page_domain = event.event_properties['[Amplitude] Page Domain']; | ||
event.event_properties.page_location = event.event_properties['[Amplitude] Page Location']; | ||
event.event_properties.page_path = event.event_properties['[Amplitude] Page Path']; | ||
event.event_properties.page_title = event.event_properties['[Amplitude] Page Title']; | ||
event.event_properties.page_url = event.event_properties['[Amplitude] Page URL']; | ||
delete event.event_properties['[Amplitude] Page Domain']; | ||
delete event.event_properties['[Amplitude] Page Location']; | ||
delete event.event_properties['[Amplitude] Page Path']; | ||
delete event.event_properties['[Amplitude] Page Title']; | ||
delete event.event_properties['[Amplitude] Page URL']; | ||
} | ||
return event; | ||
}, | ||
}; | ||
} | ||
var init = function(client, args) { | ||
const argsLength = args.length; | ||
const configuration = args[argsLength - 1]; | ||
const userAgentEnrichmentOptions = configuration['userAgentEnrichmentOptions']; | ||
const pageViewLegacy = configuration['pageViewLegacy']; | ||
if (userAgentEnrichment) { | ||
client.add(userAgentEnrichmentPlugin(userAgentEnrichmentOptions)); | ||
} | ||
if (pageViewLegacy) { | ||
client.add(pageViewPlugin()) | ||
} | ||
// as plugin order cannot be adjusted, init first then add library plugin to overwrite the library value | ||
@@ -149,0 +185,0 @@ let promise = client.init(...args).promise; |
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
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
25517
225
1
+ Added@amplitude/plugin-user-agent-enrichment-browser@^1.0.0
+ Added@amplitude/analytics-client-common@2.3.6(transitive)
+ Added@amplitude/analytics-connector@1.6.2(transitive)
+ Added@amplitude/analytics-core@2.5.5(transitive)
+ Added@amplitude/analytics-types@2.8.4(transitive)
+ Added@amplitude/experiment-core@0.10.1(transitive)
+ Added@amplitude/plugin-user-agent-enrichment-browser@1.0.1(transitive)
+ Added@amplitude/ua-parser-js@0.7.33(transitive)
+ Addedjs-base64@3.7.7(transitive)
+ Addedtslib@2.8.1(transitive)