Skip to main content
Version: Isle Royale (2.5.0)

Sandbox Environments

Learn how to use ToughClicks sandbox environments for development and testing without affecting production data.

Overview​

ToughClicks provides a separate staging environment that allows you to develop and test your integration safely before going live. The sandbox environment is an isolated instance with its own data, allowing you to:

  • Test your integration during development
  • Experiment with different configurations
  • Validate workflows before production
  • Train your team on the platform

Requesting Access​

To use a sandbox environment during development:

  1. Contact your ToughClicks account representative
  2. Request staging environment access
  3. Receive separate credentials for the staging environment

Your ToughClicks representative will set up a sandbox account with appropriate permissions and provide you with staging-specific credentials.

Accessing the Sandbox Portal​

Once configured, you can access the staging management portal at:

https://app.stage.toughclicks.com

This portal is completely separate from the production environment and includes:

  • Separate client configurations
  • Independent document management
  • Isolated packet creation
  • Dedicated testing data

Integration with JavaScript Library​

To use the sandbox environment in your application, pass the TCEnvironment.staging parameter when instantiating the library.

NPM Installation​

import { ToughClicks, TCEnvironment } from '@toughclicks/js-client-sdk';

const tc = new ToughClicks(
clientToken, // Your staging client token
packetId, // Your staging packet ID
true, // Enable debug mode (recommended for development)
TCEnvironment.staging // Use staging environment
);

CDN Installation​

<script src="https://cdn.toughclicks.com/lib/latest/toughclicks.umd.js"></script>

<script>
const { ToughClicks, TCEnvironment } = window.ToughClicks;

const tc = new ToughClicks(
clientToken,
packetId,
true,
TCEnvironment.staging
);
</script>

Complete Example​

Here's a full example using the sandbox environment:

import {
ToughClicks,
TCEnvironment,
TCDisplayMethod
} from '@toughclicks/js-client-sdk';
import '@toughclicks/js-client-sdk/toughclicks.css';

// Staging credentials
const STAGING_CLIENT_TOKEN = 'your-staging-client-token';
const STAGING_PACKET_ID = 'your-staging-packet-id';

// Initialize with staging environment
const tc = new ToughClicks(
STAGING_CLIENT_TOKEN,
STAGING_PACKET_ID,
true, // Enable debug logging
TCEnvironment.staging
);

// Configure display options
tc.setDisplayOptions({
containerId: 'tc-agreements',
signerIdSelector: 'userEmail',
displayMethod: TCDisplayMethod.individual,
shouldOpenModal: true
});

// Render
tc.render().then(() => {
console.log('ToughClicks rendered successfully in staging mode');
});

Environment Configuration​

Using Environment Variables​

For better configuration management, use environment variables to switch between staging and production:

import { ToughClicks, TCEnvironment } from '@toughclicks/js-client-sdk';

const config = {
production: {
clientToken: process.env.TOUGHCLICKS_PROD_TOKEN,
packetId: process.env.TOUGHCLICKS_PROD_PACKET,
environment: TCEnvironment.production,
debug: false
},
staging: {
clientToken: process.env.TOUGHCLICKS_STAGING_TOKEN,
packetId: process.env.TOUGHCLICKS_STAGING_PACKET,
environment: TCEnvironment.staging,
debug: true
}
};

const env = process.env.NODE_ENV === 'production' ? 'production' : 'staging';
const { clientToken, packetId, environment, debug } = config[env];

const tc = new ToughClicks(clientToken, packetId, debug, environment);

TypeScript Example​

import {
ToughClicks,
TCEnvironment,
TCDisplayOptions,
TCDisplayMethod
} from '@toughclicks/js-client-sdk';

interface EnvironmentConfig {
clientToken: string;
packetId: string;
environment: TCEnvironment;
debug: boolean;
}

