Skip to content

Commit

Permalink
feat: added disable tracking for gdpr
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanneff committed Apr 25, 2018
1 parent 9d2fa91 commit 191f580
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 6 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@ _Questions? [Contact us](https://support.branch.io/support/tickets/new)_
// for development and debugging only
Branch.setDebug(true);

// for GDPR compliance (can be called at anytime)
Branch.disabledTracking(false);

// for better Android matching
Branch.setCookieBasedMatching("cordova.app.link");

Expand Down
16 changes: 16 additions & 0 deletions src/android/io/branch/BranchSDK.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
if (args.length() == 1) {
cordova.getActivity().runOnUiThread(r);
}
} else if (action.equals("disableTracking")) {
cordova.getActivity().runOnUiThread(r);
return true;
} else if (action.equals("initSession")) {
cordova.getActivity().runOnUiThread(r);
Expand Down Expand Up @@ -591,6 +593,18 @@ private void setDebug(boolean isEnable, CallbackContext callbackContext)
}

callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, /* send boolean: false as the data */ isEnable));
/**
* <p>Disables tracking for GDPR compliance.</p>
* <p>Can flag at any time.</p>
* <p>Limits all Branch network requests and forces long link generation.</p>
*
* @param isEnable A {@link Boolean} value to enable/disable debugging mode for the app.
* @param callbackContext A callback to execute at the end of this method
*/
private void disableTracking(boolean isEnable, CallbackContext callbackContext) {
this.activity = this.cordova.getActivity();
Branch.getAutoInstance(this.activity.getApplicationContext()).disableTracking(isEnable);
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, isEnable));
}

/**
Expand Down Expand Up @@ -1257,6 +1271,8 @@ public void run() {
try {
if (this.action.equals("setDebug")) {
setDebug(this.args.getBoolean(0), this.callbackContext);
} else if (this.action.equals("disableTracking")) {
disableTracking(this.args.getBoolean(0), this.callbackContext);
} else if (this.action.equals("initSession")) {
initSession(this.callbackContext);
} else if (this.action.equals("setRequestMetadata")) {
Expand Down
6 changes: 3 additions & 3 deletions src/branch.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ Branch.prototype.disableGlobalListenersWarnings = function() {
disableGlobalListenersWarnings = true;
};

Branch.prototype.setTrackingDisabled = function(isDisabled) {
var value = typeof isDisabled === "boolean" ? isDisabled : false;
Branch.prototype.disableTracking = function(isEnabled) {
var value = typeof isEnabled === "boolean" ? isEnabled : false;
this.trackingDisabled = value;
return execute("setTrackingDisabled", [value]);
return execute("disableTracking", [value]);
};

let runOnce = true;
Expand Down
2 changes: 1 addition & 1 deletion src/ios/BranchSDK.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
// BranchSDK Basic Methods
- (void)initSession:(CDVInvokedUrlCommand*)command;
- (void)setMixpanelToken:(CDVInvokedUrlCommand*)command;
- (void)setTrackingDisabled:(CDVInvokedUrlCommand*)command;
- (void)disableTracking:(CDVInvokedUrlCommand*)command;
- (void)setDebug:(CDVInvokedUrlCommand*)command;
- (void)getAutoInstance:(CDVInvokedUrlCommand*)command;
- (void)getLatestReferringParams:(CDVInvokedUrlCommand*)command;
Expand Down
2 changes: 1 addition & 1 deletion src/ios/BranchSDK.m
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ - (void)setRequestMetadata:(CDVInvokedUrlCommand*)command

}

- (void)setTrackingDisabled:(CDVInvokedUrlCommand*)command
- (void)disableTracking:(CDVInvokedUrlCommand*)command
{

bool enabled = [[command.arguments objectAtIndex:0] boolValue] == YES;
Expand Down
2 changes: 1 addition & 1 deletion testbed/www/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const BranchInit = isDebug => {
console.log("Trigger BranchInit()");

// for GDPR compliance (can be called at anytime )
Branch.setTrackingDisabled(false);
Branch.disabledTracking(false);

// for development and debugging only
Branch.setDebug(isDebug);
Expand Down

0 comments on commit 191f580

Please sign in to comment.