amplitude / sdk-adapter

SDK Adapter tool

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool


Amplitude Browser SDK Adapter Tool

Amplitude's tool to ease engineering cost of migrating SDK libraries. Currently supported only for the browser SDK. Segment's analytics SDK API can be kept and analytics actions will be forwarded to Amplitude. Currently support track and identify calls.

Usage

1. Install

npm install 

2. Import packages

import { AnalyticsAdapter } from "sdk-adapter";
import { AnalyticsBrowser } from "@segment/analytics-next";
import { createInstance } from "@amplitude/analytics-browser";

3. Create instances of Amplitude and Segment SDKs

const amplitude = createInstance();
amplitude.init(AMPLITUDE_API_KEY);

const segment = new AnalyticsBrowser();
segment.load({ writeKey: SEGMENT_WRITE_KEY });

4. Create adapter instance and replace Segment APIs with supported adapter APIs

const analytics = new AnalyticsAdapter(segment, amplitude);
analytics.track('test event')

About

SDK Adapter tool

License:MIT License


Languages

Language:TypeScript 100.0%