Skip to content

Instantly share code, notes, and snippets.

@goatandsheep
Created August 29, 2019 20:31
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 goatandsheep/9c3cd6c57ad91cc286405749be51dcdb to your computer and use it in GitHub Desktop.
Save goatandsheep/9c3cd6c57ad91cc286405749be51dcdb to your computer and use it in GitHub Desktop.
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