Trying to add page tracking
This commit is contained in:
12
src/app/analytics.service.spec.ts
Normal file
12
src/app/analytics.service.spec.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { AnalyticsService } from './analytics.service';
|
||||
|
||||
describe('AnalyticsService', () => {
|
||||
beforeEach(() => TestBed.configureTestingModule({}));
|
||||
|
||||
it('should be created', () => {
|
||||
const service: AnalyticsService = TestBed.get(AnalyticsService);
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
18
src/app/analytics.service.ts
Normal file
18
src/app/analytics.service.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
|
||||
declare var owa_cmds: Array<any>;
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class AnalyticsService {
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
public trackPageHit(pageName: String) {
|
||||
if (typeof owa_cmds === 'object') {
|
||||
owa_cmds.push(pageName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +1,29 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import {AfterContentInit, Component, OnInit} from '@angular/core';
|
||||
import {AnalyticsService} from '../analytics.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-contact',
|
||||
templateUrl: './contact.component.html',
|
||||
styleUrls: ['./contact.component.css']
|
||||
})
|
||||
export class ContactComponent {
|
||||
export class ContactComponent implements AfterContentInit {
|
||||
|
||||
constructor() { }
|
||||
constructor(private analytics: AnalyticsService) {
|
||||
}
|
||||
|
||||
ngAfterContentInit(): void {
|
||||
this.analytics.trackPageHit('Contact');
|
||||
}
|
||||
|
||||
linkedInClicked() {
|
||||
window.open("https://www.linkedin.com/in/cameron-cordes-3b166583/")
|
||||
window.open('https://www.linkedin.com/in/cameron-cordes-3b166583/');
|
||||
}
|
||||
|
||||
githubClicked() {
|
||||
window.open("https://github.com/Stampede10343")
|
||||
window.open('https://github.com/Stampede10343');
|
||||
}
|
||||
|
||||
emailClicked() {
|
||||
window.open("mailto:cameronc.dev@gmail.com")
|
||||
window.open('mailto:cameronc.dev@gmail.com');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import {AfterContentInit, Component, OnInit} from '@angular/core';
|
||||
import {AnalyticsService} from '../analytics.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-home',
|
||||
templateUrl: './home.component.html',
|
||||
styleUrls: ['./home.component.css']
|
||||
})
|
||||
export class HomeComponent implements OnInit {
|
||||
export class HomeComponent implements AfterContentInit {
|
||||
|
||||
constructor() { }
|
||||
constructor(private analytics: AnalyticsService) { }
|
||||
|
||||
ngOnInit() {
|
||||
ngAfterContentInit(): void {
|
||||
this.analytics.trackPageHit('Home');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,24 +1,29 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {ProjectService} from "./project.service";
|
||||
import {ProjectItem} from "./project-item";
|
||||
import {AfterContentInit, Component, OnInit} from '@angular/core';
|
||||
import {ProjectService} from './project.service';
|
||||
import {ProjectItem} from './project-item';
|
||||
import {AnalyticsService} from '../analytics.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-projects',
|
||||
templateUrl: './projects.component.html',
|
||||
styleUrls: ['./projects.component.css'],
|
||||
})
|
||||
export class ProjectsComponent implements OnInit {
|
||||
export class ProjectsComponent implements OnInit, AfterContentInit {
|
||||
projects: Array<ProjectItem>;
|
||||
|
||||
constructor(private projectService: ProjectService) {
|
||||
constructor(private projectService: ProjectService, private analytics: AnalyticsService) {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.getProjects()
|
||||
this.getProjects();
|
||||
}
|
||||
|
||||
getProjects() {
|
||||
return this.projectService.getProjects().then(projects => this.projects = projects)
|
||||
this.projectService.getProjects().then(projects => this.projects = projects);
|
||||
}
|
||||
|
||||
ngAfterContentInit(): void {
|
||||
this.analytics.trackPageHit('Projects');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import {AfterContentInit, Component, OnInit} from '@angular/core';
|
||||
import {AnalyticsService} from '../analytics.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-resume',
|
||||
templateUrl: './resume.component.html',
|
||||
styleUrls: ['./resume.component.css']
|
||||
})
|
||||
export class ResumeComponent implements OnInit {
|
||||
export class ResumeComponent implements AfterContentInit {
|
||||
private analytics: AnalyticsService;
|
||||
|
||||
constructor() { }
|
||||
constructor(analytics: AnalyticsService) {
|
||||
this.analytics = analytics;
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
ngAfterContentInit(): void {
|
||||
this.analytics.trackPageHit('Resume');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user