From 2ccdb3f1a4de03c71ec89fc3362f84aa89f47c0e Mon Sep 17 00:00:00 2001 From: Sequoia AT Date: Fri, 8 Jun 2018 01:46:29 -0700 Subject: [PATCH 1/2] Fix event param settings --- .../src/main/java/io/branch/rnbranch/RNBranchModule.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/android/src/main/java/io/branch/rnbranch/RNBranchModule.java b/android/src/main/java/io/branch/rnbranch/RNBranchModule.java index 5c13b9f7d..cef37a1b1 100644 --- a/android/src/main/java/io/branch/rnbranch/RNBranchModule.java +++ b/android/src/main/java/io/branch/rnbranch/RNBranchModule.java @@ -579,9 +579,9 @@ public static BranchEvent createBranchEvent(String eventName, ReadableMap params if (params.hasKey("shipping")) event.setShipping(Double.parseDouble(params.getString("shipping"))); if (params.hasKey("tax")) event.setTax(Double.parseDouble(params.getString("tax"))); if (params.hasKey("coupon")) event.setCoupon(params.getString("coupon")); - if (params.hasKey("affiliation")) event.setTransactionID(params.getString("affiliation")); - if (params.hasKey("description")) event.setTransactionID(params.getString("description")); - if (params.hasKey("searchQuery")) event.setTransactionID(params.getString("searchQuery")); + if (params.hasKey("affiliation")) event.setAffiliation(params.getString("affiliation")); + if (params.hasKey("description")) event.setDescription(params.getString("description")); + if (params.hasKey("searchQuery")) event.setSearchQuery(params.getString("searchQuery")); if (params.hasKey("customData")) { ReadableMap customData = params.getMap("customData"); From 0818b7eb0ab418ad968c276e537c496f79686003 Mon Sep 17 00:00:00 2001 From: Sequoia AT Date: Fri, 8 Jun 2018 01:47:20 -0700 Subject: [PATCH 2/2] Test standard and custom branch event in testbed example --- examples/testbed_simple/src/BranchMethods.js | 66 +++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) diff --git a/examples/testbed_simple/src/BranchMethods.js b/examples/testbed_simple/src/BranchMethods.js index edcde5660..6935cdfed 100644 --- a/examples/testbed_simple/src/BranchMethods.js +++ b/examples/testbed_simple/src/BranchMethods.js @@ -3,7 +3,7 @@ import { ScrollView, StyleSheet, Text, View } from 'react-native' import Button from './Button' -import branch, { RegisterViewEvent } from 'react-native-branch' +import branch, { RegisterViewEvent, BranchEvent } from 'react-native-branch' const defaultBUO = { title: 'wallo' @@ -154,6 +154,68 @@ class BranchMethods extends Component { } } + logStandardEvent = async () => { + if (!this.buo) await this.createBranchUniversalObject() + try { + let branchEvent = new BranchEvent( + BranchEvent.Purchase, + this.buo, + { + transactionID: '12344555', + currency: 'USD', + revenue: 1.5, + shipping: 10.2, + tax: 12.3, + coupon: 'test_coupon', + affiliation: 'test_affiliation', + description: 'Test purchase event', + searchQuery: 'test keyword', + customData: { + "Custom_Event_Property_Key1": "Custom_Event_Property_val1", + "Custom_Event_Property_Key2": "Custom_Event_Property_val2" + } + } + ) + branchEvent.logEvent() + + this.addResult('success', 'sendStandardEvent', branchEvent) + } catch (err) { + console.log('sendStandardEvent err', err) + this.addResult('error', 'sendStandardEvent', err.toString()) + } + } + + logCustomEvent = async () => { + if (!this.buo) await this.createBranchUniversalObject() + try { + let branchEvent = new BranchEvent( + 'Test Custom Event Name', + this.buo, + { + transactionID: '12344555', + currency: 'USD', + revenue: 1.5, + shipping: 10.2, + tax: 12.3, + coupon: 'test_coupon', + affiliation: 'test_affiliation', + description: 'Test purchase event', + searchQuery: 'test keyword', + customData: { + "Custom_Event_Property_Key1": "Custom_Event_Property_val1", + "Custom_Event_Property_Key2": "Custom_Event_Property_val2" + } + } + ) + branchEvent.logEvent() + + this.addResult('success', 'sendStandardEvent', branchEvent) + } catch (err) { + console.log('sendStandardEvent err', err) + this.addResult('error', 'sendStandardEvent', err.toString()) + } + } + addResult(type, slug, payload) { let result = { type, slug, payload } this.setState({ @@ -192,6 +254,8 @@ class BranchMethods extends Component { + + )