diff --git a/addon/metrics-adapters/mixpanel.js b/addon/metrics-adapters/mixpanel.js index 0926d0e6..7f6cbb06 100644 --- a/addon/metrics-adapters/mixpanel.js +++ b/addon/metrics-adapters/mixpanel.js @@ -62,7 +62,10 @@ export default BaseAdapter.extend({ }, trackPage(options = {}) { - const event = { event: 'page viewed' }; + const config = get(this, 'config'); + let { trackPageEventName } = config; + trackPageEventName = trackPageEventName || 'page viewed'; + const event = { event: trackPageEventName }; const mergedOptions = assign(event, options); this.trackEvent(mergedOptions); diff --git a/tests/unit/metrics-adapters/mixpanel-test.js b/tests/unit/metrics-adapters/mixpanel-test.js index 78502b32..34d4431b 100644 --- a/tests/unit/metrics-adapters/mixpanel-test.js +++ b/tests/unit/metrics-adapters/mixpanel-test.js @@ -70,6 +70,25 @@ test('#trackPage calls `mixpanel.track` with the right arguments', function(asse assert.ok(stub.secondCall.calledWith('Page View', { page: '/products/1' }), 'it sends the correct arguments and options'); }); +test('#trackPageEventName - test this property is ', function(assert) { + const baseConfig = { config }; + const modifiedConfig = Object.assign({}, baseConfig); + modifiedConfig.config.trackPageEventName ='Yee Haw'; + const adapter = this.subject(modifiedConfig); + const stub = sandbox.stub(window.mixpanel, 'track').callsFake(() => { + return true; + }); + adapter.trackPage({ + page: '/products/1' + }); + adapter.trackPage({ + event: 'Page View', + page: '/products/1' + }); + assert.ok(stub.firstCall.calledWith('Yee Haw', { page: '/products/1' }), 'it sends the correct arguments and options'); + assert.ok(stub.secondCall.calledWith('Page View', { page: '/products/1' }), 'it sends the correct arguments and options'); +}); + test('#alias calls `mixpanel.alias` with the right arguments', function(assert) { const adapter = this.subject({ config }); const stub = sandbox.stub(window.mixpanel, 'alias').callsFake(() => {