Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 14c26bb

Browse filesBrowse files
authored
fix(analytics): long/double handling for android (#225)
1 parent 843ffef commit 14c26bb
Copy full SHA for 14c26bb

File tree

1 file changed

+11
-5
lines changed
Filter options

1 file changed

+11
-5
lines changed

‎packages/firebase-analytics/index.android.ts

Copy file name to clipboardExpand all lines: packages/firebase-analytics/index.android.ts
+11-5Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ Object.defineProperty(fb, 'analytics', {
1515
writable: false,
1616
});
1717

18-
function serialize(data) {
19-
let store;
18+
function numberHasDecimals(item: number) {
19+
return !(item % 1 === 0);
20+
}
2021

22+
function serialize(data) {
2123
switch (typeof data) {
2224
case 'string':
2325
case 'boolean':
@@ -31,7 +33,7 @@ function serialize(data) {
3133
}
3234

3335
if (Array.isArray(data)) {
34-
store = new java.util.ArrayList();
36+
const store = new java.util.ArrayList();
3537
data.forEach((item) => {
3638
const value = serialize(item);
3739
switch (typeof value) {
@@ -49,15 +51,19 @@ function serialize(data) {
4951
return store;
5052
}
5153

52-
store = new android.os.Bundle();
54+
const store = new android.os.Bundle();
5355
Object.keys(data).forEach((key) => {
5456
const value = serialize(data[key]);
5557
switch (typeof value) {
5658
case 'boolean':
5759
store.putBoolean(key, value);
5860
break;
5961
case 'number':
60-
store.putInt(key, value);
62+
if (numberHasDecimals(value)) {
63+
store.putDouble(key, value);
64+
} else {
65+
store.putLong(key, value);
66+
}
6167
break;
6268
case 'string':
6369
store.putString(key, value);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.