Skip to content

Commit

Permalink
feat(GDB-10629) Add GA4 tracking code in GDB Workbench (#1491)
Browse files Browse the repository at this point in the history
* feat(GDB-10629) Add GA4 tracking code in GDB Workbench

## WHAT:
Add GA4 tracking code in head section of every html page

## WHY:
To enable Google Tag Manager (GTM) on the application for enhanced tracking and analytics capabilities.

## HOW:
- Updated the `mainCtrl.$inject` array to include `$document`
- Defined the `injectGTM` function to create and append the GTM script element
- Called `injectGTM` in the controller to ensure GTM is injected upon controller initialization

NB. Do not merge to master until the TODO is removed. This branch will be used to build a TR

* Added tracking logic based on license type. Refactored license service and updated tracking service. Tests added

* align

* notes fix

* updated jsdocs

---------

Co-authored-by: Svilen Velikov <51084653+svilenvelikov@users.noreply.github.com>
  • Loading branch information
teodossidossev and svilenvelikov authored Oct 9, 2024
1 parent 5db7b7d commit 4e6499f
Show file tree
Hide file tree
Showing 7 changed files with 355 additions and 70 deletions.
8 changes: 6 additions & 2 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const modules = [
'graphdb.framework.core.directives.uppercased',
'graphdb.framework.core.directives.prop-indeterminate',
'graphdb.framework.guides.services',
'graphdb.framework.core.services.licenseService',
'graphdb.framework.core.directives.operationsstatusesmonitor',
'graphdb.framework.core.directives.autocomplete',
'ngCustomElement'
Expand Down Expand Up @@ -193,8 +194,8 @@ const moduleDefinition = function (productInfo, translations) {
workbench.constant('productInfo', productInfo);

// we need to inject $jwtAuth here in order to init the service before everything else
workbench.run(['$rootScope', '$route', 'toastr', '$sce', '$translate', 'ThemeService', 'WorkbenchSettingsStorageService', 'LSKeys', 'GuidesService',
function ($rootScope, $route, toastr, $sce, $translate, ThemeService, WorkbenchSettingsStorageService, LSKeys, GuidesService) {
workbench.run(['$rootScope', '$route', 'toastr', '$sce', '$translate', 'ThemeService', 'WorkbenchSettingsStorageService', 'LSKeys', 'GuidesService', '$licenseService',
function ($rootScope, $route, toastr, $sce, $translate, ThemeService, WorkbenchSettingsStorageService, LSKeys, GuidesService, $licenseService) {
$rootScope.$on('$routeChangeSuccess', function () {
updateTitleAndHelpInfo();

Expand Down Expand Up @@ -222,6 +223,9 @@ const moduleDefinition = function (productInfo, translations) {
ThemeService.applyDarkThemeMode();

GuidesService.init();

// Checks license status and adds tracking code when free/evaluation license
$licenseService.checkLicenseStatus();
}]);

workbench.filter('titlecase', function () {
Expand Down
44 changes: 22 additions & 22 deletions src/js/angular/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function homeCtrl($scope, $rootScope, $http, $repositories, $jwtAuth, $licenseSe
}
}

$scope.$on('autocompleteStatus', function() {
$scope.$on('autocompleteStatus', function () {
checkAutocompleteStatus();
});

Expand Down Expand Up @@ -202,7 +202,7 @@ function mainCtrl($scope, $menuItems, $jwtAuth, $http, toastr, $location, $repos
$scope.initTutorial();
});

$scope.checkMenu = debounce(function() {
$scope.checkMenu = debounce(function () {
return $('.main-menu').hasClass('collapsed');
}, 250, {trailing: false});

Expand Down Expand Up @@ -324,7 +324,7 @@ function mainCtrl($scope, $menuItems, $jwtAuth, $http, toastr, $location, $repos
$scope.isFreeAccessEnabled = function () {
return $jwtAuth.isFreeAccessEnabled();
};
$scope.hasExternalAuthUser = function() {
$scope.hasExternalAuthUser = function () {
return $jwtAuth.hasExternalAuthUser();
};
$scope.isDefaultAuthEnabled = function () {
Expand Down Expand Up @@ -401,15 +401,15 @@ function mainCtrl($scope, $menuItems, $jwtAuth, $http, toastr, $location, $repos
return $repositories.isActiveRepoFedXType();
};

$scope.isLicenseValid = function() {
$scope.isLicenseValid = function () {
return $licenseService.isLicenseValid();
};

/**
* Sets attrs property in the directive
* @param attrs
*/
$scope.setAttrs = function(attrs) {
$scope.setAttrs = function (attrs) {
$scope.attrs = attrs;
};

Expand All @@ -424,7 +424,7 @@ function mainCtrl($scope, $menuItems, $jwtAuth, $http, toastr, $location, $repos
if ($scope.attrs) {
$scope.isRestricted =
$scope.attrs.hasOwnProperty('license') && !$licenseService.isLicenseValid() ||
$scope.attrs.hasOwnProperty('write') && $scope.isSecurityEnabled() && !$scope.canWriteActiveRepo()||
$scope.attrs.hasOwnProperty('write') && $scope.isSecurityEnabled() && !$scope.canWriteActiveRepo() ||
$scope.attrs.hasOwnProperty('ontop') && $scope.isActiveRepoOntopType() ||
$scope.attrs.hasOwnProperty('fedx') && $scope.isActiveRepoFedXType();
}
Expand Down Expand Up @@ -611,7 +611,7 @@ function mainCtrl($scope, $menuItems, $jwtAuth, $http, toastr, $location, $repos
},
{
"title": $translate.instant('main.info.title.create.repo.page'),
"info": decodeHTML($translate.instant('main.info.create.repo.page', {link:"<a href=\"https://graphdb.ontotext.com/documentation/" + productInfo.productShortVersion + "/configuring-a-repository.html\" target=\"_blank\">"}))
"info": decodeHTML($translate.instant('main.info.create.repo.page', {link: "<a href=\"https://graphdb.ontotext.com/documentation/" + productInfo.productShortVersion + "/configuring-a-repository.html\" target=\"_blank\">"}))
},
{
"title": $translate.instant('main.info.title.load.sample.dataset'),
Expand All @@ -637,7 +637,7 @@ function mainCtrl($scope, $menuItems, $jwtAuth, $http, toastr, $location, $repos
}, 50);
};

$scope.getTutorialPageHtml = function(page) {
$scope.getTutorialPageHtml = function (page) {
return $sce.trustAsHtml(page.info);
};

Expand Down Expand Up @@ -811,6 +811,9 @@ function mainCtrl($scope, $menuItems, $jwtAuth, $http, toastr, $location, $repos
}
});

$scope.getProductType = function () {
return $licenseService.productType();
};

$scope.isEnterprise = function () {
return $scope.getProductType() === "enterprise";
Expand All @@ -827,24 +830,21 @@ function mainCtrl($scope, $menuItems, $jwtAuth, $http, toastr, $location, $repos
return _.indexOf(editions, $scope.getProductType()) >= 0;
};

$scope.showLicense = function() {
return $licenseService.showLicense;
$scope.showLicense = function () {
return $licenseService.showLicense();
};

$scope.getLicense = function() {
return $licenseService.license;
$scope.getLicense = function () {
return $licenseService.license();
};

$scope.isLicenseHardcoded = function() {
return $licenseService.isLicenseHardcoded;
$scope.isLicenseHardcoded = function () {
return $licenseService.isLicenseHardcoded();
};

$scope.getProductType = function() {
return $licenseService.productType;
};

$scope.getProductTypeHuman = function() {
return $licenseService.productTypeHuman;
$scope.getProductTypeHuman = function () {
return $licenseService.productTypeHuman();
};


Expand Down Expand Up @@ -977,17 +977,17 @@ function uxTestCtrl($scope, $repositories, toastr, ModalService) {
});
};

$scope.demoToast = function(alertType, secondArg=true) {
$scope.demoToast = function (alertType, secondArg = true) {
toastr[alertType]('Consectetur adipiscing elit. Sic transit gloria mundi.',
secondArg ? 'Lorem ipsum dolor sit amet' : undefined,
{timeOut: 300000, extendedTimeOut: 300000});
};

$scope.clearToasts = function() {
$scope.clearToasts = function () {
toastr.clear();
};

$scope.clearRepo = function() {
$scope.clearRepo = function () {
$repositories.setRepository('');
};
}
Loading

0 comments on commit 4e6499f

Please sign in to comment.