Skip to content

Commit baa1614

Browse files
authored
Fix Typos in Events, Add Tracking Event (#12)
1 parent c5234a1 commit baa1614

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ and this project adheres to
1010

1111
### TBA
1212

13+
## [v3.0.0] - 2022-11-08
14+
15+
- Update event names to match existing wording
16+
- Create tracking event on VendorClient
17+
1318
## [v2.0.0] - 2022-11-08
1419

1520
- Renamed thumbnailUri to thumbnailUrl

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "postmessage-communicator",
3-
"version": "2.0.0",
3+
"version": "3.0.0",
44
"description": "[![Release](https://img.shields.io/github/v/release/wayfair-incubator/oss-template?display_name=tag)](CHANGELOG.md) [![Lint](https://github.com/wayfair-incubator/oss-template/actions/workflows/lint.yml/badge.svg?branch=main)](https://github.com/wayfair-incubator/oss-template/actions/workflows/lint.yml) [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.0-4baaaa.svg)](CODE_OF_CONDUCT.md) [![Maintainer](https://img.shields.io/badge/Maintainer-Wayfair-7F187F)](https://wayfair.github.io)",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/classes/ClientCommunicator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {Communicator} from './Communicator';
22

33
export enum ClientEvent {
44
LoginWithToken = 'LoginWithToken',
5-
RefreshWithToken = 'RefreshToken',
5+
RefreshWithToken = 'RefreshWithToken',
66
}
77

88
interface InitPayload {

src/classes/VendorCommunicator.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ export enum VendorEvent {
55
AppInitialized = 'AppInitialized',
66
ContactDesigner = 'ContactDesigner',
77
DirtyStateChanged = 'DirtyStateChanged',
8-
IframeLoaded = 'IframeLoaded',
9-
ProjectSaved = 'ProjectSaved',
8+
iFrameLoaded = 'iFrameLoaded',
109
ProjectDeleted = 'ProjectDeleted',
10+
ProjectSaved = 'ProjectSaved',
11+
TrackingEvent = 'TrackingEvent',
1112
TokenRefreshRequested = 'TokenRefreshRequested',
1213
UnauthorizedToken = 'UnauthorizedToken',
1314
}
@@ -31,6 +32,11 @@ interface EventPayload {
3132
bom?: any;
3233
}
3334

35+
interface TrackingEvent {
36+
actionName: string;
37+
actionData: Record<string, unknown>;
38+
}
39+
3440
export class VendorCommunicator extends Communicator {
3541
constructor(origin: string) {
3642
super(origin);
@@ -55,7 +61,7 @@ export class VendorCommunicator extends Communicator {
5561
}
5662

5763
iframeLoaded(): void {
58-
this.post({type: VendorEvent.IframeLoaded});
64+
this.post({type: VendorEvent.iFrameLoaded});
5965
}
6066

6167
projectSaved(): void {
@@ -66,6 +72,10 @@ export class VendorCommunicator extends Communicator {
6672
this.post({type: VendorEvent.ProjectDeleted});
6773
}
6874

75+
trackEvent(payload: TrackingEvent): void {
76+
this.post({type: VendorEvent.TrackingEvent, payload});
77+
}
78+
6979
tokenRefreshRequested(): void {
7080
this.post({type: VendorEvent.TokenRefreshRequested});
7181
}

0 commit comments

Comments
 (0)