Tracking server actions with PluginPulse is as easy as tracking them on the client. The main difference is how you load the PluginPulse tracking code into your plugin.
Importing PluginPulse for server actions
Instead of a script snippet in the header, PluginPulse is loaded into a server action via an npm package in the package.json section in your server action (found at the bottom of the page).
1
Add npm package
package.json
{"dependencies":{"pluginpulse":"latest"}}
2
Rebuild the package.json
3
Import into action
Note: The server action is synchronous by default. To use PluginPulse, convert your function to async.
The overall structure of the event remains very similar. The only change is in order to identify the application, you need to pass the context from the parent function along with your plugin id and payload.
Parameters
Parameter
Required
Description
Example
plugin_id
Yes
Your PluginPulse plugin ID
"1706526741286x876166435619471400"
context
Yes
The context of the action that includes the app identifier
-
event_name
No
Name of the event/feature (default: "Server Action")
"Export PDF"
payload
No
Custom JSON data for additional context
{format: "pdf", pages: 5}
Basic
When passing no information, the below code will result in a PluginPulse event with the name "Server Action"
asyncfunction(properties,context){const{pluginpulse}=require("pluginpulse"); // Your existing code...awaitpluginpulse("your-plugin-id",context);}
Custom data
As with client side actions, you can define the data you want to pass.
The plugin version isn't available in the server action context, so all server events will be sent with the version as backend