# Collect events from apps you developed ## Start collecting events from your mobile, desktop, server, and CLI apps. Collect and unify events from your applications using Krenalis SDKs. Whether mobile, desktop, server-side, CLI, or IoT devices, each SDK lets you track events and identify users to maintain a consistent customer view. > For integrating Krenalis with websites and web apps, see the [websites integration](https://www.krenalis.com/docs/collect-events/websites.md). ## Prerequisites Before you start, make sure you have: * Access to your app's codebase and configuration. * A basic understanding of the programming language your app uses. These will help you install the Krenalis SDK and connect your app without issues. ## Steps ### 1. Connect an application Create a **source connection** for your app: 1. Go to the **Sources** page in your Krenalis workspace. 2. Click **Add a new source ⊕**, then select the card for your platform or language. 3. Click **Add source...**. 4. (Optional) Rename the connection if needed. 5. Click **Add** to confirm. The new source connection appears under **Sources** in the sidebar and can be reopened at any time. ### 2. Set up your application Depending on your application's environment, install or import the Krenalis SDK for your platform. #### Android 1. Add the dependency to your `build.gradle`: ##### Kotlin ```kotlin repositories { mavenCentral() } dependencies { implementation 'com.krenalis.analytics.kotlin:android:' } ``` ##### Java ```java repositories { mavenCentral() } dependencies { implementation 'com.krenalis.analytics.kotlin:android:' } ``` 2. Add the following permissions to your `AndroidManifest.xml` if not already present: ```xml ``` 3. Import and use the SDK: 💡 You can find the _event write key_ in Krenalis inside the Android source connection in **Settings → Event write keys**. ##### Kotlin ```kotlin import com.krenalis.analytics.kotlin.android.Analytics import kotlinx.serialization.json.buildJsonObject import kotlinx.serialization.json.put val client = Analytics("YOUR_WRITE_KEY", applicationContext) { endpoint = "YOUR_ENDPOINT" trackApplicationLifecycleEvents = true flushAt = 3 flushInterval = 10 // ...other config options } client.track( "Workout completed", buildJsonObject { put("workout_type", "Cardio"); put("duration_minutes", 45); put("calories_burned", 380); put("device", "Smartwatch") }, ) ``` ##### Java ```Java import com.krenalis.analytics.kotlin.core.Analytics; import com.krenalis.analytics.kotlin.android.AndroidAnalyticsKt; import com.krenalis.analytics.kotlin.core.compat.JavaAnalytics; import kotlin.Unit; AndroidAnalytics client = AndroidAnalyticsKt.Analytics("YOUR_WRITE_KEY", getApplicationContext(), configuration -> { configuration.setEndpoint("YOUR_ENDPOINT"); configuration.setTrackApplicationLifecycleEvents(true); configuration.setFlushAt(3); configuration.setFlushInterval(10); // ...other config options return Unit.INSTANCE; }); JavaAnalytics analyticsCompat = new JavaAnalytics(client); Map properties = new HashMap<>(); properties.put("workout_type", "Cardio"); properties.put("duration_minutes", 45); properties.put("calories_burned", 380); properties.put("device", "Smartwatch"); analyticsCompat.track("Workout completed", properties); ``` #### iOS 1. Add the Krenalis SDK for iOS to your project. In your `Package.swift`, add the following dependency: ```swift dependencies: [ .package(url: "https://github.com/krenalis/analytics-swift", from: "") ] ``` Then add `Krenalis` as a dependency of your target: ```swift .target( name: "YourApp", dependencies: [ .product(name: "Krenalis", package: "analytics-swift") ]) ``` Or, in Xcode, go to **File → Add Package Dependencies...** and enter the repository URL. 2. Import and use the SDK: 💡 You can find the _event write key_ in Krenalis inside the iOS source connection in **Settings → Event write keys**. ```swift import Krenalis let analytics = Analytics(configuration: Configuration(writeKey: "YOUR_WRITE_KEY") .endpoint("YOUR_ENDPOINT") .trackApplicationLifecycleEvents(true) .flushAt(3) .flushInterval(10)) analytics.track(name: "Workout completed", properties: [ "workout_type": "Cardio", "duration_minutes": 45, "calories_burned": 380, "device": "Smartwatch" ]) ``` #### .NET 1. In Krenalis, open your .NET source connector → **Settings → Event write keys**. 2. Copy the **event write key** and **endpoint**. 3. Install the package: ```sh dotnet add package Krenalis.Analytics --version ``` 4. Initialize the client: ```csharp using Krenalis; using Krenalis.Model; var config = new Config().SetEndpoint(""); Analytics.Initialize("", config); Analytics.Client.Track( "user-123", "Workout Completed", new Properties { { "workout_type", "Cardio" }, { "duration_minutes", 45 }, { "calories_burned", 380 }, { "device", "Smartwatch" } }) ); Analytics.Client.Flush(); Analytics.Client.Dispose(); ``` #### Node.js The Node SDK can be imported with `import` into Node projects, using ES6 modules. 1. In Krenalis, open your Node.js source connection → **Settings → Event write keys**. 2. Copy the **event write key** and **endpoint**. 3. Install the SDK: ```sh npm install @krenalis/nodejs-sdk --save ``` 4. Import and use it: ```javascript import Analytics from '@krenalis/nodejs-sdk'; const client = new Analytics('', ''); client.track({ userId: "user-123", event: 'Workout Completed', properties: { workout_type: 'Cardio', duration_minutes: 45, calories_burned: 380, device: 'Smartwatch' } }); ``` #### Java 1. In Krenalis, open your Java source connection → **Settings → Event write keys**. 2. Copy the **event write key** and **endpoint**. 4. Add `com.krenalis.analytics.java` to `pom.xml`: ```xml com.krenalis.analytics.java analytics LATEST ``` 5. Import and use the SDK: ```java import com.krenalis.analytics.Analytics; import com.krenalis.analytics.messages.IdentifyMessage; final Analytics analytics = Analytics.builder("") .endpoint("") .build(); analytics.enqueue( TrackMessage.builder("Workout Completed") .userId("703991475") .properties(new com.krenalis.analytics.messages.Properties() .putValue("workout_type", "Cardio") .putValue("duration_minutes", 45) .putValue("calories_burned", 380) .putValue("device", "Smartwatch")) ); ``` #### Python 1. In Krenalis, open your Python source connection → **Settings → Event write keys**. 2. Copy the **event write key** and **endpoint**. 3. Install the SDK: ```sh pip3 install git+https://github.com/krenalis/analytics-python ``` 4. Import and use the package: ```python import krenalis.analytics as analytics analytics.write_key = '' analytics.endpoint = '' analytics.track( user_id="703991475", event="Workout Completed", properties={ "workout_type": "Cardio", "duration_minutes": 45, "calories_burned": 380, "device": "Smartwatch", }, ) ``` #### Go 1. In Krenalis, open your Go source connection → **Settings → Event write keys**. 2. Copy the **event write key** and **endpoint**. 3. In your Go module, go get the `"github.com/krenalis/analytics-go"` package: ```sh go get github.com/krenalis/analytics-go ``` 5. Import and use the package: ```go import "github.com/krenalis/analytics-go" client := analytics.New("", "") client.Enqueue(analytics.Track{ AnonymousId: "ac3496a8-0782-4173-856f-2f7dd37d7f14", UserId: "703991475", Event: "Workout Completed", Properties: analytics.Properties{ "workout_type": "Cardio", "duration_minutes": 45, "calories_burned": 380, "device": "Smartwatch", }, }) ``` ### 3. Debug the events Use the **Event debugger** in your source connection to verify that events are received correctly. 1. In Krenalis, open your source connection. 2. Go to the **Event debugger** tab. [Event debugger](/docs/collect\-events/images/event\-debugger\.android\.png)! It shows a live sample of the most recent events received for this source connection. Use it whenever you need to quickly confirm that events are arriving as expected and to inspect their contents in real time. 3. Run your application and trigger the code that calls `track`. The event should appear almost immediately: [Event debugger](/docs/collect\-events/images/event\-debugger\-track\.android\.png)! 4. Click the collected event in the **Event debugger** list to view its JSON payload, which contains the data sent by your app. The following example shows what a typical event payload looks like: ```json { "anonymousId": "b27c5d9f-92a7-4d30-b21a-4df21a6872c2", "context": { "browser": { "name": "Safari", "version": "17.2.1" }, "ip": "172.91.24.57", "library": { "name": "krenalis.js", "version": "1.0.0" }, "locale": "en-US", "os": { "name": "macOS", "version": "14.5" }, "page": { "path": "/dashboard", "title": "User Dashboard", "url": "https://app.example.com/dashboard" }, "screen": { "width": 3024, "height": 1964, "density": 2 }, "session": { "id": "1766272512048" }, "timezone": "America/Los_Angeles", "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 14_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2.1 Safari/605.1.15" }, "event": "Workout Completed", "messageId": "f9189a52-b37b-4d7d-9f2d-08b91d85fa9c", "properties": { "workout_type": "Cardio", "duration_minutes": 45, "calories_burned": 380, "device": "Smartwatch" }, "receivedAt": "2025-10-20T16:15:24.340Z", "sentAt": "2025-10-20T16:15:24.327Z", "originalTimestamp": "2025-10-20T16:15:23.992Z", "timestamp": "2025-10-20T16:15:24.010Z", "traits": { "email": "emily.johnson@example.com", "plan": "Enterprise", "company": "Acme Corp", "jobTitle": "Product Manager", "country": "United States" }, "type": "track", "userId": "703991475" } ``` If no event appears after a few seconds: - Check your application logs for errors. - Ensure your **event write key** and **endpoint** are correct. 💡 See the [Event spec](https://www.krenalis.com/docs/collect-events/spec.md) for full details on the event schema. ### 4. Add a pipeline to import events 1. Click on the **Pipelines** tab of the connection for Android. 2. Next to the **Import events into warehouse** pipeline, click **Add pipeline...**. [Import events into warehouse](https://www.krenalis.com/docs/collect-events/images/import-events-into-warehouse.android.png)! This is an "Import users" pipeline type, which transfers identified user profiles from your application into your warehouse. > Each pipeline defines how and when event data flows from your source into the warehouse. You can add multiple pipelines per connection to handle different data segments or destinations. ### 5. Filter events If you don't want to import all events from your apps, use filters to select which events to import. Only events that match the filter conditions will be imported. If no filters are set, all events from the apps will be imported. For more information on how to use filters, see the [Filters documentation](https://www.krenalis.com/docs/filters.md). [Filter events](https://www.krenalis.com/docs/collect-events/images/filter-events.png)! In the example above, only `track` events are imported. ### 6. Save your changes When you're done, click **Add** (or **Save** if you're editing an existing pipeline). The new pipeline will appear in your source connection and can be edited or disabled at any time. ## Pipelines Once saved, the new pipeline appears in the pipelines list for Android. From here, you can monitor imports and adjust filters. Each pipeline defines how and when events flow from Android into your warehouse. [Pipeline to export user data](https://www.krenalis.com/docs/collect-events/images/pipelines.android.png)! | Column | Description | |--------------|-------------------------------------------------------------------------------------------| | **Pipeline** | Name and description of the pipeline. | | **Filters** | Conditions used to select which events are imported. If not set, all events are included. | | **Enable** | Switch to activate or deactivate the pipeline. When disabled, no events are imported. | | **Manage** | Edit settings such as filter. | | **⋮ (More)** | Additional options, such as deleting the pipeline. |