@segment/analytics.js-core
Advanced tools
Comparing version 3.0.0 to 3.1.1
@@ -0,1 +1,14 @@ | ||
3.1.1 / 2017-10-31 | ||
================== | ||
* Wrap initialize functions of integrations in try/catch statement. | ||
* Add logging of failed initializations. | ||
* Add a `failedInitializations` array to prototype to capture names of any failed integrations. | ||
3.1.0 / 2017-06-29 | ||
================== | ||
* Deprecate IE7/8 testing support | ||
* Re-modernize test dependencies | ||
3.0.0 / 2016-05-25 | ||
@@ -2,0 +15,0 @@ ================== |
@@ -36,12 +36,2 @@ /* eslint-env node */ | ||
}, | ||
sl_ie_7: { | ||
base: 'SauceLabs', | ||
browserName: 'internet explorer', | ||
version: '7' | ||
}, | ||
sl_ie_8: { | ||
base: 'SauceLabs', | ||
browserName: 'internet explorer', | ||
version: '8' | ||
}, | ||
sl_ie_9: { | ||
@@ -78,2 +68,6 @@ base: 'SauceLabs', | ||
browserDisconnectTimeout: 60000, | ||
browserNoActivityTimeout: 60000, | ||
singleRun: true, | ||
@@ -96,4 +90,3 @@ | ||
// FIXME(ndhoule): IE7/8 choke on coverage instrumentation; enable after | ||
// dropping support for those browsers | ||
// Edge and Safari 9 still panic with coverage. Keeping disabled. | ||
// coverageReporter: { | ||
@@ -100,0 +93,0 @@ // reporters: [ |
@@ -31,4 +31,3 @@ /* eslint-env node */ | ||
debug: true | ||
// FIXME(ndhoule): IE7/8 choke on coverage instrumentation; enable after | ||
// dropping support for those browsers | ||
// Edge and Safari 9 still panic with coverage. Keeping disabled. | ||
// transform: [ | ||
@@ -46,2 +45,3 @@ // [ | ||
// Edge and Safari 9 still panic with coverage. Keeping disabled. | ||
// coverageReporter: { | ||
@@ -48,0 +48,0 @@ // reporters: [ |
@@ -144,2 +144,4 @@ 'use strict'; | ||
// initialize integrations, passing ready | ||
// create a list of any integrations that did not initialize - this will be passed with all events for replay support: | ||
this.failedInitializations = []; | ||
each(function(integration) { | ||
@@ -152,3 +154,12 @@ if (options.initialPageview && integration.options.initialPageview === false) { | ||
integration.once('ready', ready); | ||
integration.initialize(); | ||
try { | ||
integration.initialize(); | ||
} catch (e) { | ||
var integrationName = 'Unknown'; | ||
if (integration.prototype && integration.prototype.name) { | ||
integrationName = integration.prototype.name; | ||
} | ||
self.failedInitializations.push(integrationName); | ||
self.log('Error initializing %s integration: %o', integrationName, e); | ||
} | ||
}, integrations); | ||
@@ -155,0 +166,0 @@ |
@@ -23,3 +23,3 @@ 'use strict'; | ||
referrer: document.referrer, | ||
search: location.search, | ||
search: searchPath(), | ||
title: document.title, | ||
@@ -59,2 +59,17 @@ url: canonicalUrl(location.search) | ||
/** | ||
* Return the search path for the page | ||
* This is preferable to window.location.search because SPAs | ||
* can have a # in the url which will include the query param in | ||
* the hash | ||
* | ||
* @return {string} | ||
*/ | ||
function searchPath() { | ||
var url = window.location.href; | ||
var u = url.indexOf('?'); | ||
return u === -1 ? '' : url.slice(u, -1); | ||
} | ||
/* | ||
@@ -61,0 +76,0 @@ * Exports. |
{ | ||
"name": "@segment/analytics.js-core", | ||
"author": "Segment <friends@segment.com>", | ||
"version": "3.0.0", | ||
"version": "3.1.1", | ||
"description": "The hassle-free way to integrate analytics into any web application.", | ||
@@ -61,6 +61,5 @@ "keywords": [ | ||
"devDependencies": { | ||
"@segment/analytics.js-integration": "^2.0.0", | ||
"@segment/analytics.js-integration": "^3.2.0", | ||
"@segment/eslint-config": "^3.1.1", | ||
"browserify": "^13.0.0", | ||
"browserify-istanbul": "^2.0.0", | ||
"browserify": "13.0.0", | ||
"compat-trigger-event": "^1.0.0", | ||
@@ -71,5 +70,4 @@ "component-each": "^0.2.6", | ||
"eslint-plugin-require-path-exists": "^1.1.5", | ||
"istanbul": "^0.4.3", | ||
"jquery": "^1.12.3", | ||
"karma": "^0.13.22", | ||
"jquery": "^3.2.1", | ||
"karma": "1.3.0", | ||
"karma-browserify": "^5.0.4", | ||
@@ -79,3 +77,3 @@ "karma-chrome-launcher": "^1.0.1", | ||
"karma-junit-reporter": "^1.0.0", | ||
"karma-mocha": "^1.0.1", | ||
"karma-mocha": "1.0.1", | ||
"karma-phantomjs-launcher": "^1.0.0", | ||
@@ -82,0 +80,0 @@ "karma-sauce-launcher": "^1.0.0", |
@@ -1,3 +0,6 @@ | ||
# analytics.js-core [![Build Status][ci-badge]][ci-link] | ||
# analytics.js-core | ||
[![CircleCI](https://circleci.com/gh/segmentio/analytics.js-core.svg?style=shield&circle-token=802e83e9a76e911d83be24df8497b6283ee5dfeb)](https://circleci.com/gh/segmentio/analytics.js-core) | ||
[![Codecov](https://img.shields.io/codecov/c/github/segmentio/analytics.js-core/master.svg?maxAge=2592000)](https://codecov.io/gh/segmentio/analytics.js-core) | ||
This is the core of [Analytics.js][], the open-source library that powers data collection at [Segment](https://segment.com). | ||
@@ -13,3 +16,1 @@ | ||
[analytics.js]: https://segment.com/docs/libraries/analytics.js/ | ||
[ci-link]: https://circleci.com/gh/segmentio/analytics.js-core | ||
[ci-badge]: https://circleci.com/gh/segmentio/analytics.js-core.svg?style=svg |
@@ -114,2 +114,32 @@ 'use strict'; | ||
it('should gracefully handle integrations that fail to initialize', function() { | ||
Test.prototype.initialize = function() { throw new Error('Uh oh!'); }; | ||
analytics.add(Test); | ||
analytics.initialize(); | ||
assert(analytics.initialized); | ||
}); | ||
it('should store the names of integrations that did not initialize', function() { | ||
Test.prototype.initialize = function() { throw new Error('Uh oh!'); }; | ||
analytics.add(Test); | ||
analytics.initialize(); | ||
assert(analytics.failedInitializations.length === 1); | ||
assert(analytics.failedInitializations[0] === Test.prototype.name); | ||
}); | ||
it('should handle cases where integration.initialize failes and integration.prototype is undefined', function() { | ||
Test.initialize = function() { throw new Error('Uh oh!'); }; | ||
Test.prototype = undefined; | ||
analytics.add(Test); | ||
analytics.initialize(); | ||
assert(analytics.failedInitializations[0] === 'Unknown'); | ||
}); | ||
it('should handle cases where initialization fails and integration.prototype.name is undefined', function() { | ||
Test.prototype.name = undefined; | ||
analytics.add(Test); | ||
analytics.initialize(); | ||
assert(analytics.failedInitializations[0] === 'Unknown'); | ||
}); | ||
it('should not error without settings', function() { | ||
@@ -116,0 +146,0 @@ analytics.initialize(); |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
171231
23
3888
16
1