-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(analytics-core): added dma logging service
- Loading branch information
1 parent
478d42a
commit 18ee923
Showing
3 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |