Skip to content

Commit a34c936

Browse files
committed
remove properties object
1 parent 9eb2be8 commit a34c936

File tree

3 files changed

+21
-35
lines changed

3 files changed

+21
-35
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
},
8585
{
8686
"path": "./build/releases/OneSignalSDK.page.es6.js",
87-
"limit": "46.452 kB",
87+
"limit": "46.352 kB",
8888
"gzip": true
8989
},
9090
{

src/core/executors/UpdateUserOperationExecutor.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { IdentityConstants, OPERATION_NAME } from '../constants';
77
import { type IPropertiesModelKeys } from '../models/PropertiesModel';
88
import { type IdentityModelStore } from '../modelStores/IdentityModelStore';
99
import { PropertiesModelStore } from '../modelStores/PropertiesModelStore';
10-
import { PropertiesObject } from '../objects/PropertiesObject';
1110
import { type NewRecordsState } from '../operationRepo/NewRecordsState';
1211
import { ExecutionResponse } from '../operations/ExecutionResponse';
1312
import { Operation } from '../operations/Operation';
@@ -17,6 +16,14 @@ import { ModelChangeTags } from '../types/models';
1716
import { ExecutionResult, type IOperationExecutor } from '../types/operation';
1817
import { type IRebuildUserService } from '../types/user';
1918

19+
type PropertiesObject = {
20+
ip?: string;
21+
tags?: Record<string, string>;
22+
language?: string;
23+
timezone_id?: string;
24+
country?: string;
25+
};
26+
2027
// Implements logic similar to Android's SDK's UpdateUserOperationExecutor
2128
// Reference: https://github.com/OneSignal/OneSignal-Android-SDK/blob/5.1.31/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/user/internal/operations/impl/executors/UpdateUserOperationExecutor.kt
2229
export class UpdateUserOperationExecutor implements IOperationExecutor {
@@ -44,7 +51,7 @@ export class UpdateUserOperationExecutor implements IOperationExecutor {
4451
private _processOperations(operations: Operation[]) {
4552
let appId: string | null = null;
4653
let onesignalId: string | null = null;
47-
let propertiesObject = new PropertiesObject();
54+
let propertiesObject: PropertiesObject = {};
4855
const refreshDeviceMetadata = false;
4956

5057
for (const operation of operations) {
@@ -171,14 +178,20 @@ function createPropertiesFromOperation(
171178
): PropertiesObject {
172179
if (operation instanceof SetPropertyOperation) {
173180
const propertyKey = operation.property;
174-
const allowedKeys = Object.keys(properties);
175-
if (allowedKeys.includes(propertyKey)) {
176-
return new PropertiesObject({
181+
const allowedKeys: IPropertiesModelKeys[] = [
182+
'ip',
183+
'tags',
184+
'language',
185+
'timezone_id',
186+
'country',
187+
];
188+
if (allowedKeys.includes(propertyKey as IPropertiesModelKeys)) {
189+
return {
177190
...properties,
178191
[propertyKey]: operation.value,
179-
});
192+
};
180193
}
181-
return new PropertiesObject({ ...properties });
194+
return { ...properties };
182195
}
183196

184197
throw new Error(`Unsupported operation type: ${operation._name}`);

src/core/objects/PropertiesObject.ts

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)