Created
August 24, 2017 16:57
-
-
Save chrisobriensp/3d4adbe48730e0b6c35f3bae3ea0b77b to your computer and use it in GitHub Desktop.
Uses Azure App Insights to track that a call to the Graph has occurred (and the duration).
This file contains hidden or 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
| private loadUpcomingMeetings(): void { | |
| this.setState((previousState: IUpcomingMeetingsState, props: IUpcomingMeetingsProps): IUpcomingMeetingsState => { | |
| previousState.loading = true; | |
| return previousState; | |
| }); | |
| this.getGraphAccessToken() | |
| .then((accessToken: string): Promise<IMeeting[]> => { | |
| // start timer here.. | |
| this._startTime = new Date(); | |
| return UpcomingMeetings.getUpcomingMeetings(accessToken, this.props.httpClient); | |
| }) | |
| .then((upcomingMeetings: IMeeting[]): void => { | |
| this.setState((prevState: IUpcomingMeetingsState, props: IUpcomingMeetingsProps): IUpcomingMeetingsState => { | |
| prevState.loading = false; | |
| prevState.upcomingMeetings = upcomingMeetings; | |
| // end timer here and log.. | |
| this._endTime = new Date(); | |
| var timeTaken: number = this._endTime.valueOf() - this._startTime.valueOf(); | |
| console.log(`componentWillMount: Took ${ timeTaken } ms to call Graph.`); | |
| AppInsights.trackEvent("Fetch calendar events", | |
| {}, | |
| { timeTaken: timeTaken } | |
| ); | |
| return prevState; | |
| }); | |
| }, (error: any): void => { | |
| this.setState((prevState: IUpcomingMeetingsState, props: IUpcomingMeetingsProps): IUpcomingMeetingsState => { | |
| prevState.loading = false; | |
| prevState.error = error; | |
| return prevState; | |
| }); | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment