Skip to content

Missing custom value when merging Group/UserTraits #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Jeonguk-ninehire opened this issue Oct 13, 2023 · 1 comment · Fixed by #34
Closed

Missing custom value when merging Group/UserTraits #33

Jeonguk-ninehire opened this issue Oct 13, 2023 · 1 comment · Fixed by #34

Comments

@Jeonguk-ninehire
Copy link

Jeonguk-ninehire commented Oct 13, 2023

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.

@edsonjab
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants