Skip to content

Commit 90fb48c

Browse files
committed
publish(7.0.2): publish 7.0.2 to npm
closes #67 closes #65
1 parent 09578c6 commit 90fb48c

3 files changed

Lines changed: 118 additions & 52 deletions

File tree

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@markpieszak/ng-application-insights",
3-
"version": "7.0.1",
3+
"version": "7.0.2",
44
"scripts": {
55
"lint": "tslint -p tsconfig.json",
66
"clean": "rimraf ./dist",
@@ -11,7 +11,7 @@
1111
},
1212
"repository": {
1313
"type": "git",
14-
"url": "https://github.com/MarkPieszak/angular-application-insights"
14+
"url": "https://github.com/TrilonIO/angular-application-insights"
1515
},
1616
"author": {
1717
"name": "Mark Pieszak | Trilon Consulting",
@@ -20,13 +20,13 @@
2020
},
2121
"license": "MIT",
2222
"bugs": {
23-
"url": "https://github.com/MarkPieszak/angular-application-insights/issues"
23+
"url": "https://github.com/TrilonIO/angular-application-insights/issues"
2424
},
2525
"main": "./dist/index.js",
2626
"types": "./dist/index.d.ts",
2727
"dependencies": {
2828
"applicationinsights-js": "^1.0.20",
29-
"@types/applicationinsights-js": "^1.0.7"
29+
"@types/applicationinsights-js": "^1.0.9"
3030
},
3131
"peerDependencies": {
3232
"@angular/router": "^7.0.0",
@@ -49,18 +49,21 @@
4949
"zone.js": "^0.8.26"
5050
},
5151
"engines": {
52-
"node": ">=6.0.0"
52+
"node": ">=10.0.0"
5353
},
5454
"keywords": [
5555
"angular",
5656
"angular2",
57-
"angular6",
57+
"angular7",
58+
"angular8",
5859
"azure application insights",
5960
"ms application insights",
6061
"application insights",
6162
"angular application insights",
6263
"microsoft application insights",
6364
"ms app insights",
64-
"aspnet core app insights"
65+
"aspnet core app insights",
66+
"trilon",
67+
"trilon.io"
6568
]
6669
}

src/app-insight.service.ts

Lines changed: 104 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ import { filter } from 'rxjs/operators';
55

66
import IAppInsights = Microsoft.ApplicationInsights.IAppInsights;
77

