Skip to content

Commit 9f9dc62

Browse files
committed
- update readme
1 parent 2ccaa22 commit 9f9dc62

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,17 @@ and send firebase event using object.
8181
```
8282

8383

84+
```Java
85+
public static class User {
86+
@FirebaseParam("userId")
87+
String id;
88+
@FirebaseParam("userName")
89+
String name;
90+
}
91+
92+
SimpleFirebaseAnalytics.sendEvent("create", user);
93+
```
94+
95+
8496
#### Limitation
8597
- use AppCompatActivity to use Fragment screen logging (FragmentLifeCycle observing supported since API level 26)

library/src/main/java/com/android/sebiya/firebase/SimpleFirebaseAnalytics.java

+21
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ public void onActivityDestroyed(Activity activity) {
7474
}
7575
}
7676
});
77+
} else {
78+
Log.e(LOG_TAG, "init. already init called. so ignore this init method");
7779
}
7880
}
7981

@@ -118,4 +120,23 @@ public static void sendEvent(Object obj) {
118120
}
119121
}
120122
}
123+
124+
public static void sendEvent(String event, Object paramObj) {
125+
if (!sAnalytics.isUserAgreed()) {
126+
return;
127+
}
128+
Bundle param = FirebaseAnnotationParser.getParam(paramObj);
129+
if (param != null) {
130+
sAnalytics.logEvent(event, param);
131+
if (ENABLE_DEBUG_LOG) {
132+
String str = LOG_TAG;
133+
StringBuilder stringBuilder = new StringBuilder();
134+
stringBuilder.append("sendEvent. event - ");
135+
stringBuilder.append(event);
136+
stringBuilder.append(", param - ");
137+
stringBuilder.append(param);
138+
Log.d(str, stringBuilder.toString());
139+
}
140+
}
141+
}
121142
}

0 commit comments

Comments
 (0)