Skip to content
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,17 @@ public void screen(String screenName, ReadableMap properties) {
mAnalytics.screen(null, screenName, toProperties(properties));
}

/*
https://segment.com/docs/libraries/android/#group
*/
@ReactMethod
public void group(String groupId, ReadableMap traits) {
if (!mEnabled) {
return;
}
mAnalytics.group(groupId, toTraits(traits));
}

/*
https://segment.com/docs/libraries/android/#flushing
*/
Expand Down Expand Up @@ -144,13 +155,13 @@ private Properties toProperties (ReadableMap map) {
ReadableType type = map.getType(key);
switch (type){
case Array:
props.putValue(key, map.getArray(key));
props.putValue(key, map.getArray(key).toArrayList());
break;
case Boolean:
props.putValue(key, map.getBoolean(key));
break;
case Map:
props.putValue(key, map.getMap(key));
props.putValue(key, map.getMap(key).toHashMap());
break;
case Null:
props.putValue(key, null);
Expand Down Expand Up @@ -181,13 +192,13 @@ private Traits toTraits (ReadableMap map) {
ReadableType type = map.getType(key);
switch (type){
case Array:
traits.putValue(key, map.getArray(key));
traits.putValue(key, map.getArray(key).toArrayList());
break;
case Boolean:
traits.putValue(key, map.getBoolean(key));
break;
case Map:
traits.putValue(key, map.getMap(key));
traits.putValue(key, map.getMap(key).toHashMap());
break;
case Null:
traits.putValue(key, null);
Expand Down
8 changes: 8 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ export default {
NativeRNSegmentIOAnalytics.screen(screenName, properties || {})
},

/*
* https://segment.com/docs/libraries/ios/#group
* https://segment.com/docs/libraries/android/#group
*/
group: function (groupId: string, traits: ?Object) {
NativeRNSegmentIOAnalytics.group(groupId, traits || {})
},

/*
* https://segment.com/docs/libraries/ios/#reset
* https://segment.com/docs/libraries/android/#how-do-you-handle-unique-identifiers-
Expand Down
7 changes: 7 additions & 0 deletions ios/RNAnalytics/RNSegmentIOAnalytics.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ @implementation RNSegmentIOAnalytics
[[SEGAnalytics sharedAnalytics] screen:screenName properties:properties];
}

/*
https://segment.com/docs/libraries/ios/#group
*/
RCT_EXPORT_METHOD(group:(NSString*)groupId traits:(NSDictionary *)traits) {
[[SEGAnalytics sharedAnalytics] group:groupId traits:traits];
}

/*
https://segment.com/docs/libraries/ios/#flushing
*/
Expand Down