From befa364f18770da533c64d3628d3c1a1a246b75b Mon Sep 17 00:00:00 2001 From: Nipun Singh <88689850+nsingh-branch@users.noreply.github.com> Date: Thu, 7 Sep 2023 14:32:18 -0700 Subject: [PATCH] fix(event): [SDK-2058] Remove v1/event code --- package.json | 2 +- src/__tests__/index.js | 22 -------- src/android/io/branch/BranchSDK.java | 47 ---------------- src/index.js | 35 ------------ src/ios/BranchSDK.h | 1 - src/ios/BranchSDK.m | 28 ---------- .../examples/templates/cordova1/index.html | 24 +++++---- .../examples/templates/cordova1/index.js | 54 ------------------- 8 files changed, 15 insertions(+), 198 deletions(-) diff --git a/package.json b/package.json index 76e277b1..cee3e9da 100644 --- a/package.json +++ b/package.json @@ -74,4 +74,4 @@ "lint-staged": "^12.4.2", "prettier": "^2.6.2" } -} +} \ No newline at end of file diff --git a/src/__tests__/index.js b/src/__tests__/index.js index bd340080..93c7ab20 100644 --- a/src/__tests__/index.js +++ b/src/__tests__/index.js @@ -62,11 +62,6 @@ exports.defineAutoTests = function() { "function" ); }); - it("should contain a method called userCompletedAction()", function() { - expect(window.Branch.userCompletedAction).toBeDefined(); - expect(_typeof(window.Branch.userCompletedAction)).toBe("function"); - }); - }); describe("Branch.getLatestReferringParams()", function() { @@ -191,21 +186,4 @@ exports.defineAutoTests = function() { 5000 ); }); - - describe("Branch.userCompletedAction()", function() { - beforeEach(function(done) { - initSession().then(function() { - done(); - }); - }, 3000); - it( - "should successfully execute the method", - function(done) { - window.Branch.userCompletedAction("login"); - expect("Success").toBe("Success"); - done(); - }, - 10000 - ); - }); }; diff --git a/src/android/io/branch/BranchSDK.java b/src/android/io/branch/BranchSDK.java index aaaa7ae9..fb26c79e 100644 --- a/src/android/io/branch/BranchSDK.java +++ b/src/android/io/branch/BranchSDK.java @@ -139,13 +139,6 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo if (action.equals("setIdentity")) { cordova.getActivity().runOnUiThread(r); return true; - } else if (action.equals("userCompletedAction")) { - if (args.length() < 1 && args.length() > 2) { - callbackContext.error(String.format("Parameter count mismatch")); - return false; - } - cordova.getActivity().runOnUiThread(r); - return true; } else if (action.equals("sendBranchEvent")) { if (args.length() < 1 && args.length() > 2) { callbackContext.error(String.format("Parameter count mismatch")); @@ -660,40 +653,6 @@ private void setRequestMetadata(String key, String val, CallbackContext callback } - /** - *

A void call to indicate that the user has performed a specific action and for that to be - * reported to the Branch API.

- * - * @param action A {@link String} value to be passed as an action that the user has carried out. - * For example "logged in" or "registered". - * @param callbackContext A callback to execute at the end of this method - */ - private void userCompletedAction(String action, CallbackContext callbackContext) { - - this.instance.userCompletedAction(action); - - callbackContext.success("Success"); - - } - - /** - *

A void call to indicate that the user has performed a specific action and for that to be - * reported to the Branch API.

- * - * @param action A {@link String} value to be passed as an action that the user has carried - * out. For example "logged in" or "registered". - * @param metaData A {@link JSONObject} containing app-defined meta-data to be attached to a - * user action that has just been completed. - * @param callbackContext A callback to execute at the end of this method - */ - private void userCompletedAction(String action, JSONObject metaData, CallbackContext callbackContext) { - - this.instance.userCompletedAction(action, metaData); - - callbackContext.success("Success"); - - } - public void sendBranchEvent(String eventName, CallbackContext callbackContext) throws JSONException { BranchEvent event; @@ -1246,12 +1205,6 @@ public void run() { } else { if (this.action.equals("setIdentity")) { setIdentity(this.args.getString(0), this.callbackContext); - } else if (this.action.equals("userCompletedAction")) { - if (this.args.length() == 2) { - userCompletedAction(this.args.getString(0), this.args.getJSONObject(1), this.callbackContext); - } else if (this.args.length() == 1) { - userCompletedAction(this.args.getString(0), this.callbackContext); - } } else if (this.action.equals("sendBranchEvent")) { if (this.args.length() == 2) { sendBranchEvent(this.args.getString(0), this.args.getJSONObject(1), this.callbackContext); diff --git a/src/index.js b/src/index.js index eae03123..a82a98b5 100644 --- a/src/index.js +++ b/src/index.js @@ -169,41 +169,6 @@ Branch.prototype.logout = function logout() { return execute("logout"); }; -//DEPRECATED -Branch.prototype.userCompletedAction = function userCompletedAction( - action, - metaData -) { - var args = [action]; - if (!action) { - return executeReject("Please set an event name"); - } - - if (metaData) { - args.push(metaData); - } - - return execute("userCompletedAction", args); -}; - -//DEPRECATED -Branch.prototype.sendCommerceEvent = function sendCommerceEvent( - action, - metaData -) { - var args = [action]; - if (!action) { - return executeReject("Please set a commerce event"); - } - - if (metaData) { - args.push(metaData); - } - - return execute("sendCommerceEvent", args); -}; - - Branch.prototype.getStandardEvents = function getStandardEvents() { return execute("getStandardEvents"); diff --git a/src/ios/BranchSDK.h b/src/ios/BranchSDK.h index bc52b107..7f1d0fc9 100644 --- a/src/ios/BranchSDK.h +++ b/src/ios/BranchSDK.h @@ -35,7 +35,6 @@ - (void)getFirstReferringParams:(CDVInvokedUrlCommand*)command; - (void)setIdentity:(CDVInvokedUrlCommand*)command; - (void)registerDeepLinkController:(CDVInvokedUrlCommand*)command; -- (void)userCompletedAction:(CDVInvokedUrlCommand*)command; - (void)logout:(CDVInvokedUrlCommand*)command; - (void)delayInitToCheckForSearchAds:(CDVInvokedUrlCommand*)command; diff --git a/src/ios/BranchSDK.m b/src/ios/BranchSDK.m index 5b971816..ddb9f108 100644 --- a/src/ios/BranchSDK.m +++ b/src/ios/BranchSDK.m @@ -225,34 +225,6 @@ - (void)registerDeepLinkController:(CDVInvokedUrlCommand*)command [branch registerDeepLinkController:controller forKey:[command.arguments objectAtIndex:0]]; } -- (void)userCompletedAction:(CDVInvokedUrlCommand*)command -{ - NSString *name; - NSDictionary *state; - - // if a state dictionary is passed as an argument - if ([command.arguments count] == 2) { - name = [command.arguments objectAtIndex:0]; - state = [command.arguments objectAtIndex:1]; - } - else { - name = [command.arguments objectAtIndex:0]; - } - - Branch *branch = [self getInstance]; - - if (state) { - [branch userCompletedAction:name withState:state]; - } - else { - [branch userCompletedAction:name]; - } - - // TODO: iOS Branch.userCompletedAction needs a callback for success or failure - CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString: @"Success"]; - [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; -} - -(void)sendBranchEvent:(CDVInvokedUrlCommand*)command { NSString *eventName = [command.arguments objectAtIndex:0]; diff --git a/src/scripts/examples/templates/cordova1/index.html b/src/scripts/examples/templates/cordova1/index.html index f37f794e..552d9f20 100644 --- a/src/scripts/examples/templates/cordova1/index.html +++ b/src/scripts/examples/templates/cordova1/index.html @@ -1,13 +1,17 @@ + - + - + Branch Testing +
Branch Universal Object @@ -15,12 +19,12 @@
Branch Deep Link - -
- - -
- + +
+ + +
+
Branch Deep Link Data @@ -49,10 +53,10 @@
-
- + + \ No newline at end of file diff --git a/src/scripts/examples/templates/cordova1/index.js b/src/scripts/examples/templates/cordova1/index.js index 74b3e9d4..b829bed7 100644 --- a/src/scripts/examples/templates/cordova1/index.js +++ b/src/scripts/examples/templates/cordova1/index.js @@ -28,7 +28,6 @@ var branchSpotlight = document.getElementById("branchSpotlight"); var branchUser = document.getElementById("branchUser"); var branchLogout = document.getElementById("branchLogout"); var branchEvent = document.getElementById("branchEvent"); -var branchCommerce = document.getElementById("branchCommerce"); // handle DOM branchUniversalObject.addEventListener("click", BranchUniversalObject); @@ -41,7 +40,6 @@ branchSpotlight.addEventListener("click", BranchSpotlight); branchUser.addEventListener("click", BranchUser); branchLogout.addEventListener("click", BranchLogout); branchEvent.addEventListener("click", BranchEvent); -branchCommerce.addEventListener("click", BranchCommerce); // run app.initialize(); @@ -102,58 +100,6 @@ function BranchEvent() { custom_dictionary: 123, anything: "everything" }; - - Branch.userCompletedAction(event, metadata) - .then(function success(res) { - logger(res); - }) - .catch(function error(err) { - logger(err, true); - }); -} - -function BranchCommerce() { - // revenue required - var event = { - revenue: 50.29, - currency: 148, // USD - transactionID: "transaction id", - coupon: "coupon", - shipping: 2.22, - tax: 5.11, - affiliation: "affiliation", - products: [ - { - sku: "u123", - name: "cactus", - price: 4.99, - quantity: 2, - brand: "brand", - category: 17, // Software - variant: "variant" - }, - { - sku: "u456", - name: "grass", - price: 0.0, - quantity: 1 - } - ] - }; - - // optional - var metadata = { - custom_dictionary: 123, - anything: "everything" - }; - - Branch.sendCommerceEvent(event, metadata) - .then(function success(res) { - logger(res); - }) - .catch(function error(err) { - logger(err, true); - }); } function BranchFirstData() {