-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.component.ts
106 lines (89 loc) · 2.56 KB
/
app.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import { Component, Inject } from '@angular/core';
import { Location } from '@angular/common';
import { AppInsightsService, SeverityLevel } from 'ng2-appinsights';
import { Observable } from 'rxjs/observable';
declare let Zone: any;
@Component({
selector: 'app',
templateUrl: 'app/app.component.html'
})
export class AppComponent {
private value: string;
constructor(private appinsightsService: AppInsightsService, private location: Location) {
this.appinsightsService.Init({
instrumentationKey: 'AIF-2139c09a-72ff-48d2-a32b-bee7b807695c',
verboseLogging: true
});
}
trackException() {
this.appinsightsService.trackException(
new Error('Sample Error'),
'SampleFunctionName',
{ sampleProp: 'sampleProp' },
{ sampleMeasurement: 1 },
SeverityLevel.Error
);
}
trackEvent() {
this.appinsightsService.trackEvent(
'SampleEvent',
{ sampleProp: 'sampleProp' },
{ sampleMeasurement: 1 }
);
}
trackTrace() {
this.appinsightsService.trackTrace(
'SampleEvent',
{ SeverityLevel: 0 },
{ sampleMeasurement: 1 }
);
}
trackDependecny() {
this.appinsightsService.trackDependency(
'DependencyID',
'SampleMethod',
'http://url',
'samplePath',
13,
true,
0
);
}
trackMetric() {
const metric = {
name: 'SampleMetric',
average: 5,
count: 10,
min: 1,
max: 10
}
this.appinsightsService.trackMetric(
metric.name,
metric.average,
metric.count,
metric.min,
metric.max
);
}
trackPageView() {
this.appinsightsService.trackPageView();
}
clearAuthenticatedUserContext() {
this.appinsightsService.clearAuthenticatedUserContext();
}
setAuthenticatedUserContext() {
this.appinsightsService.setAuthenticatedUserContext('harry671003', '123');
}
startTrackPage() {
this.appinsightsService.startTrackPage('PAGE_LOAD');
}
stopTrackPage() {
this.appinsightsService.stopTrackPage('PAGE_LOAD');
}
flush() {
this.appinsightsService.flush();
}
throwUnhandledError() {
throw new Error('Unhandled Error');
}
}