Skip to content

Commit 1cc6b27

Browse files
briemcnallybrennan
authored andcommitted
Brie/firebase sunset updates (#21)
* Bump Firebase dependency to 17.2.0
1 parent c76ed76 commit 1cc6b27

File tree

5 files changed

+42
-9
lines changed

5 files changed

+42
-9
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11

2+
1.4.0 / 2019-09-09
3+
==================
4+
5+
* Bump Firebase to 17.2.0
6+
27
1.3.1 / 2019-07-17
38
==================
49

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ dependencies {
5555
}
5656

5757
api 'com.segment.analytics.android:analytics:4.3.1'
58-
implementation 'com.google.firebase:firebase-core:17.0.1'
58+
implementation 'com.google.firebase:firebase-analytics:17.2.0'
5959

6060
testImplementation 'com.segment.analytics.android:analytics-tests:4.3.1'
6161
testImplementation 'junit:junit:4.12'

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
GROUP=com.segment.analytics.android.integrations
22

3-
VERSION=1.3.1
3+
VERSION=1.4.0-SNAPSHOT
44

55
POM_ARTIFACT_ID=firebase
66
POM_PACKAGING=aar

src/main/java/com/segment/analytics/android/integrations/firebase/FirebaseIntegration.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ private static Map<String, String> createEventMap() {
7979
EVENT_MAPPER.put("Product Shared", Event.SHARE);
8080
EVENT_MAPPER.put("Product Clicked", Event.SELECT_CONTENT);
8181
EVENT_MAPPER.put("Product Searched", Event.SEARCH);
82-
EVENT_MAPPER.put("Promotion Viewed", Event.PRESENT_OFFER);
8382
return EVENT_MAPPER;
8483
}
8584

@@ -189,7 +188,11 @@ && isNullOrEmpty(properties.currency())) {
189188
}
190189

191190
public static String makeKey(String key) {
192-
key = key.trim().replaceAll(" ", "_");
191+
if (key.contains(".")) {
192+
key = key.trim().replace(".", "_");
193+
} else {
194+
key = key.trim().replaceAll(" ", "_");
195+
}
193196
return key.substring(0, Math.min(key.length(), 40));
194197
}
195198
}

src/test/java/com/segment/analytics/android/integration/firebase/FirebaseTest.java

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,14 @@
99
import com.segment.analytics.integrations.IdentifyPayload;
1010
import com.segment.analytics.integrations.Logger;
1111
import com.segment.analytics.integrations.TrackPayload;
12-
import com.segment.analytics.test.TrackPayloadBuilder;
1312

14-
import org.hamcrest.Description;
15-
import org.hamcrest.TypeSafeMatcher;
1613
import org.json.JSONException;
1714
import org.json.JSONObject;
1815
import org.junit.Before;
1916
import org.junit.Rule;
2017
import org.junit.Test;
2118
import org.junit.runner.RunWith;
2219
import org.mockito.ArgumentMatcher;
23-
import org.mockito.InOrder;
2420
import org.mockito.Mockito;
2521
import org.powermock.api.mockito.PowerMockito;
2622
import org.powermock.core.classloader.annotations.PowerMockIgnore;
@@ -37,7 +33,6 @@
3733
import static com.segment.analytics.Analytics.LogLevel.VERBOSE;
3834
import static org.mockito.Matchers.argThat;
3935
import static org.mockito.Matchers.eq;
40-
import static org.mockito.Mockito.inOrder;
4136
import static org.mockito.Mockito.verify;
4237

4338
@RunWith(RobolectricTestRunner.class)
@@ -100,6 +95,7 @@ public void trackWithProperties() {
10095
.putValue("string", "foo")
10196
.putValue("date", new Date(117, 0, 1))
10297
.putValue("key with spaces", "bar")
98+
.putValue("key.with.periods", "test")
10399
.putValue("total", 100.0)
104100
.putValue(" extra spaces ", "baz");
105101

@@ -111,13 +107,42 @@ public void trackWithProperties() {
111107
expected.putString("string", "foo");
112108
expected.putString("date", String.valueOf(new Date(117, 0, 1)));
113109
expected.putString("key_with_spaces", "bar");
110+
expected.putString("key_with_periods", "test");
114111
expected.putDouble("value", 100.0);
115112
expected.putString("currency", "USD");
116113
expected.putString("extra_spaces", "baz");
117114

118115
verify(firebase).logEvent(eq("foo"), bundleEq(expected));
119116
}
120117

118+
@Test
119+
public void trackWithEventNameTransformation() {
120+
Properties properties = new Properties()
121+
.putValue("integer", 1)
122+
.putValue("double", 1.0)
123+
.putValue("string", "foo")
124+
.putValue("date", new Date(117, 0, 1))
125+
.putValue("key with spaces", "bar")
126+
.putValue("key.with.periods", "test")
127+
.putValue("total", 100.0)
128+
.putValue(" extra spaces ", "baz");
129+
130+
integration.track(new TrackPayload.Builder().anonymousId("1234").properties(properties).event("foo.bar").build());
131+
132+
Bundle expected = new Bundle();
133+
expected.putInt("integer", 1);
134+
expected.putDouble("double", 1.0);
135+
expected.putString("string", "foo");
136+
expected.putString("date", String.valueOf(new Date(117, 0, 1)));
137+
expected.putString("key_with_spaces", "bar");
138+
expected.putString("key_with_periods", "test");
139+
expected.putDouble("value", 100.0);
140+
expected.putString("currency", "USD");
141+
expected.putString("extra_spaces", "baz");
142+
143+
verify(firebase).logEvent(eq("foo_bar"), bundleEq(expected));
144+
}
145+
121146
/**
122147
* Uses the string representation of the object. Useful for JSON objects.
123148
* @param expected Expected object

0 commit comments

Comments
 (0)