Amplify has re-imagined the way frontend developers build fullstack applications. Develop and deploy without the hassle.

Page updated Feb 21, 2024

Create a custom plugin

You can create your custom pluggable for Analytics. This may be helpful if you want to integrate your app with a custom analytics backend.

To create a plugin implement the AnalyticsProvider interface:

import { Analytics, AnalyticsProvider } from 'aws-amplify';
export default class MyAnalyticsProvider implements AnalyticsProvider {
// category and provider name
static category = 'Analytics';
static providerName = 'MyAnalytics';
// you need to implement these four methods
// configure your provider
configure(config: object): object;
// record events and returns true if succeeds
record(params: object): Promise<boolean>;
// return 'Analytics';
getCategory(): string;
// return the name of you provider
getProviderName(): string;
}

You can now register your pluggable:

// add the plugin
Analytics.addPluggable(new MyAnalyticsProvider());
// get the plugin
Analytics.getPluggable(MyAnalyticsProvider.providerName);
// remove the plugin
Analytics.removePluggable(MyAnalyticsProvider.providerName);
// send configuration into Amplify
Analytics.configure({
MyAnalyticsProvider: {
// My Analytics provider configuration
}
});

The default provider (Amazon Pinpoint) is in use when you call Analytics.record() unless you specify a different provider: Analytics.record({..},'MyAnalytics').