Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
track(event) {
const filtered = this.trackEvents.filter(item => item === event);
if (filtered.length > 0) {
if (Analytics && typeof Analytics.record === 'function') {
Analytics.record({
name: this.trackerName,
attributes: { event },
});
} else {
throw new Error(
'No Analytics module found, please ensure @aws-amplify/analytics is imported'
);
}
}
}
componentDidUpdate(prevProps, prevState) {
const attributes = Object.assign({}, this.props, this.state);
if (Analytics && typeof Analytics.record === 'function') {
Analytics.record({
name: this.trackerName,
attributes,
});
} else {
throw new Error(
'No Analytics module found, please ensure @aws-amplify/analytics is imported'
);
}
}