diff --git a/packages/analytics/__tests__/Analytics.test.ts b/packages/analytics/__tests__/Analytics.test.ts index 7239ed3a8d0..ef1e88f0515 100644 --- a/packages/analytics/__tests__/Analytics.test.ts +++ b/packages/analytics/__tests__/Analytics.test.ts @@ -108,8 +108,12 @@ describe('Analytics test', () => { await analytics.record({ name: 'event', - attributes: 'attributes', - metrics: 'metrics', + attributes: { + key: 'value', + }, + metrics: { + metric: 123, + }, }); expect(record_spyon).toBeCalled(); }); diff --git a/packages/analytics/src/Analytics.ts b/packages/analytics/src/Analytics.ts index 3873cb86cf1..24c9584059a 100644 --- a/packages/analytics/src/Analytics.ts +++ b/packages/analytics/src/Analytics.ts @@ -27,6 +27,7 @@ import { AutoTrackSessionOpts, AutoTrackPageViewOpts, AutoTrackEventOpts, + PersonalizeAnalyticsEvent, } from './types'; import { PageViewTracker, EventTracker, SessionTracker } from './trackers'; @@ -234,7 +235,10 @@ export class AnalyticsClass { * @param event - An object with the name of the event, attributes of the event and event metrics. * @param [provider] - name of the provider. */ - public async record(event: AnalyticsEvent, provider?: string); + public async record( + event: AnalyticsEvent | PersonalizeAnalyticsEvent, + provider?: string + ); /** * Record one analytic event and send it to Pinpoint * @deprecated Use the new syntax and pass in the event as an object instead. @@ -249,7 +253,7 @@ export class AnalyticsClass { metrics?: EventMetrics ); public async record( - event: string | AnalyticsEvent, + event: string | AnalyticsEvent | PersonalizeAnalyticsEvent, providerOrAttributes?: string | EventAttributes, metrics?: EventMetrics ) { diff --git a/packages/analytics/src/types/Analytics.ts b/packages/analytics/src/types/Analytics.ts index 38427360af1..beae3bab057 100644 --- a/packages/analytics/src/types/Analytics.ts +++ b/packages/analytics/src/types/Analytics.ts @@ -92,3 +92,5 @@ export interface AnalyticsEvent { metrics?: EventMetrics; immediate?: boolean; } + +export { PersonalizeAnalyticsEvent } from './Providers/AmazonPersonalizeProvider'; diff --git a/packages/analytics/src/types/Providers/AmazonPersonalizeProvider.ts b/packages/analytics/src/types/Providers/AmazonPersonalizeProvider.ts new file mode 100644 index 00000000000..3bd4634b971 --- /dev/null +++ b/packages/analytics/src/types/Providers/AmazonPersonalizeProvider.ts @@ -0,0 +1,7 @@ +export interface PersonalizeAnalyticsEvent { + eventType?: 'Identify' | 'MediaAutoTrack'; + userId?: string; + properties?: { + [key: string]: string; + }; +}