Skip to content

Commit b3af010

Browse files
committed
refac: add JS abstraction for store info
1 parent de3371f commit b3af010

File tree

3 files changed

+30
-12
lines changed

3 files changed

+30
-12
lines changed

Adjust/plugins/sdk-plugin-webbridge/src/main/assets/adjust_config.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ function AdjustConfig(appToken, environment, legacy) {
5252
this.shouldReadDeviceIdsOnce = null;
5353
this.eventDeduplicationIdsMaxSize = null;
5454
this.isFirstSessionDelayEnabled = null;
55-
this.storeInfoName = null;
56-
this.storeInfoAppId = null;
55+
this.adjustStoreInfo = null;
5756
}
5857

5958
AdjustConfig.EnvironmentSandbox = 'sandbox';
@@ -246,7 +245,6 @@ AdjustConfig.prototype.enableFirstSessionDelay = function() {
246245
this.isFirstSessionDelayEnabled = true;
247246
};
248247

249-
AdjustConfig.prototype.setStoreInfo = function(storeName, storeAppId) {
250-
this.storeInfoName = storeName;
251-
this.storeInfoAppId = storeAppId;
248+
AdjustConfig.prototype.setStoreInfo = function(adjustStoreInfo) {
249+
this.adjustStoreInfo = JSON.stringify(adjustStoreInfo);
252250
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function AdjustStoreInfo(storeName) {
2+
this.storeName = storeName;
3+
this.storeAppId = null;
4+
}
5+
6+
AdjustStoreInfo.prototype.setStoreAppId = function(storeAppId) {
7+
this.storeAppId = storeAppId;
8+
};

Adjust/plugins/sdk-plugin-webbridge/src/main/java/com/adjust/sdk/webbridge/AdjustBridgeInstance.java

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,7 @@ public void initSdk(String adjustConfigString) {
144144
Object shouldReadDeviceIdsOnceField = jsonAdjustConfig.get("shouldReadDeviceIdsOnce");
145145
Object eventDeduplicationIdsMaxSizeField = jsonAdjustConfig.get("eventDeduplicationIdsMaxSize");
146146
Object isFirstSessionDelayEnabledField = jsonAdjustConfig.get("isFirstSessionDelayEnabled");
147-
Object storeInfoNameField = jsonAdjustConfig.get("storeInfoName");
148-
Object storeInfoAppIdField = jsonAdjustConfig.get("storeInfoAppId");
147+
Object adjustStoreInfoField = jsonAdjustConfig.get("adjustStoreInfo");
149148

150149
String appToken = AdjustBridgeUtil.fieldToString(appTokenField);
151150
String environment = AdjustBridgeUtil.fieldToString(environmentField);
@@ -380,11 +379,24 @@ public boolean launchReceivedDeeplink(Uri deeplink) {
380379
}
381380

382381
// store info
383-
String storeName = AdjustBridgeUtil.fieldToString(storeInfoNameField);
384-
String storeAppId = AdjustBridgeUtil.fieldToString(storeInfoAppIdField);
385-
AdjustStoreInfo adjustStoreInfo = new AdjustStoreInfo(storeName);
386-
adjustStoreInfo.setStoreAppId(storeAppId);
387-
adjustConfig.setStoreInfo(adjustStoreInfo);
382+
String adjustStoreInfoString = AdjustBridgeUtil.fieldToString(adjustStoreInfoField);
383+
384+
try {
385+
JSONObject jsonAdjustStoreInfo = new JSONObject(adjustStoreInfoString);
386+
387+
Object storeNameField = jsonAdjustStoreInfo.get("storeName");
388+
Object storeAppIdField = jsonAdjustStoreInfo.get("storeAppId");
389+
390+
String storeName = AdjustBridgeUtil.fieldToString(storeNameField);
391+
String storeAppId = AdjustBridgeUtil.fieldToString(storeAppIdField);
392+
AdjustStoreInfo adjustStoreInfo = new AdjustStoreInfo(storeName);
393+
adjustStoreInfo.setStoreAppId(storeAppId);
394+
395+
// set store info
396+
adjustConfig.setStoreInfo(adjustStoreInfo);
397+
} catch (Exception e) {
398+
AdjustFactory.getLogger().error("AdjustBridgeInstance adjustStoreInfo: %s", e.getMessage());
399+
}
388400

389401
Adjust.initSdk(adjustConfig);
390402

0 commit comments

Comments
 (0)