Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit copies the content of the integration repo into the "integrations" folder. Original repo: https://github.com/segment-integrations/analytics.js-integration-supporthero Readme: https://github.com/segment-integrations/analytics.js-integration-supporthero/blob/master/README.md
- Loading branch information
1 parent
5383df6
commit 32e7dce
Showing
6 changed files
with
266 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
2.0.0 / 2016-06-21 | ||
================== | ||
|
||
* Remove Duo compatibility | ||
* Add CI setup (coverage, linting, cross-browser compatibility, etc.) | ||
* Update eslint configuration | ||
|
||
1.0.3 / 2016-05-07 | ||
================== | ||
|
||
* Bump Analytics.js core, tester, integration to use Facade 2.x | ||
|
||
1.0.2 / 2015-06-30 | ||
================== | ||
|
||
* Replace analytics.js dependency with analytics.js-core | ||
|
||
1.0.1 / 2015-06-24 | ||
================== | ||
|
||
* Bump analytics.js-integration version | ||
|
||
1.0.0 / 2015-06-09 | ||
================== | ||
|
||
* Initial commit :sparkles: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# analytics.js-integration-supporthero [![Build Status][ci-badge]][ci-link] | ||
|
||
Supporthero integration for [Analytics.js][]. | ||
|
||
## License | ||
|
||
Released under the [MIT license](LICENSE). | ||
|
||
|
||
[Analytics.js]: https://segment.com/docs/libraries/analytics.js/ | ||
[ci-link]: https://circleci.com/gh/segment-integrations/analytics.js-integration-supporthero | ||
[ci-badge]: https://circleci.com/gh/segment-integrations/analytics.js-integration-supporthero.svg?style=svg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
'use strict'; | ||
|
||
/** | ||
* Module dependencies. | ||
*/ | ||
|
||
var integration = require('@segment/analytics.js-integration'); | ||
|
||
/** | ||
* Expose `SupportHero` integration. | ||
*/ | ||
|
||
var SupportHero = module.exports = integration('SupportHero') | ||
.assumesPageview() | ||
.global('supportHeroWidget') | ||
.option('token', '') | ||
.option('track', false) | ||
.tag('<script src="https://d29l98y0pmei9d.cloudfront.net/js/widget.min.js?k={{ token }}">'); | ||
|
||
/** | ||
* Initialize Support Hero. | ||
* | ||
* @api public | ||
*/ | ||
|
||
SupportHero.prototype.initialize = function() { | ||
window.supportHeroWidget = {}; | ||
window.supportHeroWidget.setUserId = window.supportHeroWidget.setUserId || function() {}; | ||
window.supportHeroWidget.setUserTraits = window.supportHeroWidget.setUserTraits || function() {}; | ||
this.load(this.ready); | ||
}; | ||
|
||
/** | ||
* Has the Support Hero library been loaded yet? | ||
* | ||
* @api private | ||
* @return {boolean} | ||
*/ | ||
|
||
SupportHero.prototype.loaded = function() { | ||
return !!window.supportHeroWidget; | ||
}; | ||
|
||
/** | ||
* Identify a user. | ||
* | ||
* @api public | ||
* @param {Facade} identify | ||
*/ | ||
|
||
SupportHero.prototype.identify = function(identify) { | ||
var id = identify.userId(); | ||
var traits = identify.traits(); | ||
if (id) { | ||
window.supportHeroWidget.setUserId(id); | ||
} | ||
if (traits) { | ||
window.supportHeroWidget.setUserTraits(traits); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{ | ||
"name": "@segment/analytics.js-integration-supporthero", | ||
"description": "The Supporthero analytics.js integration.", | ||
"version": "2.0.0", | ||
"keywords": [ | ||
"analytics.js", | ||
"analytics.js-integration", | ||
"segment", | ||
"supporthero" | ||
], | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"test": "make test" | ||
}, | ||
"author": "Segment \u003cfriends@segment.com\u003e", | ||
"license": "SEE LICENSE IN LICENSE", | ||
"homepage": "https://github.com/segmentio/analytics.js-integrations/blob/master/integrations/supporthero#readme", | ||
"bugs": { | ||
"url": "https://github.com/segmentio/analytics.js-integrations/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/segmentio/analytics.js-integrations.git" | ||
}, | ||
"dependencies": { | ||
"@segment/analytics.js-integration": "^2.1.0" | ||
}, | ||
"devDependencies": { | ||
"@segment/analytics.js-core": "^3.0.0", | ||
"@segment/analytics.js-integration-tester": "^3.1.0", | ||
"@segment/clear-env": "^2.0.0", | ||
"@segment/eslint-config": "^3.1.1", | ||
"browserify": "^13.0.0", | ||
"browserify-istanbul": "^2.0.0", | ||
"eslint": "^2.9.0", | ||
"eslint-plugin-mocha": "^2.2.0", | ||
"eslint-plugin-require-path-exists": "^1.1.5", | ||
"istanbul": "^0.4.3", | ||
"karma": "1.3.0", | ||
"karma-browserify": "^5.0.4", | ||
"karma-chrome-launcher": "^1.0.1", | ||
"karma-coverage": "^1.0.0", | ||
"karma-junit-reporter": "^1.0.0", | ||
"karma-mocha": "1.0.1", | ||
"karma-phantomjs-launcher": "^1.0.0", | ||
"karma-sauce-launcher": "^1.0.0", | ||
"karma-spec-reporter": "0.0.26", | ||
"mocha": "^2.2.5", | ||
"npm-check": "^5.2.1", | ||
"phantomjs-prebuilt": "^2.1.7", | ||
"watchify": "^3.7.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "@segment/eslint-config/mocha" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
'use strict'; | ||
|
||
var Analytics = require('@segment/analytics.js-core').constructor; | ||
var integration = require('@segment/analytics.js-integration'); | ||
var sandbox = require('@segment/clear-env'); | ||
var tester = require('@segment/analytics.js-integration-tester'); | ||
var SupportHero = require('../lib/'); | ||
|
||
describe('SupportHero', function() { | ||
var analytics; | ||
var supportHero; | ||
var options = { | ||
token: 'Y2xpZW50SWQ9MjYmaG9zdE5hbWU9dGVzdC5zdXBwb3J0aGVyby5pbw==' | ||
}; | ||
|
||
beforeEach(function() { | ||
analytics = new Analytics(); | ||
supportHero = new SupportHero(options); | ||
analytics.use(SupportHero); | ||
analytics.use(tester); | ||
analytics.add(supportHero); | ||
}); | ||
|
||
afterEach(function() { | ||
analytics.restore(); | ||
analytics.reset(); | ||
supportHero.reset(); | ||
sandbox(); | ||
}); | ||
|
||
it('should have the right settings', function() { | ||
analytics.compare(SupportHero, integration('SupportHero') | ||
.assumesPageview() | ||
.global('supportHeroWidget') | ||
.option('token', '') | ||
.option('track', false)); | ||
}); | ||
|
||
describe('before loading', function() { | ||
beforeEach(function() { | ||
analytics.stub(supportHero, 'load'); | ||
}); | ||
|
||
afterEach(function() { | ||
supportHero.reset(); | ||
}); | ||
|
||
describe('#initialize', function() { | ||
it('should set up the window.supportHeroWidget methods', function() { | ||
analytics.initialize(); | ||
analytics.page(); | ||
analytics.assert(window.supportHeroWidget.setUserId); | ||
analytics.assert(window.supportHeroWidget.setUserTraits); | ||
}); | ||
|
||
it('should call #load', function() { | ||
analytics.initialize(); | ||
analytics.page(); | ||
analytics.called(supportHero.load); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('loading', function() { | ||
it('should load', function(done) { | ||
analytics.load(supportHero, done); | ||
}); | ||
}); | ||
|
||
describe('after loading', function() { | ||
beforeEach(function(done) { | ||
analytics.once('ready', done); | ||
analytics.initialize(); | ||
analytics.page(); | ||
}); | ||
|
||
describe('#setUserId', function() { | ||
beforeEach(function() { | ||
analytics.stub(window.supportHeroWidget, 'setUserId'); | ||
}); | ||
|
||
it('should send an id', function() { | ||
analytics.identify('id'); | ||
analytics.called(window.supportHeroWidget.setUserId, 'id'); | ||
}); | ||
}); | ||
|
||
describe('#setUserTraits', function() { | ||
beforeEach(function() { | ||
analytics.stub(window.supportHeroWidget, 'setUserTraits'); | ||
}); | ||
|
||
it('should send traits', function() { | ||
analytics.identify({ trait: true }); | ||
analytics.called(window.supportHeroWidget.setUserTraits, { trait: true }); | ||
}); | ||
}); | ||
|
||
describe('#setUserId and #setUserTraits at once', function() { | ||
beforeEach(function() { | ||
analytics.stub(window.supportHeroWidget, 'setUserId'); | ||
analytics.stub(window.supportHeroWidget, 'setUserTraits'); | ||
}); | ||
|
||
it('should send an id and traits', function() { | ||
analytics.identify('id', { trait: true }); | ||
analytics.called(window.supportHeroWidget.setUserId, 'id'); | ||
analytics.called(window.supportHeroWidget.setUserTraits, { trait: true, id: 'id' }); | ||
}); | ||
}); | ||
}); | ||
}); |