Created
August 19, 2017 21:43
-
-
Save chrisobriensp/ccecd87268918e0b83e7bc11be6d1c19 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
| // start timer here.. | |
| this._startTime = new Date(); | |
| this.props.context.graphHttpClient.get(`v1.0/groups/${groupId}/events`, GraphHttpClient.configurations.v1).then((response: HttpClientResponse) => { | |
| if (response.ok) { | |
| return response.json(); | |
| } else { | |
| console.warn(response.statusText); | |
| } | |
| }).then((result: any) => { | |
| // 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 } | |
| ); | |
| console.log("componentWillMount: Fetched result.value.length = " + result.value.length); | |
| this._processing = false; | |
| // process events.. | |
| let appointments: string = ''; | |
| for (var i:number = 0; i < result.value.length; i++) { | |
| var item: any = result.value[i]; | |
| var eventItem: IEventItem = { | |
| subject: item.subject, | |
| startTime: new Date().toString(), | |
| endTime: new Date().toString(), | |
| thumbnail: "" | |
| }; | |
| fetchedEvents.push(eventItem); | |
| appointments += item.subject + "|"; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment