Skip to content

Commit 3951ff8

Browse files
authored
Analytics-Next: Add missing third party libraries (#549)
* Add walkme * Add survicate * Add smartlook * Add owneriq * Add drift * Add convertflow * Add auryc * Add asayer * Install packages in Saucelabs test * Remove unused estlint config * Fix drift tests * Fix path * Add saucelabs contextl
1 parent faa00b2 commit 3951ff8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+5414
-87
lines changed

.buildkite/pipeline.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
env:
2-
SEGMENT_CONTEXTS: 'snyk,npm,aws-credentials,ecr'
2+
SEGMENT_CONTEXTS: 'snyk,npm,aws-credentials,ecr,saucelabs,npm-publish'
33
SEGMENT_BUILDKITE_IMAGE: 'analytics-next-ci-agent'
44

55
steps:
@@ -26,6 +26,8 @@ steps:
2626
- label: 'SauceLabs'
2727
soft_fail: true
2828
command:
29+
- npm config set "//registry.npmjs.org/:_authToken" $${NPM_TOKEN}
30+
- yarn install --ignore-engines
2931
- yarn test:ci
3032
plugins:
3133
- ssh://git@github.com/segmentio/cache-buildkite-plugin#v1.0.0:

integrations/asayer/HISTORY.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2.0.0 / 2020-05-13
2+
==================
3+
4+
* New Asayer app
5+
6+
1.1.0 / 2019-06-30
7+
==================
8+
9+
* Support custom variables
10+
11+
1.0.2 / 2019-06-27
12+
==================
13+
14+
* Renamings for Segment API
15+
16+
1.0.1 / 2019-06-17
17+
==================
18+
19+
* New methods for Asayer API
20+
21+
1.0.0 / 2019-06-17
22+
==================
23+
24+
* Initial commit :sparkles:

integrations/asayer/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# analytics.js-integration-asayer [![Build Status][ci-badge]][ci-link]
2+
3+
Asayer 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://circleci.com/gh/asayerio/analytics.js-integration-asayer
12+
[ci-badge]: https://circleci.com/gh/asayerio/analytics.js-integration-asayer.svg?style=svg
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('../../karma.conf-ci.js');

integrations/asayer/karma.conf.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('../../karma.conf');

integrations/asayer/lib/index.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
'use strict'
2+
3+
var integration = require('@segment/analytics.js-integration')
4+
5+
var Asayer = module.exports = integration('asayer')
6+
.global('asayer')
7+
.option('projectId', null)
8+
.option('siteId', null) // Retain siteId for backwards compatibility.
9+
.option('obscureTextNumbers', false)
10+
.option('obscureTextEmails', false)
11+
.tag('<script src="https://static.asayer.io/tracker.js"></script>')
12+
13+
function positiveNumber (number) {
14+
number = Number(number)
15+
if (number === null || isNaN(number) || number === Infinity || number <= 0) {
16+
return
17+
}
18+
return number
19+
}
20+
21+
Asayer.prototype.initialize = function () {
22+
var projectId = positiveNumber(this.options.projectId)
23+
if (!projectId) {
24+
// Fall back to siteId.
25+
projectId = positiveNumber(this.options.siteId)
26+
}
27+
if (!projectId) {
28+
console.warn('Asayer: wrong projectId option, not loading.')
29+
return
30+
}
31+
32+
var r = window.asayer = [projectId, undefined, 28 | (+this.options.obscureTextEmails) | (+this.options.obscureTextNumbers << 1), [0]]
33+
r.start = function (v) { r.push([0]) }
34+
r.stop = function (v) { r.push([1]) }
35+
r.userID = function (id) { r.push([2, id]) }
36+
r.userAnonymousID = function (id) { r.push([3, id]) }
37+
r.metadata = function (k, v) { r.push([4, k, v]) }
38+
r.event = function (k, p) { r.push([5, k, p]) }
39+
r.active = function () { return false }
40+
r.sessionID = function () { }
41+
42+
this.load(this.ready)
43+
}
44+
45+
Asayer.prototype.identify = function (identify) {
46+
window.asayer.userAnonymousID(String(identify.anonymousId()))
47+
if (identify.userId()) {
48+
window.asayer.userID(String(identify.userId()))
49+
}
50+
var traits = identify.traits()
51+
for (var key in traits) {
52+
if (traits.hasOwnProperty(key)) {
53+
var value = traits[key]
54+
if (typeof value !== 'object' && value !== undefined) {
55+
window.asayer.metadata(key, value.toString())
56+
}
57+
}
58+
}
59+
}
60+
61+
Asayer.prototype.track = function (track) {
62+
window.asayer.event(track.event(), track.properties())
63+
}

integrations/asayer/package.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"name": "@asayerio/analytics.js-integration-asayer",
3+
"description": "The Asayer analytics.js integration.",
4+
"version": "2.0.1",
5+
"keywords": [
6+
"analytics.js",
7+
"analytics.js-integration",
8+
"segment",
9+
"asayer"
10+
],
11+
"main": "lib/index.js",
12+
"scripts": {
13+
"test": "karma start",
14+
"test:ci": "karma start karma.conf-ci.js"
15+
},
16+
"repository": {
17+
"type": "git",
18+
"url": "git+https://github.com/asayerio/analytics.js-integration-asayer.git"
19+
},
20+
"author": "Alex Tsokurov",
21+
"license": "SEE LICENSE IN LICENSE",
22+
"bugs": {
23+
"url": "https://github.com/asayerio/analytics.js-integration-asayer/issues"
24+
},
25+
"homepage": "https://github.com/asayerio/analytics.js-integration-asayer#readme",
26+
"dependencies": {
27+
"@segment/analytics.js-integration": "^3.2.0",
28+
"extend": "^3.0.2"
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+
"browserify": "^16.2.3",
35+
"eslint": "^5.16.0",
36+
"karma": "^4.1.0",
37+
"karma-browserify": "^6.0.0",
38+
"karma-chrome-launcher": "^2.2.0",
39+
"karma-mocha": "^1.3.0",
40+
"karma-mocha-reporter": "^2.2.5",
41+
"karma-sauce-launcher": "^2.0.2",
42+
"karma-spec-reporter": "^0.0.32",
43+
"karma-summary-reporter": "^1.6.0",
44+
"mocha": "^6.1.4",
45+
"watchify": "^3.11.1"
46+
},
47+
"standard": {
48+
"env": [
49+
"mocha"
50+
]
51+
}
52+
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
'use strict'
2+
3+
var Analytics = require('@segment/analytics.js-core').constructor
4+
var sandbox = require('@segment/clear-env')
5+
var tester = require('@segment/analytics.js-integration-tester')
6+
var Asayer = require('../lib/')
7+
8+
describe('asayer', function () {
9+
var analytics
10+
var asayer
11+
12+
beforeEach(function () {
13+
analytics = new Analytics()
14+
analytics.use(tester)
15+
})
16+
17+
afterEach(function () {
18+
analytics.restore()
19+
analytics.reset()
20+
asayer.reset()
21+
sandbox()
22+
})
23+
24+
describe('before loading', function () {
25+
it('should call #load', function () {
26+
asayer = new Asayer({ 'projectId': '1234' })
27+
analytics.use(Asayer)
28+
analytics.add(asayer)
29+
analytics.stub(asayer, 'load')
30+
analytics.initialize()
31+
analytics.called(asayer.load)
32+
})
33+
34+
it('should not call #load for wrong projectId', function () {
35+
asayer = new Asayer({ 'projectId': 'wrong' })
36+
analytics.use(Asayer)
37+
analytics.add(asayer)
38+
analytics.stub(asayer, 'load')
39+
analytics.initialize()
40+
analytics.didNotCall(asayer.load)
41+
})
42+
})
43+
44+
describe('after loading', function () {
45+
beforeEach(function (done) {
46+
asayer = new Asayer({ 'projectId': '1234' })
47+
analytics.use(Asayer)
48+
analytics.add(asayer)
49+
analytics.once('ready', done)
50+
analytics.initialize()
51+
})
52+
53+
describe('#identify', function () {
54+
it('should send anonymousId', function () {
55+
analytics.stub(window.asayer, 'userAnonymousID')
56+
analytics.identify()
57+
analytics.called(window.asayer.userAnonymousID)
58+
var id = window.asayer.userAnonymousID.args[0][0]
59+
analytics.assert(id && typeof id === 'string')
60+
})
61+
62+
it('should send userId', function () {
63+
analytics.stub(window.asayer, 'userID')
64+
analytics.identify('1')
65+
analytics.called(window.asayer.userID, '1')
66+
})
67+
68+
it('should send only safe traits', function () {
69+
analytics.stub(window.asayer, 'metadata')
70+
analytics.identify('1', { 'email': 'hello@asayer.io', title: { hide: 'me' }, admin: true })
71+
var traits = {}
72+
window.asayer.metadata.args.forEach(function (entry) {
73+
traits[entry[0]] = entry[1]
74+
})
75+
analytics.assert(traits.email === 'hello@asayer.io' && !traits.title && traits.admin === 'true')
76+
})
77+
})
78+
79+
describe('#track', function () {
80+
beforeEach(function () {
81+
analytics.stub(window.asayer, 'event')
82+
})
83+
84+
it('should send event properties', function () {
85+
analytics.track('segment', { test: 'success' })
86+
analytics.called(window.asayer.event, 'segment', { test: 'success' })
87+
})
88+
})
89+
})
90+
})

integrations/auryc/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Auryc Inc.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

integrations/auryc/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# analytics.js-integration-auryc
2+
3+
Auryc integration for [Analytics.js][].
4+
5+
### Tests
6+
make test
7+
8+
[Analytics.js]: https://segment.com/docs/libraries/analytics.js/

0 commit comments

Comments
 (0)