Skip to content

Commit

Permalink
feat(analytics-core): added dma logging service
Browse files Browse the repository at this point in the history
  • Loading branch information
availity-bot committed Apr 1, 2019
1 parent 478d42a commit 18ee923
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
17 changes: 17 additions & 0 deletions packages/analytics-core/src/dma.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import AvAnalyticsPlugin from './plugin';

export default class AvDmaAnalytics extends AvAnalyticsPlugin {
constructor(AvLogMessages, enabled) {
super(enabled);
this.AvLogMessages = AvLogMessages;
}

trackEvent(properties) {
properties.level = properties.level || 'info';
return this.AvLogMessages.send(properties);
}

trackPageView(url) {
return this.trackEvent({ event: 'page', url });
}
}
3 changes: 2 additions & 1 deletion packages/analytics-core/src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import AvAnalytics from './analytics';
import AvAnalyticsPlugin from './plugin';
import AvSplunkAnalytics from './splunk';
import AvDmaAnalytics from './dma';

export { AvAnalytics, AvAnalyticsPlugin, AvSplunkAnalytics };
export { AvAnalytics, AvAnalyticsPlugin, AvSplunkAnalytics, AvDmaAnalytics };
24 changes: 24 additions & 0 deletions packages/analytics-core/src/tests/dma.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { AvDmaAnalytics } from '..';

describe('AvSplunkAnalytics', () => {
let mockLog;
let mockAvSplunkAnalytics;

beforeEach(() => {
mockLog = {
send: jest.fn(),
};

mockAvSplunkAnalytics = new AvDmaAnalytics(mockLog);
});

test('AvSplunkAnalytics should be defined', () => {
expect(mockAvSplunkAnalytics).toBeDefined();
});

test('trackEvent should call AvLogMessages.send', () => {
const level = 'info';
mockAvSplunkAnalytics.trackEvent({ level });
expect(mockLog.send).toHaveBeenCalledTimes(1);
});
});

0 comments on commit 18ee923

Please sign in to comment.