<commit_before>import { Component } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { NavController } from 'ionic-angular';
import { Logger } from '../../../providers/logger/logger';

// providers
import { AppProvider } from '../../../providers/app/app';
import { PersistenceProvider } from '../../../providers/persistence/persistence';
import { ReplaceParametersProvider } from '../../../providers/replace-parameters/replace-parameters';

// pages
import { SendFeedbackPage } from '../../../pages/feedback/send-feedback/send-feedback';

@Component({
  selector: 'page-feedback-card',
  templateUrl: 'feedback-card.html'
})
export class FeedbackCardPage {
  public score: number;
  public button_title: string;
  public feedbackCardTitle: string;
  public isShowRateCard: boolean;

  constructor(
    private appProvider: AppProvider,
    private navCtrl: NavController,
    private logger: Logger,
    private persistenceProvider: PersistenceProvider,
    private translate: TranslateService,
    private replaceParametersProvider: ReplaceParametersProvider
  ) {
    this.score = 0;
    this.isShowRateCard = false;
  }

  public setShowRateCard(value) {
    this.isShowRateCard = value;

    if (this.isShowRateCard) {
      let appName = this.appProvider.info.nameCase;
      this.feedbackCardTitle = this.replaceParametersProvider.replace(
        this.translate.instant('How satisfied are you with using {{appName}}?'),
        { appName }
      );
    }
  }

  public hideCard(): void {
    this.isShowRateCard = false;
    this.logger.debug('Feedback card dismissed.');
    this.persistenceProvider.getFeedbackInfo().then(info => {
      let feedbackInfo = info;
      feedbackInfo.sent = true;
      this.persistenceProvider.setFeedbackInfo(feedbackInfo);
    });
  }

  public setScore(score: number) {
    this.score = score;
    switch (this.score) {
      case 1:
        this.button_title = this.translate.instant("I'm disappointed");
        break;
      case 2:
        this.button_title = this.translate.instant("It's ok for now");
        break;
      case 3:
        this.button_title = this.translate.instant('I love it!');
        break;
    }
  }

  public goFeedbackFlow(): void {
    this.hideCard();
    this.navCtrl.push(SendFeedbackPage, {
      score: this.score,
      fromCard: true
    });
  }
}<commit_msg>add feedback-card app sentiment analytics<commit_after>import { Component } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { NavController } from 'ionic-angular';
import { Logger } from '../../../providers/logger/logger';

// providers
import { AnalyticsProvider } from '../../../providers/analytics/analytics';
import { AppProvider } from '../../../providers/app/app';
import { PersistenceProvider } from '../../../providers/persistence/persistence';
import { ReplaceParametersProvider } from '../../../providers/replace-parameters/replace-parameters';

// pages
import { SendFeedbackPage } from '../../../pages/feedback/send-feedback/send-feedback';

@Component({
  selector: 'page-feedback-card',
  templateUrl: 'feedback-card.html'
})
export class FeedbackCardPage {
  public score: number;
  public button_title: string;
  public feedbackCardTitle: string;
  public isShowRateCard: boolean;

  constructor(
    private appProvider: AppProvider,
    private navCtrl: NavController,
    private logger: Logger,
    private persistenceProvider: PersistenceProvider,
    private analyticsProvider: AnalyticsProvider,
    private translate: TranslateService,
    private replaceParametersProvider: ReplaceParametersProvider
  ) {
    this.score = 0;
    this.isShowRateCard = false;
  }

  public setShowRateCard(value) {
    this.isShowRateCard = value;

    if (this.isShowRateCard) {
      let appName = this.appProvider.info.nameCase;
      this.feedbackCardTitle = this.replaceParametersProvider.replace(
        this.translate.instant('How satisfied are you with using {{appName}}?'),
        { appName }
      );
    }
  }

  public hideCard(): void {
    this.isShowRateCard = false;
    this.logger.debug('Feedback card dismissed.');
    this.persistenceProvider.getFeedbackInfo().then(info => {
      let feedbackInfo = info;
      feedbackInfo.sent = true;
      this.persistenceProvider.setFeedbackInfo(feedbackInfo);
    });
  }

  public setScore(score: number) {
    this.score = score;
    switch (this.score) {
      case 1:
        this.button_title = this.translate.instant("I'm disappointed");
        break;
      case 2:
        this.button_title = this.translate.instant("It's ok for now");
        break;
      case 3:
        this.button_title = this.translate.instant('I love it!');
        break;
    }
  }

  public goFeedbackFlow(): void {
    this.hideCard();
    this.analyticsProvider.logEvent('feedback_card_app_sentiment', {
      happinessLevel: this.score,
      happinessDescription: this.button_title
    });
    this.navCtrl.push(SendFeedbackPage, {
      score: this.score,
      fromCard: true
    });
  }
}
{'fraction_non_alphanumeric': 0.12764275834815253, 'fraction_numerical': 0.0015807152736613318, 'mean_word_length': 3.2218515429524603, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4548778', 'n_tokens_mistral': 1462, 'n_tokens_neox': 1424, 'n_words': 312}