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

@segment/snippet

Package Overview
Dependencies
Maintainers
298
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@segment/snippet - npm Package Compare versions

Comparing version 5.1.0 to 5.2.0

8

dist/max.template.js
module.exports=function(settings) {
var __t, __p = '';
__p += '(function() {\n // Create a queue, but don\'t obliterate an existing one!\n var analytics = window.analytics = window.analytics || [];\n\n // If the real analytics.js is already on the page return.\n if (analytics.initialize) return;\n\n // If the snippet was invoked already show an error.\n if (analytics.invoked) {\n if (window.console && console.error) {\n console.error(\'Segment snippet included twice.\');\n }\n return;\n }\n\n // Invoked flag, to make sure the snippet\n // is never invoked twice.\n analytics.invoked = true;\n\n // A list of the methods in Analytics.js to stub.\n analytics.methods = [\n \'trackSubmit\',\n \'trackClick\',\n \'trackLink\',\n \'trackForm\',\n \'pageview\',\n \'identify\',\n \'reset\',\n \'group\',\n \'track\',\n \'ready\',\n \'alias\',\n \'debug\',\n \'page\',\n \'screen\',\n \'once\',\n \'off\',\n \'on\',\n \'addSourceMiddleware\',\n \'addIntegrationMiddleware\',\n \'setAnonymousId\',\n \'addDestinationMiddleware\',\n \'register\'\n ];\n\n // Define a factory to create stubs. These are placeholders\n // for methods in Analytics.js so that you never have to wait\n // for it to load to actually record data. The `method` is\n // stored as the first argument, so we can replay the data.\n analytics.factory = function(e) {\n return function() {\n if (window.analytics.initialized) {\n // Sometimes users assigned analytics to a variable before analytics is done loading, resulting in a stale reference.\n // If so, proxy any calls to the \'real\' analytics instance.\n return window.analytics[e].apply(window.analytics, arguments);\n }\n var args = Array.prototype.slice.call(arguments);\n \n // Add buffered page context object so page information is always up-to-date\n if ([\'track\', \'screen\', \'alias\', \'group\', \'page\', \'identify\'].indexOf(e) > -1) {\n var c = document.querySelector(\'link[rel=\\\'canonical\\\']\');\n args.push({\n __t: \'bpc\',\n c: c && c.getAttribute(\'href\') || undefined,\n p: location.pathname,\n u: location.href,\n s: location.search,\n t: document.title,\n r: document.referrer\n });\n }\n\n args.unshift(e);\n analytics.push(args);\n return analytics;\n };\n };\n\n\n // For each of our methods, generate a queueing stub.\n for (var i = 0; i < analytics.methods.length; i++) {\n var key = analytics.methods[i];\n analytics[key] = analytics.factory(key);\n }\n\n // Define a method to load Analytics.js from our CDN,\n // and that will be sure to only ever load it once.\n analytics.load = function(key, options) {\n // Create an async script element based on your key.\n var t = document.createElement(\'script\');\n t.type = \'text/javascript\';\n t.async = true;\n t.src = \'https://' +
__p += '(function() {\n // Create a queue, but don\'t obliterate an existing one!\n var analytics = window.analytics = window.analytics || [];\n\n // If the real analytics.js is already on the page return.\n if (analytics.initialize) return;\n\n // If the snippet was invoked already show an error.\n if (analytics.invoked) {\n if (window.console && console.error) {\n console.error("Segment snippet included twice.");\n }\n return;\n }\n\n // Invoked flag, to make sure the snippet\n // is never invoked twice.\n analytics.invoked = true;\n\n // A list of the methods in Analytics.js to stub.\n analytics.methods = [\n "trackSubmit",\n "trackClick",\n "trackLink",\n "trackForm",\n "pageview",\n "identify",\n "reset",\n "group",\n "track",\n "ready",\n "alias",\n "debug",\n "page",\n "screen",\n "once",\n "off",\n "on",\n "addSourceMiddleware",\n "addIntegrationMiddleware",\n "setAnonymousId",\n "addDestinationMiddleware",\n "register"\n ];\n\n // Define a factory to create stubs. These are placeholders\n // for methods in Analytics.js so that you never have to wait\n // for it to load to actually record data. The `method` is\n // stored as the first argument, so we can replay the data.\n analytics.factory = function(e) {\n return function() {\n if (window.analytics.initialized) {\n // Sometimes users assigned analytics to a variable before analytics is done loading, resulting in a stale reference.\n // If so, proxy any calls to the \'real\' analytics instance.\n return window.analytics[e].apply(window.analytics, arguments);\n }\n var args = Array.prototype.slice.call(arguments);\n \n // Add buffered page context object so page information is always up-to-date\n if (["track", "screen", "alias", "group", "page", "identify"].indexOf(e) > -1) {\n var c = document.querySelector("link[rel=\'canonical\']");\n args.push({\n __t: "bpc",\n c: c && c.getAttribute("href") || undefined,\n p: location.pathname,\n u: location.href,\n s: location.search,\n t: document.title,\n r: document.referrer\n });\n }\n\n args.unshift(e);\n analytics.push(args);\n return analytics;\n };\n };\n\n\n // For each of our methods, generate a queueing stub.\n for (var i = 0; i < analytics.methods.length; i++) {\n var key = analytics.methods[i];\n analytics[key] = analytics.factory(key);\n }\n\n // Define a method to load Analytics.js from our CDN,\n // and that will be sure to only ever load it once.\n analytics.load = function(key, options) {\n // Create an async script element based on your key.\n var t = document.createElement("script");\n t.type = "text/javascript";\n t.async = true;\n t.src = "https://' +
((__t = ( settings.host )) == null ? '' : __t) +
'' +
((__t = ( settings.ajsPath )) == null ? '' : __t) +
'\';\n\n // Insert our script next to the first script element.\n var first = document.getElementsByTagName(\'script\')[0];\n first.parentNode.insertBefore(t, first);\n analytics._loadOptions = options;\n };\n analytics._writeKey = \'' +
'";\n\n // Insert our script next to the first script element.\n var first = document.getElementsByTagName("script")[0];\n first.parentNode.insertBefore(t, first);\n analytics._loadOptions = options;\n };\n analytics._writeKey = "' +
((__t = ( settings.apiKey )) == null ? '' : __t) +
'\';\n\n ' +
'";\n\n ' +
((__t = ( settings.optionalCDN )) == null ? '' : __t) +
'\n\n // Add a version to keep track of what\'s in the wild.\n analytics.SNIPPET_VERSION = \'5.1.0\';\n\n // Load Analytics.js with your key, which will automatically\n // load the tools you\'ve enabled for your account. Boosh!\n ' +
'\n\n // Add a version to keep track of what\'s in the wild.\n analytics.SNIPPET_VERSION = "5.2.0";\n\n // Load Analytics.js with your key, which will automatically\n // load the tools you\'ve enabled for your account. Boosh!\n ' +
((__t = ( settings.load )) == null ? '' : __t) +

@@ -13,0 +13,0 @@ '\n\n // Make the first page call to load the integrations. If\n // you\'d like to manually name or tag the page, edit or\n // move this call however you\'d like.\n ' +

@@ -11,3 +11,3 @@ module.exports=function(settings) {

((__t = ( settings.optionalCDN )) == null ? '' : __t) +
';analytics.SNIPPET_VERSION="5.1.0";\n' +
';analytics.SNIPPET_VERSION="5.2.0";\n' +
((__t = ( settings.load )) == null ? '' : __t) +

@@ -14,0 +14,0 @@ '\n' +

{
"name": "@segment/snippet",
"author": "Segment.io <friends@segment.com>",
"version": "5.1.0",
"version": "5.2.0",
"repository": "git://github.com/segmentio/snippet.git",

@@ -6,0 +6,0 @@ "description": "Templating methods for rendering the analytics.js snippet.",

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc