Skip to content

Instantly share code, notes, and snippets.

@watilde
Last active February 8, 2021 10:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save watilde/b7480844cd60841565f2e7574c38b64b to your computer and use it in GitHub Desktop.
Save watilde/b7480844cd60841565f2e7574c38b64b to your computer and use it in GitHub Desktop.
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