<commit_before>var fs = new FamilySearch({
  environment: 'integration',
  appKey: '<KEY>',
  redirectUri: window.location.href,
  saveAccessToken: true
});

// Process OAuth response, if we have one
fs.oauthResponse(function(){
  load();
});

// Wire up the Sign In button
document.getElementById('signin').addEventListener('click', function(){
  fs.oauthRedirect();
});

// If we're authenticated then load the pedigree
if(fs.getAccessToken()){
  load();
}

function load(){
  // We first make a request to the API to get the ID of the person
  // in the tree that represents this user.
  getUsersPersonId(function(personId){

    // Now that we have the user's person ID we can request their pedigree
    getPersonsPedigree(personId, function(persons){

      // The pedigree is returned as a flat list of persons that are
      // annotated with Ahnentafel numbers. http://en.wikipedia.org/wiki/Ahnentafel
      // We use those numbers to assemble the pedigree.

      console.log(persons);

    });
  });
}

/**
 * Fetch the user's person ID via the Current User resource
 * https://familysearch.org/developers/docs/api/users/Current_User_resource
 */
function getUsersPersonId(callback){
  fs.get('/platform/users/current', function(error, response){
    if(error) {
      handleError(error);
    }
    else {
      callback(response.data.users[0].personId);
    }
  });
}

/**
 * Load a person's ancestral pedigree.
 * https://familysearch.org/developers/docs/api/tree/Ancestry_resource
 */
function getPersonsPedigree(personId, callback){
  fs.get('/platform/ancestry?person=' + personId, function(error, response){<commit_msg>fix pedigree loading<commit_after>var fs = new FamilySearch({
  environment: 'integration',
  appKey: '<KEY>',
  redirectUri: window.location.href,
  saveAccessToken: true
});

// Process OAuth response, if we have one
fs.oauthResponse(function(){
  load();
});

// Wire up the Sign In button
document.getElementById('signin').addEventListener('click', function(){
  fs.oauthRedirect();
});

// If we're authenticated then load the pedigree
if(fs.getAccessToken()){
  load();
}

function load(){
  // We first make a request to the API to get the ID of the person
  // in the tree that represents this user.
  getUsersPersonId(function(personId){

    // Now that we have the user's person ID we can request their pedigree
    getPersonsPedigree(personId, function(persons){

      // The pedigree is returned as a flat list of persons that are
      // annotated with Ahnentafel numbers. http://en.wikipedia.org/wiki/Ahnentafel
      // We use those numbers to assemble the pedigree.

      console.log(persons);

    });
  });
}

/**
 * Fetch the user's person ID via the Current User resource
 * https://familysearch.org/developers/docs/api/users/Current_User_resource
 */
function getUsersPersonId(callback){
  fs.get('/platform/users/current', function(error, response){
    if(error) {
      handleError(error);
    }
    else {
      callback(response.data.users[0].personId);
    }
  });
}

/**
 * Load a person's ancestral pedigree.
 * https://familysearch.org/developers/docs/api/tree/Ancestry_resource
 */
function getPersonsPedigree(personId, callback){
  fs.get('/platform/tree/ancestry?person=' + personId, function(error, response){
{'fraction_non_alphanumeric': 0.12705667276051189, 'fraction_numerical': 0.0006093845216331506, 'mean_word_length': 3.7579710144927536, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 4, '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': '5114236', 'n_tokens_mistral': 1013, 'n_tokens_neox': 969, 'n_words': 277}