Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Adopt windsor node #80

Merged
merged 2 commits into from
Sep 3, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ REDIS_URL=
SENTRY_DSN=

SEGMENT_WRITE_KEY=
WINDSOR_KEY=
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"ms": "^2.1.1",
"probot": "^9.2.19",
"rexrex": "^1.3.0",
"smee-client": "^1.0.1"
"smee-client": "^1.0.1",
"windsor-node": "^0.0.3"
},
"devDependencies": {
"eslint": "^6.3.0",
Expand Down
8 changes: 4 additions & 4 deletions src/analytics.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const Analytics = require('analytics-node')
const Windsor = require('windsor-node')

if (process.env.NODE_ENV === 'test' || process.env.NODE_ENV === 'production') {
let analytics = new Analytics(process.env.SEGMENT_WRITE_KEY)
let analytics = new Windsor(process.env.WINDSOR_KEY)
module.exports = {
identify: analytics.identify.bind(analytics),
identify: analytics.user.bind(analytics),
track: x => {
try {
return analytics.track.call(analytics, typeof x === 'function' ? x() : x)
return analytics.event.call(analytics, typeof x === 'function' ? x() : x)
} catch (error) {
console.error(error)
}
Expand Down
8 changes: 5 additions & 3 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,14 @@ jest.mock(
)

jest.mock(
'analytics-node',
'windsor-node',
() =>
class {
constructor() {
this.track = jest.fn()
this.identify = jest.fn()
// this.track = jest.fn()
// this.identify = jest.fn()
this.user = jest.fn()
this.event = jest.fn()
}
}
)
Expand Down
39 changes: 36 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -911,13 +911,28 @@ aws4@^1.8.0:
resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.8.0.tgz#f0e003d9ca9e7f59c7a508945d7b2ef9a04a542f"
integrity sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==

axios-retry@3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/axios-retry/-/axios-retry-3.0.2.tgz#d644db74184858e4a5cf10f5ea88dd657bb4ba61"
integrity sha512-cX5sYst14esQAWIkyK5jrwHuS/XKLfgY7s2G9QktCPoAWEi00smMFtByIidfJVAgp0gFD41e7nxiAxIqW8ZO8A==
dependencies:
is-retry-allowed "^1.1.0"

axios-retry@^3.0.2:
version "3.1.2"
resolved "https://registry.yarnpkg.com/axios-retry/-/axios-retry-3.1.2.tgz#4f4dcbefb0b434e22b72bd5e28a027d77b8a3458"
integrity sha512-+X0mtJ3S0mmia1kTVi1eA3DAC+oWnT2A29g3CpkzcBPMT6vJm+hn/WiV9wPt/KXLHVmg5zev9mWqkPx7bHMovg==
dependencies:
is-retry-allowed "^1.1.0"

axios@0.19.0:
version "0.19.0"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.19.0.tgz#8e09bff3d9122e133f7b8101c8fbdd00ed3d2ab8"
integrity sha512-1uvKqKQta3KBxIz14F2v06AEHZ/dIoeKfbTRkK1E5oqjDnuEerLmYTgJB5AiQZHJcljpg1TuRzdjDR06qNk0DQ==
dependencies:
follow-redirects "1.5.10"
is-buffer "^2.0.2"

axios@^0.18.1:
version "0.18.1"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.18.1.tgz#ff3f0de2e7b5d180e757ad98000f1081b87bcea3"
Expand Down Expand Up @@ -4065,7 +4080,7 @@ lodash.isplainobject@^4.0.6:
resolved "https://registry.yarnpkg.com/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz#7c526a52d89b45c45cc690b88163be0497f550cb"
integrity sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs=

lodash.isstring@^4.0.1:
lodash.isstring@4.0.1, lodash.isstring@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/lodash.isstring/-/lodash.isstring-4.0.1.tgz#d527dfb5456eca7cc9bb95d5daeaf88ba54a5451"
integrity sha1-1SfftUVuynzJu5XV2ur4i6VKVFE=
Expand Down Expand Up @@ -4217,7 +4232,7 @@ map-visit@^1.0.0:
dependencies:
object-visit "^1.0.0"

md5@^2.2.1:
md5@2.2.1, md5@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/md5/-/md5-2.2.1.tgz#53ab38d5fe3c8891ba465329ea23fac0540126f9"
integrity sha1-U6s41f48iJG6RlMp6iP6wFQBJvk=
Expand Down Expand Up @@ -5420,7 +5435,7 @@ remove-trailing-separator@^1.0.1:
resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef"
integrity sha1-wkvOKig62tW8P1jg1IJJuSN52O8=

remove-trailing-slash@^0.1.0:
remove-trailing-slash@0.1.0, remove-trailing-slash@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/remove-trailing-slash/-/remove-trailing-slash-0.1.0.tgz#1498e5df0984c27e49b76ebf06887ca2d01150d2"
integrity sha1-FJjl3wmEwn5Jt26/Boh8otARUNI=
Expand Down Expand Up @@ -6493,6 +6508,11 @@ utils-merge@1.0.1:
resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713"
integrity sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=

uuid@3.2.1:
version "3.2.1"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.2.1.tgz#12c528bb9d58d0b9265d9a2f6f0fe8be17ff1f14"
integrity sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==

uuid@3.3.2, uuid@^3.0.0, uuid@^3.2.1, uuid@^3.3.2:
version "3.3.2"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.2.tgz#1b4af4955eb3077c501c23872fc6513811587131"
Expand Down Expand Up @@ -6632,6 +6652,19 @@ windows-release@^3.1.0:
dependencies:
execa "^1.0.0"

windsor-node@^0.0.3:
version "0.0.3"
resolved "https://registry.yarnpkg.com/windsor-node/-/windsor-node-0.0.3.tgz#abded3cc8343df0eb0891cd5502a62f544a0799e"
integrity sha512-DCyGU3PxWFTqulAwBZp3fLTKvoV/AAVUASku02cgnHdsCF30Tkin8K7kR+MAUrjmdP/JLhskzkNzJgmJPrrqbA==
dependencies:
axios "0.19.0"
axios-retry "3.0.2"
lodash.isstring "4.0.1"
md5 "2.2.1"
ms "2.0.0"
remove-trailing-slash "0.1.0"
uuid "3.2.1"

wordwrap@~0.0.2:
version "0.0.3"
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107"
Expand Down