API reference

Complete API documentation for Amply SDK.

Core Classes

Amply

The main SDK class for tracking events and managing campaigns.

class Amply(config: AmplyConfig, application: Application)

Methods

track

Tracks a custom event with optional properties.

Signature

fun track(event: String, properties: Map<String, Any> = emptyMap())

Parameters

Parameter
Type
Description

event

String

The event name

properties

Map<String, Any>

Optional event properties

Example


registerDeepLinkListener

Registers a listener for deep link actions from campaigns.

Signature

Parameters

Parameter
Type
Description

listener

DeepLinkListener

Callback for deep link events

DeepLinkListener Interface

Returns true if the deep link was handled, false otherwise.


setSystemEventsListener

Registers a listener for SDK system events.

Signature

SystemEventsListener Interface

System Events

Event Name
Description

SDK_INITIALIZED

SDK initialization complete

SESSION_START

New session started

SESSION_END

Session ended

CAMPAIGNS_LOADED

Campaigns fetched from server


getRecentEvents

Retrieves recent events from local storage.

Signature

Parameters

Parameter
Type
Default
Description

limit

Int

30

Maximum events to return

Returns

List of EventInterface objects, newest first.


getDataSetSnapshot

Retrieves a snapshot of a dataset for debugging or preview.

Signature

Parameters

Parameter
Type
Description

type

DataSetType

The dataset type to retrieve


Configuration

AmplyConfig

Configuration class for SDK initialization.

Android (DSL)

iOS

Properties

Property
Type
Required
Description

appId

String

Yes

Application identifier

apiKeyPublic

String

Yes

Public API key

apiKeySecret

String

Yes

Secret API key

defaultConfig

String?

No

Default campaign config JSON

configBaseUrl

String?

No

Config server URL override

backendBaseUrl

String?

No

Backend server URL override


Data Types

DataSetType

Sealed class representing dataset types for rule evaluation.

Creating DataSetType (iOS)


EventInterface

Interface representing an event.

Properties

Property
Type
Description

name

String

Event name

timestamp

Long

Unix timestamp (milliseconds)

properties

Map<String, Any>

Event properties

type

EventType

Event type (CUSTOM or SYSTEM)


EventType

Enum representing event types.


Dataset Schemas

@device

Device properties collected by the SDK.

Property
Type
Description

platform

String

"Android" or "iOS"

model

String

Device model

osVersion

String

OS version

idfa

String?

Advertising ID (if available)

idfv

String?

Vendor ID (iOS only)

appVersion

String

App version

sdkVersion

String

SDK version

nowTs

Long

Server-synced timestamp

@session

Session properties.

Property
Type
Description

counter

Int

Total session count

@triggeredEvent

Event that triggered rule evaluation.

Property
Type
Description

name

String

Event name

counter

Int

Event count (based on strategy)

globalCounter

Int

All-time event count

sessionCounter

Int

Session event count

params

List<Map>

Event parameters

type

String

"custom" or "system"

lastTriggeredTs

Long?

Last trigger timestamp

@events

Historical event data.

Property
Type
Description

data

List<Map>

Array of event records

Each event record contains:

  • name: Event name

  • counter: Global count

  • sessionCounter: Session count

  • params: Parameters

  • type: Event type


Constants

SDK Version


Error Handling

Android

iOS


Thread Safety

  • All public SDK methods are thread-safe

  • Async methods should be called from appropriate contexts (coroutines on Android, async/await on iOS)

  • Listeners may be called on background threads

Last updated