Skip to content

Commit 8be875d

Browse files
authored
[PLATFORM-2895] Part 1: Migrate integrations (#30)
* Fix latest tag * Add integration criteo This commit copies the content of the integration repo into the "integrations" folder. Original repo: https://github.com/segment-integrations/analytics.js-integration-criteo Readme: https://github.com/segment-integrations/analytics.js-integration-criteo/blob/master/README.md * Add integration convertro This commit copies the content of the integration repo into the "integrations" folder. Original repo: https://github.com/segment-integrations/analytics.js-integration-convertro Readme: https://github.com/segment-integrations/analytics.js-integration-convertro/blob/master/README.md * Add integration tvsquared This commit copies the content of the integration repo into the "integrations" folder. Original repo: https://github.com/segment-integrations/analytics.js-integration-tvsquared Readme: https://github.com/segment-integrations/analytics.js-integration-tvsquared/blob/master/README.md * Add integration localytics This commit copies the content of the integration repo into the "integrations" folder. Original repo: https://github.com/segment-integrations/analytics.js-integration-localytics Readme: https://github.com/segment-integrations/analytics.js-integration-localytics/blob/master/README.md * Add integration friendbuy This commit copies the content of the integration repo into the "integrations" folder. Original repo: https://github.com/segment-integrations/analytics.js-integration-friendbuy Readme: https://github.com/segment-integrations/analytics.js-integration-friendbuy/blob/master/README.md * Update dependencies * Fix friendbuy tests * Remove `eslint` step from circleci
1 parent b9bf273 commit 8be875d

40 files changed

+29286
-23
lines changed

.circleci/config.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ jobs:
3030
- attach_workspace: { at: . }
3131
- restore_cache:
3232
key: deps-{{ checksum "yarn.lock" }}
33-
- run:
34-
name: Linter
35-
command: yarn lint
3633
- run:
3734
name: Test updated integrations in PhantomJS
3835
command: yarn test-integrations --browsers PhantomJS

MIGRATE-INTEGRATIONS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ and pull requests.
2121
the repository:
2222
- `$ bin/boneyard-integration-repository --integration <integration name>`
2323

24-
24+
NOTE: For big migrations, it's ok to skip SauceLabs tests, but make sure
25+
local tests work (PhantomJS).

integrations/convertro/HISTORY.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
2+
2.1.2 / 2016-08-16
3+
==================
4+
5+
* npm publish
6+
7+
2.1.1 / 2016-08-16
8+
==================
9+
10+
* Merge pull request #7 from segment-integrations/update/ajs-integration
11+
* updating dependencies
12+
13+
2.1.0 / 2016-08-16
14+
==================
15+
16+
* Merge pull request #5 from segment-integrations/update/ecommerce-spec-v2
17+
* update ecommerce spec syntax to v2
18+
2.0.0 / 2016-06-21
19+
==================
20+
21+
* Remove Duo compatibility
22+
* Add CI setup (coverage, linting, cross-browser compatibility, etc.)
23+
* Update eslint configuration
24+
25+
1.0.5 / 2016-05-07
26+
==================
27+
28+
* Bump Analytics.js core, tester, integration to use Facade 2.x
29+
30+
1.0.4 / 2015-06-30
31+
==================
32+
33+
* Replace analytics.js dependency with analytics.js-core
34+
35+
1.0.3 / 2015-06-30
36+
==================
37+
38+
* Replace analytics.js dependency with analytics.js-core
39+
40+
1.0.2 / 2015-06-24
41+
==================
42+
43+
* Bump analytics.js-integration version
44+
45+
1.0.1 / 2015-06-24
46+
==================
47+
48+
* Bump analytics.js-integration version
49+
50+
1.0.0 / 2015-06-09
51+
==================
52+
53+
* Initial commit :sparkles:

integrations/convertro/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# analytics.js-integration-convertro [![Build Status][ci-badge]][ci-link]
2+
3+
Convertro integration for [Analytics.js][].
4+
5+
## License
6+
7+
Released under the [MIT license](LICENSE).
8+
9+
10+
[Analytics.js]: https://segment.com/docs/libraries/analytics.js/
11+
[ci-link]: https://ci.segment.com/gh/segment-integrations/analytics.js-integration-convertro
12+
[ci-badge]: https://ci.segment.com/gh/segment-integrations/analytics.js-integration-convertro.svg?style=svg&circle-token=1de2409e283048bf4028cf717e2bed7f6b01e6d8
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
'use strict';
2+
3+
/**
4+
* Module dependencies.
5+
*/
6+
7+
var each = require('@ndhoule/each');
8+
var integration = require('@segment/analytics.js-integration');
9+
var push = require('global-queue')('$CVO');
10+
11+
/**
12+
* Expose `Convertro` integration.
13+
*/
14+
15+
var Convertro = module.exports = integration('Convertro')
16+
.global('$CVO')
17+
.global('__cvo')
18+
.option('account', '')
19+
.option('hybridAttributionModel', false)
20+
.mapping('events')
21+
.tag('<script src="//d1ivexoxmp59q7.cloudfront.net/{{ account }}/live.js">');
22+
23+
/**
24+
* Initialize.
25+
*/
26+
27+
Convertro.prototype.initialize = function() {
28+
this.load(this.ready);
29+
};
30+
31+
/**
32+
* Loaded?
33+
*
34+
* @api public
35+
* @return {boolean}
36+
*/
37+
38+
Convertro.prototype.loaded = function() {
39+
return typeof (window.$CVO && window.$CVO.trackEvent) === 'function';
40+
};
41+
42+
/**
43+
* Identify.
44+
*
45+
* @api public
46+
* @param {Facade} identify
47+
*/
48+
49+
Convertro.prototype.identify = function(identify) {
50+
if (!identify.userId()) return;
51+
push('trackUser', identify.traits());
52+
};
53+
54+
/**
55+
* Track.
56+
*
57+
* @api public
58+
* @param {Track} track
59+
*/
60+
61+
Convertro.prototype.track = function(track) {
62+
var events = this.events(track.event());
63+
var revenue = track.revenue();
64+
var total = track.total();
65+
each(function(type) {
66+
push('trackEvent', {
67+
amount: total ? total : revenue,
68+
id: track.orderId(),
69+
type: type
70+
});
71+
}, events);
72+
};
73+
74+
/**
75+
* Order Completed & Attribution model
76+
* - Convertro has two attribution models
77+
* - the first is for when you don't know if clients are new/repeat
78+
* - the second is for when you know if a client is new/repeat
79+
* - The hybridAttributionModel allows users to
80+
* - move between the two attribution models
81+
*
82+
* - option=hybridAttributionModel (true)
83+
* - type="sale" && "sale.new"(.repeat=false), when it's a new order.
84+
* - type="sale" && "sale.repeat"(.repeat=true), when it's repeat order
85+
* - type="sale" (.repeat=null), when you can't figure out if an order is repeat / new
86+
*
87+
* - option=hybridAttributionModel (false)
88+
* - type="sale.new"(.repeat=false), when it's a new order.
89+
* - type="sale.repeat"(.repeat=true), when it's repeat order.
90+
* - type="sale" (.repeat=null), when you can't figure out if an order is repeat / new
91+
*
92+
*
93+
* @api public
94+
* @param {Track} track
95+
*/
96+
97+
Convertro.prototype.orderCompleted = function(track) {
98+
var repeat = track.proxy('properties.repeat');
99+
var amount = track.total() || track.revenue();
100+
var id = track.orderId();
101+
102+
if (typeof repeat === 'boolean') {
103+
push('trackEvent', {
104+
id: id,
105+
type: repeat ? 'sale.repeat' : 'sale.new',
106+
amount: amount
107+
});
108+
}
109+
110+
if (typeof repeat !== 'boolean' || this.options.hybridAttributionModel) {
111+
push('trackEvent', {
112+
id: id,
113+
type: 'sale',
114+
amount: amount
115+
});
116+
}
117+
};
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"name": "@segment/analytics.js-integration-convertro",
3+
"description": "The Convertro analytics.js integration.",
4+
"version": "2.1.2",
5+
"keywords": [
6+
"analytics.js",
7+
"analytics.js-integration",
8+
"segment",
9+
"convertro"
10+
],
11+
"main": "lib/index.js",
12+
"scripts": {
13+
"test": "make test"
14+
},
15+
"author": "Segment \u003c[email protected]\u003e",
16+
"license": "SEE LICENSE IN LICENSE",
17+
"homepage": "https://github.com/segmentio/analytics.js-integrations/blob/master/integrations/convertro#readme",
18+
"bugs": {
19+
"url": "https://github.com/segmentio/analytics.js-integrations/issues"
20+
},
21+
"repository": {
22+
"type": "git",
23+
"url": "git+https://github.com/segmentio/analytics.js-integrations.git"
24+
},
25+
"dependencies": {
26+
"@ndhoule/each": "^2.0.1",
27+
"@segment/analytics.js-integration": "^3.1.0",
28+
"global-queue": "^1.0.1"
29+
},
30+
"devDependencies": {
31+
"@segment/analytics.js-core": "^3.0.0",
32+
"@segment/analytics.js-integration-tester": "^3.1.0",
33+
"@segment/clear-env": "^2.0.0",
34+
"@segment/eslint-config": "^3.1.1",
35+
"browserify": "^13.0.0",
36+
"browserify-istanbul": "^2.0.0",
37+
"eslint": "^2.9.0",
38+
"eslint-plugin-mocha": "^2.2.0",
39+
"eslint-plugin-require-path-exists": "^1.1.5",
40+
"istanbul": "^0.4.3",
41+
"karma": "1.3.0",
42+
"karma-browserify": "^5.0.4",
43+
"karma-chrome-launcher": "^1.0.1",
44+
"karma-coverage": "^1.0.0",
45+
"karma-junit-reporter": "^1.0.0",
46+
"karma-mocha": "1.0.1",
47+
"karma-phantomjs-launcher": "^1.0.0",
48+
"karma-sauce-launcher": "^1.0.0",
49+
"karma-spec-reporter": "0.0.26",
50+
"mocha": "^2.2.5",
51+
"npm-check": "^5.2.1",
52+
"phantomjs-prebuilt": "^2.1.7",
53+
"watchify": "^3.7.0"
54+
}
55+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "@segment/eslint-config/mocha"
3+
}

0 commit comments

Comments
 (0)