appsflyer-react-native-plugin icon indicating copy to clipboard operation
appsflyer-react-native-plugin copied to clipboard

setConsentData type issue

Open artyorsh opened this issue 1 year ago • 5 comments

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-appsflyer/index.d.ts b/node_modules/react-native-appsflyer/index.d.ts
index e1ae493..ba6ace1 100644
--- a/node_modules/react-native-appsflyer/index.d.ts
+++ b/node_modules/react-native-appsflyer/index.d.ts
@@ -115,8 +115,8 @@ declare module "react-native-appsflyer" {
     }
 
     export const AppsFlyerConsent: {
-        forGDPRUser: (hasConsentForDataUsage: boolean, hasConsentForAdsPersonalization: boolean) => void;
-        forNonGDPRUser: () => void;
+        forGDPRUser: (hasConsentForDataUsage: boolean, hasConsentForAdsPersonalization: boolean) => AppsFlyerConsentType;
+        forNonGDPRUser: () => AppsFlyerConsentType;
     }
 
     export type AppsFlyerConsentType = typeof AppsFlyerConsent;

This issue body was partially generated by patch-package.

artyorsh avatar Feb 20 '24 16:02 artyorsh

I believe the proposed patch above doesn't go far enough in correcting the broken types. The following should actually fix the issue (ensuring that the object returned from forGDPRUser and forNonGDPRUser actually matches the expected type (an object containing isUserSubjectToGDPR, hasConsentForDataUsage and hasConsentForAdsPersonalization) based on the two platform specific implementations :

diff --git a/node_modules/react-native-appsflyer/index.d.ts b/node_modules/react-native-appsflyer/index.d.ts
index e1ae493..d6d8442 100644
--- a/node_modules/react-native-appsflyer/index.d.ts
+++ b/node_modules/react-native-appsflyer/index.d.ts
@@ -115,11 +115,15 @@ declare module "react-native-appsflyer" {
    }

    export const AppsFlyerConsent: {
-        forGDPRUser: (hasConsentForDataUsage: boolean, hasConsentForAdsPersonalization: boolean) => void;
-        forNonGDPRUser: () => void;
+        forGDPRUser: (hasConsentForDataUsage: boolean, hasConsentForAdsPersonalization: boolean) => AppsFlyerConsentType;
+        forNonGDPRUser: () => AppsFlyerConsentType;
    }

-    export type AppsFlyerConsentType = typeof AppsFlyerConsent;
+    export interface AppsFlyerConsentType {
+        isUserSubjectToGDPR: boolean;
+        hasConsentForDataUsage?: boolean;
+        hasConsentForAdsPersonalization?: boolean;
+    }

    const appsFlyer: {
        onInstallConversionData(callback: (data: ConversionData) => any): () => void;

chriskurzeja avatar Feb 26 '24 15:02 chriskurzeja

@amit-kremer93 can we get a fix for this merged. Seems like its very important with the March 6th deadline quickly approaching

walterholohan avatar Feb 29 '24 22:02 walterholohan

+1

buuuudzik avatar Mar 04 '24 15:03 buuuudzik

@chriskurzeja @artyorsh thanks for the above. Super helpful.

Just wondering what method did you use to determine if the user was in a GDPR region or not? I was thinking to use the Timezone string to determine. Been keen to see if there is a better way

walterholohan avatar Mar 06 '24 07:03 walterholohan

@chriskurzeja @artyorsh thanks for the above. Super helpful.

Just wondering what method did you use to determine if the user was in a GDPR region or not? I was thinking to use the Timezone string to determine. Been keen to see if there is a better way

A bit different for us since I work on "EU only" app. But I guess I'd rely on IP ranges.

artyorsh avatar Mar 06 '24 08:03 artyorsh

Fixed in 6.13.1

amit-kremer93 avatar Apr 04 '24 13:04 amit-kremer93

Hello, on 6.17.1 this issue is back.

Trying the exact code from the documentation: const consentData = new AppsFlyerConsent(true, true, true, true); // Send consent data to the SDK appsFlyer.setConsentData(consentData);

will return this typescript issue:

Argument of type 'AppsFlyerConsent' is not assignable to parameter of type 'AppsFlyerConsentType'. Property 'isUserSubjectToGDPR' is optional in type 'AppsFlyerConsent' but required in type 'AppsFlyerConsentType'.ts(2345)

VladPopax-Wirtek avatar Jul 23 '25 11:07 VladPopax-Wirtek