Created
January 25, 2018 15:31
-
-
Save charlypoly/65cbce56f497fa4ccd23f91d5592c5b9 to your computer and use it in GitHub Desktop.
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
import { ApolloLink, NextLink, Operation } from 'apollo-link'; | |
import { JasonBourne } from '../../../service/Marketing/JasonBourne'; | |
const PERF_MONITORED_OPERATIONS = [ | |
'loadChatsList', | |
// ... | |
]; | |
export const perfMonitorLink = new ApolloLink((operation: Operation, forward?: NextLink) => { | |
const startTime = new Date().getTime(); | |
return forward ? | |
forward(operation).map(result => { | |
const operationName = operation.operationName; | |
const ellapsedMs = new Date().getTime() - startTime; | |
if (PERF_MONITORED_OPERATIONS.includes(operationName)) { | |
JasonBourne.track({ | |
name: 'Performance.QueryLoadTime', | |
operationName, | |
ellapsedMs | |
}); | |
} | |
return result; | |
}) : | |
null; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment