-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-6 added google analytics configuration, events service and example…
… events
- Loading branch information
Showing
27 changed files
with
381 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,47 @@ | ||
import { Component } from '@angular/core'; | ||
import { Component, OnDestroy } from '@angular/core'; | ||
import { Router, NavigationEnd } from '@angular/router'; | ||
import { | ||
StorefrontComponent, | ||
HamburgerMenuService, | ||
} from '@spartacus/storefront'; | ||
import { ContentSlotComponentData, RoutingService } from '@spartacus/core'; | ||
import { Subject } from 'rxjs'; | ||
import { takeUntil } from 'rxjs/operators'; | ||
|
||
import { StorefrontComponent } from '@spartacus/storefront'; | ||
import { ContentSlotComponentData } from '@spartacus/core'; | ||
import { GoogleAnalyticsEventsService } from './shared/google-analytics/google-analytics-event.service'; | ||
|
||
@Component({ | ||
selector: 'app-root', | ||
templateUrl: './app.component.html', | ||
styleUrls: ['./app.component.scss'], | ||
}) | ||
export class AppComponent extends StorefrontComponent { | ||
export class AppComponent extends StorefrontComponent implements OnDestroy { | ||
public footerComponent: ContentSlotComponentData = { | ||
uid: 'FooterNavigationComponent', | ||
typeCode: 'FooterNavigationComponent', | ||
flexType: 'FooterNavigationComponent', | ||
}; | ||
|
||
private unsubscribe: Subject<any> = new Subject(); | ||
|
||
constructor( | ||
hamburgerMenuService: HamburgerMenuService, | ||
routingService: RoutingService, | ||
private googleAnalyticsEventsService: GoogleAnalyticsEventsService, | ||
private router: Router | ||
) { | ||
super(hamburgerMenuService, routingService); | ||
|
||
this.router.events.pipe(takeUntil(this.unsubscribe)).subscribe((event) => { | ||
if (event instanceof NavigationEnd) { | ||
this.googleAnalyticsEventsService.emitSetPage(event.urlAfterRedirects); | ||
console.log('SET PAGE', event.urlAfterRedirects); | ||
} | ||
}); | ||
} | ||
|
||
public ngOnDestroy(): void { | ||
this.unsubscribe.next(); | ||
this.unsubscribe.complete(); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
src/app/features/dvnt-bottom-navigation/dvnt-bottom-navigation.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,43 @@ | ||
import { Component } from '@angular/core'; | ||
import { FooterNavigationComponent } from '@spartacus/storefront'; | ||
import { | ||
FooterNavigationComponent, | ||
CmsComponentData, | ||
NavigationService, | ||
} from '@spartacus/storefront'; | ||
import { | ||
Product, | ||
CmsNavigationComponent, | ||
AnonymousConsentsConfig, | ||
} from '@spartacus/core'; | ||
|
||
import { GoogleAnalyticsEventsService } from 'src/app/shared/google-analytics/google-analytics-event.service'; | ||
import { | ||
GoogleEventCategory, | ||
GoogleActionCategory, | ||
GoogleLabelCategory, | ||
} from 'src/app/shared/google-analytics/google-analytics.enum'; | ||
|
||
@Component({ | ||
selector: 'app-dvnt-footer', | ||
templateUrl: './dvnt-footer.component.html', | ||
styleUrls: ['./dvnt-footer.component.scss'], | ||
}) | ||
export class DvntFooterComponent extends FooterNavigationComponent {} | ||
export class DvntFooterComponent extends FooterNavigationComponent { | ||
constructor( | ||
anonymousConsentsConfig: AnonymousConsentsConfig, | ||
componentData: CmsComponentData<CmsNavigationComponent>, | ||
service: NavigationService, | ||
private googleAnalyticsEventsService: GoogleAnalyticsEventsService | ||
) { | ||
super(componentData, service, anonymousConsentsConfig); | ||
} | ||
|
||
public footerSectionSelected(column: string, title: string): void { | ||
this.googleAnalyticsEventsService.emitEvent( | ||
GoogleEventCategory.SelectFooterSection, | ||
GoogleActionCategory.Footer, | ||
GoogleLabelCategory.FooterSection, | ||
{ column, title } | ||
); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
src/app/features/dvnt-header/dvnt-header-logo/dvnt-header-logo.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<a role="link" routerLink=""> | ||
<a (click)="goToHomePage()" role="link" routerLink=""> | ||
<img src="../../../../assets/images/homepage-logo.svg" alt="Logo" /> | ||
</a> |
20 changes: 19 additions & 1 deletion
20
src/app/features/dvnt-header/dvnt-header-logo/dvnt-header-logo.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,25 @@ | ||
import { Component } from '@angular/core'; | ||
import { GoogleAnalyticsEventsService } from 'src/app/shared/google-analytics/google-analytics-event.service'; | ||
|
||
import { | ||
GoogleEventCategory, | ||
GoogleActionCategory, | ||
GoogleLabelCategory, | ||
} from 'src/app/shared/google-analytics/google-analytics.enum'; | ||
|
||
@Component({ | ||
selector: 'app-dvnt-header-logo', | ||
templateUrl: './dvnt-header-logo.component.html', | ||
}) | ||
export class DvntHeaderLogoComponent {} | ||
export class DvntHeaderLogoComponent { | ||
constructor( | ||
private googleAnalyticsEventsService: GoogleAnalyticsEventsService | ||
) {} | ||
|
||
public goToHomePage(): void { | ||
this.googleAnalyticsEventsService.emitEvent( | ||
GoogleEventCategory.Navigation, | ||
GoogleActionCategory.HomePageRedirect | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/app/features/dvnt-header/dvnt-login/dvnt-login.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/app/features/dvnt-header/dvnt-wish-list-icon/dvnt-wish-list-icon.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...ures/dvnt-landing-page/dvnt-bestselling-products/dvnt-bestselling-products.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
<app-dvnt-carousel-products | ||
(emitClickEvent)="productSelected($event)" | ||
[componentData]="componentData$" | ||
></app-dvnt-carousel-products> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/app/features/dvnt-landing-page/dvnt-new-products/dvnt-new-products.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
<app-dvnt-carousel-products | ||
(emitClickEvent)="productSelected($event)" | ||
[componentData]="componentData$" | ||
></app-dvnt-carousel-products> |
Oops, something went wrong.