Skip to content

Commit

Permalink
fix: Update AmazonPersonalizeProvider Analytics typings (aws-amplify#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesaucode authored Jul 20, 2022
1 parent a10d920 commit b7ad126
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
8 changes: 6 additions & 2 deletions packages/analytics/__tests__/Analytics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down
8 changes: 6 additions & 2 deletions packages/analytics/src/Analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
AutoTrackSessionOpts,
AutoTrackPageViewOpts,
AutoTrackEventOpts,
PersonalizeAnalyticsEvent,
} from './types';
import { PageViewTracker, EventTracker, SessionTracker } from './trackers';

Expand Down Expand Up @@ -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.
Expand All @@ -249,7 +253,7 @@ export class AnalyticsClass {
metrics?: EventMetrics
);
public async record(
event: string | AnalyticsEvent,
event: string | AnalyticsEvent | PersonalizeAnalyticsEvent,
providerOrAttributes?: string | EventAttributes,
metrics?: EventMetrics
) {
Expand Down
2 changes: 2 additions & 0 deletions packages/analytics/src/types/Analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,5 @@ export interface AnalyticsEvent {
metrics?: EventMetrics;
immediate?: boolean;
}

export { PersonalizeAnalyticsEvent } from './Providers/AmazonPersonalizeProvider';
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export interface PersonalizeAnalyticsEvent {
eventType?: 'Identify' | 'MediaAutoTrack';
userId?: string;
properties?: {
[key: string]: string;
};
}

0 comments on commit b7ad126

Please sign in to comment.