Plugin Name: SolarEngine React Native Plugin
Developer: Mobvista Cloud (Beijing) Technology Co., Ltd.
Plugin Version: V1.6.7
Please check Changelog to see the lastest SDK versions supported (Default iOS 1.3.0.3, Android 1.2.9.8).
Description: SolarEngine (SE) is an all-in-one mobile app growth analytics and data intelligence platform. It supports data management across global channels, assisting developers to monitor every stage of business development. With our attribution tracking and user-granular ROI analysis, you'll be able to measure the true value every channel creates and optimize future growth strategies. SE also offers various analysis models and A/B testing feature to help fully visualize the user journey, identify potential pain points, implement targeted product enhancements and ultimately drive large-scale app growth.
Privacy Policy: https://www.solar-engine.com/privacyPolicyEN.html
Note:
The SolarEngine SDK supports Android 5.0(APILevel 21) and above.
Access Path: Asset Management - App Management - AppKey
For applications developed with React Native, it is recommended to integrate SolarEngine SDK React Native plugin using either npm or yarn. Please execute the following command in your project's root directory.
After the commands are completed, don't forget to update the dependencies for the remote library in the native project.
// If you use npm
npm install solarengine-analysis-react-native
// If you use yarn
yarn add solarengine-analysis-react-native
Note:
React Native version 0.60 and above supports autolinking, so you do not need to execute the following react-native link command.
react-native link solarengine-analysis-react-native
If you need to specify the version of native SDK,
// If no platform specified, modify both iOS and Android SDK versions.
node node_modules/solarengine-analysis-react-native/cli.js set-config --sdkVersion=1.2.9.8
// Just only modify the iOS SDK version
node node_modules/solarengine-analysis-react-native/cli.js set-config --sdkVersion=1.3.0.3 --platform=ios
// Just only modify the Android SDK version
node node_modules/solarengine-analysis-react-native/cli.js set-config --sdkVersion=1.2.9.8 --platform=android
If you need to remove "Remote Config & A/B Testing" module,
node node_modules/solarengine-analysis-react-native/cli.js set-config -d
If you need to re-activate "Remote Config & A/B Testing" module,
node node_modules/solarengine-analysis-react-native/cli.js set-config -e
Add the Maven repository configuration as follows:
maven {
url "https://maven-android.solar-engine.com/repository/se_sdk_for_android/"
}
maven {
url "https://developer.huawei.com/repo/"
}
maven {
url "https://developer.hihonor.com/repo"
}
Add the following permissions in the project's AndroidManifest.xml file:
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
Note:
The permission android.permission.READ_PHONE_STATE is not necessary. If you're using China Mainland SDK, it's not required to forcibly obtain this permission. If you do acquire this permission and the Android system is above 6.0, please request this permission dynamically.
Suitable for iOS 11.0 and above.
For Xcode versions, 14.0 and above are supported.
When the application is first launched after install, the SDK is pre-initialized. During pre-initialization, the SDK does not collect any personal information or report data to SolarEngine.
Function
export function preInit(appKey: string)
Sample Code
import SolarEngine from 'solarengine-analysis-react-native'; // If your app is published globally
import SolarEngine from 'solarengine-analysis-react-native-cn'; // If your app is published only in China Mainland
let appKey = "";
if (Platform.OS === 'ios') {
appKey = "your_iOS_appkey";// Input your own iOS appkey
} else if (Platform.OS === 'android') {
appKey = "your_Android_appkey";// Input your own Android appkey
}
SolarEngine.preInit(appKey);
Function
export function initialize(appKey:string,options:SolarEngineInitiateOptions,completion: (result: InitiateCompletionInfo) => void)
Parameter | Description | Type | Required |
---|---|---|---|
appKey | Appkey you obtained in Step 1 | string | Yes |
options | SolarEngine SDK configuration | SolarEngineInitiateOptions | Yes |
completion | Initialization callback info | InitiateCompletionInfo | Yes |
SolarEngineInitiateOptions description:
Parameter | Description | Type | Required |
---|---|---|---|
config | SDK related config | se_initial_config | no |
remoteConfig | A/B Testing and Remote Config related config | RemoteConfig | no |
attribution | To receive attribution callback information | attribution | no |
deeplink | To receive deeplink callback information | deeplink | no |
deferredDeeplink | To receive deferred deeplink callback information | deferredDeeplink | no |
se_initial_config description:
Parameter | Description | Type | Required |
---|---|---|---|
enableLog | Whether to enable debugging logs (default off) | boolean | NO |
enableDebug | Whether to enable Debug mode (default off) | boolean | NO |
enable2G | Whether to enable data reporting in 2G environment (default false) | boolean | NO |
enableGDPR | If your product is operated within the EU region, there will be GDPR restrictions to follow. (default false) | boolean | NO |
enablePersonalizedAd | Whether users allow Google to use their data for ad personalization. If not set, this field will not be reported. Only applicable for Android as there is no such field for iOS. | boolean | NO |
enableUserData | Whether users allow their personal data to be shared with Google. If not set, this field will not be reported. Only applicable for Android as there is no such field for iOS. | boolean | NO |
enableCoppa | Whether your app is required to comply with Children's Online Privacy Protection Rule ("COPPA"). Default false. | boolean | NO |
enableKidsApp | Whether your app is targeting kids under 13 years old and needs to be marked as "Kids App" category. Default false. | boolean | NO |
enableDeferredDeeplink | Whether to enable deferred deep linking, default False. | boolean | NO |
android.metaAppId | If Non-China-Mainland developers need to use Meta attribution, set meta appid here. | string | NO |
ios.attAuthorizationWaitingInterval | Supports ATT Authorization Waiting for up to 120 seconds when iOS devices report events for the first time. Then SDK will report the install event only after users authorize ATT or when waiting time is up. (Unit: second) | number | NO |
ios.caid | Only for China Mainland SDK | string | NO |
RemoteConfig description:
Parameter | Description | Type | Required |
---|---|---|---|
enabled | Whether to enable Remote Config SDK (default false) | boolean | YES |
mergeType | SDK configuration merge strategy: By default, server configurations are merged with local cached configurations. For specific definitions, please refer to the explanation below. | RemoteConfigMergeType | NO |
customIDProperties | Custom ID, corresponding to those set on SE dashboard | Object | NO |
customIDEventProperties | Custom ID event properties, corresponding to those set on SE dashboard | Object | NO |
customIDUserProperties | Custom ID user properties, corresponding to those set on SE dashboard | Object | NO |
RemoteConfigMergeType description:
Parameter | Description |
---|---|
User | When the app is first launched or updated, the server configuration is merged with the user's default configuration. This method can clear the local cached configuration. |
Cache | Merge the server configuration with the user's existing local cached configuration; this is the default merge strategy for the Remote Config SDK. |
To receive attribution callback information:
type attribution = (code:number,attribution?:Object) => void;
To receive deeplink callback information:
type deeplink = (code:number,deepLinkInfo?:DeepLinkInfo) => void;
DeepLinkInfo
Parameter | Description | Type |
---|---|---|
sedpLink | redirect parameters | string |
turlId | 7-character short link | string |
from | link type | string |
customParams | custom parameters | Object |
To receive deferred deeplink callback information:
type deferredDeeplink = (code:number,deferredDeepLinkInfo?:DeferredDeepLinkInfo) => void;
DeferredDeepLinkInfo
Parameter | Description | Type |
---|---|---|
sedpLink | redirect parameters | string |
turlId | 7-character short link | string |
sedpUrlscheme | The URL Scheme you input when creating deep linking | string |
Sample Code
async function Initiate(){
log("Initiate" );
let appKey = "";
if (Platform.OS === 'ios') {
appKey = "your_iOS_appKey";
} else if (Platform.OS === 'android') {
appKey = "your_Android_appKey";
}
let config:se_initial_config = buildInitialConfig();
let remoteConfig:RemoteConfig = buildRemoteConfig();
let attribution:attribution = buildAttribution();
let deeplink:deeplink = buildDeeplinkResponse();
let deferredDeeplink: deferredDeeplink = buildDeferredDeeplinkResponse();
let initiateOptions:SolarEngineInitiateOptions = {
config:config,
remoteConfig:remoteConfig,
attribution:attribution,
deeplink:deeplink,
deferredDeeplink:deferredDeeplink
}
SolarEngine.initialize(appKey,initiateOptions,(result:InitiateCompletionInfo) => {
if (result.success) {
Alert.alert('SolarEngine SDK Initiate Complete!')
}
});
}
SDK related config
function buildInitialConfig():se_initial_config{
let config:se_initial_config = {
enableLog: true,
enableDebug: false,
...
};
return config;
}
Remote Config & A/B Testing related config
function buildRemoteConfig():RemoteConfig{
let remoteConfig:RemoteConfig = {
enabled:true,
mergeType:RemoteConfigMergeType.Cache,
customIDProperties:{"name":"name_value"},
customIDEventProperties:{"age":28},
customIDUserProperties:{"key":"value"},
}
return remoteConfig;
}
To receive attribution callback information:
function buildAttribution():attribution{
const handleAttribution:attribution = (code:number,attributionInfo?:Object) => {
console.log("attribution code: " + code);
if (code === 0){
console.log("attributionInfo: " + JSON.stringify(attributionInfo));
const typedValue = attributionInfo as {channel_name : string,
attribution_time:string,
re_data: object};
console.log("channel_name: " + typedValue.channel_name)
console.log("attribution_time: " + typedValue.attribution_time)
const re_dataValue = typedValue.re_data as {install_time:string,
report_time:string
}
if(typedValue.re_data != null){
console.log("re_data.install_time: " + re_dataValue.install_time)
console.log("re_data.report_time: " + re_dataValue.report_time)
}else{
console.log("re_data: is null" )
}
}
}
return handleAttribution;
}
To receive deeplink callback information:
function buildDeeplinkResponse():deeplink{
const handleDeepLink: deeplink = (code:number,deepLinkInfo?: DeepLinkInfo) => {
if(code === 0){
if(deepLinkInfo){
console.log("deepLinkInfo.sedpLink: " + deepLinkInfo.sedpLink);
}
}else{
console.log("code: " + code);
}
};
return handleDeepLink;
}
To receive deferred deeplink callback information:
function buildDeferredDeeplinkResponse(): deferredDeeplink {
const handleDeferredDeeplink: deferredDeeplink = (
code: number,
deferreddeeplink?: DeferredDeepLinkInfo
) => {
if (code === 0) {
if (deferreddeeplink) {
log('deferreddeeplink.sedpLink: ' + deferreddeeplink.sedpLink);
}
} else {
log('code: ' + code);
}
};
return handleDeferredDeeplink;
}
InitiateCompletionInfo error codes:
101 | SDK is not pre-initialized |
102 | illegal appkey |
103 | null context(Android only) |
104 | distinct_id creation failed(Android only) |
The SDK provides an interface to obtain attribution result information, which developers can use for tracking and other logical processing.
The SDK offers two methods to retrieve attribution result information:
Please refer to above "To receive attribution callback information" part.
Function
export function retrieveAttribution(): Object|null;
Sample Code
function retrieveAttribution(){
let attribution:Object|null = SolarEngine.retrieveAttribution();
if (attribution != null) {
log('attribution: ' + JSON.stringify(attribution));
const object = attribution as { channel_name: string; attribution_time: string};
log("channel_name:" + object.channel_name);
log("attribution_time:" + object.attribution_time);
}else{
log("attribution is null");
}
}
Attribution error code descriptions and detailed attribution results can be found in:
https://help.solar-engine.com/en/docs/SDK-Attribution-Result-Details