Created
August 29, 2019 20:31
-
-
Save goatandsheep/9c3cd6c57ad91cc286405749be51dcdb 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
Auth.currentCredentials().then(creds => { | |
Analytics.autoTrack('pageView', { | |
// REQUIRED, turn on/off the auto tracking | |
enable: true, | |
// OPTIONAL, the event name, by default is 'pageView' | |
eventName: 'pageView', | |
// OPTIONAL, the attributes of the event, you can either pass an object or a function | |
// which allows you to define dynamic attributes | |
// attributes: { | |
// attr: 'attr' | |
// }, | |
// when using function | |
attributes: () => { | |
const user = Auth.essentialCredentials(creds).identityId | |
return { | |
data: { | |
user | |
} | |
} | |
}, | |
// OPTIONAL, by default is 'multiPageApp' | |
// you need to change it to 'SPA' if your app is a single-page app like React | |
type: 'SPA', | |
// OPTIONAL, the service provider, by default is the AWS Pinpoint | |
provider: 'AWSKinesis', | |
// OPTIONAL, to get the current page url | |
getUrl: () => { | |
// the default function | |
return window.location.origin + window.location.pathname; | |
} | |
}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment