Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] [v5] Adjust SDK always shows as "enabled" #259

Open
Minishlink opened this issue Jan 14, 2025 · 2 comments
Open

[Bug] [v5] Adjust SDK always shows as "enabled" #259

Minishlink opened this issue Jan 14, 2025 · 2 comments

Comments

@Minishlink
Copy link

Hello,

I haven't tested this on Android, but at least on iOS, if you use your example project, click on "Disable", and then click "Is SDK Enabled?", it shows that the SDK is still enabled. It may be disabled but the function isEnabled returns like it is enabled.
It is problematic because if you call Adjust.getAttribution, it will never call the callback in that state.
This was not the case before v5.

Thank you
Louis

@Aditi3
Copy link
Member

Aditi3 commented Jan 15, 2025

Hi @Minishlink ,

Thank you for reaching out. I ran our example app to verify the functionality of enabling and disabling the SDK, and here are my observations:

  1. When I tap Enable SDK and check Is SDK Enabled?, it confirms and returns that the SDK is enabled.
  2. When I tap Disable SDK and check Is SDK Enabled?, it confirms and returns that the SDK is disabled.

Would you happen to have any additional integration where I can verify the functionality and try to reproduce it? Or You might have tapped Enable/ Disable Offline Mode instead of Enable SDK and Disable SDK.

@Minishlink
Copy link
Author

Hello,

You're right I actually modified the example to better reflect a real-world use case where Adjust is initialized if the user didn't give its consent for it. Or maybe there was a race condition somewhere.
Note that the example App.js is a bit broken and should not be used as an example for any developer.
Anyway here's a smaller version, with different symptoms of I believe the same problem:

  1. Use the below App.js
  2. Uninstall your example app to start from scratch
  3. react-native run-ios
  4. There is nothing that initializes Adjust, but when you press is SDK enabled it shows as enabled
  5. If you press get attribution the function never resolves

In v4, if you press "get attribution" the function actually resolves with an empty object.

import React from 'react';
import {
  StyleSheet,
  View,
  Text,
  TouchableHighlight,
  Platform,
} from 'react-native';
import {Colors} from 'react-native/Libraries/NewAppScreen';
import {
  Adjust,
  AdjustConfig,
  AdjustThirdPartySharing,
} from 'react-native-adjust';
import {AdjustOaid} from 'react-native-adjust-oaid';

function initAdjust() {
  Adjust.getSdkVersion(function (sdkVersion) {
    console.log('Adjust SDK version: ' + sdkVersion);
  });

  const adjustConfig = new AdjustConfig(
    '2fm9gkqubvpc',
    AdjustConfig.EnvironmentSandbox,
  );

  adjustConfig.setLogLevel(AdjustConfig.LogLevelVerbose);
  // adjustConfig.disableSkanAttribution();
  // adjustConfig.enableCoppaCompliance();
  // adjustConfig.setAttConsentWaitingInterval(16);

  adjustConfig.setAttributionCallback(function (attribution) {
    console.log('Attribution callback received');
    console.log('Tracker token = ' + attribution.trackerToken);
    console.log('Tracker name = ' + attribution.trackerName);
    console.log('Network = ' + attribution.network);
    console.log('Campaign = ' + attribution.campaign);
    console.log('Adgroup = ' + attribution.adgroup);
    console.log('Creative = ' + attribution.creative);
    console.log('Click label = ' + attribution.clickLabel);
    console.log('Cost type = ' + attribution.costType);
    console.log('Cost amount = ' + attribution.costAmount);
    console.log('Cost currency = ' + attribution.costCurrency);
  });

  adjustConfig.setEventTrackingSucceededCallback(function (eventSuccess) {
    console.log('Event tracking succeeded callback received');
    console.log('Message: ' + eventSuccess.message);
    console.log('Timestamp: ' + eventSuccess.timestamp);
    console.log('Adid: ' + eventSuccess.adid);
    console.log('Event token: ' + eventSuccess.eventToken);
    console.log('Callback Id: ' + eventSuccess.callbackId);
    console.log('JSON response: ' + eventSuccess.jsonResponse);
  });

  adjustConfig.setEventTrackingFailedCallback(function (eventFailed) {
    console.log('Event tracking failed callback received');
    console.log('Message: ' + eventFailed.message);
    console.log('Timestamp: ' + eventFailed.timestamp);
    console.log('Adid: ' + eventFailed.adid);
    console.log('Event token: ' + eventFailed.eventToken);
    console.log('Callback Id: ' + eventFailed.callbackId);
    console.log('Will retry: ' + eventFailed.willRetry);
    console.log('JSON response: ' + eventFailed.jsonResponse);
  });

  adjustConfig.setSessionTrackingSucceededCallback(function (sessionSuccess) {
    console.log('Session tracking succeeded callback received');
    console.log('Message: ' + sessionSuccess.message);
    console.log('Timestamp: ' + sessionSuccess.timestamp);
    console.log('Adid: ' + sessionSuccess.adid);
    console.log('JSON response: ' + sessionSuccess.jsonResponse);
  });

  adjustConfig.setSessionTrackingFailedCallback(function (sessionFailed) {
    console.log('Session tracking failed callback received');
    console.log('Message: ' + sessionFailed.message);
    console.log('Timestamp: ' + sessionFailed.timestamp);
    console.log('Adid: ' + sessionFailed.adid);
    console.log('Will retry: ' + sessionFailed.willRetry);
    console.log('JSON response: ' + sessionFailed.jsonResponse);
  });

  adjustConfig.setDeferredDeeplinkCallback(function (deeplink) {
    console.log('Deferred Deeplink Callback received');
    console.log('Deeplink: ' + deeplink.deeplink);
  });

  adjustConfig.setSkanUpdatedCallback(function (skanData) {
    console.log('Skan Data updated callback received');
    console.log('Conversion value: ' + skanData.conversionValue);
    console.log('Coarse value: ' + skanData.coarseValue);
    console.log('Lock window: ' + skanData.lockWindow);
    console.log('Error: ' + skanData.error);
  });

  Adjust.addGlobalCallbackParameter('scpk1', 'scpv1');
  Adjust.addGlobalCallbackParameter('scpk2', 'scpv2');

  Adjust.addGlobalPartnerParameter('sppk1', 'sppv1');
  Adjust.addGlobalPartnerParameter('sppk2', 'sppv2');

  Adjust.removeGlobalCallbackParameter('scpk1');
  Adjust.removeGlobalPartnerParameter('sppk2');

  // Adjust.removeGlobalCallbackParameters();
  // Adjust.removeGlobalPartnerParameters();

  Adjust.requestAppTrackingAuthorization(function (status) {
    console.log('Authorization status update');
    switch (status) {
      case 0:
        // ATTrackingManagerAuthorizationStatusNotDetermined case
        console.log(
          'Authorization status: ATTrackingManagerAuthorizationStatusNotDetermined',
        );
        break;
      case 1:
        // ATTrackingManagerAuthorizationStatusRestricted case
        console.log(
          'Authorization status: ATTrackingManagerAuthorizationStatusRestricted',
        );
        break;
      case 2:
        // ATTrackingManagerAuthorizationStatusDenied case
        console.log(
          'Authorization status: ATTrackingManagerAuthorizationStatusDenied',
        );
        break;
      case 3:
        // ATTrackingManagerAuthorizationStatusAuthorized case
        console.log(
          'Authorization status: ATTrackingManagerAuthorizationStatusAuthorized',
        );
        break;
    }
  });

  if (Platform.OS === 'android') {
    AdjustOaid.readOaid();
  }

  Adjust.initSdk(adjustConfig);
}