const getConfig = (): EnvironmentConfig => {
const isDev = process.env.NODE_ENV !== 'production';

return {
clientToken: isDev
? process.env.VITE_TC_STAGING_TOKEN!
: process.env.VITE_TC_PROD_TOKEN!,
packetId: isDev
? process.env.VITE_TC_STAGING_PACKET!
: process.env.VITE_TC_PROD_PACKET!,
environment: isDev ? TCEnvironment.staging : TCEnvironment.production,
debug: isDev
};
};

const config = getConfig();
const tc = new ToughClicks(
config.clientToken,
config.packetId,
config.debug,
config.environment
);

Best Practices​

1. Keep Credentials Separate​

Never use production credentials in staging or vice versa. Store them separately:

# .env.development
VITE_TC_CLIENT_TOKEN=your-staging-client-token
VITE_TC_PACKET_ID=your-staging-packet-id
VITE_TC_ENVIRONMENT=staging

# .env.production
VITE_TC_CLIENT_TOKEN=your-production-client-token
VITE_TC_PACKET_ID=your-production-packet-id
VITE_TC_ENVIRONMENT=production

2. Enable Debug Mode in Staging​

Always enable debug mode when using the staging environment:

const tc = new ToughClicks(
clientToken,
packetId,
true, // Debug enabled for staging
TCEnvironment.staging
);

// You can also enable it later
tc.setDebug(true);

// Print current state for debugging
tc.printState();

3. Use Visual Indicators​

Make it clear when you're in staging mode:

if (tc.environment === TCEnvironment.staging) {
// Add a visual indicator
const banner = document.createElement('div');
banner.style.cssText = `
position: fixed;
top: 0;
width: 100%;
background: #ff9800;
color: white;
text-align: center;
padding: 8px;
font-weight: bold;
z-index: 10000;
`;
banner.textContent = 'STAGING ENVIRONMENT';
document.body.prepend(banner);
}

4. Test All Scenarios​

Use the staging environment to test:

  • Initial document acceptance
  • Force reacceptance workflows
  • Dynamic contract rendering
  • Custom data population
  • Error handling
  • Edge cases and boundary conditions

5. Mirror Production Setup​

Configure your staging packets to mirror your production configuration as closely as possible:

  • Same document structure
  • Similar version numbering
  • Matching display configurations
  • Identical custom data schemas

Testing Workflow​

A typical development workflow using staging:

  1. Initial Setup - Configure staging environment credentials
  2. Development - Build features using staging
  3. Testing - Validate all acceptance workflows
  4. QA - Conduct thorough testing with staging data
  5. Production Prep - Switch credentials to production
  6. Deployment - Deploy with production configuration
  7. Monitoring - Monitor production with debugging disabled

Differences from Production​

The staging environment is functionally identical to production with these exceptions:

  • Separate Data - All data is isolated from production
  • Uptime SLA - May have scheduled maintenance windows
  • Performance - May not be optimized for high-scale load
  • Features - May include experimental features not yet in production

Troubleshooting​

Environment Not Switching​

If the library isn't connecting to staging:

// Verify environment is set correctly
console.log('Environment:', tc.environment);

// Should output: "staging"

// Enable debug to see API endpoints
tc.setDebug(true);

Invalid Credentials​

Ensure you're using staging-specific credentials:

  • Staging client tokens won't work in production
  • Production tokens won't work in staging
  • Packet IDs are environment-specific

SSL/Certificate Issues​

The staging environment uses valid SSL certificates. If you encounter SSL issues:

  • Ensure you're using https:// URLs
  • Check that your system trusts standard certificate authorities
  • Verify no proxy or firewall is interfering

Moving to Production​

When you're ready to move from staging to production:

  1. Obtain production credentials from ToughClicks
  2. Update environment variables
  3. Change TCEnvironment.staging to TCEnvironment.production (or remove it as production is default)
  4. Disable debug mode
  5. Test thoroughly in production
  6. Monitor error logs
// Before (staging)
const tc = new ToughClicks(
stagingToken,
stagingPacketId,
true,
TCEnvironment.staging
);

// After (production)
const tc = new ToughClicks(
productionToken,
productionPacketId,
false, // Disable debug
TCEnvironment.production // Or omit this parameter
);

Next Steps​