Common Integration Questions
Q. How should I handle NetworkError?
A. Notify the user and either retry or proceed with original logic:
Web Javascript Integration
function handleNetworkError(response) {
if (confirm('Network error occurred. Retry?')) {
nfStart(keys, callback); // Retry
} else {
performOriginalLogic(); // Proceed
}
}
Android Integration
- Kotlin
- Java
private val callback = object : NetfunnelCallback() {
override fun onNetworkError(statusCode: Int, message: String) {
when (statusCode) {
1001 -> {
// Network not connected
showNetworkErrorDialog()
}
1002 -> {
// Network timeout - retry
retryWithDelay()
}
}
}
}
private fun retryWithDelay() {
Handler(Looper.getMainLooper()).postDelayed({
Netfunnel.nfStart(projectKey, segmentKey, callback, this)
}, 2000)
}
private final NetfunnelCallback callback = new NetfunnelCallback() {
@Override
public void onNetworkError(int statusCode, @NonNull String message) {
switch (statusCode) {
case 1001:
// Network not connected
showNetworkErrorDialog();
break;
case 1002:
// Network timeout - retry
retryWithDelay();
break;
}
}
};
private void retryWithDelay() {
new Handler(Looper.getMainLooper()).postDelayed(() -> {
Netfunnel.INSTANCE.nfStart(projectKey, segmentKey, callback, this);
}, 2000);
}
Q. What if I forget to return the key?
A. The key may be auto-returned by server timeout, but this can cause bottlenecks. Always return explicitly:
Web Javascript Integration
// Recommended: Always return key
nfStart(keys, function(response) {
if (response.status === 'Success') {
performAction()
.then(() => nfStop(keys))
.catch(() => nfStop(keys)); // Return even on error
}
});
Android Integration
- Kotlin
- Java
// Recommended: Always return key
private val callback = object : NetfunnelCallback() {
override fun onSuccess(statusCode: Int, message: String) {
performAction()
.onSuccess {
Netfunnel.nfStop(projectKey, segmentKey, completeCallback)
}
.onFailure {
Netfunnel.nfStop(projectKey, segmentKey, completeCallback) // Return even on error
}
}
}
// Recommended: Always return key
private final NetfunnelCallback callback = new NetfunnelCallback() {
@Override
public void onSuccess(int statusCode, @NonNull String message) {
performAction()
.onSuccess(() -> {
Netfunnel.INSTANCE.nfStop(projectKey, segmentKey, completeCallback);
})
.onFailure(() -> {
Netfunnel.INSTANCE.nfStop(projectKey, segmentKey, completeCallback); // Return even on error
});
}
};
Q. How do I debug NetFUNNEL integration?
A. Enable logging and check the console:
Web Javascript Integration
<script
src="https://agent-lib.stclab.com/agents/client/javascript/netfunnel-javascript-agent.js"
data-nf-client-id="your-client-id"
data-nf-print-log="true"
></script>
Then check DevTools Console for NetFUNNEL log messages.
Android Integration
- Kotlin
- Java
Netfunnel.initialize(
clientId = "{{CLIENT_ID}}",
printLog = true // Enable logging
)
Netfunnel.INSTANCE.initialize(
"{{CLIENT_ID}}"
);
Then check Logcat for NetFUNNEL log messages.
Q. Can I use both URL-triggered and code-based methods?
A. Yes, you can use both methods together within a single service:
- Use URL triggers for page-entry speed control
- Use code-based for business concurrency control
// URL trigger for landing page protection
// (configured in console)
// Basic Control for login
function handleLogin() {
Netfunnel.nfStart("login_project", "login_segment", loginCallback);
}
// Section Control for checkout
function startCheckout() {
Netfunnel.nfStartSection("checkout_project", "checkout_segment", checkoutCallback);
}
Common patterns:
- Use URL trigger integration for page entry protection
- Use Basic Control (code-based integration) for entry points (login, main features) - quick key return after screen loads
- Use Section Control (code-based integration) for important processes (checkout, payment processing) - keep key until entire process completes
However, to reduce operational complexity, it's recommended to prioritize one method.
Q. Can I use both Basic Control and Section Control in the same app?
A. Yes, you can use both methods in the same application:
iOS
- Swift
- Objective-C
// Basic Control for login
func handleLogin() {
Netfunnel.shared.nfStart(projectKey: "login_project", segmentKey: "login_segment")
}
// Section Control for checkout
func startCheckout() {
Netfunnel.shared.nfStartSection(projectKey: "checkout_project", segmentKey: "checkout_segment")
}
// Basic Control for login
- (void)handleLogin {
[[Netfunnel shared] nfStartWithProjectKey:@"login_project" segmentKey:@"login_segment"];
}
// Section Control for checkout
- (void)startCheckout {
[[Netfunnel shared] nfStartSectionWithProjectKey:@"checkout_project" segmentKey:@"checkout_segment"];
}
Common patterns:
- Use Basic Control (code-based integration) for entry points (login, main features) - quick key return after view controller loads
- Use Section Control (code-based integration) for important processes (checkout, payment) - keep key until entire process completes
Android
- Kotlin
- Java
// Basic Control for login
fun handleLogin() {
Netfunnel.nfStart("login_project", "login_segment", loginCallback, this)
}
// Section Control for checkout
fun startCheckout() {
Netfunnel.nfStartSection("checkout_project", "checkout_segment", checkoutCallback, this)
}
// Basic Control for login
public void handleLogin() {
Netfunnel.INSTANCE.nfStart("login_project", "login_segment", loginCallback, this);
}
// Section Control for checkout
public void startCheckout() {
Netfunnel.INSTANCE.nfStartSection("checkout_project", "checkout_segment", checkoutCallback, this);
}
Common patterns:
- Use Basic Control (code-based integration) for entry points (login, main features) - quick key return after Activity loads
- Use Section Control (code-based integration) for important processes (checkout, payment) - keep key until entire process completes
Q. Can I initialize NetFUNNEL multiple times?
A. No, NetFUNNEL should be initialized only once in your Application class. Multiple initializations may cause unexpected behavior.