segmentio/analytics_flutter

Missing custom value when merging Group/UserTraits

Closed this issue · 1 comments

When I send group event, groupTraits custom value is missing.

For example

Analytics analytics = createClient(Configuration(segmentWriteKey));

GroupTraits groupTraits = GroupTraits();
groupTraits.custom = {
  'title': title,
};

analytics.group(groupId, groupTraits: groupTraits);

Custom title value disappear when merging needed(analytics.state.userInfo.state.groupTraits is non null), because mergeGroupTraits function(from event.dart) don't merge custom value.

GroupTraits mergeGroupTraits(GroupTraits a, GroupTraits b) {
  return GroupTraits(
      address: a.address != null && b.address != null
          ? mergeAddress(a.address as Address, b.address as Address)
          : a.address ?? b.address,
      avatar: a.avatar ?? b.avatar,
      createdAt: a.createdAt ?? b.createdAt,
      description: a.description ?? b.description,
      email: a.email ?? b.email,
      employees: a.employees ?? b.employees,
      id: a.id ?? b.id,
      industry: a.industry ?? b.industry,
      name: a.name ?? b.name,
      phone: a.phone ?? b.phone,
      plan: a.plan ?? b.plan,
      website: a.website ?? b.website);
}

Missed custom value. This could be

GroupTraits mergeGroupTraits(GroupTraits a, GroupTraits b) {
  return GroupTraits(
      address: a.address != null && b.address != null
          ? mergeAddress(a.address as Address, b.address as Address)
          : a.address ?? b.address,
      avatar: a.avatar ?? b.avatar,
      createdAt: a.createdAt ?? b.createdAt,
      description: a.description ?? b.description,
      email: a.email ?? b.email,
      employees: a.employees ?? b.employees,
      id: a.id ?? b.id,
      industry: a.industry ?? b.industry,
      name: a.name ?? b.name,
      phone: a.phone ?? b.phone,
      plan: a.plan ?? b.plan,
      website: a.website ?? b.website,
      custom: a.custom           // Added custom value
  );
}

I think merging UserTraits have same issue.

Please check this issue. Thanks.

Hi @Jeonguk-ninehire thank you for your report, we start looking into this.