Ampli SDK Overview
The Ampli CLI, Ampli SDK, and Amplitude SDK work together to bring a tracking library into your project.
Amplitude Data can generate a tracking library for several platforms and programming languages. The autogenerated
library, the Ampli SDK, is a lightweight wrapper over the Amplitude SDK that provides type-safety, supports linting,
and enables features like input validation. The code replicates the spec in the Tracking Plan and enforces its rules
and requirements.
Ampli CLI
The Ampli CLI connects your codebase to your tracking plan. Each Source in your tracking plan represents a runtime
in which you wish to generate a strongly typed SDK.
ampli pull
logs in and downloads the Ampli SDK for your current tracking plan.
ampli status
verifies implementation status of event tracking in your project.
Ampli SDK
The Ampli SDK is a dynamic, code-generated SDK. It has strong types for the events in your tracking plan, and
provides autocomplete and static type checking.
ampli.songPlayed({ title: ‘Song #1’ })
The Ampli SDK is a light wrapper for untyped Amplitude SDKs.
Amplitude SDK
The Amplitude SDK is a static, open source SDK with untyped events.
amplitude.logEvent({ event_type: ‘Song Played’, event_properties: { title: ‘Song #1’ }})
The Ampli SDK runs on top of the Amplitude SDK.
The client.instance
is the Amplitude SDK client that makes the underlying calls to Amplitude. If you don't specify a client.instance
, Ampli uses a default instance.
class Ampli {
var client: AmplitudeClient;
load(options) {
// use provided AmplitudeCLient if available, default otherwise
this.client = options.client.instance || Amplitude.getInstance().init(...);
}
// track method wraps Amplitude SDK's logEvent()
track(event: Event) {
// use the Amplitude client to logEvents to the server
this.client.logEvent(event.eventType, event.eventProperties);
}
// strongly typed event method wraps "generic" track
myEvent(properties: EventProperties) {
this.track(new MyEvent(properties));
}
}
You can override the default client configuration with client.options
.
Last update:
2022-05-11
Report an issue with this page