-
Notifications
You must be signed in to change notification settings - Fork 51
refactor: Migrate Forwarder module to TypeScript #988
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
base: development
Are you sure you want to change the base?
refactor: Migrate Forwarder module to TypeScript #988
Conversation
5afc5b6
to
948c6a6
Compare
948c6a6
to
9acfdc4
Compare
src/forwarders.interfaces.ts
Outdated
// constructor?: new () => IMPForwarder; | ||
constructor: () => any; | ||
name: string; | ||
getId: () => number, // Should this be optional? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A side loaded kit may not implement getId
so at a minimum, this should be optional.
src/forwarders.interfaces.ts
Outdated
export type Kit = Dictionary; | ||
export interface Kit { | ||
// constructor?: new () => IMPForwarder; | ||
constructor: () => any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revisit the constructor value?
src/forwarders.interfaces.ts
Outdated
name: string; | ||
getId(): number; | ||
filters: IKitFilterSettings; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this only for sideloaded kits?
src/forwarders.interfaces.ts
Outdated
screenAttributeFilters: number[]; | ||
|
||
|
||
// Side loaded kit functioanlity in Forwarder methods |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Side loaded kit functioanlity in Forwarder methods | |
// Side loaded kit functionality in Forwarder methods |
|
||
|
||
// Side loaded kit functioanlity in Forwarder methods | ||
kitInstance: UnregisteredKit; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i see this as existing on the unregistered Kit, rather than IMPForwarder
src/forwarders.interfaces.ts
Outdated
id: number; | ||
settings: ForwarderSettings; | ||
forwarderStatsUploader: AsyncUploader; | ||
isInitialized: boolean; | ||
filteringConsentRuleValues: IFilteringConsentRuleValues; | ||
filteringUserAttributeValue: IFilteringUserAttributeValue; | ||
filteringEventAttributeValue: IFilteringEventAttributeValue; | ||
excludeAnonymousUser: boolean; | ||
userIdentityFilters: UserIdentityFilters; | ||
userAttributeFilters: UserAttributeFilters; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think a lot of these settings are actually supposed to be on an IKitConfig
or IForwarder
, and not the IMPForwarder
Class. the naming is confusing, so taht's probably why they all got combined into here. maybe this class should be named IMPForwarderClass
for now even though I know that's bad practice, but at least so we don't confuse IMPForwarder for the class, which has the class methods on it, vs having properties for an actual forwarder or kit, some of which are found here
this applies to most of the items from line 118-149, but double check
isSandbox?: boolean; | ||
hasSandbox?: boolean; | ||
isVisible?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are on the kitconfig and not the IMPForwarder class also
src/forwarders.interfaces.ts
Outdated
// constructor?: new () => IMPForwarder; | ||
constructor: () => any; | ||
name: string; | ||
getId: () => number, // Should this be optional? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
test/jest/sideloadedKit.spec.ts
Outdated
// constructor: class { | ||
// constructor() {} | ||
// } as new () => IMPForwarder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flagging to make sure you address this commented code and we don't forget
test/jest/utils.ts
Outdated
// @ts-ignore | ||
constructor: this.constructor, | ||
// constructor: this.constructor as { new(): IMPForwarder }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
test/jest/utils.ts
Outdated
@@ -74,6 +76,7 @@ export class MockForwarder { | |||
}) | |||
} | |||
|
|||
// TODO: Can we finally get rid of this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't have the historical context here. is this something you did or i did?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's something you introduced but I can't recall why it wasn't ever flagged during code review: #568
test/src/tests-forwarders.ts
Outdated
@@ -3201,6 +3204,8 @@ describe('forwarders', function() { | |||
// The received event gets replaced by the last event sent to the forwarder | |||
// SideloadedKit11 has received the session start event, but not the Test Event | |||
// SideloadedKit22 will receive the Test Event | |||
|
|||
console.log('EventName', window.SideloadedKit11.instance.receivedEvent.EventName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove?
src/apiClient.ts
Outdated
@@ -23,7 +23,7 @@ export interface IAPIClient { | |||
) => void; | |||
initializeForwarderStatsUploader: () => AsyncUploader; | |||
prepareForwardingStats: ( | |||
forwarder: MPForwarder, | |||
forwarder: IMPForwarder, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to self: This might need to be a RegisteredKit
src/apiClient.ts
Outdated
@@ -192,7 +192,7 @@ export default function APIClient( | |||
}; | |||
|
|||
this.prepareForwardingStats = function( | |||
forwarder: MPForwarder, | |||
forwarder: IMPForwarder, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may need to become a RegisteredKit
5239dcd
to
6cb7247
Compare
|
Instructions
development
Summary
Testing Plan
Reference Issue (For mParticle employees only. Ignore if you are an outside contributor)