Skip to content

Commit befa364

Browse files
fix(event): [SDK-2058] Remove v1/event code
1 parent 70de5d2 commit befa364

File tree

8 files changed

+15
-198
lines changed

8 files changed

+15
-198
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,4 @@
7474
"lint-staged": "^12.4.2",
7575
"prettier": "^2.6.2"
7676
}
77-
}
77+
}

src/__tests__/index.js

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,6 @@ exports.defineAutoTests = function() {
6262
"function"
6363
);
6464
});
65-
it("should contain a method called userCompletedAction()", function() {
66-
expect(window.Branch.userCompletedAction).toBeDefined();
67-
expect(_typeof(window.Branch.userCompletedAction)).toBe("function");
68-
});
69-
7065
});
7166

7267
describe("Branch.getLatestReferringParams()", function() {
@@ -191,21 +186,4 @@ exports.defineAutoTests = function() {
191186
5000
192187
);
193188
});
194-
195-
describe("Branch.userCompletedAction()", function() {
196-
beforeEach(function(done) {
197-
initSession().then(function() {
198-
done();
199-
});
200-
}, 3000);
201-
it(
202-
"should successfully execute the method",
203-
function(done) {
204-
window.Branch.userCompletedAction("login");
205-
expect("Success").toBe("Success");
206-
done();
207-
},
208-
10000
209-
);
210-
});
211189
};