8+
// Since AI.SeverityLevel isn't working we can just use our own
9+
export enum SeverityLevel {
10+
Verbose = 0,
11+
Information = 1,
12+
Warning = 2,
13+
Error = 3,
14+
Critical = 4,
15+
}
16+
817
export class AppInsightsConfig implements Microsoft.ApplicationInsights.IConfig {
918
instrumentationKeySetLater?: boolean;
1019
// Will be deprecated in next major version
@@ -64,8 +73,12 @@ export class AppInsightsService implements IAppInsights {
6473
}
6574

6675
// https://github.com/Microsoft/ApplicationInsights-JS/blob/master/API-reference.md#trackevent
67-
// trackEvent(name: string, properties?: {[string]:string}, measurements?: {[string]:number})
68-
// Log a user action or other occurrence.
76+
/**
77+
* Log a user action or other occurrence.
78+
* @param name A string to identify this event in the portal.
79+
* @param properties map[string, string] - additional data used to filter events and metrics in the portal. Defaults to empty.
80+
* @param measurements map[string, number] - metrics associated with this event, displayed in Metrics Explorer on the portal. Defaults to empty.
81+
*/
6982
trackEvent(eventName: string, eventProperties?: { [name: string]: string }, metricProperty?: { [name: string]: number }) {
7083
try {
7184
AppInsights.trackEvent(eventName, eventProperties, metricProperty);
@@ -74,6 +87,10 @@ export class AppInsightsService implements IAppInsights {
7487
}
7588
}
7689

90+
/**
91+
* Start timing an extended event. Call {@link stopTrackEvent} to log the event when it ends.
92+
* @param name A string that identifies this event uniquely within the document.
93+
*/
7794
startTrackEvent(name: string): any {
7895
try {
7996
AppInsights.startTrackEvent(name);
@@ -82,6 +99,12 @@ export class AppInsightsService implements IAppInsights {
8299
}
83100
}
84101

102+
/**
103+
* Log an extended event that you started timing with {@link startTrackEvent}.
104+
* @param name The string you used to identify this event in startTrackEvent.
105+
* @param properties map[string, string] - additional data used to filter events and metrics in the portal. Defaults to empty.
106+
* @param measurements map[string, number] - metrics associated with this event, displayed in Metrics Explorer on the portal. Defaults to empty.
107+
*/
85108
stopTrackEvent(name: string, properties?: { [p: string]: string }, measurements?: { [p: string]: number }): any {
86109
try {
87110
AppInsights.stopTrackEvent(name, properties, measurements);
@@ -91,8 +114,14 @@ export class AppInsightsService implements IAppInsights {
91114
}
92115

93116
// https://github.com/Microsoft/ApplicationInsights-JS/blob/master/API-reference.md#trackpageview
94-
// trackPageView(name?: string, url?: string, properties?:{[string]:string}, measurements?: {[string]:number}, duration?: number)
95-
// Logs that a page or similar container was displayed to the user.
117+
/**
118+
* Logs that a page or other item was viewed.
119+
* @param name The string you used as the name in startTrackPage. Defaults to the document title.
120+
* @param url String - a relative or absolute URL that identifies the page or other item. Defaults to the window location.
121+
* @param properties map[string, string] - additional data used to filter pages and metrics in the portal. Defaults to empty.
122+
* @param measurements map[string, number] - metrics associated with this page, displayed in Metrics Explorer on the portal. Defaults to empty.
123+
* @param duration number - the number of milliseconds it took to load the page. Defaults to undefined. If set to default value, page load time is calculated internally.
124+
*/
96125
trackPageView(name?: string, url?: string, properties?: { [name: string]: string }, measurements?: { [name: string]: number }, duration?: number) {
97126
try {
98127
AppInsights.trackPageView(name, url, properties, measurements, duration);
@@ -102,10 +131,11 @@ export class AppInsightsService implements IAppInsights {
102131
}
103132

104133
// https://github.com/Microsoft/ApplicationInsights-JS/blob/master/API-reference.md#starttrackpage
105-
// startTrackPage(name?: string)
106-
// Starts the timer for tracking a page view. Use this instead of trackPageView if you want to control when the
107-
// page view timer starts and stops, but don't want to calculate the duration yourself. This method doesn't send any
108-
// telemetry. Call stopTrackPage to log the end of the page view and send the event.
134+
/**
135+
* Starts timing how long the user views a page or other item. Call this when the page opens.
136+
* This method doesn't send any telemetry. Call {@link stopTrackTelemetry} to log the page when it closes.
137+
* @param name A string that idenfities this item, unique within this HTML document. Defaults to the document title.
138+
*/
109139
startTrackPage(name?: string) {
110140
try {
111141
AppInsights.startTrackPage(name);
@@ -115,9 +145,13 @@ export class AppInsightsService implements IAppInsights {
115145
}
116146

117147
// https://github.com/Microsoft/ApplicationInsights-JS/blob/master/API-reference.md#stoptrackpage
118-
// stopTrackPage(name?: string, url?: string, properties?: Object, measurements?: Object)
119-
// Stops the timer that was started by calling startTrackPage and sends the page view telemetry with the
120-
// specified properties and measurements. The duration of the page view will be the time between calling startTrackPage and stopTrackPage.
148+
/**
149+
* Logs how long a page or other item was visible, after {@link startTrackPage}. Call this when the page closes.
150+
* @param name The string you used as the name in startTrackPage. Defaults to the document title.
151+
* @param url String - a relative or absolute URL that identifies the page or other item. Defaults to the window location.
152+
* @param properties map[string, string] - additional data used to filter pages and metrics in the portal. Defaults to empty.
153+
* @param measurements map[string, number] - metrics associated with this page, displayed in Metrics Explorer on the portal. Defaults to empty.
154+
*/
121155
stopTrackPage(name?: string, url?: string, properties?: { [name: string]: string }, measurements?: { [name: string]: number }) {
122156
try {
123157
AppInsights.stopTrackPage(name, url, properties, measurements);
@@ -127,9 +161,16 @@ export class AppInsightsService implements IAppInsights {
127161
}
128162

129163
// https://github.com/Microsoft/ApplicationInsights-JS/blob/master/API-reference.md#trackmetric
130-
// trackMetric(name: string, average: number, sampleCount?: number, min?: number, max?: number, properties?: {[string]:string})
131-
// Log a positive numeric value that is not associated with a specific event.
132-
// Typically used to send regular reports of performance indicators.
164+
/**
165+
* Log a numeric value that is not associated with a specific event. Typically used to send regular reports of performance indicators.
166+
* To send a single measurement, use just the first two parameters. If you take measurements very frequently, you can reduce the
167+
* telemetry bandwidth by aggregating multiple measurements and sending the resulting average at intervals.
168+
* @param name A string that identifies the metric.
169+
* @param average Number representing either a single measurement, or the average of several measurements.
170+
* @param sampleCount The number of measurements represented by the average. Defaults to 1.
171+
* @param min The smallest measurement in the sample. Defaults to the average.
172+
* @param max The largest measurement in the sample. Defaults to the average.
173+
*/
133174
trackMetric(name: string, average: number, sampleCount?: number, min?: number, max?: number, properties?: { [name: string]: string }) {
134175
try {
135176
AppInsights.trackMetric(name, average, sampleCount, min, max, properties);
@@ -139,10 +180,15 @@ export class AppInsightsService implements IAppInsights {
139180
}
140181

141182
// https://github.com/Microsoft/ApplicationInsights-JS/blob/master/API-reference.md#trackexception
142-
// trackException(exception: Error, handledAt?: string, properties?: {[string]:string}, measurements?: {[string]:number}, severityLevel?: AI.SeverityLevel)
143-
// Log an exception you have caught. (Exceptions caught by the browser are also logged.)
183+
/**
184+
* Log an exception you have caught.
185+
* @param exception An Error from a catch clause, or the string error message.
186+
* @param properties map[string, string] - additional data used to filter events and metrics in the portal. Defaults to empty.
187+
* @param measurements map[string, number] - metrics associated with this event, displayed in Metrics Explorer on the portal. Defaults to empty.
188+
* @param severityLevel SeverityLevel | AI.SeverityLevel - severity level
189+
*/
144190
trackException(exception: Error, handledAt?: string, properties?: { [name: string]: string },
145-
measurements?: { [name: string]: number }, severityLevel?: AI.SeverityLevel) {
191+
measurements?: { [name: string]: number }, severityLevel?: SeverityLevel | AI.SeverityLevel) {
146192
try {
147193
AppInsights.trackException(exception, handledAt, properties, measurements, severityLevel);
148194
} catch (ex) {
@@ -151,9 +197,14 @@ export class AppInsightsService implements IAppInsights {
151197
}
152198

153199
// https://github.com/Microsoft/ApplicationInsights-JS/blob/master/API-reference.md#tracktrace
154-
// trackTrace(message: string, properties?: {[string]:string}, severityLevel?: AI.SeverityLevel)
200+
// trackTrace(message: string, properties?: {[string]:string}, severityLevel?: SeverityLevel | AI.SeverityLevel)
155201
// Log a diagnostic event such as entering or leaving a method.
156-
trackTrace(message: string, properties?: { [name: string]: string }, severityLevel?: AI.SeverityLevel) {
202+
/**
203+
* Log a diagnostic message.
204+
* @param message A message string
205+
* @param properties map[string, string] - additional data used to filter traces in the portal. Defaults to empty.
206+
*/
207+
trackTrace(message: string, properties?: { [name: string]: string }, severityLevel?: SeverityLevel | AI.SeverityLevel) {
157208
try {
158209
AppInsights.trackTrace(message, properties, severityLevel);
159210
} catch (ex) {
@@ -162,11 +213,22 @@ export class AppInsightsService implements IAppInsights {
162213
}
163214

164215
// https://github.com/Microsoft/ApplicationInsights-JS/blob/master/API-reference.md#trackdependency
165-
// trackDependency(id: string, method: string, absoluteUrl: string, pathName: string, totalTime: number, success: boolean, resultCode: number)
166-
// Log a dependency call (for instance: ajax)
167-
trackDependency(id: string, method: string, absoluteUrl: string, pathName: string, totalTime: number, success: boolean, resultCode: number) {
216+
/**
217+
* Log a dependency call (for instance: ajax)
218+
* @param id unique id, this is used by the backend o correlate server requests. Use Util.newId() to generate a unique Id.
219+
* @param method represents request verb (GET, POST, etc.)
220+
* @param absoluteUrl absolute url used to make the dependency request
221+
* @param pathName the path part of the absolute url
222+
* @param totalTime total request time
223+
* @param success indicates if the request was sessessful
224+
* @param resultCode response code returned by the dependency request
225+
* @param properties map[string, string] - additional data used to filter events and metrics in the portal. Defaults to empty.
226+
* @param measurements map[string, number] - metrics associated with this event, displayed in Metrics Explorer on the portal. Defaults to empty.
227+
*/
228+
trackDependency(id: string, method: string, absoluteUrl: string, pathName: string, totalTime: number, success: boolean,
229+
resultCode: number, properties?: { [name: string]: string }, measurements?: { [name: string]: number }) {
168230
try {
169-
AppInsights.trackDependency(id, method, absoluteUrl, pathName, totalTime, success, resultCode);
231+
AppInsights.trackDependency(id, method, absoluteUrl, pathName, totalTime, success, resultCode, properties, measurements);
170232
} catch (ex) {
171233
console.warn('Angular application insights Error [trackDependency]: ', ex);
172234
}
@@ -186,21 +248,18 @@ export class AppInsightsService implements IAppInsights {
186248
}
187249

188250
// https://github.com/Microsoft/ApplicationInsights-JS/blob/master/API-reference.md#setauthenticatedusercontext
189-
// setAuthenticatedUserContext(authenticatedUserId: string, accountId?: string)
190-
// Set the authenticated user id and the account id in this session. Use this when you have identified a specific
191-
// signed-in user. Parameters must not contain spaces or ,;=|
192-
/**
193-
* Sets the authenticated user id and the account id.
194-
* User auth id and account id should be of type string. They should not contain commas, semi-colons, equal signs, spaces, or vertical-bars.
195-
*
196-
* By default the method will only set the authUserID and accountId for all events in this page view. To add them to all events within
197-
* the whole session, you should either call this method on every page view or set `storeInCookie = true`.
198-
*
199-
* @param authenticatedUserId {string} - The authenticated user id. A unique and persistent string that represents each authenticated user in the service.
200-
* @param accountId {string} - An optional string to represent the account associated with the authenticated user.
201-
* @param storeInCookie {boolean} - AuthenticateUserID will be stored in a cookie and added to all events within this session.
202-
*/
203-
setAuthenticatedUserContext(authenticatedUserId: string, accountId?: string, storeInCookie:boolean = false) {
251+
/**
252+
* Sets the authenticated user id and the account id.
253+
* User auth id and account id should be of type string. They should not contain commas, semi-colons, equal signs, spaces, or vertical-bars.
254+
*
255+
* By default the method will only set the authUserID and accountId for all events in this page view. To add them to all events within
256+
* the whole session, you should either call this method on every page view or set `storeInCookie = true`.
257+
*
258+
* @param authenticatedUserId {string} - The authenticated user id. A unique and persistent string that represents each authenticated user in the service.
259+
* @param accountId {string} - An optional string to represent the account associated with the authenticated user.
260+
* @param storeInCookie {boolean} - AuthenticateUserID will be stored in a cookie and added to all events within this session.
261+
*/
262+
setAuthenticatedUserContext(authenticatedUserId: string, accountId?: string, storeInCookie: boolean = false) {
204263
try {
205264
AppInsights.setAuthenticatedUserContext(authenticatedUserId, accountId, storeInCookie);
206265
} catch (ex) {
@@ -209,8 +268,9 @@ export class AppInsightsService implements IAppInsights {
209268
}
210269

211270
// https://github.com/Microsoft/ApplicationInsights-JS/blob/master/API-reference.md#clearauthenticatedusercontext
212-
// clearAuthenticatedUserContext ()
213-
// Clears the authenticated user id and the account id from the user context, and clears the associated cookie.
271+
/**
272+
* Clears the authenticated user id and the account id from the user context.
273+
*/
214274
clearAuthenticatedUserContext() {
215275
try {
216276
AppInsights.clearAuthenticatedUserContext();
@@ -223,6 +283,10 @@ export class AppInsightsService implements IAppInsights {
223283
console.warn('Angular application insights Error [_onerror]: ', message);
224284
}
225285

286+
/**
287+
* Initialize Application Insights for Angular
288+
* Make sure your config{} has been set
289+
*/
226290
public init(): void {
227291
if (this.config) {
228292

@@ -283,4 +347,3 @@ export class AppInsightsService implements IAppInsights {
283347
}
284348
}
285349
}
286-

0 commit comments

Comments
 (0)