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

Update from $window.analytics to $window.ga #1397

Open
wants to merge 7 commits into
base: master
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
10 changes: 6 additions & 4 deletions src/mocks/googleAnalytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
*/
ngCordovaMocks.factory('$cordovaGoogleAnalytics', ['$q', function ($q) {
var throwsError = false;
var methods = {};
var methods = {
ga: {}
};

/**
* @ngdoc property
Expand All @@ -19,7 +21,7 @@ ngCordovaMocks.factory('$cordovaGoogleAnalytics', ['$q', function ($q) {
* A flag that signals whether a promise should be rejected or not.
* This property should only be used in automated tests.
**/
methods.throwsError = throwsError;
methods.ga.throwsError = throwsError;

var methodsName = [
'startTrackerWithId',
Expand All @@ -35,7 +37,7 @@ ngCordovaMocks.factory('$cordovaGoogleAnalytics', ['$q', function ($q) {
];

methodsName.forEach(function (funcName) {
methods[funcName] = function () {
methods.ga[funcName] = function () {
var defer = $q.defer();

(this.throwsError) ?
Expand All @@ -46,5 +48,5 @@ ngCordovaMocks.factory('$cordovaGoogleAnalytics', ['$q', function ($q) {
};
});

return methods;
return methods.ga;
}]);
28 changes: 14 additions & 14 deletions src/plugins/3dtouch.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

angular.module('ngCordova.plugins.3dtouch', [])

.factory('$cordova3DTouch', ['$q', function($q) {
.factory('$cordova3DTouch', ['$q', function ($q) {
var quickActions = [];
var quickActionHandler = {};

var createQuickActionHandler = function(quickActionHandler) {
var createQuickActionHandler = function (quickActionHandler) {
return function (payload) {
for (var key in quickActionHandler) {
if (payload.type === key) {
Expand Down Expand Up @@ -52,7 +52,7 @@ angular.module('ngCordova.plugins.3dtouch', [])
* @param function callback (optional)
* @return promise
*/
addQuickAction: function(type, title, iconType, iconTemplate, subtitle, callback) {
addQuickAction: function (type, title, iconType, iconTemplate, subtitle, callback) {
var deferred = $q.defer();

var quickAction = {
Expand All @@ -69,14 +69,14 @@ angular.module('ngCordova.plugins.3dtouch', [])
quickAction.iconTemplate = iconTemplate;
}

this.isAvailable().then(function() {
this.isAvailable().then(function () {
quickActions.push(quickAction);
quickActionHandler[type] = callback;
window.ThreeDeeTouch.configureQuickActions(quickActions);
window.ThreeDeeTouch.onHomeIconPressed = createQuickActionHandler(quickActionHandler);
deferred.resolve(quickActions);
},
function(err) {
function (err) {
deferred.reject(err);
});

Expand All @@ -90,15 +90,15 @@ angular.module('ngCordova.plugins.3dtouch', [])
* @param function callback
* @return promise
*/
addQuickActionHandler: function(type, callback) {
addQuickActionHandler: function (type, callback) {
var deferred = $q.defer();

this.isAvailable().then(function() {
this.isAvailable().then(function () {
quickActionHandler[type] = callback;
window.ThreeDeeTouch.onHomeIconPressed = createQuickActionHandler(quickActionHandler);
deferred.resolve(true);
},
function(err) {
function (err) {
deferred.reject(err);
});

Expand All @@ -110,14 +110,14 @@ angular.module('ngCordova.plugins.3dtouch', [])
*
* @return bool
*/
enableLinkPreview: function() {
enableLinkPreview: function () {
var deferred = $q.defer();

this.isAvailable().then(function() {
this.isAvailable().then(function () {
window.ThreeDeeTouch.enableLinkPreview();
deferred.resolve(true);
},
function(err) {
function (err) {
deferred.reject(err);
});

Expand All @@ -130,14 +130,14 @@ angular.module('ngCordova.plugins.3dtouch', [])
* @param function callback
* @return promise
*/
addForceTouchHandler: function(callback) {
addForceTouchHandler: function (callback) {
var deferred = $q.defer();

this.isAvailable().then(function() {
this.isAvailable().then(function () {
window.ThreeDeeTouch.watchForceTouches(callback);
deferred.resolve(true);
},
function(err) {
function (err) {
deferred.reject(err);
});

Expand Down
20 changes: 10 additions & 10 deletions src/plugins/googleAnalytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ angular.module('ngCordova.plugins.googleAnalytics', [])
startTrackerWithId: function (id) {
var d = $q.defer();

$window.analytics.startTrackerWithId(id, function (response) {
$window.ga.analytics.startTrackerWithId(id, function (response) {
d.resolve(response);
}, function (error) {
d.reject(error);
Expand All @@ -21,7 +21,7 @@ angular.module('ngCordova.plugins.googleAnalytics', [])
setUserId: function (id) {
var d = $q.defer();

$window.analytics.setUserId(id, function (response) {
$window.ga.analytics.setUserId(id, function (response) {
d.resolve(response);
}, function (error) {
d.reject(error);
Expand All @@ -33,7 +33,7 @@ angular.module('ngCordova.plugins.googleAnalytics', [])
debugMode: function () {
var d = $q.defer();

$window.analytics.debugMode(function (response) {
$window.ga.analytics.debugMode(function (response) {
d.resolve(response);
}, function () {
d.reject();
Expand All @@ -45,7 +45,7 @@ angular.module('ngCordova.plugins.googleAnalytics', [])
trackView: function (screenName) {
var d = $q.defer();

$window.analytics.trackView(screenName, function (response) {
$window.ga.analytics.trackView(screenName, function (response) {
d.resolve(response);
}, function (error) {
d.reject(error);
Expand All @@ -62,7 +62,7 @@ angular.module('ngCordova.plugins.googleAnalytics', [])
d.reject('Parameter "key" must be an integer.');
}

$window.analytics.addCustomDimension(parsedKey, value, function () {
$window.ga.analytics.addCustomDimension(parsedKey, value, function () {
d.resolve();
}, function (error) {
d.reject(error);
Expand All @@ -74,7 +74,7 @@ angular.module('ngCordova.plugins.googleAnalytics', [])
trackEvent: function (category, action, label, value) {
var d = $q.defer();

$window.analytics.trackEvent(category, action, label, value, function (response) {
$window.ga.analytics.trackEvent(category, action, label, value, function (response) {
d.resolve(response);
}, function (error) {
d.reject(error);
Expand All @@ -86,7 +86,7 @@ angular.module('ngCordova.plugins.googleAnalytics', [])
trackException: function (description, fatal) {
var d = $q.defer();

$window.analytics.trackException(description, fatal, function (response) {
$window.ga.analytics.trackException(description, fatal, function (response) {
d.resolve(response);
}, function (error) {
d.reject(error);
Expand All @@ -98,7 +98,7 @@ angular.module('ngCordova.plugins.googleAnalytics', [])
trackTiming: function (category, milliseconds, variable, label) {
var d = $q.defer();

$window.analytics.trackTiming(category, milliseconds, variable, label, function (response) {
$window.ga.analytics.trackTiming(category, milliseconds, variable, label, function (response) {
d.resolve(response);
}, function (error) {
d.reject(error);
Expand All @@ -110,7 +110,7 @@ angular.module('ngCordova.plugins.googleAnalytics', [])
addTransaction: function (transactionId, affiliation, revenue, tax, shipping, currencyCode) {
var d = $q.defer();

$window.analytics.addTransaction(transactionId, affiliation, revenue, tax, shipping, currencyCode, function (response) {
$window.ga.analytics.addTransaction(transactionId, affiliation, revenue, tax, shipping, currencyCode, function (response) {
d.resolve(response);
}, function (error) {
d.reject(error);
Expand All @@ -122,7 +122,7 @@ angular.module('ngCordova.plugins.googleAnalytics', [])
addTransactionItem: function (transactionId, name, sku, category, price, quantity, currencyCode) {
var d = $q.defer();

$window.analytics.addTransactionItem(transactionId, name, sku, category, price, quantity, currencyCode, function (response) {
$window.ga.analytics.addTransactionItem(transactionId, name, sku, category, price, quantity, currencyCode, function (response) {
d.resolve(response);
}, function (error) {
d.reject(error);
Expand Down
12 changes: 6 additions & 6 deletions src/plugins/serial.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ angular.module('ngCordova.plugins.serial', [])
return q.promise;
};

serialService.open = function(options) {
serialService.open = function (options) {
var q = $q.defer();

serial.open(options, function success() {
Expand All @@ -32,7 +32,7 @@ angular.module('ngCordova.plugins.serial', [])
return q.promise;
};

serialService.write = function(data) {
serialService.write = function (data) {
var q = $q.defer();

serial.write(data, function success() {
Expand All @@ -44,7 +44,7 @@ angular.module('ngCordova.plugins.serial', [])
return q.promise;
};

serialService.writeHex = function(data) {
serialService.writeHex = function (data) {
var q = $q.defer();

serial.writeHex(data, function success() {
Expand All @@ -56,7 +56,7 @@ angular.module('ngCordova.plugins.serial', [])
return q.promise;
};

serialService.read = function() {
serialService.read = function () {
var q = $q.defer();

serial.read(function success(buffer) {
Expand All @@ -69,14 +69,14 @@ angular.module('ngCordova.plugins.serial', [])
return q.promise;
};

serialService.registerReadCallback = function(successCallback, errorCallback) {
serialService.registerReadCallback = function (successCallback, errorCallback) {
serial.registerReadCallback(function success(buffer) {
var view = new Uint8Array(buffer);
successCallback(view);
}, errorCallback);
};

serialService.close = function() {
serialService.close = function () {
var q = $q.defer();

serial.close(function success() {
Expand Down
2 changes: 1 addition & 1 deletion test/mocks/toast.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('ngCordovaMocks', function () {
$rootScope = _$rootScope_;
}));

it('should show a toast', function () {
it('should show a toast', function (done) {

functionNames.forEach(function(functionName){
$cordovaToast[functionName](message)
Expand Down
Loading