Skip to content

Commit b9bf273

Browse files
authored
Add integration adometry (#29)
* Add integration adometry This commit copies the content of the integration repo into the "integrations" folder. Original repo: https://github.com/segment-integrations/analytics.js-integration-adometry Readme: https://github.com/segment-integrations/analytics.js-integration-adometry/blob/master/README.md * Fix package json
1 parent 838338b commit b9bf273

File tree

12 files changed

+5765
-36
lines changed

12 files changed

+5765
-36
lines changed
Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
{
2-
"Name": "@segment/analytics.js-integration-adlearn-open-platform",
3-
"Description": "The Adlearn Open Platform analytics.js integration.",
4-
"Version": "2.0.0",
5-
"Keywords": [
2+
"name": "@segment/analytics.js-integration-adlearn-open-platform",
3+
"description": "The Adlearn Open Platform analytics.js integration.",
4+
"version": "2.0.0",
5+
"keywords": [
66
"analytics.js",
77
"analytics.js-integration",
88
"segment",
99
"adlearn"
1010
],
11-
"Main": "lib/index.js",
12-
"Scripts": {
11+
"main": "lib/index.js",
12+
"scripts": {
1313
"test": "make test"
1414
},
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/adlearn-open-platform#readme",
18-
"Bugs": {
19-
"URL": "https://github.com/segmentio/analytics.js-integrations/issues"
15+
"repository": {
16+
"type": "git",
17+
"url": "git+https://github.com/segmentio/analytics.js-integrations.git"
2018
},
21-
"Repository": {
22-
"Type": "git",
23-
"URL": "git+https://github.com/segmentio/analytics.js-integrations.git"
19+
"author": "Segment <[email protected]>",
20+
"license": "SEE LICENSE IN LICENSE",
21+
"bugs": {
22+
"url": "https://github.com/segmentio/analytics.js-integrations/issues"
2423
},
25-
"Dependencies": {
24+
"homepage": "https://github.com/segmentio/analytics.js-integrations/blob/master/integrations/adlearn-open-platform#readme",
25+
"dependencies": {
2626
"@ndhoule/each": "^2.0.1",
2727
"@segment/analytics.js-integration": "^2.0.1"
2828
},
29-
"DevDependencies": {
29+
"devDependencies": {
3030
"@segment/analytics.js-core": "^3.0.0",
3131
"@segment/analytics.js-integration-tester": "^3.1.0",
3232
"@segment/clear-env": "^1.0.0",
@@ -51,4 +51,4 @@
5151
"phantomjs-prebuilt": "^2.1.7",
5252
"watchify": "^3.7.0"
5353
}
54-
}
54+
}

integrations/adometry/HISTORY.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
2.0.0 / 2016-06-21
2+
==================
3+
4+
* Remove Duo compatibility
5+
* Add CI setup (coverage, linting, cross-browser compatibility, etc.)
6+
* Update eslint configuration
7+
8+
1.2.1 / 2016-05-07
9+
==================
10+
11+
* Bump Analytics.js core, tester, integration to use Facade 2.x
12+
13+
1.2.0 / 2015-08-17
14+
==================
15+
16+
* add anonymousId to page closes #3
17+
18+
1.1.0 / 2015-08-13
19+
==================
20+
21+
* Update `page` behavior to use generic pageId conversion value rather than mapped
22+
23+
1.0.5 / 2015-06-30
24+
==================
25+
26+
* Replace analytics.js dependency with analytics.js-core
27+
28+
1.0.4 / 2015-06-30
29+
==================
30+
31+
* Replace analytics.js dependency with analytics.js-core
32+
33+
1.0.3 / 2015-06-24
34+
==================
35+
36+
* Bump analytics.js-integration version
37+
38+
1.0.2 / 2015-06-24
39+
==================
40+
41+
* Bump analytics.js-integration version
42+
1.0.1 / 2015-06-10
43+
==================
44+
45+
* Bump dependency versions
46+
47+
1.0.0 / 2015-06-09
48+
==================
49+
50+
* Initial commit :sparkles:

integrations/adometry/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# analytics.js-integration-adometry [![Build Status][ci-badge]][ci-link]
2+
3+
Adometry 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-adometry
12+
[ci-badge]: https://ci.segment.com/gh/segment-integrations/analytics.js-integration-adometry.svg?style=svg&circle-token=07cc48c74696bfdcbd68d260037ab51a64cefdfd

integrations/adometry/lib/index.js

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
'use strict';
2+
3+
/**
4+
* Module dependencies.
5+
*/
6+
7+
var each = require('@ndhoule/each');
8+
var entries = require('@ndhoule/entries');
9+
var extend = require('@ndhoule/extend');
10+
var integration = require('@segment/analytics.js-integration');
11+
var map = require('@ndhoule/map');
12+
var pick = require('@ndhoule/pick');
13+
var values = require('@ndhoule/values');
14+
15+
/**
16+
* Map of special #track properties to their default Adometry shorthands.
17+
*
18+
* https://segment.com/docs/api/tracking/track/#special-properties
19+
*/
20+
21+
var TRACK_SPECIAL_PROPERTIES = {
22+
revenue: 'rev',
23+
value: 'val'
24+
};
25+
26+
/**
27+
* Expose `Adometry`.
28+
*/
29+
30+
var Adometry = module.exports = integration('Adometry')
31+
.global('DMTRY')
32+
.option('advertiserId', '')
33+
.option('campaignId', '')
34+
.option('pageId', '')
35+
.tag('page', '<script src="//js.dmtry.com/channel.js#gid:{{ campaignId }};advid:{{ advertiserId }};pid:{{ pageId }}{{ properties }}">')
36+
.tag('track', '<script src="//js.dmtry.com/channel.js#gid:{{ campaignId }};advid:{{ advertiserId }};pid:{{ placementId }}{{ properties }}">')
37+
.mapping('events')
38+
.mapping('aliases');
39+
40+
/**
41+
* Track.
42+
*
43+
* @api public
44+
* @param {Track} track
45+
*/
46+
47+
Adometry.prototype.track = function(track) {
48+
var event = track.event();
49+
if (!event) return;
50+
51+
var self = this;
52+
var placementIds = this.events(event);
53+
var aliases = extend({}, this.options.aliases, TRACK_SPECIAL_PROPERTIES);
54+
var properties = track.properties(aliases);
55+
var filteredProperties = pick(values(aliases), properties);
56+
57+
each(function(placementId) {
58+
self.load('track', {
59+
advertiserId: self.options.advertiserId,
60+
campaignId: self.options.campaignId,
61+
placementId: placementId,
62+
properties: self._hashify(filteredProperties, 'cus.')
63+
});
64+
}, placementIds);
65+
};
66+
67+
/**
68+
* Page.
69+
*
70+
* @api public
71+
* @param {Page} page
72+
*/
73+
74+
Adometry.prototype.page = function(page) {
75+
var self = this;
76+
var anonymousId = page.anonymousId();
77+
var properties = { ano: anonymousId };
78+
79+
self.load('page', {
80+
properties: self._hashify(properties, 'cus.')
81+
});
82+
};
83+
84+
/**
85+
* Creates an Adometry-compatible hash from an object.
86+
*
87+
* @api private
88+
* @param {object} props A hash of key-value pairs.
89+
* @param {string} prefix A prefix to add to each key.
90+
* @return {string}
91+
*/
92+
93+
// TODO: Move into a lib file and test separately once we have multi-file support
94+
Adometry.prototype._hashify = function(props, prefix) {
95+
prefix = prefix || '';
96+
props = entries(props);
97+
98+
if (!props || !props.length) {
99+
return '';
100+
}
101+
102+
return ';' + map(function(prop) {
103+
return prefix + prop[0] + ':' + prop[1];
104+
}, props).join(';');
105+
};

integrations/adometry/package.json

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"name": "@segment/analytics.js-integration-adometry",
3+
"description": "The Adometry analytics.js integration.",
4+
"version": "2.0.0",
5+
"keywords": [
6+
"analytics.js",
7+
"analytics.js-integration",
8+
"segment",
9+
"adometry"
10+
],
11+
"main": "lib/index.js",
12+
"scripts": {
13+
"test": "make test"
14+
},
15+
"repository": {
16+
"type": "git",
17+
"url": "git+https://github.com/segmentio/analytics.js-integrations.git"
18+
},
19+
"author": "Segment <[email protected]>",
20+
"license": "SEE LICENSE IN LICENSE",
21+
"bugs": {
22+
"url": "https://github.com/segmentio/analytics.js-integrations/issues"
23+
},
24+
"homepage": "https://github.com/segmentio/analytics.js-integrations/blob/master/integrations/adometry#readme",
25+
"dependencies": {
26+
"@ndhoule/each": "^2.0.1",
27+
"@ndhoule/entries": "^2.0.0",
28+
"@ndhoule/extend": "^2.0.0",
29+
"@ndhoule/map": "^2.0.1",
30+
"@ndhoule/pick": "^2.0.0",
31+
"@ndhoule/values": "^2.0.1",
32+
"@segment/analytics.js-integration": "^2.1.0"
33+
},
34+
"devDependencies": {
35+
"@segment/analytics.js-core": "^3.0.0",
36+
"@segment/analytics.js-integration-tester": "^3.1.0",
37+
"@segment/clear-env": "^2.0.0",
38+
"@segment/eslint-config": "^3.1.1",
39+
"@segment/fmt": "^1.0.0",
40+
"browserify": "^13.0.0",
41+
"browserify-istanbul": "^2.0.0",
42+
"eslint": "^2.9.0",
43+
"eslint-plugin-mocha": "^2.2.0",
44+
"eslint-plugin-require-path-exists": "^1.1.5",
45+
"istanbul": "^0.4.3",
46+
"karma": "1.3.0",
47+
"karma-browserify": "^5.0.4",
48+
"karma-chrome-launcher": "^1.0.1",
49+
"karma-coverage": "^1.0.0",
50+
"karma-junit-reporter": "^1.0.0",
51+
"karma-mocha": "1.0.1",
52+
"karma-phantomjs-launcher": "^1.0.0",
53+
"karma-sauce-launcher": "^1.0.0",
54+
"karma-spec-reporter": "0.0.26",
55+
"mocha": "^2.2.5",
56+
"npm-check": "^5.2.1",
57+
"phantomjs-prebuilt": "^2.1.7",
58+
"proclaim": "^3.4.1",
59+
"watchify": "^3.7.0"
60+
}
61+
}
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)