Set up User Simulation

The Muxy debugging system provides user-simulation for testing and debugging in the development environment.

In production, the Muxy JS SDK automatically detects specific information about the current user and their role, and uses that information to provide a context for API calls.

In your development environment, you can provide test values to simulate these environment-specific values that are normally auto-detected. The simulated values are used only in development mode and are ignored once the extension is released on Twitch, so you can include these calls in both development and production code and still have the correct behavior.

Setting simulated user values

Provide the simulated values as options to the debug() function:

const opts = new Muxy.DebuggingOptions();
opts
  .channelID('5678')
  .userID('1234')
  .role('viewer');

Muxy.debug(opts);

const medkit = new Muxy.SDK();
medkit.loaded().then(() => {
  console.log('MEDKit is ready to roll!');
});

The following debug options are available:

Option

Value

channelID

String, Sets the current channel (the Twitch channel the viewer is "watching")

userID

String. Sets the current user's Twitch ID

role

String, Sets the current user's role. Valid values are viewer, broadcaster, admin

jwt

String, A self-signed JWT to use for all backend request

Using a self-signed JWT

One of the more powerful debugging options is the jwt. Since, as a developer,
you have access to the Client ID and Secret for your extension, you can sign a
JWT that will verify your requests. We do this internally for you when your
extension is running in sandbox or production environments, but you may want to
do it yourself if you are running parts of your extension on your own site.

The process is the same as the Signing the JWT section of Server Communication.

Once you have your encoded JWT (in the form eyJhbGciOiJIUzI1NiIsInR5cCI6I...),
you can pass this as a debugging option when initializing the Muxy SDK.

This token gives you full access to the broadcaster-only functionality, if the JWT payload
contains those privileges.

const opts = new Muxy.DebuggingOptions();
opts.role('broadcaster').jwt('eyJhbGciOiJIUzI1NiIsInR5cCI6I...');

Muxy.debug(opts);
Muxy.setup({
  clientID: '<extension client id>'
});

// instantiate the SDK control class
const medkit = new Muxy.SDK();
medkit.loaded().then(() => {
  medkit.setChannelState({ broadcasters_age: 24 }); // Normally live-dashboard or config only.
});