Skip to content

Commit

Permalink
Check to prevent parsing when tracking is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
nsingh-branch committed Oct 3, 2023
1 parent 1c4ea34 commit 514b2f8
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions Branch-SDK/src/main/java/io/branch/referral/ReferringUrlUtility.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,33 @@ class ReferringUrlUtility (prefHelper: PrefHelper) {
}

fun parseReferringURL(urlString: String) {
val uri = Uri.parse(urlString)

for (originalParamName in uri.queryParameterNames) {
val paramName = originalParamName.lowercase()
val paramValue = uri.getQueryParameter(originalParamName)
BranchLogger.v("Found URL Query Parameter - Key: $paramName, Value: $paramValue")

if (isSupportedQueryParameter(paramName)) {
val param = findUrlQueryParam(paramName)
param.value = paramValue
param.timestamp = Date()
param.isDeepLink = true

// If there is no validity window, set to default.
if (param.validityWindow == 0L) {
param.validityWindow = defaultValidityWindowForParam(paramName)
}
if (!Branch.getInstance().isTrackingDisabled) {
val uri = Uri.parse(urlString)

for (originalParamName in uri.queryParameterNames) {
val paramName = originalParamName.lowercase()
val paramValue = uri.getQueryParameter(originalParamName)
BranchLogger.v("Found URL Query Parameter - Key: $paramName, Value: $paramValue")

if (isSupportedQueryParameter(paramName)) {
val param = findUrlQueryParam(paramName)
param.value = paramValue
param.timestamp = Date()
param.isDeepLink = true

// If there is no validity window, set to default.
if (param.validityWindow == 0L) {
param.validityWindow = defaultValidityWindowForParam(paramName)
}

urlQueryParameters[paramName] = param
urlQueryParameters[paramName] = param
}
}
}

prefHelper.setReferringUrlQueryParameters(serializeToJson(urlQueryParameters))
prefHelper.setReferringUrlQueryParameters(serializeToJson(urlQueryParameters))

BranchLogger.v("Current referringURLQueryParameters: " + prefHelper.referringURLQueryParameters.toString())
BranchLogger.v("Current referringURLQueryParameters: " + prefHelper.referringURLQueryParameters.toString())
}
}

fun getURLQueryParamsForRequest(request: ServerRequest): JSONObject {
Expand Down

0 comments on commit 514b2f8

Please sign in to comment.