Skip to content

Commit

Permalink
Catch ReferenceError when calq is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
rothlis committed Nov 20, 2015
1 parent 21a1448 commit 3496d2b
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dist/angulartics-calq.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/angulartics-calq.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 36 additions & 6 deletions lib/angulartics-calq.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,55 @@ angular.module('angulartics.calq', ['angulartics'])
.config(['$analyticsProvider', function ($analyticsProvider) {

$analyticsProvider.registerPageTrack(function (path) {
calq.action.trackPageView();
try {
calq.action.trackPageView();
} catch (e) {
if (!(e instanceof ReferenceError)) {
throw e;
}
}
});

$analyticsProvider.registerEventTrack(function (action, properties) {
calq.action.track(action, properties);
try {
calq.action.track(action, properties);
} catch (e) {
if (!(e instanceof ReferenceError)) {
throw e;
}
}
});

$analyticsProvider.registerSetSuperProperties(function (properties) {
for (var key in properties) {
calq.action.setGlobalProperty(key, properties[key]);
try {
for (var key in properties) {
calq.action.setGlobalProperty(key, properties[key]);
}
} catch (e) {
if (!(e instanceof ReferenceError)) {
throw e;
}
}
});

$analyticsProvider.registerSetUsername(function (userId) {
calq.user.identify(userId);
try {
calq.user.identify(userId);
} catch (e) {
if (!(e instanceof ReferenceError)) {
throw e;
}
}
});

$analyticsProvider.registerSetUserProperties(function (properties) {
calq.user.profile(properties);
try {
calq.user.profile(properties);
} catch (e) {
if (!(e instanceof ReferenceError)) {
throw e;
}
}
});

}]);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angulartics-calq",
"version": "0.1.1",
"version": "0.1.2",
"description": "Calq plugin for Angulartics",
"keywords": [
"calq",
Expand Down

0 comments on commit 3496d2b

Please sign in to comment.