-
Notifications
You must be signed in to change notification settings - Fork 0
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
Update event payloads #14
Changes from 3 commits
593a17f
85becf0
29ad73e
56feb8b
712e2f5
ae01369
6d49acb
cadcea9
f0d94ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,14 +6,15 @@ export enum VendorEvent { | |
ContactDesigner = 'ContactDesigner', | ||
DirtyStateChanged = 'DirtyStateChanged', | ||
iFrameLoaded = 'iFrameLoaded', | ||
iFrameRedirect = 'iFrameRedirect', | ||
ProjectDeleted = 'ProjectDeleted', | ||
ProjectSaved = 'ProjectSaved', | ||
TrackingEvent = 'TrackingEvent', | ||
TokenRefreshRequested = 'TokenRefreshRequested', | ||
UnauthorizedToken = 'UnauthorizedToken', | ||
} | ||
|
||
interface Metadata { | ||
interface AddToCartMetadata { | ||
source?: string; | ||
title: string; | ||
brand: string; | ||
|
@@ -22,15 +23,36 @@ interface Metadata { | |
thumbnailUrl: string; | ||
area?: number; | ||
price?: number; | ||
retailPrice?: number; | ||
} | ||
|
||
interface EventPayload { | ||
interface AddToCartPayload { | ||
schema: string; | ||
token: string; | ||
customerId: string; | ||
projectId: string; | ||
versionId: string; | ||
metadata: Metadata; | ||
metadata: AddToCartMetadata; | ||
bom?: any; | ||
} | ||
|
||
interface DesignerMetadata { | ||
source?: string; | ||
title: string; | ||
brand: string; | ||
style: string; | ||
color: string; | ||
thumbnailUrl: string; | ||
area?: number; | ||
} | ||
|
||
interface ConsultDesignerPayload { | ||
schema: string; | ||
token: string; | ||
customerId: string; | ||
projectId: string; | ||
versionId: string; | ||
metadata: ConsultDesignerMetadata; | ||
bom?: any; | ||
} | ||
|
||
|
@@ -39,47 +61,80 @@ interface TrackingEvent { | |
actionData: Record<string, unknown>; | ||
} | ||
|
||
interface ProjectSavedPayload { | ||
message: string; | ||
customerId: string; | ||
projectId: string; | ||
versionId: string; | ||
} | ||
|
||
interface ProjectDeletedPayload { | ||
message: string; | ||
customerId: string; | ||
projectId: string; | ||
} | ||
|
||
interface DirtyStateChangedPayload { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add projectId |
||
message: string; | ||
isDirty: boolean; | ||
} | ||
|
||
interface iFrameRedirectPayload { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to generalize this into a navigation event?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have a small preference to keep them separate, because we want to see a clear difference between an "application exit" event and a navigation tracking event. It's just a convenience on our side for developers to be able to see when an event is expected to trigger a redirect. |
||
message: string; | ||
app: string; | ||
key: string; | ||
} | ||
|
||
interface TokenRefreshRequestedPayload { | ||
message: string; | ||
requestId: string; | ||
} | ||
|
||
export class VendorCommunicator extends Communicator { | ||
constructor(origin: string) { | ||
super(origin); | ||
this.target = window.parent; | ||
this.origin = origin; | ||
} | ||
|
||
addToCart(payload: EventPayload): void { | ||
addToCart(payload: AddToCartPayload): void { | ||
this.post({type: VendorEvent.AddToCart, payload}); | ||
} | ||
|
||
appInitialized(): void { | ||
this.post({type: VendorEvent.AddToCart}); | ||
appInitialized(message: string): void { | ||
this.post({type: VendorEvent.AddToCart, payload: message}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just noticed this should be type: VendorEvent.AppInitialized |
||
} | ||
|
||
contactDesigner(payload: EventPayload): void { | ||
contactDesigner(payload: ConsultDesignerPayload): void { | ||
this.post({type: VendorEvent.ContactDesigner, payload}); | ||
} | ||
|
||
dirtyStateChanged(): void { | ||
this.post({type: VendorEvent.DirtyStateChanged}); | ||
dirtyStateChanged(payload: DirtyStateChangedPayload): void { | ||
this.post({type: VendorEvent.DirtyStateChanged, payload}); | ||
} | ||
|
||
iframeLoaded(): void { | ||
this.post({type: VendorEvent.iFrameLoaded}); | ||
iframeLoaded(message: string): void { | ||
this.post({type: VendorEvent.iFrameLoaded, payload: message}); | ||
} | ||
|
||
iframeRedirect(payload: iFrameRedirectPayload): void { | ||
this.post({type: VendorEvent.iFrameRedirect, payload}); | ||
} | ||
|
||
projectSaved(): void { | ||
this.post({type: VendorEvent.ProjectSaved}); | ||
projectSaved(payload: ProjectSavedPayload): void { | ||
this.post({type: VendorEvent.ProjectSaved, payload}); | ||
} | ||
|
||
projectDeleted(): void { | ||
this.post({type: VendorEvent.ProjectDeleted}); | ||
projectDeleted(payload: ProjectDeletedPayload): void { | ||
this.post({type: VendorEvent.ProjectDeleted, payload}); | ||
} | ||
|
||
trackEvent(payload: TrackingEvent): void { | ||
this.post({type: VendorEvent.TrackingEvent, payload}); | ||
} | ||
|
||
tokenRefreshRequested(): void { | ||
this.post({type: VendorEvent.TokenRefreshRequested}); | ||
tokenRefreshRequested(payload: TokenRefreshRequestedPayload): void { | ||
this.post({type: VendorEvent.TokenRefreshRequested, payload}); | ||
} | ||
|
||
unauthorizedToken(error: string): void { | ||
|
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.
Let's add
message
to the EventPayload interface since you are sending it.