Skip to content

Commit 2a2100f

Browse files
briemcnallyMarco Cattaneo
and
Marco Cattaneo
authored
[STRATCONN-161] Map - to _ in properties and event names (#30)
* Added check on makeKey to remove dash from event-names * Update Snapshot Co-authored-by: Marco Cattaneo <[email protected]>
1 parent c4d7097 commit 2a2100f

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2.1.1 / 2020-04-21
2+
==================
3+
* Adds check on `makeKey` to replace `-` to `_` on properties and event names.
4+
15
2.1.0 / 2020-02-20
26
==================
37
* Add support for explicitly tracking screen calls.

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
GROUP=com.segment.analytics.android.integrations
22

3-
VERSION=2.1.0-SNAPSHOT
3+
VERSION=2.1.1-SNAPSHOT
44

55
POM_ARTIFACT_ID=firebase
66
POM_PACKAGING=aar

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

+2
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ && isNullOrEmpty(properties.currency())) {
215215
public static String makeKey(String key) {
216216
if (key.contains(".")) {
217217
key = key.trim().replace(".", "_");
218+
} else if (key.contains("-")) {
219+
key = key.trim().replace("-", "_");
218220
} else {
219221
key = key.trim().replaceAll(" ", "_");
220222
}

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

+12
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,18 @@ public void trackScreenWithName() {
157157
verify(firebase).setCurrentScreen(any(Activity.class), eq("home_screen"), (String) isNull());
158158
}
159159

160+
@Test
161+
public void makeKeyWithDash() {
162+
integration.track(new TrackPayload.Builder().anonymousId("12345").event("test-event-dashed").build());
163+
verify(firebase).logEvent(eq("test_event_dashed"), bundleEq(new Bundle()));
164+
}
165+
166+
@Test
167+
public void makeKeyWithDot() {
168+
integration.track(new TrackPayload.Builder().anonymousId("12345").event("test.event").build());
169+
verify(firebase).logEvent(eq("test_event"), bundleEq(new Bundle()));
170+
}
171+
160172
/**
161173
* Uses the string representation of the object. Useful for JSON objects.
162174
* @param expected Expected object

0 commit comments

Comments
 (0)