diff --git a/packages/analytics/src/Analytics.ts b/packages/analytics/src/Analytics.ts index 24c9584059a..8142e2257c9 100644 --- a/packages/analytics/src/Analytics.ts +++ b/packages/analytics/src/Analytics.ts @@ -28,6 +28,7 @@ import { AutoTrackPageViewOpts, AutoTrackEventOpts, PersonalizeAnalyticsEvent, + KinesisAnalyticsEvent, } from './types'; import { PageViewTracker, EventTracker, SessionTracker } from './trackers'; @@ -236,7 +237,7 @@ export class AnalyticsClass { * @param [provider] - name of the provider. */ public async record( - event: AnalyticsEvent | PersonalizeAnalyticsEvent, + event: AnalyticsEvent | PersonalizeAnalyticsEvent | KinesisAnalyticsEvent, provider?: string ); /** @@ -253,7 +254,11 @@ export class AnalyticsClass { metrics?: EventMetrics ); public async record( - event: string | AnalyticsEvent | PersonalizeAnalyticsEvent, + event: + | string + | AnalyticsEvent + | PersonalizeAnalyticsEvent + | KinesisAnalyticsEvent, providerOrAttributes?: string | EventAttributes, metrics?: EventMetrics ) { @@ -283,7 +288,10 @@ export class AnalyticsClass { return this.record(event, provider); } - private _sendEvent(params: { event: AnalyticsEvent; provider?: string }) { + private _sendEvent(params: { + event: AnalyticsEvent | PersonalizeAnalyticsEvent | KinesisAnalyticsEvent; + provider?: string; + }) { if (this._disabled) { logger.debug('Analytics has been disabled'); return Promise.resolve(); diff --git a/packages/analytics/src/types/Analytics.ts b/packages/analytics/src/types/Analytics.ts index beae3bab057..412945ed556 100644 --- a/packages/analytics/src/types/Analytics.ts +++ b/packages/analytics/src/types/Analytics.ts @@ -94,3 +94,4 @@ export interface AnalyticsEvent { } export { PersonalizeAnalyticsEvent } from './Providers/AmazonPersonalizeProvider'; +export { KinesisAnalyticsEvent } from './Providers/AWSKinesisProvider'; diff --git a/packages/analytics/src/types/Providers/AWSKinesisProvider.ts b/packages/analytics/src/types/Providers/AWSKinesisProvider.ts new file mode 100644 index 00000000000..422c5fea356 --- /dev/null +++ b/packages/analytics/src/types/Providers/AWSKinesisProvider.ts @@ -0,0 +1,5 @@ +export interface KinesisAnalyticsEvent { + data: object | string; + partitionKey: string; + streamName: string; +} diff --git a/packages/analytics/src/types/Providers/AmazonPersonalizeProvider.ts b/packages/analytics/src/types/Providers/AmazonPersonalizeProvider.ts index 3bd4634b971..e1544f0fb33 100644 --- a/packages/analytics/src/types/Providers/AmazonPersonalizeProvider.ts +++ b/packages/analytics/src/types/Providers/AmazonPersonalizeProvider.ts @@ -1,5 +1,5 @@ export interface PersonalizeAnalyticsEvent { - eventType?: 'Identify' | 'MediaAutoTrack'; + eventType?: string; userId?: string; properties?: { [key: string]: string;