Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core/telemetry): matomo usage POC #4135

Closed
wants to merge 6 commits into from
Closed
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
2 changes: 2 additions & 0 deletions app/__module.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ angular.module('portainer', [
'portainer.integrations',
'rzModule',
'moment-picker',
'angulartics',
'angulartics.piwik',
]);

if (require) {
Expand Down
9 changes: 7 additions & 2 deletions app/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,13 @@ angular.module('portainer').config([
},
]);

AnalyticsProvider.setAccount({ tracker: __CONFIG_GA_ID, set: { anonymizeIp: true } });
AnalyticsProvider.startOffline(true);
// $analyticsProvider.withBase(false);
// $analyticsProvider.withAutoBase(true);

// need to set trackRelativePath

// AnalyticsProvider.setAccount({ tracker: __CONFIG_GA_ID, set: { anonymizeIp: true } });
// AnalyticsProvider.startOffline(true);

toastr.options.timeOut = 3000;

Expand Down
20 changes: 20 additions & 0 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,26 @@
<link rel="shortcut icon" href="${require('./assets/ico/favicon.ico')}" />
<meta name="msapplication-config" content="${require('./assets/ico/browserconfig.xml')}" />
<meta name="theme-color" content="#ffffff" />

<!-- Matomo -->
<script type="text/javascript">
var _paq = (window._paq = window._paq || []);
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['enableLinkTracking']);
(function () {
var u = '//188.166.250.54/';
_paq.push(['setTrackerUrl', u + 'matomo.php']);
_paq.push(['setSiteId', '1']);
var d = document,
g = d.createElement('script'),
s = d.getElementsByTagName('script')[0];
g.type = 'text/javascript';
g.async = true;
g.src = u + 'matomo.js';
s.parentNode.insertBefore(g, s);
})();
</script>
<!-- End Matomo Code -->
</head>

<body ng-controller="MainController">
Expand Down
26 changes: 13 additions & 13 deletions app/portainer/__module.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ async function initAuthentication(authManager, Authentication, $rootScope, $stat
await Authentication.init();
}

function initAnalytics(Analytics, $rootScope) {
Analytics.offline(false);
Analytics.registerScriptTags();
Analytics.registerTrackers();
$rootScope.$on('$stateChangeSuccess', function (event, toState) {
Analytics.trackPage(toState.url);
Analytics.pageView();
});
}
// function initAnalytics(Analytics, $rootScope) {
// Analytics.offline(false);
// Analytics.registerScriptTags();
// Analytics.registerTrackers();
// $rootScope.$on('$stateChangeSuccess', function (event, toState) {
// Analytics.trackPage(toState.url);
// Analytics.pageView();
// });
// }

angular.module('portainer.app', []).config([
'$stateRegistryProvider',
Expand Down Expand Up @@ -51,10 +51,10 @@ angular.module('portainer.app', []).config([
deferred.resolve();
} else {
StateManager.initialize()
.then(function success(state) {
if (state.application.analytics) {
initAnalytics(Analytics, $rootScope);
}
.then(function success() {
// if (state.application.analytics) {
// initAnalytics(Analytics, $rootScope);
// }
return $async(initAuthentication, authManager, Authentication, $rootScope, $state);
})
.then(() => deferred.resolve())
Expand Down
2 changes: 2 additions & 0 deletions app/vendors.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,7 @@ import 'js-yaml/dist/js-yaml.js';
import 'angular-ui-bootstrap';
import 'angular-moment-picker';
import 'angular-multiselect/isteven-multi-select.js';
import 'angulartics/dist/angulartics.min.js';
import 'angulartics-piwik/src/angulartics-piwik.js';

window.angular = angular;
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
"angular-utils-pagination": "~0.11.1",
"angularjs-scroll-glue": "^2.2.0",
"angularjs-slider": "^6.4.0",
"angulartics": "^1.6.0",
"angulartics-piwik": "^1.0.6",
"babel-plugin-angularjs-annotate": "^0.10.0",
"bootbox": "^5.4.0",
"bootstrap": "^3.4.0",
Expand Down Expand Up @@ -162,4 +164,4 @@
"*.js": "eslint --cache --fix",
"*.{js,css,md,html}": "prettier --write"
}
}
}
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1301,6 +1301,18 @@ angularjs-slider@^6.4.0:
resolved "https://registry.yarnpkg.com/angularjs-slider/-/angularjs-slider-6.7.0.tgz#eb2229311b81b79315a36e7b5eb700e128f50319"
integrity sha512-Cizsuax65wN2Y+htmA3safE5ALOSCyWcKyWkziaO8vCVymi26bQQs6kKDhkYc8GFix/KE7Oc9gH3QLlTUgD38w==

angulartics-piwik@^1.0.6:
version "1.0.6"
resolved "https://registry.yarnpkg.com/angulartics-piwik/-/angulartics-piwik-1.0.6.tgz#cf050b65e8974f3f9ae9a2a1cef4bc1cac82099f"
integrity sha1-zwULZeiXTz+a6aKhzvS8HKyCCZ8=
dependencies:
angulartics "*"

angulartics@*, angulartics@^1.6.0:
version "1.6.0"
resolved "https://registry.yarnpkg.com/angulartics/-/angulartics-1.6.0.tgz#a89c17ef8ea2334ebced65d6265951846f848172"
integrity sha512-fywhCi1InawcX+rpLv9NQ32Ed87KoZeH20SUIsRUz9dYJSxuk4/uxiKiopITveGxTC8THYHFEATj9Y/X+BvMqA==

ansi-colors@^3.0.0, ansi-colors@^3.2.1:
version "3.2.4"
resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-3.2.4.tgz#e3a3da4bfbae6c86a9c285625de124a234026fbf"
Expand Down