src/android/io/branch/BranchSDK.java

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,6 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
139139
if (action.equals("setIdentity")) {
140140
cordova.getActivity().runOnUiThread(r);
141141
return true;
142-
} else if (action.equals("userCompletedAction")) {
143-
if (args.length() < 1 && args.length() > 2) {
144-
callbackContext.error(String.format("Parameter count mismatch"));
145-
return false;
146-
}
147-
cordova.getActivity().runOnUiThread(r);
148-
return true;
149142
} else if (action.equals("sendBranchEvent")) {
150143
if (args.length() < 1 && args.length() > 2) {
151144
callbackContext.error(String.format("Parameter count mismatch"));
@@ -660,40 +653,6 @@ private void setRequestMetadata(String key, String val, CallbackContext callback
660653

661654
}
662655

663-
/**
664-
* <p>A void call to indicate that the user has performed a specific action and for that to be
665-
* reported to the Branch API.</p>
666-
*
667-
* @param action A {@link String} value to be passed as an action that the user has carried out.
668-
* For example "logged in" or "registered".
669-
* @param callbackContext A callback to execute at the end of this method
670-
*/
671-
private void userCompletedAction(String action, CallbackContext callbackContext) {
672-
673-
this.instance.userCompletedAction(action);
674-
675-
callbackContext.success("Success");
676-
677-
}
678-
679-
/**
680-
* <p>A void call to indicate that the user has performed a specific action and for that to be
681-
* reported to the Branch API.</p>
682-
*
683-
* @param action A {@link String} value to be passed as an action that the user has carried
684-
* out. For example "logged in" or "registered".
685-
* @param metaData A {@link JSONObject} containing app-defined meta-data to be attached to a
686-
* user action that has just been completed.
687-
* @param callbackContext A callback to execute at the end of this method
688-
*/
689-
private void userCompletedAction(String action, JSONObject metaData, CallbackContext callbackContext) {
690-
691-
this.instance.userCompletedAction(action, metaData);
692-
693-
callbackContext.success("Success");
694-
695-
}
696-
697656
public void sendBranchEvent(String eventName, CallbackContext callbackContext) throws JSONException {
698657

699658
BranchEvent event;
@@ -1246,12 +1205,6 @@ public void run() {
12461205
} else {
12471206
if (this.action.equals("setIdentity")) {
12481207
setIdentity(this.args.getString(0), this.callbackContext);
1249-
} else if (this.action.equals("userCompletedAction")) {
1250-
if (this.args.length() == 2) {
1251-
userCompletedAction(this.args.getString(0), this.args.getJSONObject(1), this.callbackContext);
1252-
} else if (this.args.length() == 1) {
1253-
userCompletedAction(this.args.getString(0), this.callbackContext);
1254-
}
12551208
} else if (this.action.equals("sendBranchEvent")) {
12561209
if (this.args.length() == 2) {
12571210
sendBranchEvent(this.args.getString(0), this.args.getJSONObject(1), this.callbackContext);

src/index.js

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -169,41 +169,6 @@ Branch.prototype.logout = function logout() {
169169
return execute("logout");
170170
};
171171

172-
//DEPRECATED
173-
Branch.prototype.userCompletedAction = function userCompletedAction(
174-
action,
175-
metaData
176-
) {
177-
var args = [action];
178-
if (!action) {
179-
return executeReject("Please set an event name");
180-
}
181-
182-
if (metaData) {
183-
args.push(metaData);
184-
}
185-
186-
return execute("userCompletedAction", args);
187-
};
188-
189-
//DEPRECATED
190-
Branch.prototype.sendCommerceEvent = function sendCommerceEvent(
191-
action,
192-
metaData
193-
) {
194-
var args = [action];
195-
if (!action) {
196-
return executeReject("Please set a commerce event");
197-
}
198-
199-
if (metaData) {
200-
args.push(metaData);
201-
}
202-
203-
return execute("sendCommerceEvent", args);
204-
};
205-
206-
207172
Branch.prototype.getStandardEvents = function getStandardEvents() {
208173
return execute("getStandardEvents");
209174

src/ios/BranchSDK.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
- (void)getFirstReferringParams:(CDVInvokedUrlCommand*)command;
3636
- (void)setIdentity:(CDVInvokedUrlCommand*)command;
3737
- (void)registerDeepLinkController:(CDVInvokedUrlCommand*)command;
38-
- (void)userCompletedAction:(CDVInvokedUrlCommand*)command;
3938
- (void)logout:(CDVInvokedUrlCommand*)command;
4039
- (void)delayInitToCheckForSearchAds:(CDVInvokedUrlCommand*)command;
4140

src/ios/BranchSDK.m

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -225,34 +225,6 @@ - (void)registerDeepLinkController:(CDVInvokedUrlCommand*)command
225225
[branch registerDeepLinkController:controller forKey:[command.arguments objectAtIndex:0]];
226226
}
227227

228-
- (void)userCompletedAction:(CDVInvokedUrlCommand*)command
229-
{
230-
NSString *name;
231-
NSDictionary *state;
232-
233-
// if a state dictionary is passed as an argument
234-
if ([command.arguments count] == 2) {
235-
name = [command.arguments objectAtIndex:0];
236-
state = [command.arguments objectAtIndex:1];
237-
}
238-
else {
239-
name = [command.arguments objectAtIndex:0];
240-
}
241-
242-
Branch *branch = [self getInstance];
243-
244-
if (state) {
245-
[branch userCompletedAction:name withState:state];
246-
}
247-
else {
248-
[branch userCompletedAction:name];
249-
}
250-
251-
// TODO: iOS Branch.userCompletedAction needs a callback for success or failure
252-
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString: @"Success"];
253-
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
254-
}
255-
256228
-(void)sendBranchEvent:(CDVInvokedUrlCommand*)command
257229
{
258230
NSString *eventName = [command.arguments objectAtIndex:0];

src/scripts/examples/templates/cordova1/index.html

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
11
<!DOCTYPE html>
22
<html>
3+
34
<head>
4-
<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:;">
5+
<meta http-equiv="Content-Security-Policy"
6+
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:;">
57
<meta name="format-detection" content="telephone=no">
68
<meta name="msapplication-tap-highlight" content="no">
7-
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
9+
<meta name="viewport"
10+
content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
811
<link rel="stylesheet" type="text/css" href="css/index.css">
912
<title>Branch Testing</title>
1013
</head>
14+
1115
<body>
1216
<fieldset>
1317
<legend>Branch Universal Object</legend>
1418
<button id="branchUniversalObject">Create</button>
1519
</fieldset>
1620
<fieldset>
1721
<legend>Branch Deep Link</legend>
18-
<input id="alias" name="alias" type="text" placeholder="Deep link alias (optional)">
19-
<section>
20-
<button id="branchDeepLink">Create</button>
21-
<button id="branchShareSheet">Share</button>
22-
</section>
23-
<input type="text" id="generated-url" placeholder="Deep link" readonly>
22+
<input id="alias" name="alias" type="text" placeholder="Deep link alias (optional)">
23+
<section>
24+
<button id="branchDeepLink">Create</button>
25+
<button id="branchShareSheet">Share</button>
26+
</section>
27+
<input type="text" id="generated-url" placeholder="Deep link" readonly>
2428
</fieldset>
2529
<fieldset>
2630
<legend>Branch Deep Link Data</legend>
@@ -49,10 +53,10 @@
4953
<input type="text" id="custom-action" name="custom-action" placeholder="Event Name">
5054
<section>
5155
<button id="branchEvent">Create</button>
52-
<button id="branchCommerce">Commerce</button>
5356
</section>
5457
</fieldset>
5558
<script type="text/javascript" src="cordova.js"></script>
5659
<script type="text/javascript" src="js/index.js"></script>
5760
</body>
58-
</html>
61+
62+
</html>

src/scripts/examples/templates/cordova1/index.js

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ var branchSpotlight = document.getElementById("branchSpotlight");
2828
var branchUser = document.getElementById("branchUser");
2929
var branchLogout = document.getElementById("branchLogout");
3030
var branchEvent = document.getElementById("branchEvent");
31-
var branchCommerce = document.getElementById("branchCommerce");
3231

3332
// handle DOM
3433
branchUniversalObject.addEventListener("click", BranchUniversalObject);
@@ -41,7 +40,6 @@ branchSpotlight.addEventListener("click", BranchSpotlight);
4140
branchUser.addEventListener("click", BranchUser);
4241
branchLogout.addEventListener("click", BranchLogout);
4342
branchEvent.addEventListener("click", BranchEvent);
44-
branchCommerce.addEventListener("click", BranchCommerce);
4543

4644
// run
4745
app.initialize();
@@ -102,58 +100,6 @@ function BranchEvent() {
102100
custom_dictionary: 123,
103101
anything: "everything"
104102
};
105-
106-
Branch.userCompletedAction(event, metadata)
107-
.then(function success(res) {
108-
logger(res);
109-
})
110-
.catch(function error(err) {
111-
logger(err, true);
112-
});
113-
}
114-
115-
function BranchCommerce() {
116-
// revenue required
117-
var event = {
118-
revenue: 50.29,
119-
currency: 148, // USD
120-
transactionID: "transaction id",
121-
coupon: "coupon",
122-
shipping: 2.22,
123-
tax: 5.11,
124-
affiliation: "affiliation",
125-
products: [
126-
{
127-
sku: "u123",
128-
name: "cactus",
129-
price: 4.99,
130-
quantity: 2,
131-
brand: "brand",
132-
category: 17, // Software
133-
variant: "variant"
134-
},
135-
{
136-
sku: "u456",
137-
name: "grass",
138-
price: 0.0,
139-
quantity: 1
140-
}
141-
]
142-
};
143-
144-
// optional
145-
var metadata = {
146-
custom_dictionary: 123,
147-
anything: "everything"
148-
};
149-
150-
Branch.sendCommerceEvent(event, metadata)
151-
.then(function success(res) {
152-
logger(res);
153-
})
154-
.catch(function error(err) {
155-
logger(err, true);
156-
});
157103
}
158104

159105
function BranchFirstData() {

0 commit comments

Comments
 (0)