From 52382b7b559ba7c5654ab77141c569354e4db9db Mon Sep 17 00:00:00 2001 From: leonardosantiagozup <58442587+leonardosantiagozup@users.noreply.github.com> Date: Fri, 26 Jun 2020 13:51:20 -0300 Subject: [PATCH] Click event/touchable (#131) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add screen and click events in beagle angular components * add click event in touchable component * add click event in touchable component Co-authored-by: Tiago Peres França --- .../beagle-touchable/beagle-touchable.component.ts | 7 +++++++ src/components/schemas/touchable.ts | 3 +++ 2 files changed, 10 insertions(+) diff --git a/src/components/beagle-touchable/beagle-touchable.component.ts b/src/components/beagle-touchable/beagle-touchable.component.ts index 14cd3c4c..4b6619bf 100644 --- a/src/components/beagle-touchable/beagle-touchable.component.ts +++ b/src/components/beagle-touchable/beagle-touchable.component.ts @@ -15,6 +15,8 @@ */ import { Component, Input, ViewEncapsulation } from '@angular/core' +import { ClickEvent } from '@zup-it/beagle-web/types' +import { BeagleAnalytics } from '@zup-it/beagle-web' import { BeagleTouchableInterface } from '../schemas/touchable' @Component({ @@ -25,8 +27,13 @@ import { BeagleTouchableInterface } from '../schemas/touchable' }) export class BeagleTouchableComponent implements BeagleTouchableInterface { @Input() onPress: () => void + @Input() clickAnalyticsEvent?: ClickEvent + beagleAnalytics = BeagleAnalytics.getAnalytics() handleClick() { + if (this.clickAnalyticsEvent && this.beagleAnalytics) { + this.beagleAnalytics.trackEventOnClick(this.clickAnalyticsEvent) + } if (this.onPress) this.onPress() } } diff --git a/src/components/schemas/touchable.ts b/src/components/schemas/touchable.ts index 859fdb3f..50615628 100644 --- a/src/components/schemas/touchable.ts +++ b/src/components/schemas/touchable.ts @@ -14,6 +14,9 @@ * limitations under the License. */ +import { ClickEvent } from '@zup-it/beagle-web/types' + export interface BeagleTouchableInterface { onPress: () => void, + clickAnalyticsEvent?: ClickEvent, }