-
Notifications
You must be signed in to change notification settings - Fork 142
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-mouseflow Readme: https://github.com/segment-integrations/analytics.js-integration-mouseflow/blob/master/README.md
- Loading branch information
1 parent
e247b74
commit b1e5e0e
Showing
6 changed files
with
338 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,46 @@ | ||
2.2.2 / 2017-08-30 | ||
================== | ||
|
||
* Update ajs dependency to ^3.0.0 | ||
|
||
2.2.1 / 2017-08-29 | ||
================== | ||
|
||
* Resolve NPM release issue | ||
|
||
2.1.0 / 2017-08-28 | ||
================== | ||
|
||
* Add custom path to page calls | ||
|
||
2.0.0 / 2016-06-21 | ||
================== | ||
|
||
* Remove Duo compatibility | ||
* Add CI setup (coverage, linting, cross-browser compatibility, etc.) | ||
* Update eslint configuration | ||
|
||
1.0.4 / 2016-05-07 | ||
================== | ||
|
||
* Bump Analytics.js core, tester, integration to use Facade 2.x | ||
|
||
1.0.3 / 2015-06-30 | ||
================== | ||
|
||
* Replace analytics.js dependency with analytics.js-core | ||
|
||
1.0.2 / 2015-06-24 | ||
================== | ||
|
||
* Bump analytics.js-integration version | ||
|
||
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-mouseflow [![Build Status][ci-badge]][ci-link] | ||
|
||
Mouseflow 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-mouseflow | ||
[ci-badge]: https://circleci.com/gh/segment-integrations/analytics.js-integration-mouseflow.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,98 @@ | ||
'use strict'; | ||
|
||
/** | ||
* Module dependencies. | ||
*/ | ||
|
||
var each = require('component-each'); | ||
var integration = require('@segment/analytics.js-integration'); | ||
var push = require('global-queue')('_mfq'); | ||
|
||
/** | ||
* Expose `Mouseflow`. | ||
*/ | ||
|
||
var Mouseflow = module.exports = integration('Mouseflow') | ||
.assumesPageview() | ||
.global('_mfq') | ||
.global('mouseflow') | ||
.global('mouseflowHtmlDelay') | ||
.option('apiKey', '') | ||
.option('mouseflowHtmlDelay', 0) | ||
.tag('<script src="//cdn.mouseflow.com/projects/{{ apiKey }}.js">'); | ||
|
||
/** | ||
* Initalize. | ||
* | ||
* @api public | ||
*/ | ||
|
||
Mouseflow.prototype.initialize = function() { | ||
window.mouseflowHtmlDelay = this.options.mouseflowHtmlDelay; | ||
this.load(this.ready); | ||
}; | ||
|
||
/** | ||
* Loaded? | ||
* | ||
* @api private | ||
* @return {boolean} | ||
*/ | ||
|
||
Mouseflow.prototype.loaded = function() { | ||
return !!window.mouseflow; | ||
}; | ||
|
||
/** | ||
* Page. | ||
* | ||
* http://mouseflow.zendesk.com/entries/22528817-Single-page-websites | ||
* | ||
* @api public | ||
* @param {Page} page | ||
*/ | ||
|
||
Mouseflow.prototype.page = function(page) { | ||
push('newPageView', page.path()); | ||
}; | ||
|
||
/** | ||
* Identify. | ||
* | ||
* http://mouseflow.zendesk.com/entries/24643603-Custom-Variables-Tagging | ||
* | ||
* @api public | ||
* @param {Identify} identify | ||
*/ | ||
|
||
Mouseflow.prototype.identify = function(identify) { | ||
set(identify.traits()); | ||
}; | ||
|
||
/** | ||
* Track. | ||
* | ||
* http://mouseflow.zendesk.com/entries/24643603-Custom-Variables-Tagging | ||
* | ||
* @api public | ||
* @param {Track} track | ||
*/ | ||
|
||
Mouseflow.prototype.track = function(track) { | ||
var props = track.properties(); | ||
props.event = track.event(); | ||
set(props); | ||
}; | ||
|
||
/** | ||
* Push each key and value in the given `obj` onto the queue. | ||
* | ||
* @api private | ||
* @param {Object} obj | ||
*/ | ||
|
||
function set(obj) { | ||
each(obj, function(key, value) { | ||
push('setVariable', key, value); | ||
}); | ||
} |
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,57 @@ | ||
{ | ||
"name": "@segment/analytics.js-integration-mouseflow", | ||
"description": "The Mouseflow analytics.js integration.", | ||
"version": "2.2.2", | ||
"keywords": [ | ||
"analytics.js", | ||
"analytics.js-integration", | ||
"segment", | ||
"mouseflow" | ||
], | ||
"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/mouseflow#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": "^3.0.0", | ||
"component-each": "^0.2.6", | ||
"global-queue": "^1.0.1", | ||
"is": "^3.1.0", | ||
"use-https": "^0.1.1" | ||
}, | ||
"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,122 @@ | ||
'use strict'; | ||
|
||
var Analytics = require('@segment/analytics.js-core').constructor; | ||
var integration = require('@segment/analytics.js-integration'); | ||
var tester = require('@segment/analytics.js-integration-tester'); | ||
var sandbox = require('@segment/clear-env'); | ||
var Mouseflow = require('../lib/'); | ||
|
||
describe('Mouseflow', function() { | ||
var analytics; | ||
var mouseflow; | ||
var options = { | ||
apiKey: '093c80cf-1455-4ad6-b130-ce44cd25ca7c' | ||
}; | ||
|
||
beforeEach(function() { | ||
analytics = new Analytics(); | ||
mouseflow = new Mouseflow(options); | ||
analytics.use(Mouseflow); | ||
analytics.use(tester); | ||
analytics.add(mouseflow); | ||
}); | ||
|
||
afterEach(function() { | ||
analytics.restore(); | ||
analytics.reset(); | ||
mouseflow.reset(); | ||
sandbox(); | ||
}); | ||
|
||
it('should have the correct settings', function() { | ||
analytics.compare(Mouseflow, integration('Mouseflow') | ||
.assumesPageview() | ||
.global('_mfq') | ||
.global('mouseflow') | ||
.global('mouseflowHtmlDelay') | ||
.option('apiKey', '') | ||
.option('mouseflowHtmlDelay', 0)); | ||
}); | ||
|
||
describe('before loading', function() { | ||
beforeEach(function() { | ||
analytics.stub(mouseflow, 'load'); | ||
}); | ||
|
||
describe('#initialize', function() { | ||
it('should call #load', function() { | ||
analytics.initialize(); | ||
analytics.page(); | ||
analytics.called(mouseflow.load); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('loading', function() { | ||
it('should load', function(done) { | ||
analytics.load(mouseflow, done); | ||
}); | ||
}); | ||
|
||
describe('after loading', function() { | ||
beforeEach(function(done) { | ||
analytics.once('ready', done); | ||
analytics.initialize(); | ||
analytics.page(); | ||
}); | ||
|
||
it('should set window.mouseflowHtmlDelay', function() { | ||
analytics.assert(window.mouseflowHtmlDelay === 0); | ||
}); | ||
|
||
describe('#page', function() { | ||
beforeEach(function() { | ||
analytics.stub(window._mfq, 'push'); | ||
}); | ||
|
||
it('should pass the path', function() { | ||
analytics.page({ path: '/path' }); | ||
analytics.called(window._mfq.push, ['newPageView', '/path']); | ||
}); | ||
}); | ||
|
||
describe('#identify', function() { | ||
beforeEach(function() { | ||
analytics.stub(window._mfq, 'push'); | ||
}); | ||
|
||
it('should send id', function() { | ||
analytics.identify(123); | ||
analytics.called(window._mfq.push, ['setVariable', 'id', 123]); | ||
}); | ||
|
||
it('should send traits', function() { | ||
analytics.identify({ a: 1 }); | ||
analytics.called(window._mfq.push, ['setVariable', 'a', 1]); | ||
}); | ||
|
||
it('should send id and traits', function() { | ||
analytics.identify(123, { a: 1 }); | ||
analytics.called(window._mfq.push, ['setVariable', 'id', 123]); | ||
analytics.called(window._mfq.push, ['setVariable', 'a', 1]); | ||
}); | ||
}); | ||
|
||
describe('#track', function() { | ||
beforeEach(function() { | ||
analytics.stub(window._mfq, 'push'); | ||
}); | ||
|
||
it('should send event', function() { | ||
analytics.track('event-name'); | ||
analytics.called(window._mfq.push, ['setVariable', 'event', 'event-name']); | ||
}); | ||
|
||
it('should send props', function() { | ||
analytics.track('event-name', { a: 1 }); | ||
analytics.called(window._mfq.push, ['setVariable', 'event', 'event-name']); | ||
analytics.called(window._mfq.push, ['setVariable', 'a', 1]); | ||
}); | ||
}); | ||
}); | ||
}); |