Operational

DocsGithub Open app

Operational

Github Articles Pitch Usecases Playground API

Contents

Start hereSetup Operational
The Manual
IntroductionPWA & push notificationsConventionsSetupTest modeNotifications
Integrations
Nodejs SDKPHP SDKWordpress plugin
Events API
IntroductionSend your first eventEvent parametersStructured EventsActionsContextsCategoriesError handling
Self hosting
IntroductionInstall locallyInstall on VPSInstall on RenderInstall via DockerInstall via Docker and CoolifyOnboardingSetup .envSetup PWA & push notificationsBest practices
Other
VisionRoadmapContributing

Sending contextual events

Contextual events are events-in-events. Think of them as specific group of events that chained together. You can use this to visualized cron jobs, complex functions, workflows, etc.

Here’s a simple example:

// first event
let e = {
  name: "cron job started",
  avatar: "🤖",
  contextId : "1_cron_job", // contextId needs to be common for all contextual events
  contextStart : true // context start is only true for the first contextual event
};

await ops.events.ingest(e);

// later on
e = {
  name: "processing",
  contextId : "1_cron_job",
  content : "343543 job failed"
};

await ops.events.ingest(e);

// some time later
e = {
  name: "processing",
  contextId : "1_cron_job",
  contextId : "183542 job passed"
};

await ops.events.ingest(e);

To start with contextual events, you need to make contextStart : true for the first event in the context and supply a contextId that is common for all contextual events in the chain. Note that you only need to mark the first event in the chain with contextStart:true.

What is the contextId?

Imagine contextual events as part of a chain. To join events together in this chain, you need to have a common id. contextId is exactly that.

However, you need a id that is also sufficiently unique for a chain of events that happen over various time periods and in seperate parts of your codebase.

For instance, if you’re tracking user signup flow, you might want to have "user_signup_" + userId as the contextId. This will generate a context of user_signup events for that specific user only.

Here’s an example.

const e = {
  name : 'Cron job started',
  contextId : 'cronjob_1',
  contextStart : true,
  avatar: "🤖",
}

Then further down your code base, add this in:

const e = {
  name : 'Cron job: processing job',
  contextId : 'cronjob_1',
}

And finally:

const e = {
  name : 'Cron job: processing finished',
  contextId : 'cronjob_1',
  type : "rows",
  content : [
    {
      label : 'Successful jobs',
      content : 10
    },
    {
      label : 'Failed jobs',
      content : 3
    }
  ]
}

Putting it all together, these events will look like this:

ActionsCategories

Operational

Event tracker for your product.

PrivacyTerms
About the product
  • Use cases
  • Playground
  • API
  • Pitch
  • Wordpress plugin
  • Bubble plugin
Related to the product
  • VS Logsnag
  • Open Source
  • Articles
Useful articles for your business
  • Force post: The Payment Hack that lets Merchants charge you without approval
  • 6 Best practices for early stage B2B SaaS customer support
  • Setup event notifications for your SaaS
  • How to get high quality users for your B2B SaaS business?