lib/uploadToSentry.js
function uploadFile(endpoint, releaseVersion, filePath) {
  // sentry lets you use the tilde to indicate it just looks at relative locations
  // instead of relying on the host/domain.
  var IGNORE_DOMAIN = '~';
  var staticBase = process.env.STATIC_BASE;
  var IGNORE_PATH = staticBase ? url.parse(staticBase).path + '/' : '';
  var CONFLICT_CODE = 409;

  var fileData = path.parse(filePath);
  var fileName = fileData.name + fileData.ext;
  var sentryFilePath = IGNORE_DOMAIN + IGNORE_PATH + fileName;

  return new Promise(function(resolve, reject) {
    superagent
      .post(endpoint)
      .set(HEADERS)
      .attach('file', filePath)
      .field('name', sentryFilePath)
      .end(function(err, res) {
        if (!err) {
          console.log('Sentry (release: ' + releaseVersion +
            ') - Successfully uploaded ' + fileName);
          resolve();
        } if (err && err.response && err.response.statusCode === CONFLICT_CODE) {
          console.log('Sentry (' + releaseVersion + ') - ' + fileName +
            ' already exists.');
          resolve();
        } else {
          reject(err);
        }
      });
  });
}
function uploadFile(endpoint, releaseVersion, filePath) {
  // sentry lets you use the tilde to indicate it just looks at relative locations
  // instead of relying on the host/domain.
  var IGNORE_DOMAIN = '~';
  var staticBase = process.env.STATIC_BASE;
  var IGNORE_PATH = staticBase ? url.parse(staticBase).path + '/' : '';
  var CONFLICT_CODE = 409;

  var fileData = path.parse(filePath);
  var fileName = fileData.name + fileData.ext;
  var sentryFilePath = IGNORE_DOMAIN + IGNORE_PATH + fileName;

  return new Promise(function(resolve, reject) {
    superagent
      .post(endpoint)
      .set(HEADERS)
      .attach('file', filePath)
      .field('name', sentryFilePath)
      .end(function(err, res) {
        if (!err) {
          console.log('Sentry (release: ' + releaseVersion +
            ') - Successfully uploaded ' + fileName);
          resolve();
        } if (err && err.response && err.response.statusCode === CONFLICT_CODE) {
          console.log('Sentry (' + releaseVersion + ') - ' + fileName +
            ' already exists.');
          resolve();
        } else {
          reject(err);
        }
      });
  });
}
function uploadFile ( endpoint , releaseVersion , filePath ) { // sentry lets you use the tilde to indicate it just looks at relative locations // instead of relying on the host/domain. var IGNORE_DOMAIN = '~' ; var staticBase = process . env . STATIC_BASE ; var IGNORE_PATH = staticBase ? url . parse ( staticBase ) . path + '/' : '' ; var CONFLICT_CODE = 409 ; var fileData = path . parse ( filePath ) ; var fileName = fileData . name + fileData . ext ; var sentryFilePath = IGNORE_DOMAIN + IGNORE_PATH + fileName ; return new Promise ( function ( resolve , reject ) { superagent . post ( endpoint ) . set ( HEADERS ) . attach ( 'file' , filePath ) . field ( 'name' , sentryFilePath ) . end ( function ( err , res ) { if ( ! err ) { console . log ( 'Sentry (release: ' + releaseVersion + ') - Successfully uploaded ' + fileName ) ; resolve ( ) ; } if ( err && err . response && err . response . statusCode === CONFLICT_CODE ) { console . log ( 'Sentry (' + releaseVersion + ') - ' + fileName + ' already exists.' ) ; resolve ( ) ; } else { reject ( err ) ; } } ) ; } ) ; }
Uploads a single file to a selected release.
@param {String} endpoint
The endpoint to push these files to
@param {String} releaseVersion
The release version for this file
@param {String} filePath
The absolute file path for the file we want to upload to the release
Uploads a single file to a selected release .