Last active
February 8, 2021 10:20
-
-
Save watilde/b7480844cd60841565f2e7574c38b64b 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 UAParser from 'ua-parser-js'; | |
import { Analytics, AWSKinesisProvider } from 'aws-amplify'; | |
import awsconfig from './aws-exports'; | |
Analytics.configure({ | |
AWSKinesis: { | |
region: awsconfig.aws_project_region, | |
bufferSize: 1000, | |
flushSize: 100, | |
flushInterval: 5000, | |
resendLimit: 5 | |
} | |
}); | |
Analytics.addPluggable(new AWSKinesisProvider()); | |
const parser = new UAParser(); | |
const monitorWebVitals = (metric) => { | |
const data = { | |
name: metric.name, | |
value: metric.value, | |
url: window.location.href, | |
...parser.getResult() | |
}; | |
Analytics.record({ | |
data: data, | |
streamName: 'amplifyobservabilityKinesis-dev' | |
}, 'AWSKinesis'); | |
}; | |
export default monitorWebVitals; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment