Skip to content

Commit

Permalink
Release of version 0.22.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Krzysztof Kurzawa committed Jul 15, 2024
1 parent eb380ac commit de64abc
Show file tree
Hide file tree
Showing 19 changed files with 442 additions and 26 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

All notable changes to this project will be documented in this file.

## [0.22.0] - 2024-07-16

IMPORTANT:
The SDK version 0.21.0 has been omitted for technical reasons.

### Added
- We added a`testDelivery` and `journeyId` parameters to tracked notification events (`push.view`, `push.click`, and so on). It describes if the notification was sent as a test notification from a campaign.
- We added a new `Synerise.content.generateDocumentWithApiQuery(apiQuery, onSuccess, onError)` method. It is analogous to `Synerise.content.generateDocument(slug:onSuccess:onError:)`, but can contain more context parameters provided in a query object.
- We added a new `Content.generateScreenViewWithApiQuery(apiQuery, onSuccess, onError)` method. It is analogous to `Synerise.content.generateScreenView(feedSlug:onSuccess:onError:)`, but can contain more context parameters provided in a query object.
- Anchors from Drag & Drop Builder in the In-App editor are interpreted as URL or as deeplink depending on the value.

### Changed
- We added validation of reserved parameters in events. Now, if a parameter is forbidden, it is removed from the parameters and a log is printed.
- Stability improvements.
- Update of native SDK's dependencies.

## [0.20.0] - 2024-06-02

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Synerise React Native SDK (react-native-synerise-sdk) (0.20.0)
# Synerise React Native SDK (react-native-synerise-sdk) (0.21.0)

[![Platform](https://img.shields.io/badge/platform-iOS-orange.svg)](https://github.com/synerise/synerise-ios-sdk)
[![Platform](https://img.shields.io/badge/platform-iOS-orange.svg)](https://github.com/synerise/ios-sdk)
[![Platform](https://img.shields.io/badge/platform-Android-orange.svg)](https://github.com/synerise/android-sdk)
[![Languages](https://img.shields.io/badge/language-TypeScript%20%7C%20Java%20%7C%20Objective--C-orange.svg)](https://github.com/synerise/react-native-synerise-sdk)
[![npm](https://img.shields.io/npm/v/react-native-synerise-sdk.svg)](https://www.npmjs.com/package/react-native-synerise-sdk)
Expand Down
7 changes: 4 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ ext.versions = [
'minSdk' : 21,
'compileSdk' : 33,
'targetSdk' : 33,
'versionCode': 34,
'versionName': "0.20.0"
'versionCode': 36,
'versionName': "0.22.0"
]

buildscript {
Expand Down Expand Up @@ -42,6 +42,7 @@ android {
all {
}
}
namespace "com.synerise.sdk.react"
}

repositories {
Expand All @@ -57,7 +58,7 @@ repositories {
dependencies {
implementation 'com.facebook.react:react-native:+'
implementation "com.squareup.okhttp3:logging-interceptor:4.9.1"
api 'com.synerise.sdk:synerise-mobile-sdk:5.17.0'
api 'com.synerise.sdk:synerise-mobile-sdk:5.19.0'
}

//apply from: 'publish.gradle'
3 changes: 1 addition & 2 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.synerise.sdk.react">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>

141 changes: 138 additions & 3 deletions android/src/main/java/com/synerise/sdk/react/RNContent.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,38 @@
import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.ReadableType;
import com.facebook.react.bridge.WritableArray;
import com.facebook.react.bridge.WritableMap;
import com.google.gson.Gson;
import com.synerise.sdk.client.model.simpleAuth.ClientData;
import com.synerise.sdk.content.Content;
import com.synerise.sdk.content.model.Audience;
import com.synerise.sdk.content.model.DocumentsApiQuery;
import com.synerise.sdk.content.model.DocumentsApiQueryType;
import com.synerise.sdk.content.model.ScreenViewResponse;
import com.synerise.sdk.content.model.document.Document;
import com.synerise.sdk.content.model.document.DocumentApiQuery;
import com.synerise.sdk.content.model.recommendation.FiltersJoinerRule;
import com.synerise.sdk.content.model.recommendation.RecommendationRequestBody;
import com.synerise.sdk.content.model.recommendation.RecommendationResponse;
import com.synerise.sdk.content.model.screenview.ScreenView;
import com.synerise.sdk.content.model.screenview.ScreenViewApiQuery;
import com.synerise.sdk.content.widgets.dataModel.Recommendation;
import com.synerise.sdk.core.listeners.DataActionListener;
import com.synerise.sdk.core.net.IDataApiCall;
import com.synerise.sdk.error.ApiError;
import com.synerise.sdk.promotions.model.promotion.PromotionStatus;

import org.json.JSONException;
import org.json.JSONObject;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Locale;
Expand Down Expand Up @@ -191,13 +200,11 @@ public void onDataAction(ApiError apiError) {

@ReactMethod
public void getRecommendationsV2(ReadableMap recommendationsOptions, Callback callback) {
String productId = recommendationsOptions.hasKey("productID") ? recommendationsOptions.getString("productID") : "";
String slugName = recommendationsOptions.hasKey("slug") ? recommendationsOptions.getString("slug") : "";

if (getRecommendationsApiCall != null) getRecommendationsApiCall.cancel();

RecommendationRequestBody recommendationRequestBody = new RecommendationRequestBody();
recommendationRequestBody.setProductId(productId);
RecommendationRequestBody recommendationRequestBody = readableMapToRecommendationRequestBody(recommendationsOptions);

getRecommendationsApiCall = Content.getRecommendationsV2(slugName, recommendationRequestBody);
getRecommendationsApiCall.execute(new DataActionListener<RecommendationResponse>() {
Expand Down Expand Up @@ -252,6 +259,37 @@ public void onDataAction(ApiError apiError) {
});
}

@ReactMethod
public void generateDocumentWithApiQuery(ReadableMap documentApiQueryMap, Callback callback) {
if (generateDocumentApiCall != null) generateDocumentApiCall.cancel();

DocumentApiQuery documentApiQuery = readableMapToDocumentApiQuery(documentApiQueryMap);
generateDocumentApiCall = Content.generateDocument(documentApiQuery);
generateDocumentApiCall.execute(new DataActionListener<Document>() {

@Override
public void onDataAction(Document document) {
WritableMap documentMap = Arguments.createMap();
documentMap.putString("uuid", document.getUuid());
documentMap.putString("slug", document.getSlug());
documentMap.putString("schema", document.getSchema());
try {
String jsonObject = gson.toJson(document);
WritableMap objectMap = convertJsonToMap(new JSONObject(jsonObject));
documentMap.putMap("content", objectMap);
executeSuccessCallbackResponse(callback, documentMap, null);
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new DataActionListener<ApiError>() {
@Override
public void onDataAction(ApiError apiError) {
executeFailureCallbackResponse(callback, null, apiError);
}
});
}

@ReactMethod
public void generateScreenView(String feedSlug, Callback callback) {
if (generateScreenViewApiCall != null) generateScreenViewApiCall.cancel();
Expand Down Expand Up @@ -294,6 +332,103 @@ public void onDataAction(ApiError apiError) {
);
}

@ReactMethod
public void generateScreenViewWithApiQuery(ReadableMap screenViewApiQueryMap, Callback callback) {
String feedSlug = screenViewApiQueryMap.hasKey("feedSlug") ? screenViewApiQueryMap.getString("feedSlug") : "";
String productId = screenViewApiQueryMap.hasKey("productId") ? screenViewApiQueryMap.getString("productId") : "";
ScreenViewApiQuery screenViewApiQuery = new ScreenViewApiQuery(feedSlug, productId);
if (generateScreenViewApiCall != null) generateScreenViewApiCall.cancel();
generateScreenViewApiCall = Content.generateScreenView(screenViewApiQuery);
generateScreenViewApiCall.execute(
new DataActionListener<ScreenView>() {
@Override
public void onDataAction(ScreenView data) {
WritableMap screenViewMap = Arguments.createMap();
screenViewMap.putMap("audience", audienceNewScreenViewsToWritableMap(data.getAudience()));
screenViewMap.putString("identifier", data.getId());
screenViewMap.putString("hash", data.getHash());
screenViewMap.putString("path", data.getPath());
screenViewMap.putString("name", data.getName());
screenViewMap.putInt("priority", data.getPriority());
screenViewMap.putMap("data", screenViewDataToWritableMap(data.getData()));

try {
Date createdAtDate = new SimpleDateFormat(ISO8601_FORMAT, Locale.getDefault()).parse(data.getCreatedAt());
Date updatedAtDate = new SimpleDateFormat(ISO8601_FORMAT, Locale.getDefault()).parse(data.getUpdatedAt());

if (createdAtDate != null) {
screenViewMap.putDouble("createdAt", createdAtDate.getTime());
}
if (updatedAtDate != null) {
screenViewMap.putDouble("updatedAt", updatedAtDate.getTime());
}
} catch (ParseException e) {
e.printStackTrace();
}

executeSuccessCallbackResponse(callback, screenViewMap, null);
}
}, new DataActionListener<ApiError>() {
@Override
public void onDataAction(ApiError apiError) {
executeFailureCallbackResponse(callback, null, apiError);
}
}
);
}

private DocumentApiQuery readableMapToDocumentApiQuery(ReadableMap map) {
String slugName = map.hasKey("feedSlug") ? map.getString("feedSlug") : "";
DocumentApiQuery documentApiQuery = new DocumentApiQuery(slugName);
documentApiQuery.setProductId(map.hasKey("productId") ? map.getString("productId") : null);
documentApiQuery.setItemsIds(map.hasKey("itemsIds") ? readableArrayToListOfStrings(map.getArray("itemsIds")) : null);
documentApiQuery.setItemsExcluded(map.hasKey("itemsExcluded") ? readableArrayToListOfStrings(map.getArray("itemsExcluded")) : null);
documentApiQuery.setAdditionalFilters(map.hasKey("additionalFilters") ? map.getString("additionalFilters") : null);
documentApiQuery.setAdditionalElasticFilters(map.hasKey("additionalElasticFilters") ? map.getString("additionalElasticFilters") : null);
documentApiQuery.setDisplayAttributes(map.hasKey("displayAttribute") ? readableArrayToListOfStrings(map.getArray("displayAttribute")) : null);
documentApiQuery.setIncludeContextItems(map.hasKey("includeContextItems") ? map.getBoolean("includeContextItems") : null);
if (map.hasKey("filtersJoiner")) {
documentApiQuery.setFiltersJoiner(FiltersJoinerRule.valueOf(map.getString("filtersJoiner")));
}
if (map.hasKey("elasticFiltersJoiner")) {
documentApiQuery.setElasticFiltersJoiner(FiltersJoinerRule.valueOf(map.getString("elasticFiltersJoiner")));
}

return documentApiQuery;
}

private RecommendationRequestBody readableMapToRecommendationRequestBody(ReadableMap map) {
RecommendationRequestBody recommendationRequestBody = new RecommendationRequestBody();
recommendationRequestBody.setProductId(map.hasKey("productID") ? map.getString("productID") : null);
recommendationRequestBody.setItemsIds(map.hasKey("itemsIds") ? readableArrayToListOfStrings(map.getArray("itemsIds")) : null);
recommendationRequestBody.setItemsExcluded(map.hasKey("itemsExcluded") ? readableArrayToListOfStrings(map.getArray("itemsExcluded")) : null);
recommendationRequestBody.setAdditionalFilters(map.hasKey("additionalFilters") ? map.getString("additionalFilters") : null);
recommendationRequestBody.setAdditionalElasticFilters(map.hasKey("additionalElasticFilters") ? map.getString("additionalElasticFilters") : null);
recommendationRequestBody.setDisplayAttributes(map.hasKey("displayAttribute") ? readableArrayToListOfStrings(map.getArray("displayAttribute")) : null);
recommendationRequestBody.setIncludeContextItems(map.hasKey("includeContextItems") ? map.getBoolean("includeContextItems") : null);
if (map.hasKey("filtersJoiner")) {
recommendationRequestBody.setFiltersJoiner(FiltersJoinerRule.valueOf(map.getString("filtersJoiner")));
}
if (map.hasKey("elasticFiltersJoiner")) {
recommendationRequestBody.setElasticFiltersJoiner(FiltersJoinerRule.valueOf(map.getString("elasticFiltersJoiner")));
}

return recommendationRequestBody;
}

private static ArrayList<String> readableArrayToListOfStrings(ReadableArray readableArray) {
ArrayList<String> list = new ArrayList<>();

for (int i = 0; i < readableArray.size(); i++) {
ReadableType type = readableArray.getType(i);
if (type == ReadableType.String) {
list.add(readableArray.getString(i));
}
}

return list;
}

private WritableArray recommendationToWritableArray(List<Recommendation> array) {
WritableArray writableArray = Arguments.createArray();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class RNSyneriseInitializer {
public Boolean isCrashHandlingEnabled;
public static volatile boolean isInitialized = false;

public static final String SDK_PLUGIN_VERSION = "0.20.0";
public static final String SDK_PLUGIN_VERSION = "0.22.0";

public void initialize(Application app) {
if (isInitialized == false) {
Expand Down
2 changes: 1 addition & 1 deletion ios/ReactNativeSynerise/Main/RNSyneriseInitializer.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#import "RNSyneriseInitializer.h"

NSString * const SNRSyneriseSDKPluginVersion = @"0.20.0";
NSString * const SNRSyneriseSDKPluginVersion = @"0.22.0";

@implementation RNSyneriseInitializer

Expand Down
Loading

0 comments on commit de64abc

Please sign in to comment.