Skip to content

Commit

Permalink
fix(event): [SDK-2058] Remove v1/event code
Browse files Browse the repository at this point in the history
  • Loading branch information
nsingh-branch authored Sep 7, 2023
1 parent 70de5d2 commit befa364
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 198 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@
"lint-staged": "^12.4.2",
"prettier": "^2.6.2"
}
}
}
22 changes: 0 additions & 22 deletions src/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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
);
});
};
47 changes: 0 additions & 47 deletions src/android/io/branch/BranchSDK.java
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down Expand Up @@ -660,40 +653,6 @@ private void setRequestMetadata(String key, String val, CallbackContext callback

}

/**
* <p>A void call to indicate that the user has performed a specific action and for that to be
* reported to the Branch API.</p>
*
* @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");

}

/**
* <p>A void call to indicate that the user has performed a specific action and for that to be
* reported to the Branch API.</p>
*
* @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;
Expand Down Expand Up @@ -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);
Expand Down
35 changes: 0 additions & 35 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
1 change: 0 additions & 1 deletion src/ios/BranchSDK.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
28 changes: 0 additions & 28 deletions src/ios/BranchSDK.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
24 changes: 14 additions & 10 deletions src/scripts/examples/templates/cordova1/index.html
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
<!DOCTYPE html>
<html>

<head>
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; media-src *; img-src 'self' data: content:;">
<meta http-equiv="Content-Security-Policy"
content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; media-src *; img-src 'self' data: content:;">
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
<meta name="viewport"
content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
<link rel="stylesheet" type="text/css" href="css/index.css">
<title>Branch Testing</title>
</head>

<body>
<fieldset>
<legend>Branch Universal Object</legend>
<button id="branchUniversalObject">Create</button>
</fieldset>
<fieldset>
<legend>Branch Deep Link</legend>
<input id="alias" name="alias" type="text" placeholder="Deep link alias (optional)">
<section>
<button id="branchDeepLink">Create</button>
<button id="branchShareSheet">Share</button>
</section>
<input type="text" id="generated-url" placeholder="Deep link" readonly>
<input id="alias" name="alias" type="text" placeholder="Deep link alias (optional)">
<section>
<button id="branchDeepLink">Create</button>
<button id="branchShareSheet">Share</button>
</section>
<input type="text" id="generated-url" placeholder="Deep link" readonly>
</fieldset>
<fieldset>
<legend>Branch Deep Link Data</legend>
Expand Down Expand Up @@ -49,10 +53,10 @@
<input type="text" id="custom-action" name="custom-action" placeholder="Event Name">
<section>
<button id="branchEvent">Create</button>
<button id="branchCommerce">Commerce</button>
</section>
</fieldset>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
</body>
</html>

</html>
54 changes: 0 additions & 54 deletions src/scripts/examples/templates/cordova1/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit befa364

Please sign in to comment.