Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

feat(avatars): add metrics for avatar cropping operations #2591

Closed

Conversation

eoger
Copy link
Contributor

@eoger eoger commented Jun 12, 2015

Fixes #2533

@@ -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"
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

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

@eoger eoger force-pushed the issue-2533-metrics-avatar-cropping branch from 864c42d to f8d9ecd Compare June 12, 2015 23:08
@pdehaan
Copy link
Contributor

pdehaan commented Jun 12, 2015

app/tests/spec/lib/cropper.js
  line 87  col 31  'event' is defined but never used.
✖ 1 problem
Warning: Task "jshint:app" failed.� Use --force to continue.
Aborted due to warnings.


beforeEach(function () {
mockMetrics = {
logEvent: function (event) {
Copy link
Contributor

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.

@eoger eoger force-pushed the issue-2533-metrics-avatar-cropping branch from f8d9ecd to 699d210 Compare June 12, 2015 23:41
@eoger
Copy link
Contributor Author

eoger commented Jun 12, 2015

I'm gonna git hook commit "grunt lint", this is getting ridiculous.

@pdehaan
Copy link
Contributor

pdehaan commented Jun 12, 2015

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 prepush.

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');

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.

Copy link
Contributor

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.

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.

Copy link
Contributor

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. 👍

@eoger eoger force-pushed the issue-2533-metrics-avatar-cropping branch from 699d210 to 651a676 Compare June 16, 2015 22:34
@eoger
Copy link
Contributor Author

eoger commented Jun 16, 2015

Ready for another review 👍

@shane-tomlinson
Copy link

@eoger - rebase please!

@eoger eoger force-pushed the issue-2533-metrics-avatar-cropping branch from 651a676 to c929dab Compare June 17, 2015 14:32
@eoger
Copy link
Contributor Author

eoger commented Jun 17, 2015

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;
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good one thank you!

@eoger eoger force-pushed the issue-2533-metrics-avatar-cropping branch from c929dab to 1dc2a83 Compare June 17, 2015 18:21
@@ -102,6 +107,26 @@ function (p, Cocktail, FormView, SettingsMixin, AvatarMixin, Template,
self.navigate('settings');
return result;
});
},

onRotate: function () {
Copy link
Contributor

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 _.

@eoger eoger force-pushed the issue-2533-metrics-avatar-cropping branch from 1dc2a83 to 6c3d639 Compare June 18, 2015 21:40
@eoger
Copy link
Contributor Author

eoger commented Jun 18, 2015

PR corrected, ty zaach

@zaach
Copy link
Contributor

zaach commented Jun 18, 2015

Looks like it needs another rebase, then it should be good to go.

@eoger eoger force-pushed the issue-2533-metrics-avatar-cropping branch from 6c3d639 to 20afb6f Compare June 18, 2015 22:46
@eoger
Copy link
Contributor Author

eoger commented Jun 18, 2015

Yep "use strict" again, corrected!

},

_onRotate: function () {
this.logScreenEvent('rotate.cw');

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.

@shane-tomlinson
Copy link

@eoger - can you rebase & add the requested docs?

@eoger eoger force-pushed the issue-2533-metrics-avatar-cropping branch from 20afb6f to 55ccd71 Compare June 22, 2015 17:21
@eoger
Copy link
Contributor Author

eoger commented Jun 22, 2015

Done!

@vladikoff
Copy link
Contributor

@eoger sorry needs a rebase, there is a bower.json change that we need to alphabetize.

@eoger eoger force-pushed the issue-2533-metrics-avatar-cropping branch from 55ccd71 to 8902331 Compare June 29, 2015 17:44
@eoger
Copy link
Contributor Author

eoger commented Jun 29, 2015

Rebased and ready to merge.

* }
*/
function Cropper (options) {

/*jshint maxcomplexity:10 */

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.

@shane-tomlinson
Copy link

Removed the jshint line and manually merged in commit f0f917e.

Thanks @eoger!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants