Ziplyne DAP SDK
A lightweight pure JavaScript Analytics SDK for React Native that allows apps to send event tracking data to the Ziplyne backend. Now compatible with Expo!
Features
- ✅ Pure JavaScript - No native dependencies required
- ✅ Expo Compatible - Works with Expo managed workflow
- ✅ Cross-Platform - Works on iOS, Android, and Web
- ✅ Simple JavaScript API for tracking events
- ✅ Automatic company identification via API keys
- ✅ Promise-based async API
- ✅ Comprehensive error handling
- ✅ TypeScript support included
Installation
npm install ziplyne-dap-sdk
That's it! No additional setup, no pod install, no native linking required.
Usage
Initialize the SDK
const ZiplyneDAP = require("ziplyne-dap-sdk");
// or with ES6 modules:
// import ZiplyneDAP from "ziplyne-dap-sdk";
// Initialize with your company API key
ZiplyneDAP.init("your_company_api_key");
Track Events
// Track simple events (returns a Promise)
await ZiplyneDAP.track("AppLaunched");
// Track events with properties
await ZiplyneDAP.track("Signup", {
email: "user@example.com",
source: "Referral"
});
await ZiplyneDAP.track("Purchase", {
amount: 49.99,
currency: "USD",
product: "Premium Plan"
});
// Handle errors
try {
await ZiplyneDAP.track("CustomEvent", { userId: "123" });
console.log("Event tracked successfully!");
} catch (error) {
console.error("Failed to track event:", error.message);
}
API Reference
ZiplyneDAP.init(apiKey)
Initializes the SDK with your company's API key.
- Parameters:
apiKey
(string): Your company's unique API key
ZiplyneDAP.track(eventName, properties)
Tracks an event with optional properties.
- Parameters:
eventName
(string): Name of the event to trackproperties
(object, optional): Additional properties for the event
- Returns:
Promise<boolean>
- Resolves totrue
on success - Throws: Error if not initialized, invalid parameters, or network failure
Event Payload
Events are sent to the Ziplyne server with the following structure:
{
"apiKey": "your_company_api_key",
"event": "Signup",
"properties": {
"email": "user@example.com",
"source": "Referral"
},
"timestamp": 1692455123.23
}
Platform Support
- ✅ iOS - Full support
- ✅ Android - Full support
- ✅ Web - Full support
- ✅ Expo - Compatible with managed workflow
Requirements
- React Native: >= 0.60.0 (for React Native projects)
- Expo: Any version (managed or bare workflow)
- Node.js: >= 12.0.0 (for other JavaScript environments)
Error Handling
The SDK includes comprehensive error handling:
- ✅ Validates API key format
- ✅ Ensures SDK is initialized before tracking
- ✅ Handles network errors gracefully
- ✅ Provides clear error messages for debugging
- ✅ Promise-based API for proper async error handling
Why Pure JavaScript?
This SDK was converted from a native iOS implementation to pure JavaScript to:
- ✅ Enable Expo compatibility - Works with Expo managed workflow
- ✅ Simplify installation - No native linking or pod install required
- ✅ Support all platforms - iOS, Android, and Web with one codebase
- ✅ Reduce bundle size - No native dependencies
- ✅ Improve maintainability - Single JavaScript codebase
Migration from v1.0.2
If you're upgrading from the native iOS version:
- Remove native dependencies - No more pod install needed
- Update method calls -
track()
now returns a Promise - Handle async operations - Use
await
or.then()
for tracking calls
// Before (v1.0.2)
ZiplyneDAP.track("Event");
// After (v1.0.3+)
await ZiplyneDAP.track("Event");
License
MIT