Skip to content

Commit

Permalink
Merge branch 'release/0.3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
poteto committed Sep 23, 2015
2 parents 30f3704 + 5df2993 commit 77418bd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
4 changes: 3 additions & 1 deletion addon/services/metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const {
get,
set,
merge,
copy,
A: emberArray,
String: { dasherize }
} = Ember;
Expand Down Expand Up @@ -102,7 +103,8 @@ export default Service.extend({
const cachedAdapters = get(this, '_adapters');
const allAdapterNames = keys(cachedAdapters);
const [selectedAdapterNames, options] = args.length > 1 ? [[args[0]], args[1]] : [allAdapterNames, args[0]];
const mergedOptions = merge(get(this, 'context'), options);
const context = copy(get(this, 'context'));
const mergedOptions = merge(context, options);

selectedAdapterNames
.map((adapterName) => get(cachedAdapters, adapterName))
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ember-metrics",
"version": "0.3.0",
"version": "0.3.1",
"description": "Send data to multiple analytics integrations without re-implementing new API",
"directories": {
"doc": "doc",
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/services/metrics-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,17 @@ test('#invoke includes `context` properties', function(assert){
assert.ok(GoogleAnalyticsSpy.calledWith({ userName: 'Jimbo', page: 'page/1', title: 'page one' }), 'it includes context properties');
});

test('#invoke does not leak options between calls', function(assert){
const service = this.subject({ metricsAdapters });
const GoogleAnalyticsSpy = sandbox.spy(get(service, '_adapters.GoogleAnalytics'), 'trackPage');

set(service, 'context.userName', 'Jimbo');
service.invoke('trackPage', 'GoogleAnalytics', { page: 'page/1', title: 'page one', callOne: true });
service.invoke('trackPage', 'GoogleAnalytics', { page: 'page/1', title: 'page one', callTwo: true });

assert.ok(GoogleAnalyticsSpy.calledWith({ userName: 'Jimbo', page: 'page/1', title: 'page one', callTwo: true }), 'it does not include options from previous call');
});

test('it implements standard contracts', function(assert) {
const service = this.subject({ metricsAdapters });
sandbox.stub(window.mixpanel);
Expand Down

0 comments on commit 77418bd

Please sign in to comment.