Skip to content
This repository was archived by the owner on Jan 25, 2022. It is now read-only.
This repository was archived by the owner on Jan 25, 2022. It is now read-only.

Support for nested objects for event properties (hash of hashes)  #63

@danielgomezrico

Description

@danielgomezrico

There are some events that require nested properties, for example, if you want to record a Product List Viewed you need to send the products array with each product property.

Check the example here:
https://segment.com/docs/connections/spec/ecommerce/v2/#product-list-viewed

Segment.track('Product List Viewed', {
  'list_id': 'hot_deals_1',
  'category': 'Deals',
  'products': [
    {
      'product_id': '507f1f77bcf86cd799439011',
      'sku': '45790-32',
      'name': 'Monopoly: 3rd Edition',
      'price': 19,
      'position': 1,
      'category': 'Games',
      'url': 'https://www.example.com/product/path',
      'image_url': 'https://www.example.com/product/path.jpg'
    },
    {
      'product_id': '505bd76785ebb509fc183733',
      'sku': '46493-32',
      'name': 'Uno Card Game',
      'price': 3,
      'position': 2,
      'category': 'Games'
    }
  ]
});

Current

If you send this with segment it returns a crash which is shown in #62

/flutter (10715): Invalid argument: Instance of 'MappedListIterable<MapEntry, Map<String, dynamic>>'
I/flutter (10715): 	#0      StandardMessageCodec.writeValue (package:flutter/src/services/message_codecs.dart:404:7)
I/flutter (10715): 	#1      StandardMessageCodec.writeValue.<anonymous closure> (package:flutter/src/services/message_codecs.dart:401:9)
I/flutter (10715): 	#2      _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:377:8)
I/flutter (10715): 	#3      StandardMessageCodec.writeValue (package:flutter/src/services/message_codecs.dart:399:13)
I/flutter (10715): 	#4      StandardMessageCodec.writeValue.<anonymous closure> (package:flutter/src/services/message_codecs.dart:401:9)
I/flutter (10715): 	#5      _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:377:8)
I/flutter (10715): 	#6      StandardMessageCodec.writeValue (package:flutter/src/services/message_codecs.dart:399:13)
I/flutter (10715): 	#7      StandardMethodCodec.encodeMethodCall (package:flutter/src/services/message_codecs.dart:536:18)
I/flutter (10715): 	#8      MethodChannel._invokeMethod (package:flutter/src/servi

Expected

No errors and nested properties works fine

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions