Skip to main content

Custom Event Instrumentation

Generates: Events

Track custom business events, user actions, and application milestones.

Basic Usage

Track Event with Attributes

// Track a custom event
PulseSDK.INSTANCE.trackEvent(
name = "purchase_completed",
observedTimeStampInMs = System.currentTimeMillis(),
params = mapOf(
"amount" to 99.99,
"currency" to "USD",
"itemCount" to 3,
),
)

Track Event Without Attributes

// Track without attributes
PulseSDK.INSTANCE.trackEvent(
name = "app_opened",
observedTimeStampInMs = System.currentTimeMillis(),
)

Common Use Cases

E-commerce Events

PulseSDK.INSTANCE.trackEvent(
name = "product_viewed",
observedTimeStampInMs = System.currentTimeMillis(),
params = mapOf(
"productId" to "SKU-12345",
"category" to "electronics",
"price" to 299.99,
),
)

User Actions

PulseSDK.INSTANCE.trackEvent(
name = "button_clicked",
observedTimeStampInMs = System.currentTimeMillis(),
params = mapOf(
"buttonId" to "checkout",
"screen" to "CartScreen",
),
)

Generated Telemetry

Type: Log Record (Event)
Body: Custom event name (set by you)
pulse.type: custom_event

Attributes

Custom Event Attributes

AttributeDescriptionExampleAlways Present
pulse.typeInstrumentation type"custom_event"✅ Yes
screen.nameCurrent screen/activity name"MainActivity"⚠️ If available
session.idSession identifier"f40364c92b85ec0c19c35a65be42b97f"✅ Yes
Custom attributesAny key-value pairs you defineproductId: "SKU-12345", amount: 99.99⚠️ Only if provided

Note: All custom events include global attributes (service, device, OS, session, network carrier, etc.) in the resources object. See Global Attributes for complete list.

Sample Payload: Custom Event

{
"body": "product_viewed",
"date": "2025-11-27T08:43:00.000000Z",
"id": "0iiPdg5oW57kWey8dHienFjlP9S",
"timestamp": "2025-11-27T08:43:00.000000Z",
"attributes": {
"pulse.type": "custom_event",
"productId": "SKU-12345",
"category": "electronics",
"price": 299.99,
"screen.name": "MainActivity",
"session.id": "f40364c92b85ec0c19c35a65be42b97f"
},
"resources": {
"android.os.api_level": "36",
"app.build_id": "1",
"app.build_name": "1.0_1",
"device.manufacturer": "Google",
"device.model.identifier": "sdk_gphone64_arm64",
"device.model.name": "sdk_gphone64_arm64",
"os.description": "BE2A.250530.026.D1",
"os.name": "Android",
"os.type": "linux",
"os.version": "16",
"rum.sdk.version": "0.16.0-alpha-SNAPSHOT",
"service.name": "PulseReactNativeOtelExample",
"service.version": "1.0_1",
"telemetry.sdk.language": "java",
"telemetry.sdk.name": "opentelemetry",
"telemetry.sdk.version": "1.54.1"
}
}

Note: The name parameter you provide becomes the body of the log record. The pulse.type is always "custom_event".