Created
October 15, 2020 16:24
-
-
Save malliapi/15df7da5195c3b256194aa06925d5d39 to your computer and use it in GitHub Desktop.
Analytics Utils HOC
This file contains 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 React from 'react'; | |
import { trackEvent } from './tealium'; | |
const getDisplayName = Component => Component.displayName || Component.name || 'Component'; | |
export function withAnalytics(OriginalComponent) { | |
const WithAnalytics = props => <OriginalComponent {...props} track={trackEvent} />; | |
WithAnalytics.displayName = `WithAnalytics(${getDisplayName(OriginalComponent)})`; | |
WithAnalytics.WrappedComponent = OriginalComponent; | |
return WithAnalytics; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment