Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions packages/firebase-analytics/index.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ Object.defineProperty(fb, 'analytics', {
writable: false,
});

function serialize(data) {
let store;
function numberHasDecimals(item: number) {
return !(item % 1 === 0);
}

function serialize(data) {
switch (typeof data) {
case 'string':
case 'boolean':
Expand All @@ -31,7 +33,7 @@ function serialize(data) {
}

if (Array.isArray(data)) {
store = new java.util.ArrayList();
const store = new java.util.ArrayList();
data.forEach((item) => {
const value = serialize(item);
switch (typeof value) {
Expand All @@ -49,15 +51,19 @@ function serialize(data) {
return store;
}

store = new android.os.Bundle();
const store = new android.os.Bundle();
Object.keys(data).forEach((key) => {
const value = serialize(data[key]);
switch (typeof value) {
case 'boolean':
store.putBoolean(key, value);
break;
case 'number':
store.putInt(key, value);
if (numberHasDecimals(value)) {
store.putDouble(key, value);
} else {
store.putLong(key, value);
}
break;
case 'string':
store.putString(key, value);
Expand Down