config-plugins
config-plugins copied to clipboard
feat(adjust): add meta install referrer
Why
This PR adds support for the Meta (Facebook) install referrer plugin in the react-native-adjust config plugin. The Meta install referrer is required for tracking Facebook ad campaigns and attribution in React Native apps using the Adjust SDK.
Currently, users need to manually add the com.adjust.sdk:adjust-android-meta-referrer:5.4.0 dependency to their Android build.gradle file when they want to track Meta install referrers. This enhancement allows the config plugin to automatically handle this dependency injection when configured.
Reference: https://dev.adjust.com/en/sdk/react-native/plugins/meta-referrer-plugin
How
- Added a new optional
metaInstallReferrerboolean parameter to the plugin configuration options - Modified the
addAndroidPackagingOptionsfunction to conditionally include the Meta install referrer dependency (com.adjust.sdk:adjust-android-meta-referrer:5.4.0) when the parameter is enabled - Updated TypeScript type definitions to include the new parameter alongside the existing
targetAndroid12option - Enhanced the
withGradlefunction to pass through the new parameter to the dependency injection logic - Updated README.md with comprehensive documentation including usage examples and a link to the official Adjust documentation
- Maintained backward compatibility - existing configurations continue to work without changes
The implementation follows the existing code patterns and architecture, ensuring consistency with the current plugin structure.
Test Plan
Manual Testing:
-
Basic functionality test:
{ "plugins": [ ["@config-plugins/react-native-adjust", { "metaInstallReferrer": true }] ] }- Run
npx expo prebuild --clean - Verify that
android/app/build.gradlecontains the Meta install referrer dependency
- Run
-
Combined configuration test:
{ "plugins": [ [ "@config-plugins/react-native-adjust", { "targetAndroid12": true, "metaInstallReferrer": true } ] ] }- Run
npx expo prebuild --clean - Verify both the Android 12 permission and Meta dependency are added
- Run
-
Backward compatibility test:
{ "plugins": ["@config-plugins/react-native-adjust"] }- Run
npx expo prebuild --clean - Verify existing functionality works without the Meta dependency
- Run
-
Parameter disabled test:
{ "plugins": [ ["@config-plugins/react-native-adjust", { "metaInstallReferrer": false }] ] }- Run
npx expo prebuild --clean - Verify Meta dependency is not added when explicitly disabled
- Run
Expected Results:
- When
metaInstallReferrer: true, the generatedandroid/app/build.gradleshould contain:implementation 'com.adjust.sdk:adjust-android-meta-referrer:5.4.0' - When the parameter is not set or
false, the Meta dependency should not be present - All existing functionality should remain unchanged
- TypeScript compilation should pass without errors