@@ -7,7 +7,6 @@ import { IdentityConstants, OPERATION_NAME } from '../constants';
77import { type IPropertiesModelKeys } from '../models/PropertiesModel' ;
88import { type IdentityModelStore } from '../modelStores/IdentityModelStore' ;
99import { PropertiesModelStore } from '../modelStores/PropertiesModelStore' ;
10- import { PropertiesObject } from '../objects/PropertiesObject' ;
1110import { type NewRecordsState } from '../operationRepo/NewRecordsState' ;
1211import { ExecutionResponse } from '../operations/ExecutionResponse' ;
1312import { Operation } from '../operations/Operation' ;
@@ -17,6 +16,14 @@ import { ModelChangeTags } from '../types/models';
1716import { ExecutionResult , type IOperationExecutor } from '../types/operation' ;
1817import { 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
2229export 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 } ` ) ;
0 commit comments