developers:javascript-api:modules:configs

Configs

How to configure a client, how configurations are overriden and what configuration capabilities there are.

Overriding Configurations

All configurations have a default value. This value will be used if no other value is submitted. There are two ways to submit a custom configuration to the JavaScript API.

Starting Configuration

The JavaScript API can be started using configurations. When calling the start function of the API, we can pass an object with a “configs” property submitting values. An example would be:

<html>
  <head>
    <script src="https://duckprove.com/sites/example.js"></script>
    <script type="text/javascript">duckprove.start({ configs: { enableConsoleWarnings: false } });</script>
  </head>
</html>

Using this method, all users will have the submitted configuration. However, this configuration can be overriden per user using the browser console.

Local Configuration

In most browsers there are developer tools, which usually can be opened using F12. If we open the console in the developer tools, we can execute the following command as an example:

duckprove.configs.enableTimings(true);

This will enable timing information for this browser. Those settings are stored in the local storage. Those settings can also be changed using the set-function:

duckprove.configs.set('enableTimings', true);

Restoring Configurations

All local settings can be reset to the default values using the following command:

duckprove.configs.reset();

This command drops local stored configurations. That means, configurations passed in the start function will still apply. If there is a string passed to the reset function, it will search for a setting called like the passed string, and only drop that configuration. An example:

duckprove.configs.reset('enableSystem');

This would only reset the local configuration of the enableSystem setting.

Available Functions

duckprove.configs.set(key, value)

This function sets the key passed to the value. Only the local configuration will be affected. Other users will not be affected of this change.

duckprove.configs.reset([key])

If a key is passed, the local configuration of this key will be deleted. Otherwise, all local configurations will be deleted.

duckprove.configs._____([value])

For all configuration keys, there is a function available. if the value is passed, the local configuration will be set using this value. If no parameters are passed into this function, it will return the current value.

Available Configurations

enableAutoViewTracking

The default value for this setting is true. If this setting is enabled, a view is automatically created when the JavaScript API is started.

enableSystem

The default value for this setting is true. The enableSystem setting can disable DuckProve completely. If set to true, which is the default, the system will be enabled. If the system is disabled, tracking will be disabled, no experiments and no site scripts will be executed.

enableTracking

The default value for this setting is true. The enableTracking setting can disable all tracking features. This is particularly useful on test systems. If this value is set to false, no values and page views will arrive in the DuckProve backend.

enableTimings

The default value for this setting is false. The enableTimings setting can enable timing information, which is useful for testing resource intensive experiments. If enabled, for each experiment it will output the duration of the execution in the browser console. This feature requires timing functionality of a browser.

enableConsoleInfos

The default value for this setting is false. The enableConsoleInfos setting can enable debugging information in the browser console. This is kind of changing the log level to a debugging mode.

enableConsoleWarnings

The default value for this setting is true. The enableConsoleWarnings setting can disable warnings in the browser console. Generally, if an experiment or a site script fails to execute because of a syntax or runtime error, a warning will be sent to the browser console. If this setting is set to true, those warnings will appear.

enableRun

The default value for this setting is true. The enableRun setting can disable experiments from being executed if not logged in. This setting will have no effect on tracking, and a user which has running disabled will still be considered as a participant.

enablePreview

The default value for this setting is true. The enablePreview setting can disable all experiments from being executed if logged in. This setting will have no effect on tracking.

sessionDuration

The default value for this setting is 1800. The sessionDuration setting will control how long a session of a user will be valid. This setting is in seconds. By default, the user will receive a new session key if 1800 seconds of inactivity occur.

sampleRate

The default value for this setting is 1. The sampleRate setting will control the chance of this user to participate in the DuckProve system. If the user is not considered a sample, no experiments will be executed and no tracking will occur. By default, 100% of users are participating. If this setting was set to 0.5, only 50% of users would be participating.

validateParticipation

The default value for this setting is true. If this setting is enabled, users which have a corrupt participation or fixation length will not be tracked.