Skip to content

Instantly share code, notes, and snippets.

@chrisobriensp
Created August 19, 2017 21:43
Show Gist options
  • Select an option

  • Save chrisobriensp/ccecd87268918e0b83e7bc11be6d1c19 to your computer and use it in GitHub Desktop.

Select an option

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).
// 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