<commit_before>import superagent from 'superagent';
import request from 'request';
import urls from '../constants/URLs';
import Fs from 'fs';
import fse from 'fs-extra';
import mkdirp from 'mkdirp';
import path from 'path';
import AdmZip from 'adm-zip';
import http from 'http';
import NotificationActions from '../actions/NotificationActions';
import UserStore from '../stores/UserStore';
import StoreActions from '../actions/StoreActions';
import StoreStore from '../stores/StoreStore';

var FetchStream = require('fetch').FetchStream;
class StoreService {

  getLibrary() {
    superagent
      .get(urls.LIBRARY_URL)
      .set('Authorization', 'bearer ' + UserStore.jwt)
      .end((err, res) => {
        if(err) {
          NotificationActions.storeError(res.statusCode, err);
          return;
        }
        if(!('body' in res)) {
          console.log("Error: no response body");
          NotificationActions.storeError(res.statusCode, 'no response body');
          return;
        }
        StoreActions.setLibrary(res.body);
      });
  }

  purchase(contentId, provider, token) {
    superagent
      .post(urls.PURCHASE_URL)
      .send({
        contentId: contentId,
        provider: provider,
        payload: token,
      })
      .set('Authorization', 'bearer ' + UserStore.jwt)
      .end((err, res) => {
        if(!err) {
          console.log('successful purchase');
          StoreActions.addToLibrary(contentId);
          amplitude.logEvent('successfulPurchase', {
            id: contentId,
            name: StoreStore.getContent(contentId).name
          });
        } else {
          console.log('unsuccessful purchase: ', err);
          NotificationActions.productError(err.status, 'Unsuccessful purchase, your card was declined. Contact <EMAIL> for more details.');
          amplitude.logEvent('unsuccessfulPurchase', {
            id: contentId,
            name: StoreStore.getContent(contentId).name
          });
        }
      });
  }

  getAllPublisherInfo() {
    superagent
      .get(urls.PUBLISHERS_ALL_URL)
      .set('Authorization', 'bearer ' + UserStore.jwt)
      .end((err, res) => {
        if(err) {
          NotificationActions.storeError(res.statusCode, err);
          return;
        }
        if(!('body' in res)) {
          console.log("Error: no response body");
          NotificationActions.storeError(res.statusCode, 'no response body');
          return;
        }
        StoreActions.setAllPublisherInfo(res.body);
      });
  }

  getAllPublisherProducts() {
    superagent
      .get(urls.PUBLISHER_STATUS_ALL_URL)
      .set('Authorization', 'bearer ' + UserStore.jwt)
      .end((err, res) => {
        if(err) {
          NotificationActions.storeError(res.statusCode, err);
          return;
        }
        if(!('body' in res)) {
          console.log("Error: no response body");
          NotificationActions.storeError(res.statusCode, 'no response body');
          return;
        }
        StoreActions.setAllPublisherProducts(res.body);
      });
  }

  getAllProducts(){
    superagent
      .get(urls.PRODUCTS_ALL_URL)
      .end(function(err, res){
        if(err) {
          NotificationActions.storeError(res.statusCode, err);
          return;
        }
        if(!('body' in res)) {
          console.log("Error: no response body");
          NotificationActions.storeError(res.statusCode, 'no response body');
          return;
        }
        StoreActions.setAllProducts(res.body);
      });
  }
}

export default new StoreService()
<commit_msg>only log successful/unsuccessful purchases when using stripe<commit_after>import superagent from 'superagent';
import request from 'request';
import urls from '../constants/URLs';
import Fs from 'fs';
import fse from 'fs-extra';
import mkdirp from 'mkdirp';
import path from 'path';
import AdmZip from 'adm-zip';
import http from 'http';
import NotificationActions from '../actions/NotificationActions';
import UserStore from '../stores/UserStore';
import StoreActions from '../actions/StoreActions';
import StoreStore from '../stores/StoreStore';

var FetchStream = require('fetch').FetchStream;
class StoreService {

  getLibrary() {
    superagent
      .get(urls.LIBRARY_URL)
      .set('Authorization', 'bearer ' + UserStore.jwt)
      .end((err, res) => {
        if(err) {
          NotificationActions.storeError(res.statusCode, err);
          return;
        }
        if(!('body' in res)) {
          console.log("Error: no response body");
          NotificationActions.storeError(res.statusCode, 'no response body');
          return;
        }
        StoreActions.setLibrary(res.body);
      });
  }

  purchase(contentId, provider, token) {
    superagent
      .post(urls.PURCHASE_URL)
      .send({
        contentId: contentId,
        provider: provider,
        payload: token,
      })
      .set('Authorization', 'bearer ' + UserStore.jwt)
      .end((err, res) => {
        if(!err) {
          StoreActions.addToLibrary(contentId);
          if (provider === 'stripe') {
            console.log('successful purchase');
            amplitude.logEvent('successfulPurchase', {
              id: contentId,
              name: StoreStore.getContent(contentId).name
            });
          }
        } else {
          if (provider === 'stripe') {
            console.log('unsuccessful purchase: ', err);
            NotificationActions.productError(err.status, 'Unsuccessful purchase, your card was declined. Contact <EMAIL> for more details.');
            amplitude.logEvent('unsuccessfulPurchase', {
              id: contentId,
              name: StoreStore.getContent(contentId).name
            });
          } else {
            NotificationActions.productError(err.status, 'Error adding to library: ' + err.response.body);
          }
        }
      });
  }

  getAllPublisherInfo() {
    superagent
      .get(urls.PUBLISHERS_ALL_URL)
      .set('Authorization', 'bearer ' + UserStore.jwt)
      .end((err, res) => {
        if(err) {
          NotificationActions.storeError(res.statusCode, err);
          return;
        }
        if(!('body' in res)) {
          console.log("Error: no response body");
          NotificationActions.storeError(res.statusCode, 'no response body');
          return;
        }
        StoreActions.setAllPublisherInfo(res.body);
      });
  }

  getAllPublisherProducts() {
    superagent
      .get(urls.PUBLISHER_STATUS_ALL_URL)
      .set('Authorization', 'bearer ' + UserStore.jwt)
      .end((err, res) => {
        if(err) {
          NotificationActions.storeError(res.statusCode, err);
          return;
        }
        if(!('body' in res)) {
          console.log("Error: no response body");
          NotificationActions.storeError(res.statusCode, 'no response body');
          return;
        }
        StoreActions.setAllPublisherProducts(res.body);
      });
  }

  getAllProducts(){
    superagent
      .get(urls.PRODUCTS_ALL_URL)
      .end(function(err, res){
        if(err) {
          NotificationActions.storeError(res.statusCode, err);
          return;
        }
        if(!('body' in res)) {
          console.log("Error: no response body");
          NotificationActions.storeError(res.statusCode, 'no response body');
          return;
        }
        StoreActions.setAllProducts(res.body);
      });
  }
}

export default new StoreService()

{'fraction_non_alphanumeric': 0.12758760654850493, 'fraction_numerical': 0.0, 'mean_word_length': 2.2985274431057565, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '4772021', 'n_tokens_mistral': 2131, 'n_tokens_neox': 2097, 'n_words': 429}