/* jshint node: true */

module.exports = function(environment) {
  var ENV = {
    modulePrefix: 'client',
    environment: environment,
    rootURL: '/',
    locationType: 'auto',

    'ember-simple-auth': {
      authorizer: 'authorizer:token',
      routeAfterAuthentication: 'dashboard',
      routeIfAlreadyAuthenticated: 'dashboard'
    },

    'ember-simple-auth-token': {
      refreshLeeway: 20,
      timeFactor: 1000, // backend is in seconds and the frontend is in ms.
    },

    EmberENV: {
      FEATURES: {
        // Here you can enable experimental features on an ember canary build
        // e.g. 'with-controller': true
      },
      EXTEND_PROTOTYPES: {
        // Prevent Ember Data from overriding Date.parse.
        Date: false
      }
    },

    APP: {
      // Here you can pass flags/options to your application instance
      // when it is created
    }
  };

  if (environment === 'development') {
    // ENV.APP.LOG_RESOLVER = true;
    // ENV.APP.LOG_ACTIVE_GENERATION = true;
    // ENV.APP.LOG_TRANSITIONS = true;
    // ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
    // ENV.APP.LOG_VIEW_LOOKUPS = true;
    ENV.APP.API_HOST = 'https://localhost:8080';
  }

  if (environment === 'test') {
    // Testem prefers this...
    ENV.locationType = 'none';

    // keep test console output quieter
    ENV.APP.LOG_ACTIVE_GENERATION = false;
    ENV.APP.LOG_VIEW_LOOKUPS = false;

    ENV.APP.rootElement = '#ember-testing';
  }

  if (environment === 'production') {
    ENV.APP.API_HOST = process.env.API_HOST;
    ENV.rollbar = {
      accessToken: process.env.ROLLBAR_POST_CLIENT_ITEM_ACCESS_TOKEN
    };
    ENV.segment = {
      WRITE_KEY: process.env.SEGMENT_WRITE_KEY
    };
  }

  ENV['ember-simple-auth-token'].serverTokenEndpoint = ENV.APP.API_HOST + '/api-token-auth/';
  ENV['ember-simple-auth-token'].serverTokenRefreshEndpoint = ENV.APP.API_HOST + '/api-token-refresh/';
  return ENV;
};

@@ -1551,24 +1551,233 @@
 rollbar = %7B%0A
+      // TODO: ember-simple-auth-token is raising errors when tokens expire.%0A      // This generates a ton of error noise in rollbar. It needs to be fixed%0A      // before I can use this.%0A      enabled: false,%0A
       access

Disable Rollbar on JS until I figure out the auth error spamming.