Skip to content

Commit

Permalink
Add integration vero
Browse files Browse the repository at this point in the history
This commit copies the content of the integration repo into
the "integrations" folder.

Original repo: https://github.com/segment-integrations/analytics.js-integration-vero
Readme: https://github.com/segment-integrations/analytics.js-integration-vero/blob/master/README.md
  • Loading branch information
SegmentDestinationsBot committed Dec 10, 2019
1 parent 7269285 commit 8dbc299
Show file tree
Hide file tree
Showing 6 changed files with 483 additions and 0 deletions.
36 changes: 36 additions & 0 deletions integrations/vero/HISTORY.md
@@ -0,0 +1,36 @@
2.1.0 / 2017-04-14
==================

* Add support for Vero tags.

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-08-20
==================

* #identify method will now send to Vero when either userId OR email is present, rather than requiring both.

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:
12 changes: 12 additions & 0 deletions integrations/vero/README.md
@@ -0,0 +1,12 @@
# analytics.js-integration-vero [![Build Status][ci-badge]][ci-link]

Vero 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-vero
[ci-badge]: https://circleci.com/gh/segment-integrations/analytics.js-integration-vero.svg?style=svg
151 changes: 151 additions & 0 deletions integrations/vero/lib/index.js
@@ -0,0 +1,151 @@
'use strict';

/**
* Module dependencies.
*/

var cookie = require('component-cookie');
var integration = require('@segment/analytics.js-integration');
var push = require('global-queue')('_veroq');

/**
* Expose `Vero` integration.
*/

var Vero = module.exports = integration('Vero')
.global('_veroq')
.option('apiKey', '')
.tag('<script src="//d3qxef4rp70elm.cloudfront.net/m.js">');

/**
* Initialize.
*
* https://github.com/getvero/vero-api/blob/master/sections/js.md
*
* @api public
*/

Vero.prototype.initialize = function() {
// clear default cookie so vero parses correctly.
// this is for the tests.
// basically, they have window.addEventListener('unload')
// which then saves their "command_store", which is an array.
// so we just want to create that initially so we can reload the tests.
if (!cookie('__veroc4')) cookie('__veroc4', '[]');
push('init', { api_key: this.options.apiKey });
this.load(this.ready);
};

/**
* Loaded?
*
* @api private
* @return {boolean}
*/

Vero.prototype.loaded = function() {
return !!(window._veroq && window._veroq.push !== Array.prototype.push);
};

/**
* Page.
*
* https://www.getvero.com/knowledge-base#/questions/71768-Does-Vero-track-pageviews
*
* @api public
* @param {Page} page
*/

Vero.prototype.page = function(page) {
push('trackPageview');
var tags = page.options('Vero').tags;
if (tags) this.addOrRemoveTags(tags);
};

/**
* Identify.
*
* https://www.getvero.com/api/http/#users
* https://github.com/getvero/vero-api/blob/master/sections/js.md#user-identification
*
* @api public
* @param {Identify} identify
*/

Vero.prototype.identify = function(identify) {
var traits = identify.traits();
var email = identify.email();
var id = identify.userId();
// userId OR email address are required by Vero's API. When userId isn't present,
// email will be used as the userId.
if (!id && !email) return;
push('user', traits);
// check for tags and either add or remove.
var tags = identify.options('Vero').tags;
if (tags) this.addOrRemoveTags(tags);
};

/**
* Track.
*
* https://www.getvero.com/api/http/#actions
* https://github.com/getvero/vero-api/blob/master/sections/js.md#tracking-events
*
* @api public
* @param {Track} track
*/

Vero.prototype.track = function(track) {
var regex = /[uU]nsubscribe/;

if (track.event().match(regex)) {
push('unsubscribe', { id: track.properties().id });
} else {
push('track', track.event(), track.properties(), { source: 'segment' });
}
// check for tags and either add or remove.
var tags = track.options('Vero').tags;
if (tags) this.addOrRemoveTags(tags);
};

/**
* Alias.
*
* https://www.getvero.com/api/http/#users
* https://github.com/getvero/vero-api/blob/master/sections/api/users.md
*
* @api public
* @param {Alias} alias
*/

Vero.prototype.alias = function(alias) {
var to = alias.to();

if (alias.from()) {
push('reidentify', to, alias.from());
} else {
push('reidentify', to);
}
var tags = alias.options('Vero').tags;
if (tags) this.addOrRemoveTags(tags);
};

/**
* AddOrRemoveTags.
*
* http://developers.getvero.com/?javascript#tags
*
* @api public
* @param {Object} tags
*/

Vero.prototype.addOrRemoveTags = function(tags) {
var payload = {};
if (!tags.action || !tags.values) return;
var action = tags.action;
payload[action] = tags.values;
if (tags.id) {
payload.id = tags.id;
}
push('tags', payload);
};
55 changes: 55 additions & 0 deletions integrations/vero/package.json
@@ -0,0 +1,55 @@
{
"name": "@segment/analytics.js-integration-vero",
"description": "The Vero analytics.js integration.",
"version": "2.1.0",
"keywords": [
"analytics.js",
"analytics.js-integration",
"segment",
"vero"
],
"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/vero#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",
"component-cookie": "^1.1.2",
"global-queue": "^1.0.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"
}
}
3 changes: 3 additions & 0 deletions integrations/vero/test/.eslintrc
@@ -0,0 +1,3 @@
{
"extends": "@segment/eslint-config/mocha"
}

0 comments on commit 8dbc299

Please sign in to comment.