Skip to content
This repository has been archived by the owner on Sep 15, 2021. It is now read-only.

Google Analytics: API Update #1393

Open
wants to merge 1 commit into
base: dev-next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/plugins/googleAnalytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ angular.module('ngCordova.plugins.googleAnalytics', [])
.factory('$cordovaGoogleAnalytics', ['$q', '$window', function ($q, $window) {

return {
startTrackerWithId: function (id) {
startTrackerWithId: function (id, dispatchPeriod) {
var d = $q.defer();

$window.ga.startTrackerWithId(id, function (response) {
$window.ga.startTrackerWithId(id, dispatchPeriod, function (response) {
d.resolve(response);
}, function (error) {
d.reject(error);
Expand Down Expand Up @@ -54,10 +54,10 @@ angular.module('ngCordova.plugins.googleAnalytics', [])
return d.promise;
},

trackView: function (screenName) {
trackView: function (screenName, campaingUrl, newSession) {
var d = $q.defer();

$window.ga.trackView(screenName, function (response) {
$window.ga.trackView(screenName, campaingUrl, newSession, function (response) {
d.resolve(response);
}, function (error) {
d.reject(error);
Expand All @@ -83,10 +83,10 @@ angular.module('ngCordova.plugins.googleAnalytics', [])
return d.promise;
},

trackEvent: function (category, action, label, value) {
trackEvent: function (category, action, label, value, newSession) {
var d = $q.defer();

$window.ga.trackEvent(category, action, label, value, function (response) {
$window.ga.trackEvent(category, action, label, value, newSession, function (response) {
d.resolve(response);
}, function (error) {
d.reject(error);
Expand Down
16 changes: 8 additions & 8 deletions test/plugins/googleAnalytics.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('Service: $cordovaGoogleAnalytics', function() {
var result;

spyOn($window.ga, 'startTrackerWithId')
.and.callFake(function (id, successCb, errorCb) {
.and.callFake(function (id, dispatchPeriod, successCb, errorCb) {
successCb('tracker started');
});

Expand All @@ -54,7 +54,7 @@ describe('Service: $cordovaGoogleAnalytics', function() {
var result;

spyOn($window.ga, 'startTrackerWithId')
.and.callFake(function (id, successCb, errorCb) {
.and.callFake(function (id, dispatchPeriod, successCb, errorCb) {
errorCb('tracker id is not valid');
});

Expand Down Expand Up @@ -196,7 +196,7 @@ describe('Service: $cordovaGoogleAnalytics', function() {
var result;

spyOn($window.ga, 'trackView')
.and.callFake(function (screenName, successCb, errorCb) {
.and.callFake(function (screenName, campaingUrl, newSession, successCb, errorCb) {
successCb('Track Screen: ' + screenName);
});

Expand All @@ -217,7 +217,7 @@ describe('Service: $cordovaGoogleAnalytics', function() {
var result;

spyOn($window.ga, 'trackView')
.and.callFake(function (screenName, successCb, errorCb) {
.and.callFake(function (screenName, campaingUrl, newSession, successCb, errorCb) {
errorCb('Expected one non-empty string argument');
});

Expand Down Expand Up @@ -277,12 +277,12 @@ describe('Service: $cordovaGoogleAnalytics', function() {
var result;

spyOn($window.ga, 'trackEvent')
.and.callFake(function (category, action, label, value, successCb, errorCb) {
.and.callFake(function (category, action, label, value, newSession, successCb, errorCb) {
successCb('Track Event: ' + category);
});

$cordovaGoogleAnalytics
.trackEvent('Videos', 'Video Load Time', 'Gone With the Wind', 100)
.trackEvent('Videos', 'Video Load Time', 'Gone With the Wind', 100, false)
.then(function (response) {
result = response;
});
Expand All @@ -291,7 +291,7 @@ describe('Service: $cordovaGoogleAnalytics', function() {

expect(result).toBe('Track Event: Videos');
expect($window.ga.trackEvent).toHaveBeenCalledWith(
'Videos', 'Video Load Time', 'Gone With the Wind', 100,
'Videos', 'Video Load Time', 'Gone With the Wind', 100, false,
jasmine.any(Function),
jasmine.any(Function)
);
Expand All @@ -302,7 +302,7 @@ describe('Service: $cordovaGoogleAnalytics', function() {
var result;

spyOn($window.ga, 'trackEvent')
.and.callFake(function (category, action, label, value, successCb, errorCb) {
.and.callFake(function (category, action, label, value, newSession, successCb, errorCb) {
errorCb('Tracker not started');
});

Expand Down