Skip to content

Commit

Permalink
Fix: Analytics Type issue (#10185)
Browse files Browse the repository at this point in the history
* kinesis fix
  • Loading branch information
ashika01 authored Aug 9, 2022
1 parent 5f427f3 commit 92cef8a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
14 changes: 11 additions & 3 deletions packages/analytics/src/Analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
AutoTrackPageViewOpts,
AutoTrackEventOpts,
PersonalizeAnalyticsEvent,
KinesisAnalyticsEvent,
} from './types';
import { PageViewTracker, EventTracker, SessionTracker } from './trackers';

Expand Down Expand Up @@ -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
);
/**
Expand All @@ -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
) {
Expand Down Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions packages/analytics/src/types/Analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,4 @@ export interface AnalyticsEvent {
}

export { PersonalizeAnalyticsEvent } from './Providers/AmazonPersonalizeProvider';
export { KinesisAnalyticsEvent } from './Providers/AWSKinesisProvider';
5 changes: 5 additions & 0 deletions packages/analytics/src/types/Providers/AWSKinesisProvider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface KinesisAnalyticsEvent {
data: object | string;
partitionKey: string;
streamName: string;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export interface PersonalizeAnalyticsEvent {
eventType?: 'Identify' | 'MediaAutoTrack';
eventType?: string;
userId?: string;
properties?: {
[key: string]: string;
Expand Down

0 comments on commit 92cef8a

Please sign in to comment.