Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Analytics Type issue #10185

Merged
merged 6 commits into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 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
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';
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface KinesisAnalyticsEvent {
ashika01 marked this conversation as resolved.
Show resolved Hide resolved
data: Blob | 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;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just made it string since a lotta different eventType seems to be supported as per docs - https://docs.aws.amazon.com/personalize/latest/dg/API_UBS_PutEvents.html

I dont see value in doing this string | 'Identify' | 'MediaAutoTrack' unless we plan to restrict other use cases and make this ENUM. Advice me if this is better

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better as a string unless they expose this in a place where we can inherit the typing from their code. The value of providing more feedback to our customers probably isn't worth the customer and maintenance pain of keeping lists in parity.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would do that in a different PR maybe?

Copy link
Contributor Author

@ashika01 ashika01 Aug 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to as its all part of analytics typing error

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and this is one liner and customers have already reported issue with the type. I would go with this included :)

userId?: string;
properties?: {
[key: string]: string;
Expand Down