Skip to content

Instantly share code, notes, and snippets.

@dhavaln
Created July 3, 2018 07:07
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 dhavaln/9451ca9eb6b9267ccebc15338fc5e32e to your computer and use it in GitHub Desktop.
Save dhavaln/9451ca9eb6b9267ccebc15338fc5e32e to your computer and use it in GitHub Desktop.
ToDo App Component with Analytics custom events
import { Component } from '@angular/core';
import Amplify, { API, Analytics } from 'aws-amplify';
import aws_exports from '../aws-exports';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
todos = [];
loading = false;
ngOnInit(){
Amplify.configure(aws_exports);
Analytics.record('app_loaded');
this.loading = true;
API.get('sampleCloudApi', '/items', {}).then(data => {
this.loading = false;
this.todos = data;
Analytics.record('todos_loaded');
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment