Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8ffa067

Browse files
committed
Added Matomo analytics to the Skills component
1 parent 665060b commit 8ffa067

File tree

3 files changed

+20
-40
lines changed

3 files changed

+20
-40
lines changed

‎src/app/skills/models/struct-skill.ts‎

Lines changed: 7 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,55 +6,24 @@ export class StructSkill {
66
static DefaultHeight: string = "80px";
77
static CategoryWeightThreshold = 0.5;
88

9-
item: string;
10-
fontSize: string;
11-
percentOfTime: number;
12-
kind: string;
13-
successors: StructSkill[];
9+
id!: number;
10+
item!: string;
11+
fontSize!: string;
12+
percentOfTime!: number;
13+
kind!: string;
14+
successors!: StructSkill[];
1415
public expandCollapseIcon: string = "arrow_drop_down_circle";
1516

1617
public nodeAlwaysVisible: boolean = false;
1718
//private _nodeVisible: boolean = false;
18-
19-
constructor(
20-
itemObj: any,
21-
fontSize: any,
22-
percentOfTime: any,
23-
kind: any,
24-
childrenArr?: any[]
25-
) {
26-
this.item = itemObj;
27-
this.fontSize = fontSize;
28-
this.percentOfTime = percentOfTime;
29-
this.kind = kind;
30-
this.successors = childrenArr
31-
? StructSkill.CreateChildrenArray(childrenArr)
32-
: [];
33-
}
34-
35-
static CreateChildrenArray(childrenArr?: any[]) {
36-
let snChildren = new Array<StructSkill>();
37-
if (childrenArr) {
38-
childrenArr.map(child => {
39-
let sn = new StructSkill(
40-
child.item,
41-
child.fontSize,
42-
child.percentOfTime,
43-
child.kind,
44-
child.successors
45-
);
46-
snChildren.push(sn);
47-
});
48-
}
49-
return snChildren;
50-
}
5119
}
5220

5321
export class SkillFlatNode {
5422
constructor(
5523
public expandable: boolean,
5624
public name: string,
5725
public fontSize: string,
26+
public itemId: number,
5827
public percentOfTime: number,
5928
public kind: string,
6029
public level: number

‎src/app/skills/skills.component.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<button
1717
mat-icon-button
1818
matTreeNodeToggle
19-
[attr.aria-label]="'toggle ' + node.name"
19+
[attr.aria-label]="'toggle ' + node.name"(click)="trackNodeExpandCollapse(node)"
2020
>
2121
<mat-icon class="mat-icon-rtl-mirror" color="accent">
2222
{{treeControl.isExpanded(node) ? 'expand_more' : 'chevron_right'}}

‎src/app/skills/skills.component.ts‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import {
66
MatTreeFlattener
77
} from "@angular/material/tree";
88

9+
import { MatomoTracker } from 'ngx-matomo';
10+
911
import { StructSkill, SkillFlatNode } from "./models/struct-skill";
1012
import { SkillsService } from "./skills.service";
1113

@@ -24,6 +26,7 @@ export class SkillsComponent implements OnInit {
2426
!!node.successors && node.successors.length > 0,
2527
node.item,
2628
node.fontSize,
29+
node.id,
2730
node.percentOfTime,
2831
node.kind,
2932
level
@@ -32,7 +35,8 @@ export class SkillsComponent implements OnInit {
3235

3336
dataSource: MatTreeFlatDataSource<StructSkill, SkillFlatNode>;
3437

35-
constructor(private skillsService: SkillsService) {
38+
constructor(private skillsService: SkillsService,
39+
private matomoTracker: MatomoTracker) {
3640
this.treeControl = new FlatTreeControl<SkillFlatNode>(
3741
node => node.level,
3842
node => node.expandable
@@ -60,13 +64,20 @@ export class SkillsComponent implements OnInit {
6064
}
6165

6266
ngOnInit(): void {
67+
this.matomoTracker.setDocumentTitle('ngx-Matomo SkillsComponent');
6368
this.skillsService.getAll();
6469
}
6570

6671
hasChild = (index: number, node: SkillFlatNode): boolean => {
72+
/*
6773
console.log(
6874
`hasChild: node.name = ${node.name} node.expandable = ${node.expandable}`
6975
);
76+
*/
7077
return node.expandable;
7178
};
79+
80+
trackNodeExpandCollapse(node: SkillFlatNode): void {
81+
this.matomoTracker.trackEvent('Node expanded or collapsed', `Node with itemId ${node.itemId} is expanded? ${this.treeControl.isExpanded(node)}`, node.name, node.level);
82+
}
7283
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /