From 688c5b393e9bb6c333bb33b5e14d7121ca5ea7a0 Mon Sep 17 00:00:00 2001 From: Christian Brevik Date: Tue, 26 Jan 2016 18:57:45 +0100 Subject: [PATCH] minor fixes, more example code --- README.md | 2 +- .../GoogleAnalyticsBridge.java | 4 +-- example/index.android.js | 29 +++++++++++++++++++ example/index.ios.js | 28 ++++++++++++++++++ example/ios/example.xcodeproj/project.pbxproj | 8 ++--- 5 files changed, 64 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 111de5909..dbf2a4fb1 100644 --- a/README.md +++ b/README.md @@ -156,7 +156,7 @@ See the [Google Analytics docs](https://developers.google.com/analytics/devguide ```javascript GoogleAnalytics.trackPurchase({ - id: 'P12345' + id: 'P12345', name: 'Android Warhol T-Shirt', category: 'Apparel/T-Shirts', brand: 'Google', diff --git a/android/src/main/java/com/idehub/GoogleAnalyticsBridge/GoogleAnalyticsBridge.java b/android/src/main/java/com/idehub/GoogleAnalyticsBridge/GoogleAnalyticsBridge.java index cca67e91a..08865dae1 100644 --- a/android/src/main/java/com/idehub/GoogleAnalyticsBridge/GoogleAnalyticsBridge.java +++ b/android/src/main/java/com/idehub/GoogleAnalyticsBridge/GoogleAnalyticsBridge.java @@ -92,7 +92,7 @@ public void trackPurchaseEvent(ReadableMap product, ReadableMap transaction, Str if (tracker != null) { Product ecommerceProduct = new Product() - .setId(product.getString("productId")) + .setId(product.getString("id")) .setName(product.getString("name")) .setCategory(product.getString("category")) .setBrand(product.getString("brand")) @@ -102,7 +102,7 @@ public void trackPurchaseEvent(ReadableMap product, ReadableMap transaction, Str .setQuantity(product.getInt("quantity")); ProductAction productAction = new ProductAction(ProductAction.ACTION_PURCHASE) - .setTransactionId(transaction.getString("transactionId")) + .setTransactionId(transaction.getString("id")) .setTransactionAffiliation(transaction.getString("affiliation")) .setTransactionRevenue(transaction.getDouble("revenue")) .setTransactionTax(transaction.getDouble("tax")) diff --git a/example/index.android.js b/example/index.android.js index b92760c44..aec9b2cf1 100644 --- a/example/index.android.js +++ b/example/index.android.js @@ -22,6 +22,35 @@ var example = React.createClass({ GoogleAnalytics.setDryRun(false); GoogleAnalytics.trackEvent('testcategory', 'Hello Android', { label: "notdry", value: 1 }); + GoogleAnalytics.trackPurchaseEvent( + { + id: 'P12345', + name: 'Android Warhol T-Shirt', + category: 'Apparel/T-Shirts', + brand: 'Google', + variant: 'Black', + price: 29.20, + quantity: 1, + couponCode: 'APPARELSALE' + }, { + id: 'T12345', + affiliation: 'Google Store - Online', + revenue: 37.39, + tax: 2.85, + shipping: 5.34, + couponCode: 'SUMMER2013' + } + ); + + + GoogleAnalytics.trackException("This is an error message", false); + + GoogleAnalytics.trackSocialInteraction('Twitter', 'Post'); + + GoogleAnalytics.setUser('12345678'); + + GoogleAnalytics.allowIDFA(true); + return ( diff --git a/example/index.ios.js b/example/index.ios.js index 12a784407..49d375fd6 100644 --- a/example/index.ios.js +++ b/example/index.ios.js @@ -23,6 +23,34 @@ var example = React.createClass({ GoogleAnalytics.setDryRun(false); GoogleAnalytics.trackEvent('testcategory', 'Hello iOS', { label: "notdry", value: 1 }); + GoogleAnalytics.trackPurchaseEvent( + { + id: 'P12345', + name: 'Android Warhol T-Shirt', + category: 'Apparel/T-Shirts', + brand: 'Apple', + variant: 'Black', + price: 29.20, + quantity: 1, + couponCode: 'APPARELSALE' + }, { + id: 'T12345', + affiliation: 'Apple Store - Online', + revenue: 37.39, + tax: 2.85, + shipping: 5.34, + couponCode: 'SUMMER2013' + } + ); + + GoogleAnalytics.trackException("This is an error message", false); + + GoogleAnalytics.trackSocialInteraction('Twitter', 'Post'); + + GoogleAnalytics.setUser('12345678'); + + GoogleAnalytics.allowIDFA(true); + return ( diff --git a/example/ios/example.xcodeproj/project.pbxproj b/example/ios/example.xcodeproj/project.pbxproj index 77242976e..d9c3108fd 100644 --- a/example/ios/example.xcodeproj/project.pbxproj +++ b/example/ios/example.xcodeproj/project.pbxproj @@ -23,11 +23,11 @@ 146834051AC3E58100842450 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; }; 832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; }; A79186011C30977F001236A6 /* libRCTGoogleAnalyticsBridge.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A79186001C308FDC001236A6 /* libRCTGoogleAnalyticsBridge.a */; }; - A79186031C309837001236A6 /* AdSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A79186021C309837001236A6 /* AdSupport.framework */; }; A79186051C30983F001236A6 /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A79186041C30983F001236A6 /* CoreData.framework */; }; A79186071C309848001236A6 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A79186061C309848001236A6 /* SystemConfiguration.framework */; }; A79186091C30984E001236A6 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = A79186081C30984E001236A6 /* libz.tbd */; }; A791860B1C309879001236A6 /* libsqlite3.0.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = A791860A1C309879001236A6 /* libsqlite3.0.tbd */; }; + A7B8CAC11C57E98C004DAC02 /* AdSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A7B8CAC01C57E98C004DAC02 /* AdSupport.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -140,11 +140,11 @@ 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = ""; }; 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = ""; }; A79185FB1C308FDC001236A6 /* RCTGoogleAnalyticsBridge.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTGoogleAnalyticsBridge.xcodeproj; path = ../../ios/RCTGoogleAnalyticsBridge/RCTGoogleAnalyticsBridge.xcodeproj; sourceTree = ""; }; - A79186021C309837001236A6 /* AdSupport.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AdSupport.framework; path = System/Library/Frameworks/AdSupport.framework; sourceTree = SDKROOT; }; A79186041C30983F001236A6 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; }; A79186061C309848001236A6 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; A79186081C30984E001236A6 /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; }; A791860A1C309879001236A6 /* libsqlite3.0.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libsqlite3.0.tbd; path = usr/lib/libsqlite3.0.tbd; sourceTree = SDKROOT; }; + A7B8CAC01C57E98C004DAC02 /* AdSupport.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AdSupport.framework; path = System/Library/Frameworks/AdSupport.framework; sourceTree = SDKROOT; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -159,12 +159,12 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + A7B8CAC11C57E98C004DAC02 /* AdSupport.framework in Frameworks */, A79186011C30977F001236A6 /* libRCTGoogleAnalyticsBridge.a in Frameworks */, A791860B1C309879001236A6 /* libsqlite3.0.tbd in Frameworks */, A79186091C30984E001236A6 /* libz.tbd in Frameworks */, A79186071C309848001236A6 /* SystemConfiguration.framework in Frameworks */, A79186051C30983F001236A6 /* CoreData.framework in Frameworks */, - A79186031C309837001236A6 /* AdSupport.framework in Frameworks */, 146834051AC3E58100842450 /* libReact.a in Frameworks */, 00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */, 00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */, @@ -313,11 +313,11 @@ 83CBB9F61A601CBA00E9B192 = { isa = PBXGroup; children = ( + A7B8CAC01C57E98C004DAC02 /* AdSupport.framework */, A791860A1C309879001236A6 /* libsqlite3.0.tbd */, A79186081C30984E001236A6 /* libz.tbd */, A79186061C309848001236A6 /* SystemConfiguration.framework */, A79186041C30983F001236A6 /* CoreData.framework */, - A79186021C309837001236A6 /* AdSupport.framework */, 13B07FAE1A68108700A75B9A /* example */, 832341AE1AAA6A7D00B99B32 /* Libraries */, 00E356EF1AD99517003FC87E /* exampleTests */,