Skip to content

Commit f5930c6

Browse files
committed
address more pr comments
1 parent b2d4239 commit f5930c6

6 files changed

Lines changed: 14 additions & 11 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
},
8282
{
8383
"path": "./build/releases/OneSignalSDK.page.es6.js",
84-
"limit": "63.75 kB",
84+
"limit": "64 kB",
8585
"gzip": true
8686
},
8787
{

src/core/controllers/CustomEventController.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import MainHelper from '../../shared/helpers/MainHelper';
22
import { IdentityModelStore } from '../modelStores/IdentityModelStore';
3-
import { TrackEventOperation } from '../operations/TrackEventOperation';
3+
import { TrackCustomEventOperation } from '../operations/TrackCustomEventOperation';
44
import type {
55
ICustomEvent,
66
ICustomEventController,
@@ -25,7 +25,7 @@ export class CustomEventController implements ICustomEventController {
2525
const appId = MainHelper.getAppId();
2626
const identityModel = this._identityModelStore.model;
2727

28-
const op = new TrackEventOperation({
28+
const op = new TrackCustomEventOperation({
2929
appId,
3030
onesignalId: identityModel.onesignalId,
3131
externalId: identityModel.externalId,

src/core/executors/CustomEventOperationExecutor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { VERSION } from 'src/shared/utils/EnvVariables';
1212
import { OPERATION_NAME } from '../constants';
1313
import { ExecutionResponse } from '../operations/ExecutionResponse';
1414
import { Operation } from '../operations/Operation';
15-
import { TrackEventOperation } from '../operations/TrackEventOperation';
15+
import { TrackCustomEventOperation } from '../operations/TrackCustomEventOperation';
1616
import { RequestService } from '../requestService/RequestService';
1717
import type { ICustomEventMetadata } from '../types/customEvents';
1818
import { ExecutionResult, type IOperationExecutor } from '../types/operation';
@@ -45,7 +45,7 @@ export class CustomEventsOperationExecutor implements IOperationExecutor {
4545
// TODO: each trackEvent is sent individually right now; may need to batch in the future
4646
const operation = operations[0];
4747

48-
if (!(operation instanceof TrackEventOperation)) {
48+
if (!(operation instanceof TrackCustomEventOperation)) {
4949
throw new Error(
5050
`Unrecognized operation! Expected TrackEventOperation, got: ${operation.constructor.name}`,
5151
);

src/core/executors/LoginUserOperationExecutor.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import { LoginUserOperation } from '../operations/LoginUserOperation';
2525
import { type Operation } from '../operations/Operation';
2626
import { RefreshUserOperation } from '../operations/RefreshUserOperation';
2727
import { SetAliasOperation } from '../operations/SetAliasOperation';
28-
import { TrackEventOperation } from '../operations/TrackEventOperation';
2928
import { TransferSubscriptionOperation } from '../operations/TransferSubscriptionOperation';
3029
import { UpdateSubscriptionOperation } from '../operations/UpdateSubscriptionOperation';
3130
import { RequestService } from '../requestService/RequestService';

src/core/modelRepo/OperationModelStore.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Operation } from '../operations/Operation';
88
import { RefreshUserOperation } from '../operations/RefreshUserOperation';
99
import { SetAliasOperation } from '../operations/SetAliasOperation';
1010
import { SetPropertyOperation } from '../operations/SetPropertyOperation';
11-
import { TrackEventOperation } from '../operations/TrackEventOperation';
11+
import { TrackCustomEventOperation } from '../operations/TrackCustomEventOperation';
1212
import { TransferSubscriptionOperation } from '../operations/TransferSubscriptionOperation';
1313
import { UpdateSubscriptionOperation } from '../operations/UpdateSubscriptionOperation';
1414
import { ModelName } from '../types/models';
@@ -68,7 +68,7 @@ export class OperationModelStore extends ModelStore<Operation> {
6868
operation = new SetPropertyOperation();
6969
break;
7070
case OPERATION_NAME.CUSTOM_EVENT:
71-
operation = new TrackEventOperation();
71+
operation = new TrackCustomEventOperation();
7272
break;
7373
default:
7474
throw new Error(`Unrecognized operation: ${operationName}`);

src/core/operations/TrackEventOperation.ts renamed to src/core/operations/TrackCustomEventOperation.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type ITrackEventOp = Pick<OperationProps, 'externalId' | 'timestamp' | 'event'>;
2323
/**
2424
* An Operation to track a custom event for a specific user.
2525
*/
26-
export class TrackEventOperation extends Operation<ITrackEventOp> {
26+
export class TrackCustomEventOperation extends Operation<ITrackEventOp> {
2727
constructor(props?: OperationProps);
2828
constructor(props: OperationProps) {
2929
super(OPERATION_NAME.CUSTOM_EVENT, props?.appId, props?.onesignalId);
@@ -62,11 +62,15 @@ export class TrackEventOperation extends Operation<ITrackEventOp> {
6262
this.setProperty('event', value);
6363
}
6464

65+
private get key(): string {
66+
return `${this.appId}.User.${this.onesignalId}.CustomEvent.${this.event.name}`;
67+
}
68+
6569
override get createComparisonKey(): string {
66-
return `${this.appId}.User.${this.onesignalId}.CustomEvent`;
70+
return this.key;
6771
}
6872
override get modifyComparisonKey(): string {
69-
return `${this.appId}.User.${this.onesignalId}.CustomEvent.${this.name}`;
73+
return this.key;
7074
}
7175

7276
// TODO: no batching of custom events until finalized

0 commit comments

Comments
 (0)