Skip to content

Commit 10f6812

Browse files
authored
Merge pull request #492 from Iterable/eudc-updates
[MOB-6321] prepare EUDC updates for release
2 parents cb26f25 + b5ea762 commit 10f6812

File tree

6 files changed

+53
-1
lines changed

6 files changed

+53
-1
lines changed

android/src/main/java/com/iterable/reactnative/Serialization.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import com.iterable.iterableapi.IterableAction;
1616
import com.iterable.iterableapi.IterableActionContext;
1717
import com.iterable.iterableapi.IterableConfig;
18+
import com.iterable.iterableapi.IterableDataRegion;
1819
import com.iterable.iterableapi.IterableInAppCloseAction;
1920
import com.iterable.iterableapi.IterableInAppDeleteActionType;
2021
import com.iterable.iterableapi.IterableInAppHandler;
@@ -198,6 +199,24 @@ static IterableConfig.Builder getConfigFromReadableMap(ReadableMap iterableConte
198199
configBuilder.setLogLevel(logLevel);
199200
}
200201

202+
if(iterableContextJSON.has("dataRegion")) {
203+
int dataRegion = iterableContextJSON.getInt("dataRegion");
204+
IterableDataRegion iterableDataRegion = IterableDataRegion.US;
205+
switch (dataRegion) {
206+
case 0:
207+
iterableDataRegion = IterableDataRegion.US;
208+
break;
209+
case 1:
210+
iterableDataRegion = IterableDataRegion.EU;
211+
break;
212+
default:
213+
iterableDataRegion = IterableDataRegion.US;
214+
break;
215+
}
216+
217+
configBuilder.setDataRegion(iterableDataRegion);
218+
}
219+
201220
if (iterableContextJSON.has("encryptionEnforced")) {
202221
configBuilder.setEncryptionEnforced(iterableContextJSON.optBoolean("encryptionEnforced"));
203222
}

ios/RNIterableAPI/Serialization.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,18 @@ extension IterableConfig {
7070
if let useInMemoryStorageForInApp = dict["useInMemoryStorageForInApps"] as? Bool {
7171
config.useInMemoryStorageForInApps = useInMemoryStorageForInApp
7272
}
73+
74+
if let dataRegion = dict["dataRegion"] as? NSNumber {
75+
switch dataRegion {
76+
case 0:
77+
config.dataRegion = IterableDataRegion.US
78+
case 1:
79+
config.dataRegion = IterableDataRegion.EU
80+
default:
81+
config.dataRegion = IterableDataRegion.US
82+
}
83+
}
84+
7385

7486
return config
7587
}

ts/IterableConfig.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import { IterableInAppShowResponse } from './IterableInAppClasses'
1010

1111
import IterableInAppMessage from './IterableInAppMessage'
1212

13+
import { IterableDataRegion } from './IterableDataRegion'
14+
1315
type AuthCallBack = (() => void)
1416

1517
/**
@@ -115,6 +117,11 @@ class IterableConfig {
115117
*/
116118
useInMemoryStorageForInApps: boolean = false
117119

120+
/**
121+
* This specifies the data region which determines the data center and associated endpoints used by the SDK
122+
*/
123+
dataRegion: IterableDataRegion = IterableDataRegion.US
124+
118125
/**
119126
* Android only feature: This controls whether the SDK should enforce encryption for all PII stored on disk.
120127
* By default, the SDK will not enforce encryption and may fallback to unencrypted storage in case the encryption fails.
@@ -135,6 +142,7 @@ class IterableConfig {
135142
"allowedProtocols": this.allowedProtocols,
136143
"androidSdkUseInMemoryStorageForInApps": this.androidSdkUseInMemoryStorageForInApps,
137144
"useInMemoryStorageForInApps": this.useInMemoryStorageForInApps,
145+
"dataRegion": this.dataRegion,
138146
"encryptionEnforced": this.encryptionEnforced
139147
}
140148
}

ts/IterableDataRegion.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
enum IterableDataRegion {
2+
US = 0,
3+
EU = 1
4+
}
5+
6+
export {
7+
IterableDataRegion
8+
}

ts/__tests__/Iterable.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
IterableActionSource
2020
} from '../Iterable'
2121
import { IterableLogger } from '../IterableLogger'
22+
import { IterableDataRegion } from '../IterableDataRegion'
2223

2324
beforeEach(() => {
2425
jest.clearAllMocks()
@@ -239,6 +240,7 @@ test('iterableConfig_noParams_defaultValues', () => {
239240
expect(config.allowedProtocols).toEqual([])
240241
expect(config.androidSdkUseInMemoryStorageForInApps).toBe(false)
241242
expect(config.useInMemoryStorageForInApps).toBe(false)
243+
expect(config.dataRegion).toBe(IterableDataRegion.US)
242244
expect(config.encryptionEnforced).toBe(false)
243245
})
244246

@@ -262,6 +264,7 @@ test('iterableConfig_noParams_defaultDictValues', () => {
262264
expect(configDict.allowedProtocols).toEqual([])
263265
expect(configDict.androidSdkUseInMemoryStorageForInApps).toBe(false)
264266
expect(configDict.useInMemoryStorageForInApps).toBe(false)
267+
expect(configDict.dataRegion).toBe(IterableDataRegion.US)
265268
expect(configDict.encryptionEnforced).toBe(false)
266269
})
267270

ts/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import useDeviceOrientation from './useDeviceOrientation'
4040
import InboxImpressionRowInfo from './InboxImpressionRowInfo'
4141

4242
import IterableConfig from './IterableConfig'
43+
import { IterableDataRegion } from './IterableDataRegion'
4344

4445
export {
4546
Iterable,
@@ -63,7 +64,8 @@ export {
6364
IterableInboxEmptyState,
6465
IterableInboxMessageCell,
6566
useAppStateListener,
66-
useDeviceOrientation
67+
useDeviceOrientation,
68+
IterableDataRegion
6769
}
6870
export type {
6971
IterableInAppContent,

0 commit comments

Comments
 (0)