Plugins
Starting with version 0.9.x, the ALTCHA widget supports a variety of plugins that extend its core functionality. Plugins allow you to easily add features like analytics, data obfuscation, and file uploads without modifying the core code.
The available plugins include:
Enabling Plugins
To enable a plugin, simply import the plugin’s script from the altcha
package:
Alternatively, you can include the scripts via a <script>
tag, using files from the dist_plugins
directory or a CDN:
It’s recommended to import plugins before the main altcha
package to ensure they are registered before any widget instances are created.
Analytics Plugin
The Analytics plugin allows you to track form interactions using ALTCHA Forms. It’s easy to enable and doesn’t require additional configuration:
For more details, refer to the HTML submissions documentation.
Obfuscation Plugin
The Obfuscation plugin is designed to protect sensitive data, such as email addresses and phone numbers, by making them difficult for bots to scrape:
After enabling this plugin, configure the obfuscated
attribute on your widget as described in the data obfuscation documentation.
Upload Plugin
The Upload plugin facilitates file uploads from type=file
inputs in custom HTML forms, seamlessly integrating with ALTCHA Forms. It supports automatic uploads and end-to-end encryption (E2E) for files:
For more information, see the HTML submissions documentation.
Advanced Usage
Direct Access
The ALTCHA widget exports a getPlugin(name)
function, which returns an instance of the specified plugin. This allows you to interact with the plugin directly. For example, to add a file using the Upload plugin:
Creating Custom Plugins
If you need functionality beyond what the built-in plugins offer, you can create your own plugin. Here’s a minimal example of how to structure a custom plugin:
The plugin constructor receives a context
argument containing the el
(the widget’s HTML element) and other helpful methods: