@segment/snippet
Advanced tools
Comparing version 4.15.0 to 4.15.1
@@ -9,5 +9,5 @@ module.exports=function(settings) { | ||
((__t = ( settings.apiKey )) == null ? '' : __t) + | ||
'\'\n\n analytics._cdn = \'' + | ||
((__t = ( settings.host )) == null ? '' : __t) + | ||
'\'\n\n // Add a version to keep track of what\'s in the wild.\n analytics.SNIPPET_VERSION = \'4.15.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 ' + | ||
((__t = ( settings.optionalCDN )) == null ? '' : __t) + | ||
'\n\n // Add a version to keep track of what\'s in the wild.\n analytics.SNIPPET_VERSION = \'4.15.1\';\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) + | ||
@@ -14,0 +14,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 ' + |
@@ -9,5 +9,5 @@ module.exports=function(settings) { | ||
((__t = ( settings.apiKey )) == null ? '' : __t) + | ||
'";analytics._cdn="' + | ||
((__t = ( settings.host )) == null ? '' : __t) + | ||
'";analytics.SNIPPET_VERSION="4.15.0";\n' + | ||
'";' + | ||
((__t = ( settings.optionalCDN )) == null ? '' : __t) + | ||
';analytics.SNIPPET_VERSION="4.15.1";\n' + | ||
((__t = ( settings.load )) == null ? '' : __t) + | ||
@@ -14,0 +14,0 @@ '\n' + |
@@ -28,2 +28,4 @@ 'use strict'; | ||
settings.page = renderPage(settings.page); | ||
settings.optionalCDN = renderOptionalCDNHost(settings); | ||
return maxTemplate(settings); | ||
@@ -58,2 +60,4 @@ }; | ||
options.ajsPath || (options.ajsPath = '/analytics.js/v1/\" + key + \"/analytics.min.js'); | ||
options.useHostForBundles || (options.useHostForBundles = false); | ||
if (!has.call(options, 'page')) options.page = true; | ||
@@ -100,1 +104,11 @@ if (!has.call(options, 'load')) options.load = true; | ||
} | ||
function renderOptionalCDNHost(settings) { | ||
if (!settings) return ''; | ||
if (typeof settings.useHostForBundles === 'boolean' && settings.useHostForBundles) { | ||
return 'analytics._cdn = "https://' + settings.host + '"'; | ||
} | ||
return ''; | ||
} |
{ | ||
"name": "@segment/snippet", | ||
"author": "Segment.io <friends@segment.com>", | ||
"version": "4.15.0", | ||
"version": "4.15.1", | ||
"repository": "git://github.com/segmentio/snippet.git", | ||
@@ -10,2 +10,8 @@ "description": "Templating methods for rendering the analytics.js snippet.", | ||
"typings": "./types.d.ts", | ||
"scripts": { | ||
"build": "rm -rf ./dist && make build", | ||
"example": "cd ./example && yarn start", | ||
"e2e-tests": "yarn jest --runTestsByPath --forceExit e2e-tests/*", | ||
"e2e": "yarn build && start-server-and-test example http://localhost:8080 e2e-tests" | ||
}, | ||
"dependencies": { | ||
@@ -17,2 +23,3 @@ "@ndhoule/map": "^2.0.1" | ||
"@segment/eslint-config": "^3.4.0", | ||
"@types/jest": "^27.0.1", | ||
"browserify": "^13.1.0", | ||
@@ -24,2 +31,3 @@ "browserify-istanbul": "^2.0.0", | ||
"istanbul": "^0.4.5", | ||
"jest": "^27.2.0", | ||
"karma": "^1.1.0", | ||
@@ -39,5 +47,8 @@ "karma-browserify": "^5.0.4", | ||
"sinon": "^1.17.5", | ||
"start-server-and-test": "^1.14.0", | ||
"ts-jest": "^27.0.5", | ||
"typescript": "^4.4.3", | ||
"uglify-js": "^2.8.29", | ||
"watchify": "^3.11.0" | ||
"webdriverio": "^7.12.5" | ||
} | ||
} |
@@ -14,5 +14,6 @@ 'use strict'; | ||
var pageRegex = /['"](<%= settings\.page %>)['"]/; | ||
var optionalCDNRegex = /['"](<%= settings\.optionalCDN %>)['"]/; | ||
var lineRegex = /(<%= settings\.load %>|<%= settings\.page %>|}}\(\);)/g; | ||
var versionRegex = /<%= settings\.version %>/; | ||
var snippet = template(source.replace(loadRegex, '$1').replace(pageRegex, '$1').replace(versionRegex, packageJSON.version), { variable: 'settings' }); | ||
var snippet = template(source.replace(optionalCDNRegex, '$1').replace(loadRegex, '$1').replace(pageRegex, '$1').replace(versionRegex, packageJSON.version), { variable: 'settings' }); | ||
var snippetMin = template(minify(source, { | ||
@@ -22,3 +23,3 @@ mangle: { except: ['analytics', 'key'] }, | ||
fromString: true | ||
}).code.replace(loadRegex, '$1').replace(pageRegex, '$1').replace(lineRegex, '\n$1').replace(versionRegex, packageJSON.version), { variable: 'settings' }); | ||
}).code.replace(optionalCDNRegex, '$1').replace(loadRegex, '$1').replace(pageRegex, '$1').replace(lineRegex, '\n$1').replace(versionRegex, packageJSON.version), { variable: 'settings' }); | ||
@@ -25,0 +26,0 @@ mkdirp(path.join(__dirname, '../dist'), function() { |
@@ -78,5 +78,5 @@ (function(){ | ||
}; | ||
analytics._writeKey = '<%= settings.apiKey %>' | ||
analytics._writeKey = '<%= settings.apiKey %>'; | ||
analytics._cdn = '<%= settings.host %>' | ||
'<%= settings.optionalCDN %>' | ||
@@ -83,0 +83,0 @@ // Add a version to keep track of what's in the wild. |
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
26966
18
432
29