Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sayan-rudder committed Feb 24, 2020
1 parent b049b83 commit ab6d901
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ class Analytics {
this.groupId =
this.storage.getGroupId() != undefined ? this.storage.getGroupId() : "";

this.groupTraits =
this.groupTraits =
this.storage.getGroupTraits() != undefined
? this.storage.getGroupTraits()
: {};

this.anonymousId = this.getAnonymousId();
this.storage.setUserId(this.userId);
this.eventRepository = EventRepository;
Expand Down Expand Up @@ -331,12 +331,13 @@ class Analytics {
* @param {*} callback
*/
group(groupId, traits, options, callback) {

if (!arguments.length) return;

if (typeof options == "function") (callback = options), (options = null);
if (typeof traits == "function") (callback = traits), (options = null), (traits = null);
if (typeof groupId == "object") (options = traits), (traits = groupId), (groupId = this.groupId);
if (typeof traits == "function")
(callback = traits), (options = null), (traits = null);
if (typeof groupId == "object")
(options = traits), (traits = groupId), (groupId = this.groupId);

this.groupId = groupId;
this.storage.setGroupId(this.groupId);
Expand All @@ -347,7 +348,7 @@ class Analytics {
this.groupTraits[key] = traits[key];
}
} else {
this.groupTraits = {}
this.groupTraits = {};
}
this.storage.setGroupTraits(this.groupTraits);

Expand Down Expand Up @@ -529,11 +530,11 @@ class Analytics {
? rudderElement["message"]["userId"]
: this.userId;

if(type == "group"){
if(this.groupId){
rudderElement["message"]["traits"] = this.groupId
if (type == "group") {
if (this.groupId) {
rudderElement["message"]["groupId"] = this.groupId;
}
if(this.groupTraits){
if (this.groupTraits) {
rudderElement["message"]["traits"] = Object.assign(
{},
this.groupTraits
Expand Down

0 comments on commit ab6d901

Please sign in to comment.