countly-sdk-react-native-bridge
Advanced tools
Comparing version 19.8.3 to 19.8.4
@@ -19,3 +19,3 @@ /** | ||
Countly.messagingMode = {"DEVELOPMENT":1,"PRODUCTION":0, "ADHOC": 2}; | ||
Countly.messagingMode = {"DEVELOPMENT":"1","PRODUCTION":"0", "ADHOC": "2"}; | ||
if (Platform.OS.match("android")) { | ||
@@ -105,3 +105,23 @@ Countly.messagingMode.DEVELOPMENT = 2; | ||
}; | ||
// As per the above documentation apply auto tracking method. | ||
// https://reactnavigation.org/docs/screen-tracking | ||
Countly.previousRouteName = ""; | ||
Countly.autoTrackingView = function(state){ | ||
const currentRouteName = getActiveRouteName(state); | ||
if(currentRouteName != Countly.previousRouteName){ | ||
Countly.recordView(currentRouteName); | ||
} | ||
Countly.previousRouteName = currentRouteName; | ||
}; | ||
const getActiveRouteName = function(state){ | ||
const route = state.routes[state.index]; | ||
if (route.state) { | ||
// Dive into nested navigators | ||
return getActiveRouteName(route.state); | ||
} | ||
return route.name; | ||
}; | ||
Countly.setViewTracking = function(boolean){ | ||
@@ -111,2 +131,7 @@ CountlyReactNative.setViewTracking([boolean || "false"]); | ||
Countly.pushTokenType = function(tokenType){ | ||
var args = []; | ||
args.push(tokenType || ""); | ||
CountlyReactNative.pushTokenType(args); | ||
} | ||
Countly.sendPushToken = function(options){ | ||
@@ -116,5 +141,7 @@ var args = []; | ||
args.push((options.messagingMode || "").toString()); | ||
CountlyReactNative.onRegistrationId(args); | ||
CountlyReactNative.sendPushToken(args); | ||
} | ||
Countly.askForNotificationPermission = function(){ | ||
CountlyReactNative.askForNotificationPermission([]); | ||
} | ||
// countly start for android | ||
@@ -190,2 +217,3 @@ Countly.start = function(){ | ||
} | ||
Countly.isCrashReportingEnabled = false; | ||
@@ -198,3 +226,2 @@ Countly.enableCrashReporting = function(){ | ||
var jsStackTrace = parseErrorStackLib(error); | ||
// console.log(jsStackTrace[0]); | ||
var fname = jsStackTrace[0].file; | ||
@@ -205,6 +232,21 @@ if (fname.startsWith("http")) { | ||
} | ||
if (Platform.OS.match("android")) { | ||
var errorTitle = `${error.name} (${jsStackTrace[0].methodName}@${fname})`; | ||
CountlyReactNative.logJSException(errorTitle, error.message.trim(), error.stack.toString().trim()); | ||
var errorTitle = `${error.name} (${jsStackTrace[0].methodName}@${fname})`; | ||
const regExp = "(.*)(@?)http(s?).*/(.*)\\?(.*):(.*):(.*)"; | ||
const stackArr = error.stack.split("\n").map(row => { | ||
row = row.trim(); | ||
if (!row.includes("http")) return row; | ||
else { | ||
const matches = row.match(regExp); | ||
return matches && matches.length == 8 ? `${matches[1]}${matches[2]}${matches[4]}(${matches[6]}:${matches[7]})` : row; | ||
} | ||
}) | ||
const stack = stackArr.join("\n"); | ||
if (Platform.OS.match("android")) { | ||
CountlyReactNative.logJSException(errorTitle, error.message.trim(), stack); | ||
} | ||
else if (Platform.OS.match("ios")) { | ||
const errMessage = `[React] ${errorTitle}: ${error.message}`; | ||
const errStack = error.message + "\n" + stack; | ||
CountlyReactNative.logJSException(errorTitle, errMessage, errStack); | ||
} | ||
if (previousHandler) { | ||
@@ -218,2 +260,3 @@ previousHandler(error, isFatal); | ||
} | ||
Countly.addCrashLog = function(crashLog){ | ||
@@ -220,0 +263,0 @@ CountlyReactNative.addCrashLog([crashLog]); |
@@ -5,2 +5,4 @@ import React, { Component } from 'react'; | ||
import { PushNotificationIOS } from 'react-native'; | ||
import { NavigationContainer } from '@react-navigation/native'; | ||
import { createStackNavigator } from '@react-navigation/stack'; | ||
// import StackTrace from '/Countly.StackTrace.js'; | ||
@@ -10,3 +12,68 @@ // import stacktrace from 'react-native-stacktrace'; | ||
Countly.autoTrackingView = function(state){ | ||
} | ||
// Auto Navigation Example. | ||
const Stack = createStackNavigator(); | ||
export const navigationRef = React.createRef(); | ||
export function navigate(name){ | ||
navigationRef.current?.navigate(name); | ||
} | ||
class PageOne extends Component { | ||
render(){ | ||
return( | ||
<ScrollView> | ||
<Text>Page One</Text> | ||
<Button onPress={() => navigate('PageOne')} title="Go to Page One"></Button> | ||
<Button onPress={() => navigate('PageTwo')} title="Go to Page Two"></Button> | ||
<Button onPress={() => navigate('PageThree')} title="Go to Page Three"></Button> | ||
<Button onPress={() => navigate('Example')} title="Go to Page Example"></Button> | ||
</ScrollView> | ||
); | ||
} | ||
} | ||
class PageTwo extends Component { | ||
render(){ | ||
return( | ||
<View> | ||
<Text>Page Two</Text> | ||
<Button onPress={() => navigate('PageOne')} title="Go to Page One"></Button> | ||
<Button onPress={() => navigate('PageTwo')} title="Go to Page Two"></Button> | ||
<Button onPress={() => navigate('PageThree')} title="Go to Page Three"></Button> | ||
<Button onPress={() => navigate('Example')} title="Go to Page Example"></Button> | ||
</View> | ||
); | ||
} | ||
} | ||
class PageThree extends Component { | ||
render(){ | ||
return( | ||
<View> | ||
<Text>Page Three</Text> | ||
<Button onPress={() => navigate('PageOne')} title="Go to Page One"></Button> | ||
<Button onPress={() => navigate('PageTwo')} title="Go to Page Two"></Button> | ||
<Button onPress={() => navigate('PageThree')} title="Go to Page Three"></Button> | ||
<Button onPress={() => navigate('Example')} title="Go to Page Example"></Button> | ||
</View> | ||
); | ||
} | ||
} | ||
// Auto Navigation Example. | ||
class AwesomeProject extends Component { | ||
render() { | ||
return ( | ||
<NavigationContainer onStateChange={Countly.autoTrackingView}> | ||
<Stack.Navigator initialRouteName="Example"> | ||
<Stack.Screen name="Example" component = {Example} /> | ||
<Stack.Screen name="PageOne" component={PageOne} /> | ||
<Stack.Screen name="PageTwo" component={PageTwo} /> | ||
<Stack.Screen name="PageThree" component={PageThree} /> | ||
</Stack.Navigator> | ||
</NavigationContainer> | ||
) | ||
} | ||
} | ||
class Example extends Component { | ||
constructor(props) { | ||
@@ -35,3 +102,4 @@ super(props); | ||
onInit(){ | ||
Countly.init("https://try.count.ly","0e8a00e8c01395a0af8be0e55da05a404bb23c3e"); | ||
Countly.init("https://trinisoft.count.ly", "f0b2ac6919f718a13821575db28c0e2971e05ec5"); | ||
// Countly.init("https://try.count.ly","0e8a00e8c01395a0af8be0e55da05a404bb23c3e"); | ||
// ,"","5", "Rate us.", "How would you rate the app?", "Dismiss",false | ||
@@ -253,7 +321,27 @@ } | ||
getRemoteConfigValueForKey(){ | ||
Countly.getRemoteConfigValueForKey("test1",function(data){ | ||
getRemoteConfigValueForKeyBoolean(){ | ||
Countly.getRemoteConfigValueForKey("booleanValue", function(data){ | ||
console.log(data); | ||
}); | ||
}; | ||
} | ||
getRemoteConfigValueForKeyFloat(){ | ||
Countly.getRemoteConfigValueForKey("floatValue", function(data){ | ||
console.log(data); | ||
}); | ||
} | ||
getRemoteConfigValueForKeyInteger(){ | ||
Countly.getRemoteConfigValueForKey("integerValue", function(data){ | ||
console.log(data); | ||
}); | ||
} | ||
getRemoteConfigValueForKeyString(){ | ||
Countly.getRemoteConfigValueForKey("stringValue", function(data){ | ||
console.log(data); | ||
}); | ||
} | ||
getRemoteConfigValueForKeyJSON(){ | ||
Countly.getRemoteConfigValueForKey("jsonValue", function(data){ | ||
console.log(data); | ||
}); | ||
} | ||
@@ -335,3 +423,3 @@ remoteConfigClearValues(){ | ||
showFeedbackPopup(){ | ||
Countly.showFeedbackPopup("5cda549bd9e26f31bca772c6", "Submit"); | ||
Countly.showFeedbackPopup("5e4254507975d006a22535fc", "Submit"); | ||
} | ||
@@ -410,3 +498,5 @@ | ||
return ( | ||
<ScrollView > | ||
<View style={{ justifyContent: 'center', alignItems: 'center', margin: 20 }}> | ||
@@ -416,2 +506,6 @@ <Image source={{uri: 'https://count.ly/images/logos/countly-logo.png'}} style={ {width: 144, height: 42} } onError={(e) => console.log(e.nativeEvent.error) }/> | ||
</View> | ||
<Button onPress={() => navigate('PageOne')} title="Go to Page One"></Button> | ||
< Button onPress = { this.test } title = "Test" color = "#1b1c1d"> </Button> | ||
@@ -489,3 +583,10 @@ < Button onPress = { this.onInit } title = "Init"> </Button> | ||
< Button onPress = { this.updateRemoteConfigExceptKeys } title = "Update Remote Config Except Keys" color = "#00b5ad"> </Button> | ||
< Button onPress = { this.getRemoteConfigValueForKey } title = "Get config value" color = "#00b5ad"> </Button> | ||
< Button onPress = { this.getRemoteConfigValueForKeyBoolean } title = "Boolean Test" color = "#00b5ad"> </Button> | ||
< Button onPress = { this.getRemoteConfigValueForKeyFloat } title = "Float Test" color = "#00b5ad"> </Button> | ||
< Button onPress = { this.getRemoteConfigValueForKeyInteger } title = "Integer Test" color = "#00b5ad"> </Button> | ||
< Button onPress = { this.getRemoteConfigValueForKeyString } title = "String Test" color = "#00b5ad"> </Button> | ||
< Button onPress = { this.getRemoteConfigValueForKeyJSON } title = "JSON Test" color = "#00b5ad"> </Button> | ||
< Button onPress = { this.remoteConfigClearValues } title = "Clear remote config cache" color = "#00b5ad"> </Button> | ||
@@ -492,0 +593,0 @@ |
{ | ||
"name": "countly-sdk-react-native-bridge", | ||
"version": "19.8.3", | ||
"version": "19.8.4", | ||
"author": { | ||
@@ -5,0 +5,0 @@ "name": "Trinisoft Technologies", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
237222
36
2384