API Reference

BirdSdk

BirdSdk is the main class for the Bird SDK. It provides access to the SDK's core features and plugins.

Examples

If using the SDK as a script tag, the SDK is automatically initialized with the provided configuration and can be accessed through the global Bird variable.

// Identify the user
await Bird.contact.identify({
	strategy: 'Visitor',
	identifier: {
		key: 'emailaddress',
		value: 'dan@example.com',
	},
});

// Track an event
Bird.tracker.web.pageViewed(event_props, event_opts);

Properties

PropertyType

api

BirdSdkApi

contact

IdentityManager

tracker

BirdTracker

Accessors

status

get status(): SdkStatus

Provides the current status of the SDK. The status can be one of the following:

  • idle: The SDK has not been initialized yet.

  • initializing: The SDK is currently initializing.

  • initialized: The SDK has been initialized successfully.

  • error: The SDK failed to initialize.

set status(status: SdkStatus): void

Parameters

status: SdkStatus

Returns

SdkStatus

Methods

init()

init(opts: BirdSdkInitOptions): Promise<void>

Initializes the Bird SDK with the provided options.

  • If using the SDK as a script tag, this method is automatically called with the provided configuration.

  • This method should be called once before using any other SDK methods.

  • This is an async method and should be awaited before using the SDK.

Parameters

opts: BirdSdkInitOptions

Returns

Promise<void>


BirdInTheWindow

Represents the Bird SDK instance that is available in the global scope.

Example

You can access the sdk instance in the global scope after the sdk is loaded:

<script src="sdk_url" data-config-url="your_config_url"></script>

<script>
	window.Bird.contact.identify(...identify_args);
</script>

Properties

PropertyTypeDescription

Bird?

BirdSdk

BirdSdk is the main class for the Bird SDK. It provides access to the SDK's core features and plugins.

birdAsyncInit?

(sdk: BirdSdk, conf?: BirdSdkConf) => void

This function is used to initialize the sdk asynchronously. It can be used to override the default configuration of the sdk.

Example


BirdPluginContext

BirdPluginContext is the context that is passed to the plugins when they are initialized. It provides access to the sdk's core features and allows the plugins to interact with the sdk.

Example

const plugin: BirdPlugin = (ctx) => {
	ctx.tracker.track(...trackArgs);
};

Properties

PropertyType

api

BirdSdkApi

contact

IdentityManager

getConf

() => null | { apiHost: string; embeddables: EmbeddablesConf; tracking: TrackingConf; trackingEndpoint: string; workspaceId: string; writeKey: string; }

persister

BirdSdkPersister

status

SdkStatus

tracker

BirdTracker


createBirdSdk()

function createBirdSdk(deps: CreateSdkDependencies): BirdSdk;

Factory function to create an instance of BirdSdk.

Parameters

deps: CreateSdkDependencies = {}

Returns

BirdSdk

Remarks

  • No dependencies are required but can be injected to override the default implementations.

Last updated