Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,43 @@ jobs:
- name: Build example for iOS
run: |
yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}"

plugin-integration-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup

- name: Install JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'

- name: Install Maestro
run: |
curl -Ls "https://get.maestro.mobile.dev" | bash
export PATH="$HOME/.maestro/bin:$PATH"
maestro --version
echo "$HOME/.maestro/bin" >> $GITHUB_PATH
echo "MAESTRO=$HOME/.maestro/bin/maestro" >> $GITHUB_ENV

- name: Run Plugin Integration Test
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 34
target: default
arch: x86_64
script: |
cd $GITHUB_WORKSPACE
yarn install --immutable
cd example
npx react-native start &
sleep 30
npx react-native run-android --no-packager
sleep 15
export PATH="$HOME/.maestro/bin:$PATH"
maestro test .maestro/flows/plugin-integration-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,11 @@ class MappinteligencePluginModule(private val reactContext: ReactApplicationCont
@ReactMethod
override fun trackCustomPage(
pageTitle: String?,
pageParams: ReadableMap,
sessionParams: ReadableMap,
userCategoryParams: ReadableMap,
ecommerceParams: ReadableMap,
campaignParams: ReadableMap,
pageParams: ReadableMap?,
sessionParams: ReadableMap?,
userCategoryParams: ReadableMap?,
ecommerceParams: ReadableMap?,
campaignParams: ReadableMap?,
promise: Promise
) {
runOnPlugin(
Expand All @@ -294,10 +294,10 @@ class MappinteligencePluginModule(private val reactContext: ReactApplicationCont

/** Track page with a provided [PageViewEvent] */
@ReactMethod
override fun trackPageWithCustomData(params: ReadableMap, pageTitle: String, promise: Promise) {
override fun trackPageWithCustomData(params: ReadableMap?, pageTitle: String, promise: Promise) {
runOnPlugin(
whenInitialized = {
instance?.trackCustomPage(pageTitle, params.toMap(keyTransform = { it.toString() }))
instance?.trackCustomPage(pageTitle, params?.toMap(keyTransform = { it.toString() }) ?: emptyMap())
}
)
promise.resolve(true)
Expand All @@ -319,11 +319,11 @@ class MappinteligencePluginModule(private val reactContext: ReactApplicationCont
@ReactMethod
override fun trackAction(
name: String,
eventParameters: ReadableMap,
sessionParameters: ReadableMap,
userCategories: ReadableMap,
eCommerceParameters: ReadableMap,
campaignParameters: ReadableMap,
eventParameters: ReadableMap?,
sessionParameters: ReadableMap?,
userCategories: ReadableMap?,
eCommerceParameters: ReadableMap?,
campaignParameters: ReadableMap?,
promise: Promise
) {
runOnPlugin(
Expand Down Expand Up @@ -367,18 +367,19 @@ class MappinteligencePluginModule(private val reactContext: ReactApplicationCont
}

@ReactMethod
fun trackException(exception: ReadableMap, promise: Promise) {
fun trackException(exception: ReadableMap?, promise: Promise) {
runOnPlugin(
whenInitialized = {
val innerException = Exception(exception.getString("message"))
val message = exception?.getString("message") ?: "Unknown exception"
val innerException = Exception(message)
instance?.trackException(innerException)
}
)
promise.resolve(true)
}

@ReactMethod
override fun trackMedia(readableMap: ReadableMap, promise: Promise) {
override fun trackMedia(readableMap: ReadableMap?, promise: Promise) {
runOnPlugin(
whenInitialized = {
MediaEventMapper(readableMap).getData()?.let { instance?.trackMedia(it) }
Expand Down Expand Up @@ -508,11 +509,6 @@ class MappinteligencePluginModule(private val reactContext: ReactApplicationCont
throw Exception("Native crash")
}

@ReactMethod
fun nativeCrash() {
throw Exception("Native crash");
}

override fun getName(): String {
return NAME
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ interface MappintelligencePluginSpec : TurboModule {
promise: Promise
)
fun trackException(name: String, message: String, stacktrace: String?, promise: Promise)
fun trackException(exception: ReadableMap, promise: Promise)
fun trackException(exception: ReadableMap?, promise: Promise)
fun trackMedia(readableMap: ReadableMap?, promise: Promise)
fun trackUrl(url: String, mediaCode: String?, promise: Promise)
fun trackExceptionWithName(name: String, message: String, stacktrace: String?, promise: Promise)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.facebook.react.bridge.ReadableMap
import com.mappinteligenceplugin.mapper.Util.optBoolean
import com.mappinteligenceplugin.mapper.Util.optString
import com.mappinteligenceplugin.mapper.Util.toMap
import com.mappinteligenceplugin.mapper.Util.optMap
import webtrekk.android.sdk.events.eventParams.CampaignParameters

class CampaignParametersMapper(private val readableMap: ReadableMap?) : Mapper<CampaignParameters> {
Expand All @@ -20,7 +21,7 @@ class CampaignParametersMapper(private val readableMap: ReadableMap?) : Mapper<C
this.action = action
this.mediaCode = mediaCode
this.oncePerSession = oncePerSession
this.customParameters = map.getMap("customParameters").toMap(keyTransform = {
this.customParameters = map.optMap("customParameters").toMap(keyTransform = {
it.toString().toInt()
})
}
Expand Down
15 changes: 15 additions & 0 deletions example/.maestro/flows/plugin-integration-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Plugin Integration Test - exercises all MappIntelligencePlugin methods
# and asserts no exceptions occurred.
appId: com.mappinteligencepluginexample
---
- launchApp
- tapOn:
text: "Plugin Integration Test"
- tapOn:
id: "run-plugin-tests"
- extendedWaitUntil:
visible:
id: "plugin-test-results"
timeout: 60000
- assertVisible:
id: "plugin-test-all-passed"
5 changes: 5 additions & 0 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.0.2",
"private": true,
"scripts": {
"test:integration": "maestro test .maestro/flows/plugin-integration-test.yaml",
"android": "react-native run-android",
"android:clean": "rm -rf android/build android/app/build && react-native run-android",
"ios": "react-native run-ios",
Expand Down Expand Up @@ -41,6 +42,10 @@
"react-native-builder-bob": "^0.40.8",
"react-native-monorepo-config": "^0.1.9"
},
"peerDependencies": {
"react": "*",
"react-native": "*"
},
"engines": {
"node": ">=18"
}
Expand Down
5 changes: 5 additions & 0 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
LogLevel,
} from 'mapp-intelligence-reactnative-plugin';
import FetchExample from './FetchExample';
import PluginIntegrationTest from './PluginIntegrationTest';

const Stack = createNativeStackNavigator();

Expand Down Expand Up @@ -82,6 +83,10 @@ const App = () => {
}}
>
<Stack.Screen name={Routes.HOME.valueOf()} component={Home} />
<Stack.Screen
name={Routes.PLUGIN_INTEGRATION_TEST.valueOf()}
component={PluginIntegrationTest}
/>
<Stack.Screen
name={Routes.PAGE_TRACKING.valueOf()}
component={PageTracking}
Expand Down
1 change: 1 addition & 0 deletions example/src/HomeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const HomeScreen = (props: { navigation: any }) => {
<View style={DefaultStyles.sectionContainer}>
<FlatList
data={[
Routes.PLUGIN_INTEGRATION_TEST,
Routes.CONFIG_TRACKING,
Routes.PAGE_TRACKING,
Routes.ACTION_TRACKING,
Expand Down
Loading