Skip to content

Commit 9f47e67

Browse files
alanjcharlesoscb
andauthored
Feat: Add AdvertisingId Plugin (#574)
* chore: lint * feat: add advertisingId plugin * chore: refactor and add shutdown method * chore: debug with oscar * feat: add advertisingId plugin * refactor: rever device_setup.sh * refactor: clean example app update readme * chore: remove android deps/packages in example * chore: remove ad_id permission in manifest * refactor: remove google play services * refactor: bump ci sdk to 31 * refactor: revert ci changes * chore: refactor with Oscar's suggestions * chore:fix yarn conflict * chore: fix yarn.lock * chore: update device_setup.sh to 31 * remove google deps * chore:revert ci * chore: refactor ci * refactor: fix tests remove google-services.json from core * Update .github/workflows/ci.yml Co-authored-by: Oscar Bazaldua <[email protected]> Co-authored-by: Alan Charles <[email protected]> Co-authored-by: Oscar Bazaldua <[email protected]>
1 parent 4ffd374 commit 9f47e67

32 files changed

+697
-61
lines changed

example/CONTRIBUTING.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Contributing
2+
3+
We want this community to be friendly and respectful to each other. Please follow it in all your interactions with the project.
4+
5+
## Adding Android Packages
6+
7+
Add necessary Gradle Dependencies
8+
9+
```sh
10+
implementation project(':segmentanalyticsreactnative')
11+
implementation "com.google.android.gms:play-services-ads-identifier:18.0.1"
12+
implementation project(':analyticsreactnativepluginadvertisingid')
13+
```
14+
15+
16+
Add project to `settings.gradle`
17+
18+
```sh
19+
include ':analyticsreactnativepluginadvertisingid'
20+
project(':analyticsreactnativepluginadvertisingid').projectDir = new File(rootProject.projectDir, '../../packages/plugins/plugin-advertising-id/android')
21+
```
22+
23+
Add package to `MainActivity.java`
24+
25+
```sh
26+
@Override
27+
protected List<ReactPackage> getPackages() {
28+
@SuppressWarnings("UnnecessaryLocalVariable")
29+
List<ReactPackage> packages = new PackageList(this).getPackages();
30+
// Packages that cannot be autolinked yet can be added manually here, for
31+
// AnalyticsReactNativeExample:
32+
// packages.add(new MyReactNativePackage());
33+
packages.add(new AnalyticsReactNativePackage());
34+
packages.add(new AnalyticsReactNativePluginAdvertisingIdPackage());
35+
return packages;
36+
}
37+
```

example/android/.project

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
</natures>
1717
<filteredResources>
1818
<filter>
19-
<id>1644522731203</id>
19+
<id>0</id>
2020
<name></name>
2121
<type>30</type>
2222
<matcher>

example/android/.settings/org.eclipse.buildship.core.prefs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
55
connection.project.dir=
66
eclipse.preferences.version=1
77
gradle.user.home=
8-
java.home=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
8+
java.home=/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home
99
jvm.arguments=
1010
offline.mode=false
1111
override.workspace.settings=true

example/android/app/build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
apply plugin: "com.android.application"
2-
apply plugin: 'com.google.gms.google-services'
2+
// apply plugin: 'com.google.gms.google-services'
33

44
import com.android.build.OutputFile
55

@@ -210,6 +210,8 @@ dependencies {
210210
}
211211

212212
implementation project(':segmentanalyticsreactnative')
213+
// implementation "com.google.android.gms:play-services-ads-identifier:18.0.1"
214+
implementation project(':analyticsreactnativepluginadvertisingid')
213215

214216
androidTestImplementation('com.wix:detox:+')
215217
}

example/android/app/google-services.json

Lines changed: 0 additions & 47 deletions
This file was deleted.

example/android/app/src/main/AndroidManifest.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<uses-permission android:name="android.permission.INTERNET" />
55
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
6-
6+
<!-- <uses-permission android:name="com.google.android.gms.permission.AD_ID"/> -->
77
<application
88
android:name=".MainApplication"
99
android:label="@string/app_name"
@@ -12,6 +12,10 @@
1212
android:allowBackup="false"
1313
android:theme="@style/AppTheme"
1414
android:networkSecurityConfig="@xml/network_security_config">
15+
<!-- Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713 -->
16+
<!-- <meta-data
17+
android:name="com.google.android.gms.ads.APPLICATION_ID"
18+
android:value="ca-app-pub-3940256099942544~3347511713"/> -->
1519
<activity
1620
android:name=".MainActivity"
1721
android:label="@string/app_name"
@@ -39,7 +43,8 @@
3943
<activity
4044
android:name="com.zoontek.rnbootsplash.RNBootSplashActivity"
4145
android:theme="@style/BootTheme"
42-
android:launchMode="singleTask">
46+
android:launchMode="singleTask"
47+
android:exported="true">
4348
<intent-filter>
4449
<action android:name="android.intent.action.MAIN" />
4550
<category android:name="android.intent.category.LAUNCHER" />

example/android/app/src/main/java/com/example/segmentanalyticsreactnative/MainApplication.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import java.lang.reflect.InvocationTargetException;
1212
import java.util.List;
1313
import com.segmentanalyticsreactnative.AnalyticsReactNativePackage;
14+
import com.analyticsreactnativepluginadvertisingid.AnalyticsReactNativePluginAdvertisingIdPackage;
15+
1416

1517
public class MainApplication extends Application implements ReactApplication {
1618

@@ -26,8 +28,8 @@ protected List<ReactPackage> getPackages() {
2628
List<ReactPackage> packages = new PackageList(this).getPackages();
2729
// Packages that cannot be autolinked yet can be added manually here, for
2830
// AnalyticsReactNativeExample:
29-
// packages.add(new MyReactNativePackage());
3031
packages.add(new AnalyticsReactNativePackage());
32+
packages.add(new AnalyticsReactNativePluginAdvertisingIdPackage());
3133
return packages;
3234
}
3335

example/android/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ buildscript {
55
ext {
66
buildToolsVersion = "30.0.2"
77
minSdkVersion = 21
8-
compileSdkVersion = 30
9-
targetSdkVersion = 30
10-
ndkVersion = "21.4.7075529"
8+
compileSdkVersion = 31
9+
targetSdkVersion = 31
10+
ndkVersion = "23.2.8568313"
1111
}
1212
repositories {
1313
google()

example/android/settings.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ include ':app'
44

55
include ':segmentanalyticsreactnative'
66
project(':segmentanalyticsreactnative').projectDir = new File(rootProject.projectDir, '../../packages/core/android')
7+
8+
include ':analyticsreactnativepluginadvertisingid'
9+
project(':analyticsreactnativepluginadvertisingid').projectDir = new File(rootProject.projectDir, '../../packages/plugins/plugin-advertising-id/android')

example/ios/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,4 +466,4 @@ SPEC CHECKSUMS:
466466

467467
PODFILE CHECKSUM: 0c7eb82d495ca56953c50916b7b49e7512632eb6
468468

469-
COCOAPODS: 1.11.3
469+
COCOAPODS: 1.11.2

example/src/App.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ import { Logger } from './plugins/Logger';
3333
// @ts-ignore
3434
import { AmplitudeSessionPlugin } from '@segment/analytics-react-native-plugin-amplitude-session';
3535

36+
//@ts-ignore
37+
// import { AdvertisingIdPlugin } from '@segment/analytics-react-native-plugin-advertising-id';
38+
3639
const segmentClient = createClient({
3740
writeKey: 'WRITE_KEY',
3841
trackAppLifecycleEvents: true,
@@ -59,6 +62,10 @@ segmentClient.add({ plugin: LoggerPlugin });
5962

6063
segmentClient.add({ plugin: new AmplitudeSessionPlugin() });
6164

65+
// segmentClient.add({
66+
// plugin: new AdvertisingIdPlugin(),
67+
// });
68+
6269
const MainStack = createStackNavigator();
6370
const RootStack = createStackNavigator();
6471

packages/core/android/.settings/org.eclipse.buildship.core.prefs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
arguments=
22
auto.sync=false
33
build.scans.enabled=false
4-
connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(7.1.1))
5-
connection.project.dir=../../../example/android
4+
connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(7.4.2))
5+
connection.project.dir=
66
eclipse.preferences.version=1
77
gradle.user.home=
8-
java.home=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
8+
java.home=/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home
99
jvm.arguments=
1010
offline.mode=false
1111
override.workspace.settings=true

packages/core/android/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ buildscript {
1717
apply plugin: 'com.android.library'
1818
apply plugin: 'kotlin-android'
1919

20+
2021
def getExtOrDefault(name) {
2122
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['AnalyticsReactNative_' + name]
2223
}

packages/plugins/plugin-advertising-id/CHANGELOG.md

Whitespace-only changes.

0 commit comments

Comments
 (0)