lib/utils/tracking.js/sendPending
function sendPending(options = {}) {
  return BbPromise.try(() => {
    const isForced = options && options.isForced;
    serverlessRunEndTime = null; // Needed for testing
    if (options.serverlessExecutionSpan) {
      options.serverlessExecutionSpan.then(markServerlessRunEnd, markServerlessRunEnd);
    }
    if (isTrackingDisabled && !isForced) return null;
    if (!cacheDirPath) return null;

    const limit = pLimit(3);
    return fse.readdirAsync(cacheDirPath).then(
      dirFilenames => {
        if (!options.serverlessExecutionSpan) process.nextTick(markServerlessRunEnd);
        return BbPromise.all(
          dirFilenames.map(dirFilename =>
            limit(() => {
              if (serverlessRunEndTime) return null;
              if (!isUuid(dirFilename)) return null;
              return fse.readJsonAsync(join(cacheDirPath, dirFilename)).then(
                data => {
                  const timestamp = resolveTimestamp(data.event);
                  if (timestamp < timestampWeekBefore) {
                    // Stale event, do not send, and remove from cache
                    return fse.unlinkAsync(join(cacheDirPath, dirFilename)).catch(error => {
                      logError(`Could not remove cache file ${dirFilename}`, error);
                    });
                  }
                  return request(data.type, data.event, { id: dirFilename, timeout: 3000 });
                },
                readJsonError => {
                  if (readJsonError.code === 'ENOENT') return null; // Race condition
                  logError(`Cannot read cache file: ${dirFilename}`, readJsonError);
                  return fse.unlinkAsync(join(cacheDirPath, dirFilename)).catch(error => {
                    logError(`Could not remove cache file ${dirFilename}`, error);
                  });
                }
              );
            })
          )
        );
      },
      readdirError => {
        if (readdirError.code !== 'ENOENT') logError('Cannot access cache dir', readdirError);
      }
    );
  }).then(() => null); // Do not leak any result
}