From Contentsquare SDK to CSQ SDK

Contentsquare SDK

CSQ SDK
The latest version of our SDK provides a unified set of APIs for Product Analytics, Experience Analytics, and Experience Monitoring, eliminating redundant APIs that perform the same actions.
Upgrading to the latest version ensures you benefit from all our newest features and product enhancements.
Dependency upgrades
Section titled Dependency upgradesUpgrade your dependency based on your current SDK.
CSQ SDK (com.contentsquare.android:sdk
< 1.0)
Upgrade to the latest CSQ SDK version:
implementation("com.contentsquare.android:sdk:0.7.1")implementation("com.contentsquare.android:sdk-compose:0.7.1")implementation("com.contentsquare.android:sdk:1.0.0")implementation("com.contentsquare.android:sdk-compose:1.0.0")
implementation 'com.contentsquare.android:sdk:0.7.1'implementation 'com.contentsquare.android:sdk-compose:0.7.1'implementation 'com.contentsquare.android:sdk:1.0.0'implementation 'com.contentsquare.android:sdk-compose:1.0.0'
Contentsquare SDK (com.contentsquare.android:library
)
Replace Contentsquare SDK dependencies with the CSQ SDK:
implementation("com.contentsquare.android:library:4.39.1")implementation("com.contentsquare.android:sdk-compose:4.39.1")implementation("com.contentsquare.android:sdk:1.0.0")implementation("com.contentsquare.android:sdk-compose:1.0.0")
implementation 'com.contentsquare.android:library:4.39.1'implementation 'com.contentsquare.android:sdk-compose:4.39.1'implementation 'com.contentsquare.android:sdk:1.0.0'implementation 'com.contentsquare.android:sdk-compose:1.0.0'
Library imports
Section titled Library importsReplace the Contentsquare SDK import with a CSQ SDK import.
import com.contentsquare.android.Contentsquareimport com.contentsquare.CSQ
import com.contentsquare.android.Contentsquare;import com.contentsquare.CSQ;
SDK start
Section titled SDK startStart the CSQ SDK manually using CSQ.start()
— unlike earlier versions, it no longer starts automatically.
import android.app.Applicationimport com.contentsquare.CSQ
class MyApplication : Application() { override fun onCreate() { super.onCreate()
CSQ.start(this) }}
import android.app.Application;import com.contentsquare.CSQ;
public class MyApplication extends Application { @Override public void onCreate() { super.onCreate();
CSQ.start(this); }}
Get user consent
Section titled Get user consentThe CSQ SDK treats users as opted-out by default.
import android.app.Applicationimport com.contentsquare.CSQ
// ...CSQ.start(context)// ...
val optinButton: Button = ...optinButton.setOnClickListener { CSQ.optIn(it.context) // Then finish initialization and move to the next screen...}
import android.app.Application;import com.contentsquare.CSQ;
// ...CSQ.start(context);// ...
Button optinButton = ...optinButton.setOnClickListener(view -> { CSQ.optIn(view.getContext()); // Then finish initialization and move to the next screen...});
Implement the optIn()
API to forward user consent to the SDK and generate a user ID.
Transactions
Section titled Transactions-
Update your transaction imports:
import com.contentsquare.android.api.model.Transactionimport com.contentsquare.android.api.Currenciesimport com.contentsquare.api.model.Transactionimport com.contentsquare.api.model.Currencyimport com.contentsquare.android.api.model.Transaction;import com.contentsquare.android.api.Currencies;import com.contentsquare.api.model.Transaction;import com.contentsquare.api.model.Currency; -
Replace
Currencies
byCurrency
(typeInt
->Currency
):val currency: Int = Currencies.USDval currency: Currency = Currency.USDval transaction = Transaction.builder(100f, Currencies.EUR).id("optionalId").build()val transaction = Transaction(100f, Currency.EUR, "optionalId")The
Currency
Enum provides both alphabetic and numeric codes, and conversion methods.val USDCurrency = Currency.USDval USDCurrencyFromString = Currency.fromString("USD")USDCurrencyFromString.stringCode // "USD"val USDCurrencyFromInteger = Currency.fromInteger(840)USDCurrencyFromInteger.integerCode // 840int oldCurrency = Currencies.USD;Currency newCurrency = Currency.USD;Transaction transaction = Transaction.Companion.builder(100f, Currencies.EUR).id("optionalId").build;Transaction transaction = Transaction(100f, Currency.EUR, "optionalId");The
Currency
Enum provides both alphabetic and numeric codes, and conversion methods.Currency USDCurrency = Currency.USD;Currency USDCurrencyFromString = Currency.fromString("USD");USDCurrencyFromString.stringCode // "USD"Currency USDCurrencyFromInteger = Currency.fromInteger(840);USDCurrencyFromInteger.integerCode // 840 -
Replace
Transaction.builder
byTransaction
andContentsquare.send()
byCSQ.trackTransaction()
:val builder = Transaction.builder(100f, Currency.EUR).id("optionalId")Contentsquare.send(builder.build())val transaction = Transaction(100f, Currency.EUR, "optionalId")CSQ.trackTransaction(transaction)Transaction.TransactionBuilder builder = Transaction.Companion.builder(100f, Currency.EUR).id("optionalId");Contentsquare.send(builder.build());Transaction transaction = new Transaction(100f, Currency.EUR, "optionalId");CSQ.trackTransaction(transaction);
Update APIs
Section titled Update APIsSearch and replace all legacy SDK API calls in your app to the latest CSQ APIs using the following mappings. Updating your API calls ensures continued functionality without disruption.
In most cases, this process consists in updating the namespace and method names, with no changes to parameters.
Contentsquare.start(this)CSQ.start(this)
For more information on SDK methods, see the SDK API reference.
GDPR / Identification
Contentsquare SDK | CSQ SDK |
---|---|
Contentsquare.optIn(Context) | CSQ.optIn(Context) |
Contentsquare.optOut(Context) | CSQ.optOut() |
Contentsquare.getUserId() | CSQ.metadata.userId |
Contentsquare.getProjectId() | CSQ.metadata.projectId |
Contentsquare.getSessionNumber() | CSQ.metadata.sessionId |
Property tracking
Contentsquare SDK | CSQ SDK |
---|---|
Contentsquare.send(String key, Long value) Contentsquare.send(String key, String value) | CSQ.addDynamicVar(String key, Long value) CSQ.addDynamicVar(String key, String value) |
View tracking
Contentsquare SDK | CSQ SDK |
---|---|
Contentsquare.excludeFromExposureMetric(View) | CSQ.excludeFromExposureMetric(View) |
Interoperability
Contentsquare SDK | CSQ SDK |
---|---|
Contentsquare.onSessionReplayLinkChange(callback) | CSQ.metadata.onChanged(Metadata) |
CsWebViewManager.injectEventTrackingInterface(webView: WebView) | CSQ.registerWebView(WebView webView) |
CsWebViewManager.removeEventTrackingInterface(webView: WebView) | CSQ.unregisterWebView(WebView) |
Event tracking
Contentsquare SDK | CSQ SDK |
---|---|
Contentsquare.send(Transaction transaction) | CSQ.trackTransaction(Transaction) |
Contentsquare.send(string) / Contentsquare.send(String screenName, CustomVar[] customVars) | CSQ.trackScreenview(name:String, cvars: List<CustomVar>) |
Contentsquare.consumeEvent(motionEvent) | CSQ.trackMotionEvent(motionEvent: MotionEvent) |
Contentsquare SDK | CSQ SDK |
---|---|
import com.contentsquare.android.compose.analytics.TriggeredOnResume TriggeredOnResume(block: () -> Unit) | import com.contentsquare.api.compose.screen.TriggeredOnResume TriggeredOnResume(block: () -> Unit) |
Error tracking
Contentsquare SDK | CSQ SDK |
---|---|
ErrorAnalysis.setUrlMaskingPatterns(List<String>) | CSQ.setUrlMaskingPatterns(List<String>) |
import com.contentsquare.android.error.analysis.ErrorAnalysis | import com.contentsquare.api.model.NetworkMetric |
ErrorAnalysis.getInstance().newNetworkMetric(url, ErrorAnalysis.HttpMethod.GET) | NetworkMetric(url, HttpMethod.GET) |
networkMetric.stop() | CSQ.trackNetworkMetric(NetworkMetric) |
Personal Data Handling and Masking
Contentsquare SDK | CSQ SDK |
---|---|
Contentsquare.doNotTrack(Class<? extends Activity>... activitiesClasses) | CSQ.ignoreInteractions(view: View) |
Contentsquare.setDefaultMasking(boolean masked) | CSQ.setDefaultMasking(boolean masked) |
Contentsquare.mask(View view) | CSQ.mask(View) |
Contentsquare.mask(Class<?> type) | CSQ.mask(Class<?> type) |
Contentsquare.unMask(View view) | CSQ.unmask(View) |
Contentsquare.unmask(Class<?> type) | CSQ.unmask(Class<?> type) |
Contentsquare SDK | CSQ SDK |
---|---|
Modifier.sessionReplayMask(enableMasking: Boolean) | @Composable |
Modifier.excludeFromGestureRecognition() | @Composable |
SDK initialization and manipulation
Contentsquare SDK | CSQ SDK |
---|---|
Contentsquare.start(Context) | CSQ.start(Context) |
Contentsquare.stopTracking() | CSQ.pauseTracking() |
Contentsquare.resumeTracking() | CSQ.resumeTracking() |
Checklist
Section titled ChecklistCongratulations! You’re all set. Use this checklist to ensure everything is correctly updated.
Ensure that your build files no longer reference
com.contentsquare.android
, com.contentsquare.android:library
, or
com.contentsquare.android:sdk-compose
.
Your import com.contentsquare.android.Contentsquare
declarations have been updated to import com.contentsquare.CSQ
.
You no longer have references to Contentsquare.
methods in your
codebase.
All calls to the CSQ SDK use the CSQ.
namespace.