function _onPress_enableSdk() {
  Adjust.enable();
}

function _onPress_disableSdk() {
  Adjust.disable();
}

function _onPress_isSdkEnabled() {
  Adjust.isEnabled(isEnabled => {
    if (isEnabled) {
      console.log('SDK is enabled');
    } else {
      console.log('SDK is disabled');
    }
  });
}

const App = () => {
  return (
    <View style={styles.container}>
      <TouchableHighlight style={styles.button} onPress={initAdjust}>
        <Text>Init SDK</Text>
      </TouchableHighlight>
      <TouchableHighlight style={styles.button} onPress={_onPress_enableSdk}>
        <Text>Enable SDK</Text>
      </TouchableHighlight>
      <TouchableHighlight style={styles.button} onPress={_onPress_disableSdk}>
        <Text>Disable SDK</Text>
      </TouchableHighlight>
      <TouchableHighlight
        style={styles.button}
        onPress={() => {
          Adjust.trackThirdPartySharing(new AdjustThirdPartySharing(true));
        }}>
        <Text>Enable 3rd party sharing</Text>
      </TouchableHighlight>
      <TouchableHighlight
        style={styles.button}
        onPress={() => {
          Adjust.trackThirdPartySharing(new AdjustThirdPartySharing(false));
        }}>
        <Text>Disable 3rd party sharing</Text>
      </TouchableHighlight>
      <TouchableHighlight
        style={styles.button}
        onPress={() => {
          Adjust.getAttribution(adjustAttribution => {
            console.log('attribution', adjustAttribution);
          });
        }}>
        <Text>Get attribution</Text>
      </TouchableHighlight>
      <TouchableHighlight style={styles.button} onPress={_onPress_isSdkEnabled}>
        <Text>is SDK Enabled?</Text>
      </TouchableHighlight>
    </View>
  );
};

const styles = StyleSheet.create({
  scrollView: {
    backgroundColor: Colors.lighter,
  },
  engine: {
    position: 'absolute',
    right: 0,
  },
  body: {
    backgroundColor: Colors.white,
  },
  sectionContainer: {
    marginTop: 32,
    paddingHorizontal: 24,
  },
  sectionTitle: {
    fontSize: 24,
    fontWeight: '600',
    color: Colors.black,
  },
  sectionDescription: {
    marginTop: 8,
    fontSize: 18,
    fontWeight: '400',
    color: Colors.dark,
  },
  highlight: {
    fontWeight: '700',
  },
  footer: {
    color: Colors.dark,
    fontSize: 12,
    fontWeight: '600',
    padding: 4,
    paddingRight: 12,
    textAlign: 'right',
  },
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  button: {
    alignItems: 'center',
    backgroundColor: '#61D4FB',
    padding: 10,
    width: '60%',
    height: 40,
    margin: 10,
  },
});

export default App;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants