Server-Side SDKs
Ensure you have completed the Prerequisites section before continuing.
Installation & Configuration
- Java / Spring Boot
- Node.js
- Python
- Ruby
Spring Boot (recommended)
Add the starter to your build.gradle:
dependencies {
implementation 'com.dashx:dashx-spring-boot-starter:1.6.0'
}
Or with Maven:
<dependency>
<groupId>com.dashx</groupId>
<artifactId>dashx-spring-boot-starter</artifactId>
<version>1.6.0</version>
</dependency>
Configure via application.properties:
dashx.public-key=${DASHX_PUBLIC_KEY}
dashx.private-key=${DASHX_PRIVATE_KEY}
dashx.target-environment=${DASHX_TARGET_ENVIRONMENT}
Or application.yml:
dashx:
public-key: ${DASHX_PUBLIC_KEY}
private-key: ${DASHX_PRIVATE_KEY}
target-environment: ${DASHX_TARGET_ENVIRONMENT}
The starter auto-configures a DashX bean — inject it wherever needed:
import com.dashx.DashX;
import org.springframework.stereotype.Service;
@Service
public class MyService {
private final DashX dashX;
public MyService(DashX dashX) {
this.dashX = dashX;
}
}
Optional properties
| Property | Default | Description |
|---|---|---|
dashx.base-url | https://api.dashx.com/graphql | GraphQL endpoint |
dashx.connection-timeout | 10000 | Connection timeout (ms) |
dashx.response-timeout | 30000 | Response timeout (ms) |
dashx.max-connections | 500 | Connection pool size |
dashx.max-idle-time | 20000 | Max idle time per connection (ms) |
Standalone (without Spring Boot)
Add the core SDK:
dependencies {
implementation 'com.dashx:dashx-java:1.6.0'
}
Configure manually:
import com.dashx.DashX;
import com.dashx.DashXConfig;
DashX dashX = DashX.getInstance();
dashX.configure(
new DashXConfig.Builder()
.publicKey("your-public-key")
.privateKey("your-private-key")
.targetEnvironment("production")
.build()
);
// When done, release resources
dashX.close();
If you're using npm:
npm install @dashx/node
If you're using yarn:
yarn add @dashx/node
const DashX = require('@dashx/node');
// Initialize DashX SDK
const dx = DashX.createClient({
publicKey: process.env.DASHX_PUBLIC_KEY,
privateKey: process.env.DASHX_PRIVATE_KEY,
});
The SDK can also be initialized with no parameters, dashx-node will then look for these env variables DASHX_PUBLIC_KEY and DASHX_PRIVATE_KEY.
const DashX = require('@dashx/node');
// Initialize DashX SDK
const dx = DashX.createClient();
pip install dashx
Add this line to your application's Gemfile:
gem 'dashx'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install dashx
require 'dashx'
DashX.configure do |config|
config.public_key = ENV['DASHX_PUBLIC_KEY']
config.private_key = ENV['DASHX_PRIVATE_KEY']
end
Usage
- Java / Spring Boot
- Node.js
- Python
- Ruby
All methods return CompletableFuture — the SDK uses non-blocking I/O under the hood (Spring WebFlux / Reactor Netty).
Identify a user
import java.util.Map;
dashX.identify(Map.of(
"uid", "123",
"email", "john@example.com",
"firstName", "John",
"lastName", "Doe"
)).thenAccept(account -> {
System.out.println("Identified: " + account.getUid());
});
Supported attributes: uid, anonymousUid, email, phone, name, firstName, lastName.
If no uid or anonymousUid is provided, the SDK generates an anonymous UID automatically.
Keep a member online from your app
If your team works in your own app instead of DashX, mint a member token for the signed-in member and hand it to the browser SDK, which keeps that member online for automatic assignment. Pass the member's email or DashX account id:
String memberToken = dashX.generateMemberToken("agent@example.com").get();
The DashX API mints the token, which lasts 12 hours. This fails with a DashXException if no enabled member has that email or id, or if several enabled members share the email. In that case, pass the account id. Requires SDK 1.7.0 or later.
generateIdentityToken signs tokens for your users and visitors only; use generateMemberToken for a member.
Track events
// Basic event
dashX.track("Button Clicked");
// Event with a user
dashX.track("Button Clicked", "user-uid");
// Event with data
dashX.track("Button Clicked", Map.of(
"label", "Sign Up",
"placement", "header"
));
// Event with user and data
dashX.track("Button Clicked", "user-uid", Map.of(
"label", "Sign Up",
"placement", "header"
));
Send broadcasts
Send push notifications, emails, SMS, WhatsApp, in-app messages, and more:
import com.dashx.graphql.generated.types.CreateBroadcastInput;
import com.dashx.graphql.generated.types.TemplateSubkind;
// Using a template
dashX.sendBroadcast(
CreateBroadcastInput.newBuilder()
.templateSubkind(TemplateSubkind.PUSH)
.templateIdentifier("welcome-push")
.content(Map.of("to", List.of("user-123", "user-456")))
.data(Map.of("promo_code", "WELCOME10"))
.build()
);
// Using inline content
dashX.sendBroadcast(
CreateBroadcastInput.newBuilder()
.templateSubkind(TemplateSubkind.PUSH)
.content(Map.of(
"to", List.of("user-123"),
"title", "Order shipped!",
"body", "Your order #1234 is on its way."
))
.build()
);
Supported TemplateSubkind values: EMAIL, SMS, PUSH, WHATSAPP, IN_APP.
Search records (CMS)
import com.dashx.graphql.utils.SearchRecordsOptions;
dashX.searchRecords("blog",
SearchRecordsOptions.newBuilder()
.filter(Map.of("status", "published"))
.order(List.of(Map.of("created_at", "DESC")))
.limit(10)
.page(1)
.language("en_US")
.preview(true)
.build()
).thenAccept(records -> {
records.forEach(System.out::println);
});
Asset management
// Get a single asset
dashX.getAsset("asset-id").thenAccept(asset -> {
System.out.println(asset.getUrl());
});
// List assets with filtering and pagination
dashX.listAssets(
Map.of("resourceId", "resource-uuid"), // filter
List.of(Map.of("createdAt", "DESC")), // order
10, // limit
1 // page
);
Issue management
Every issue call returns a CompletableFuture. Call .get() (or .join()) to wait for the result, or chain it.
Create an issue
Save the issue id that createIssue (or upsertIssue) returns against your own record. You need it to read or update the issue later.
import com.dashx.graphql.generated.types.CreateIssueInput;
import com.dashx.graphql.generated.types.Issue;
import com.dashx.graphql.generated.types.IssuePriority;
Issue issue = dashX.createIssue(
CreateIssueInput.newBuilder()
.title("Login button broken on mobile")
.issueType("Bug")
.issueStatus("Open")
.group("Engineering")
.priority(IssuePriority.HIGH)
.description("The login button is unresponsive on iOS Safari.")
.labels(List.of("mobile", "auth"))
.properties(Map.of("browser", "Safari", "os", "iOS 17"))
.requestedBy(Map.of("uid", "user-123", "name", "Jane Doe"))
.build()
).get();
String issueId = issue.getId();
Create or update by your own key (upsert)
upsertIssue takes an idempotencyKey, such as your own record's id. The first call creates the issue. Later calls with the same key update that issue instead of creating a new one, so you can call it whenever your record changes, for example to sync its status.
import com.dashx.graphql.generated.types.UpsertIssueInput;
dashX.upsertIssue(
UpsertIssueInput.newBuilder()
.idempotencyKey("order-1042")
.issueType("Bug")
.title("Login button broken on mobile")
.issueStatus("In Progress")
.build()
).get();
On an update, fields you leave unset keep their current value. title is required on every call and replaces the current title. Upsert cannot clear a field. To remove the assignee, description, due date, group or parent, use updateIssue.
Get an issue
import com.dashx.graphql.generated.types.Account;
Issue issue = dashX.getIssue(issueId).get();
String status = issue.getIssueStatus().getName();
Account assignee = issue.getAssignee(); // null if unassigned
For an account's display name, use getFirstName() and getLastName(). getName() can be empty.
Update an issue
updateIssue changes only the fields you set on the builder. Unlike upsertIssue, it can clear fields, and it can change the assignee and the status in the same call.
import com.dashx.graphql.utils.UpdateIssueInput;
// Assign
dashX.updateIssue(
UpdateIssueInput.newBuilder(issueId).assigneeId(agentId).build()
).get();
// Unassign and change the status together
dashX.updateIssue(
UpdateIssueInput.newBuilder(issueId)
.clearAssignee()
.issueStatus("Approved")
.build()
).get();
| Builder method | Effect |
|---|---|
issueStatus(String) | Status by id, identifier or exact name. It must belong to the issue's type. |
assigneeId(String) / clearAssignee() | Sets or removes the assignee. After clearAssignee(), if the issue's group has an auto-assignment rule for the resulting status, the issue may be assigned again right away. |
title(String) | |
description(String) / clearDescription() | |
priority(IssuePriority) | |
position(Integer) | |
properties(Map) | Custom field values. |
labels(List) | |
dueAt(String) / clearDueAt() | ISO 8601 timestamp. |
group(String) / clearGroup() | Group by id or name. |
parent(String) / clearParent() | Parent issue id. |
requestedBy(Map) | Requester, identified like identify, e.g. Map.of("email", "...") or Map.of("uid", "..."). |
DashX records each change in the issue's activity log, so you don't need to write it yourself.
List the agents in a group
To show who an issue can be assigned to, list the members of a group by its id or exact name. Group membership is managed in DashX.
List<Account> agents = dashX.listGroupMembers("Support").get();
This fails with a DashXException if no member group has that id or name, or if more than one member group has that name. In that case, pass the id.
To find a single agent by email instead, use findMemberByEmail. It ignores users and visitors with the same email.
Optional<Account> agent = dashX.findMemberByEmail("agent@example.com").get();
Issue history
getIssueActivity returns an issue's history, oldest first. Each entry includes the actor and, for assignee, status, group and requester changes, the old and new values.
import com.dashx.model.IssueActivity;
for (IssueActivity entry : dashX.getIssueActivity(issueId).get()) {
if (entry.isAssigneeChange()) {
Account from = entry.getFromAssignee();
Account to = entry.getToAssignee();
}
}
List and count issues
List<Issue> urgent = dashX.listIssues(
Map.of("priority", Map.of("eq", "URGENT")),
List.of(Map.of("createdAt", "desc")),
50, // limit
1 // page
).get();
int count = dashX.aggregateIssues(
Map.of("priority", Map.of("eq", "URGENT"))
).get().getCount();
Error handling
The SDK throws three types of exceptions, all extending DashXException (a RuntimeException):
DashXConfigurationException— Missing or invalid configuration (e.g., nullpublicKey, negative timeout)DashXValidationException— Invalid method arguments (e.g., null options, empty event name)DashXGraphQLException— Errors returned by the DashX API; callgetErrors()to inspect individual GraphQL errors
import com.dashx.exception.*;
dashX.track("Event").exceptionally(ex -> {
Throwable cause = ex.getCause();
if (cause instanceof DashXGraphQLException graphQLEx) {
// Server returned GraphQL errors
graphQLEx.getErrors().forEach(e -> System.err.println(e.getMessage()));
} else if (cause instanceof DashXValidationException) {
// Invalid arguments (null event name, etc.)
} else if (cause instanceof DashXConfigurationException) {
// SDK not configured or misconfigured
}
return null;
});
Resource cleanup
Call close() to release the underlying connection pool when the SDK is no longer needed. In Spring Boot, this is handled automatically.
DashX dashX = DashX.getInstance();
dashX.configure(config);
// ... use the client ...
dashX.close();
Named instances
For advanced use cases (e.g., different keys for analytics vs. notifications):
DashX analytics = DashX.getInstance("analytics");
analytics.configure(analyticsConfig);
DashX notifications = DashX.getInstance("notifications");
notifications.configure(notificationsConfig);
// Clean up a specific instance
DashX.removeInstance("analytics");
// Or clean up all instances
DashX.resetInstances();
Connection tuning
The SDK uses connection pooling with configurable timeouts. Here are recommended values by traffic level:
| Scenario | connection-timeout | response-timeout | max-connections | max-idle-time |
|---|---|---|---|---|
| Low (< 100 req/min) | 10000 | 30000 | 100 | 20000 |
| Medium (100–1000 req/min) | 10000 | 30000 | 500 | 30000 |
| High (> 1000 req/min) | 15000 | 45000 | 1000 | 60000 |
| Behind proxy / load balancer | 20000 | 60000 | 500 | 45000 |
Troubleshooting
If you encounter "Connection prematurely closed BEFORE response" errors, increase timeouts:
dashx.response-timeout=60000
dashx.connection-timeout=20000
Enable debug logging in application.properties:
logging.level.com.dashx=DEBUG
logging.level.reactor.netty=DEBUG
Coming soon — refer to the @dashx/node README for usage examples.
Coming soon — refer to the dashx Python README for usage examples.
Coming soon — refer to the dashx Ruby README for usage examples.