Skip to content

Commit 6a396dc

Browse files
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
1 parent 838338b commit 6a396dc

File tree

12 files changed

+5841
-0
lines changed

12 files changed

+5841
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
**This repository has been moved to [Analytics JS integrations](https://github.com/segmentio/analytics.js-integrations), please create the issue there**
3+
4+
See [README](README.md) for more information. Issues/Pull Requests created in this repository are not longer monitored.
5+
6+
Thank you,
7+
8+
_The Segment team_
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
**This repository has been moved to [Analytics JS integrations](https://github.com/segmentio/analytics.js-integrations), please move the changes there and create the Pull Request**
3+
4+
See [README](README.md) for more information. Issues/Pull Requests created in this repository are not longer monitored.
5+
6+
Thank you,
7+
8+
_The Segment team_

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:
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/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
# [MOVED] Analytics JS integration adometry
3+
4+
**This repository has been moved to the open source [Analytics JS Integrations](https://github.com/segmentio/analytics.js-integrations).**
5+
6+
If you want to fork, contribute, or open issues, please do it in the new repository. Existing issues/pull requests will be addressed in the new location.
7+
8+
* [New location](https://github.com/segmentio/analytics.js-integrations/tree/master/integrations/adometry)
9+
* Last release for this repository: [none](n/a)
10+
* [Commit](https://github.com/segmentio/analytics.js-integrations/commit/e742996b7dc7accafb6159a90a042fa4b1fc7c38)
11+
* [Previous version of this README](README-OLD.md)
12+
13+
Released under the [MIT license](LICENSE).
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/* eslint-env node */
2+
'use strict';
3+
4+
var baseConfig = require('./karma.conf');
5+
6+
var customLaunchers = {
7+
sl_chrome_latest: {
8+
base: 'SauceLabs',
9+
browserName: 'chrome',
10+
platform: 'linux',
11+
version: 'latest'
12+
},
13+
sl_chrome_latest_1: {
14+
base: 'SauceLabs',
15+
browserName: 'chrome',
16+
platform: 'linux',
17+
version: 'latest-1'
18+
},
19+
sl_firefox_latest: {
20+
base: 'SauceLabs',
21+
browserName: 'firefox',
22+
platform: 'linux',
23+
version: 'latest'
24+
},
25+
sl_firefox_latest_1: {
26+
base: 'SauceLabs',
27+
browserName: 'firefox',
28+
platform: 'linux',
29+
version: 'latest-1'
30+
},
31+
sl_safari_9: {
32+
base: 'SauceLabs',
33+
browserName: 'safari',
34+
version: '9.0'
35+
},
36+
// FIXME(ndhoule): Bad IE7/8 support in testing packages make these fail
37+
// sl_ie_7: {
38+
// base: 'SauceLabs',
39+
// browserName: 'internet explorer',
40+
// version: '7'
41+
// },
42+
// sl_ie_8: {
43+
// base: 'SauceLabs',
44+
// browserName: 'internet explorer',
45+
// version: '8'
46+
// },
47+
sl_ie_9: {
48+
base: 'SauceLabs',
49+
browserName: 'internet explorer',
50+
version: '9'
51+
},
52+
sl_ie_10: {
53+
base: 'SauceLabs',
54+
browserName: 'internet explorer',
55+
version: '10'
56+
},
57+
sl_ie_11: {
58+
base: 'SauceLabs',
59+
browserName: 'internet explorer',
60+
version: '11'
61+
},
62+
sl_edge_latest: {
63+
base: 'SauceLabs',
64+
browserName: 'microsoftedge'
65+
}
66+
};
67+
68+
module.exports = function(config) {
69+
baseConfig(config);
70+
71+
if (!process.env.SAUCE_USERNAME || !process.env.SAUCE_ACCESS_KEY) {
72+
throw new Error('SAUCE_USERNAME and SAUCE_ACCESS_KEY environment variables are required but are missing');
73+
}
74+
75+
config.set({
76+
browserDisconnectTolerance: 1,
77+
78+
singleRun: true,
79+
80+
reporters: ['progress', 'junit', 'coverage'],
81+
82+
browsers: ['PhantomJS'].concat(Object.keys(customLaunchers)),
83+
84+
customLaunchers: customLaunchers,
85+
86+
junitReporter: {
87+
outputDir: process.env.TEST_REPORTS_DIR,
88+
suite: require('./package.json').name
89+
},
90+
91+
sauceLabs: {
92+
testName: require('./package.json').name
93+
},
94+
95+
coverageReporter: {
96+
reporters: [
97+
{ type: 'lcov' }
98+
]
99+
}
100+
});
101+
};
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/* eslint-env node */
2+
'use strict';
3+
4+
module.exports = function(config) {
5+
config.set({
6+
files: [
7+
'test/**/*.test.js'
8+
],
9+
10+
browsers: ['PhantomJS'],
11+
12+
frameworks: ['browserify', 'mocha'],
13+
14+
reporters: ['spec', 'coverage'],
15+
16+
preprocessors: {
17+
'test/**/*.js': 'browserify'
18+
},
19+
20+
client: {
21+
mocha: {
22+
grep: process.env.GREP,
23+
reporter: 'html',
24+
timeout: 10000
25+
}
26+
},
27+
28+
browserify: {
29+
debug: true,
30+
transform: [
31+
[
32+
'browserify-istanbul',
33+
{
34+
instrumenterConfig: {
35+
embedSource: true
36+
}
37+
}
38+
]
39+
]
40+
},
41+
42+
coverageReporter: {
43+
reporters: [
44+
{ type: 'text' },
45+
{ type: 'html' },
46+
{ type: 'json' }
47+
]
48+
}
49+
});
50+
};

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+
};

0 commit comments

Comments
 (0)