Server Actions

How to track server actions with PluginPulse

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.

async function(properties, context) {
    const { pluginpulse } = require("pluginpulse");
}

Sending events in server actions

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"

async function(properties, context) {
    const { pluginpulse } = require("pluginpulse");

    // Your existing code...

    await pluginpulse("your-plugin-id", context);
}

Custom data

As with client side actions, you can define the data you want to pass.

async function(properties, context) {
  const { pluginpulse } = require("pluginpulse");
  
  // Your existing code...
  
  await pluginpulse("your-plugin-id", context, {
    event_name: "PDF Generated",
    payload: {
      size: "A4",
    },
  });
}

Last updated