<commit_before>(function() {
  'use strict';

  var exports = window.fxpay.utils.namespace('fxpay.receipts');
  var API = require('fxpay/api').API;
  var products = require('fxpay/products');
  var settings = require('fxpay/settings');
  var utils = require('fxpay/utils');

  exports.all = function receipts_all() {
    var nativeNum = 0;
    var receipts = [];
    if (settings.appSelf && settings.appSelf.receipts) {
      nativeNum = settings.appSelf.receipts.length;
      receipts = Array.prototype.slice.call(settings.appSelf.receipts);
    }

    var locNum = 0;
    var storedReceipts = settings.localStorage.getItem(
      settings.localStorageKey);

    if (storedReceipts) {
      storedReceipts = JSON.parse(storedReceipts);
      for (var j = 0; j < storedReceipts.length; j++) {
        if (receipts.indexOf(storedReceipts[j]) === -1) {
          receipts.push(storedReceipts[j]);
          locNum++;
        } else {
          settings.log.info(
            'ignoring dupe receipt fetched from local storage',
            storedReceipts[j].substring(0, 5));
        }
      }
    }

    settings.log.info('receipts fetched from mozApps:', nativeNum);
    settings.log.info('receipts fetched from localStorage:', locNum);

    return receipts;
  };


  exports.add = function receipts_add(receipt, onFinish) {
    if (settings.hasAddReceipt) {
      settings.log.info('adding receipt to device with addReceipt');
      return addReceiptNatively(receipt, onFinish);
    } else {
      settings.log.info('adding receipt to device with localStorage');
      return addReceiptWithLocStor(receipt, onFinish);
    }
  };


  exports.verify = function receipts_verify(receipt, onRestore) {
    exports.verifyData(receipt,
                       function(err, data,  productInfo) {
      if (err) {
        return onRestore(err, productInfo);
      }
      // The issuer of the receipt is the site of the Marketplace.
      // This is the site we want to use for making API requests.
      var apiUrlBase = data.iss;
      settings.log.info('derived base API URL from receipt:', apiUrlBase);
      var api = new API(apiUrlBase);

      settings.log.info('about to post to verifier URL', data.verify);<commit_msg>Log full receipt object for debugging<commit_after>(function() {
  'use strict';

  var exports = window.fxpay.utils.namespace('fxpay.receipts');
  var API = require('fxpay/api').API;
  var products = require('fxpay/products');
  var settings = require('fxpay/settings');
  var utils = require('fxpay/utils');

  exports.all = function receipts_all() {
    var nativeNum = 0;
    var receipts = [];
    if (settings.appSelf && settings.appSelf.receipts) {
      nativeNum = settings.appSelf.receipts.length;
      receipts = Array.prototype.slice.call(settings.appSelf.receipts);
    }

    var locNum = 0;
    var storedReceipts = settings.localStorage.getItem(
      settings.localStorageKey);

    if (storedReceipts) {
      storedReceipts = JSON.parse(storedReceipts);
      for (var j = 0; j < storedReceipts.length; j++) {
        if (receipts.indexOf(storedReceipts[j]) === -1) {
          receipts.push(storedReceipts[j]);
          locNum++;
        } else {
          settings.log.info(
            'ignoring dupe receipt fetched from local storage',
            storedReceipts[j].substring(0, 5));
        }
      }
    }

    settings.log.info('receipts fetched from mozApps:', nativeNum);
    settings.log.info('receipts fetched from localStorage:', locNum);

    return receipts;
  };


  exports.add = function receipts_add(receipt, onFinish) {
    if (settings.hasAddReceipt) {
      settings.log.info('adding receipt to device with addReceipt');
      return addReceiptNatively(receipt, onFinish);
    } else {
      settings.log.info('adding receipt to device with localStorage');
      return addReceiptWithLocStor(receipt, onFinish);
    }
  };


  exports.verify = function receipts_verify(receipt, onRestore) {
    exports.verifyData(receipt,
                       function(err, data,  productInfo) {
      if (err) {
        return onRestore(err, productInfo);
      }
      settings.log.debug('receipt data:', data);
      // The issuer of the receipt is the site of the Marketplace.
      // This is the site we want to use for making API requests.
      var apiUrlBase = data.iss;
      settings.log.info('derived base API URL from receipt:', apiUrlBase);
      var api = new API(apiUrlBase);

      settings.log.info('about to post to verifier URL', data.verify);
{'fraction_non_alphanumeric': 0.11771225892263357, 'fraction_numerical': 0.002660164043449346, 'mean_word_length': 2.872961373390558, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '3354937', 'n_tokens_mistral': 1478, 'n_tokens_neox': 1364, 'n_words': 329}