feat(analytics): Facebook "Pixel" (#7871)
This commit is contained in:
@@ -26,22 +26,14 @@ describe('Analytics Service', function () {
|
||||
describe('register', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
sandbox.stub(amplitude, 'setUserId');
|
||||
sandbox.stub(window, 'ga');
|
||||
sandbox.stub(window, 'fbq');
|
||||
});
|
||||
|
||||
it('sets up user with Amplitude', function() {
|
||||
it('records a registration event on Facebook', function() {
|
||||
analytics.register();
|
||||
clock.tick();
|
||||
expect(amplitude.setUserId).to.have.been.calledOnce;
|
||||
expect(amplitude.setUserId).to.have.been.calledWith(user._id);
|
||||
});
|
||||
|
||||
it('sets up user with Google Analytics', function() {
|
||||
analytics.register();
|
||||
clock.tick();
|
||||
expect(ga).to.have.been.calledOnce;
|
||||
expect(ga).to.have.been.calledWith('set', {userId: user._id});
|
||||
expect(fbq).to.have.been.calledOnce;
|
||||
expect(fbq).to.have.been.calledWith('track', 'CompleteRegistration');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -74,6 +66,7 @@ describe('Analytics Service', function () {
|
||||
beforeEach(function() {
|
||||
sandbox.stub(amplitude, 'logEvent');
|
||||
sandbox.stub(window, 'ga');
|
||||
sandbox.stub(window, 'fbq');
|
||||
});
|
||||
|
||||
context('successful tracking', function() {
|
||||
@@ -113,6 +106,15 @@ describe('Analytics Service', function () {
|
||||
expect(ga).to.have.been.calledOnce;
|
||||
expect(ga).to.have.been.calledWith('send', properties);
|
||||
});
|
||||
|
||||
it('tracks a page view with Facebook', function() {
|
||||
var properties = {'hitType':'pageview','eventCategory':'behavior','eventAction':'tasks'};
|
||||
analytics.track(properties);
|
||||
clock.tick();
|
||||
|
||||
expect(fbq).to.have.been.calledOnce;
|
||||
expect(fbq).to.have.been.calledWith('track', 'PageView');
|
||||
});
|
||||
});
|
||||
|
||||
context('unsuccessful tracking', function() {
|
||||
|
||||
Reference in New Issue
Block a user