-
Notifications
You must be signed in to change notification settings - Fork 120
feat(avatars): add metrics for avatar cropping operations #2591
Conversation
@@ -27,7 +27,8 @@ | |||
"JavaScript-MD5": "1.1.0", | |||
"jquery-ui-touch-punch": "https://github.com/zaach/jquery-ui-touch-punch.git#89e5a9159494de37df1e09cccf9036dda5429830", | |||
"blueimp-canvas-to-blob": "2.1.0", | |||
"mailcheck": "https://github.com/mailcheck/mailcheck.git#9fcf9c40da06f6769e5d702dd0fd1f33f36e55a6" | |||
"mailcheck": "https://github.com/mailcheck/mailcheck.git#9fcf9c40da06f6769e5d702dd0fd1f33f36e55a6", | |||
"jquery-simulate": "~1.0.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if you want to drop the semver range operator ~
here. For consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, I added the dependency with bower install --save this is why, I'll correct it right away
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EXCUSES!
Actually, I think that Bower (like npm) has a --save-exact
flag which drops that range operator.
bower/bower#1654
864c42d
to
f8d9ecd
Compare
|
||
beforeEach(function () { | ||
mockMetrics = { | ||
logEvent: function (event) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This unused event
here was causing the JSHint error/warning that broke the Travis build. Since it isn't doing anything here, we can probably just drop the event
parameter and the logEvent()
is just a noop.
f8d9ecd
to
699d210
Compare
I'm gonna git hook commit "grunt lint", this is getting ridiculous. |
But... then what will I do with all these GIFs? We could use something like https://www.npmjs.com/package/pre-commit or https://www.npmjs.com/package/husky and make it a devDep so everybody is forced into the precommit route. IIRC, we used husky (with grunt-newer so it'd only lint modified files instead of all files) in https://github.com/mozilla/chronicle/ and then just ran the custom lint task on I can't remember if @shane-tomlinson mentioned that he had a local precommit hook, or if @zaach or @vladikoff use one. UPDATE: Filed as #2592 so we can hug it out during the next triage meeting. |
@@ -71,22 +74,28 @@ function (_) { | |||
this.slider.on('input', function () { | |||
self.resize(parseInt(this.value, 10)); | |||
}); | |||
this.slider.on('change', function () { | |||
self.metrics.logEvent('avatar-cropper.zoom.range'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zaach - IIRC, you wanted to keep this particular module pretty "pure" so that it could be extracted into its own library. Adding metrics will destroy that purity since metrics are very specific to our app.
If we are going to integrate this more fully with the app, I think we should turn it into a Backbone based view and use all the functionality available to us to reduce boilerplate, if not, then let's try to move the metrics out of here somehow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good point. The view could pass in an event emitter (e.g. an object extended with Backbone event mixin) that listens for events and forwards them to our metrics. If the cropper receives such an object it'll trigger the events on that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good point. The view could pass in an event emitter (e.g. an object extended with Backbone event mixin) that listens for events and forwards them to our metrics. If the cropper receives such an object it'll trigger the events on that.
I can deal with that. Another options is to allow a consumer to pass in individual callbacks for rotate, zoom out and zoom in. The callbacks would log the events. Instead of requiring the mediator between DOM events and metrics be an EventEmitter, the mediator between the two would just be functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, the tried and true JavaScript callback. 👍
699d210
to
651a676
Compare
Ready for another review 👍 |
@eoger - rebase please! |
651a676
to
c929dab
Compare
Done 👍 |
this.onTranslate = options.onTranslate ? options.onTranslate : _.noop; | ||
this.onZoomIn = options.onZoomIn ? options.onZoomIn : _.noop; | ||
this.onZoomOut = options.onZoomOut ? options.onZoomOut : _.noop; | ||
this.onZoomRangeChange = options.onZoomRangeChange ? options.onZoomRangeChange : _.noop; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: you could use ||
instead of ternary operators here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good one thank you!
c929dab
to
1dc2a83
Compare
@@ -102,6 +107,26 @@ function (p, Cocktail, FormView, SettingsMixin, AvatarMixin, Template, | |||
self.navigate('settings'); | |||
return result; | |||
}); | |||
}, | |||
|
|||
onRotate: function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since these methods are only used internally they can begin with _
.
1dc2a83
to
6c3d639
Compare
PR corrected, ty zaach |
Looks like it needs another rebase, then it should be good to go. |
6c3d639
to
20afb6f
Compare
Yep "use strict" again, corrected! |
}, | ||
|
||
_onRotate: function () { | ||
this.logScreenEvent('rotate.cw'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These events need to be added to the docs.
@eoger - can you rebase & add the requested docs? |
20afb6f
to
55ccd71
Compare
Done! |
@eoger sorry needs a rebase, there is a |
55ccd71
to
8902331
Compare
Rebased and ready to merge. |
* } | ||
*/ | ||
function Cropper (options) { | ||
|
||
/*jshint maxcomplexity:10 */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jshint is gone. This line is no longer needed.
Fixes #2533