Merge branch 'hotfix/1.1-google-analytics'

This commit is contained in:
Michael Auer
2020-12-07 16:31:48 +01:00
4 changed files with 40 additions and 54 deletions

View File

@@ -1,41 +1,8 @@
<lib-offline-overlay>
<!-- lib offline depends on these three elements to be present inside of it -->
<app-header
[ngClass]="{ loading: loading }"
*ngIf="authenticated"
></app-header>
<app-content
[ngClass]="{ loading: loading }"
*ngIf="authenticated"
></app-content>
<app-header [ngClass]="{ loading: loading }" *ngIf="authenticated"></app-header>
<app-content [ngClass]="{ loading: loading }" *ngIf="authenticated"></app-content>
<app-menu [ngClass]="{ loading: loading }" *ngIf="authenticated"></app-menu>
<img
*ngIf="loading"
src="/assets/images/Icon_Loading.svg"
class="app-loader"
/>
<img *ngIf="loading" src="/assets/images/Icon_Loading.svg" class="app-loader" />
</lib-offline-overlay>
<router-outlet></router-outlet>
<script *ngIf="includeGoogleAnalytics">
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
(i[r] =
i[r] ||
function () {
(i[r].q = i[r].q || []).push(arguments);
}),
(i[r].l = 1 * new Date());
(a = s.createElement(o)), (m = s.getElementsByTagName(o)[0]);
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m);
})(
window,
document,
'script',
'https://www.google-analytics.com/analytics.js',
'ga'
);
ga('create', 'UA-76423009-5', 'auto');
</script>

View File

@@ -1,4 +1,4 @@
import { Component, OnDestroy, OnInit } from '@angular/core';
import { Component, Inject, OnDestroy, OnInit, Renderer2 } from '@angular/core';
import { Router, NavigationEnd } from '@angular/router';
import { Store } from '@ngxs/store';
import { Subject } from 'rxjs';
@@ -9,6 +9,7 @@ import { ModuleSwitcher } from './core/models/app-switcher.enum';
import { AppState } from './core/store/state/app.state';
import { AppConfiguration } from './app-configuration';
import { NativeContainerService } from 'shared/lib/barcode-scanner';
import { DOCUMENT } from '@angular/common';
@Component({
selector: 'app-root',
@@ -31,7 +32,9 @@ export class AppComponent implements OnInit, OnDestroy {
private appService: AppService,
private router: Router,
private store: Store,
private nativeContainer: NativeContainerService
private nativeContainer: NativeContainerService,
@Inject(DOCUMENT) private document: Document,
private renderer: Renderer2
) {
// intialisations done only when app loads
this.appService.appLoadInitialisations();
@@ -54,6 +57,10 @@ export class AppComponent implements OnInit, OnDestroy {
this.loading = false;
this.containerNotificationMessage();
});
if (this.includeGoogleAnalytics) {
this.initGoogleAnalytics();
}
}
ngOnDestroy() {
@@ -67,4 +74,26 @@ export class AppComponent implements OnInit, OnDestroy {
this.nativeContainer.sendMessage({ userAuthenticated: this.ssoService.isAuthenticated() });
}
}
private initGoogleAnalytics() {
const htmlScript: HTMLScriptElement = this.renderer.createElement('script');
htmlScript.text = `
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
(i[r] =
i[r] ||
function () {
(i[r].q = i[r].q || []).push(arguments);
}),
(i[r].l = 1 * new Date());
(a = s.createElement(o)), (m = s.getElementsByTagName(o)[0]);
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m);
})(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-76423009-5', 'auto');
`;
this.renderer.appendChild(this.document.body, htmlScript);
}
}

View File

@@ -1,11 +1,6 @@
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import {
NgModule,
ErrorHandler,
LOCALE_ID,
APP_INITIALIZER,
} from '@angular/core';
import { NgModule, ErrorHandler, LOCALE_ID, APP_INITIALIZER } from '@angular/core';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
@@ -32,10 +27,7 @@ import { AppState } from './core/store/state/app.state';
import { CartEntryState } from './core/store/state/cart-entry.state';
import { BranchState } from './core/store/state/branches.state';
import { SsoModule, SsoInterface } from 'sso';
import {
SsoAuthorizationInterceptor,
HttpErrorHandlerInterceptor,
} from './core/interceptors';
import { SsoAuthorizationInterceptor, HttpErrorHandlerInterceptor } from './core/interceptors';
import { DatePipe } from '@angular/common';
import { CountryState } from './core/store/state/countries.state';
import { HimaSalesErrorHandler } from './core/error/hima-sales.error-handler';
@@ -93,9 +85,7 @@ export function noop() {
return function () {};
}
export function remissionModuleOptionsFactory(
config: AppConfiguration
): RemissionModuleOptions {
export function remissionModuleOptionsFactory(config: AppConfiguration): RemissionModuleOptions {
return config.remissionModuleOptions;
}

6
package-lock.json generated
View File

@@ -3262,7 +3262,7 @@
},
"@isa/catsearch-api": {
"version": "0.0.56",
"resolved": "https://pkgs.dev.azure.com/hugendubel/_packaging/hugendubel@Local/npm/registry/@isa/catsearch-api/-/catsearch-api-0.0.56.tgz",
"resolved": "https://pkgs.dev.azure.com/hugendubel/_packaging/hugendubel/npm/registry/@isa/catsearch-api/-/catsearch-api-0.0.56.tgz",
"integrity": "sha1-VQWugpfYeSER3UnIsYOQVtnd5FA=",
"requires": {
"tslib": "^1.9.0"
@@ -3270,7 +3270,7 @@
},
"@isa/print-api": {
"version": "0.0.56",
"resolved": "https://pkgs.dev.azure.com/hugendubel/_packaging/hugendubel@Local/npm/registry/@isa/print-api/-/print-api-0.0.56.tgz",
"resolved": "https://pkgs.dev.azure.com/hugendubel/_packaging/hugendubel/npm/registry/@isa/print-api/-/print-api-0.0.56.tgz",
"integrity": "sha1-8cSMtEczwDnSe/C8piozLDmVYMA=",
"requires": {
"tslib": "^1.9.0"
@@ -3278,7 +3278,7 @@
},
"@isa/remi-api": {
"version": "0.0.56",
"resolved": "https://pkgs.dev.azure.com/hugendubel/_packaging/hugendubel@Local/npm/registry/@isa/remi-api/-/remi-api-0.0.56.tgz",
"resolved": "https://pkgs.dev.azure.com/hugendubel/_packaging/hugendubel/npm/registry/@isa/remi-api/-/remi-api-0.0.56.tgz",
"integrity": "sha1-bQBbsKL7D+j+nrB26qIOaobBjmc=",
"requires": {
"tslib": "^1.9.0"