diff --git a/apps/flutter_client_contract_test_service/bin/contract_test_service.dart b/apps/flutter_client_contract_test_service/bin/contract_test_service.dart index 6024cb7..0d54be1 100644 --- a/apps/flutter_client_contract_test_service/bin/contract_test_service.dart +++ b/apps/flutter_client_contract_test_service/bin/contract_test_service.dart @@ -23,7 +23,7 @@ class TestApiImpl extends SdkTestApi { 'tags', 'client-independence', 'context-comparison', - 'inline-context', + 'inline-context-all', 'anonymous-redaction', 'client-prereq-events', 'auto-env-attributes', diff --git a/packages/common/lib/src/events/default_event_processor.dart b/packages/common/lib/src/events/default_event_processor.dart index e68e496..bcbbc40 100644 --- a/packages/common/lib/src/events/default_event_processor.dart +++ b/packages/common/lib/src/events/default_event_processor.dart @@ -95,7 +95,9 @@ final class DefaultEventProcessor implements EventProcessor { @override void processCustomEvent(CustomEvent event) { - _enqueue(CustomEventSerialization.toJson(event)); + _enqueue(CustomEventSerialization.toJson(event, + allAttributesPrivate: _allAttributesPrivate, + globalPrivateAttributes: _globalPrivateAttributes)); } @override diff --git a/packages/common/lib/src/serialization/event_serialization.dart b/packages/common/lib/src/serialization/event_serialization.dart index 0c5c58f..644c53c 100644 --- a/packages/common/lib/src/serialization/event_serialization.dart +++ b/packages/common/lib/src/serialization/event_serialization.dart @@ -18,7 +18,9 @@ final class IdentifyEventSerialization { } final class CustomEventSerialization { - static Map toJson(CustomEvent event) { + static Map toJson(CustomEvent event, + {required bool allAttributesPrivate, + required Set globalPrivateAttributes}) { final json = {}; json['kind'] = 'custom'; @@ -30,7 +32,10 @@ final class CustomEventSerialization { if (event.metricValue != null) { json['metricValue'] = event.metricValue; } - json['contextKeys'] = event.context.keys; + json['context'] = LDContextSerialization.toJson(event.context, + isEvent: true, + allAttributesPrivate: allAttributesPrivate, + globalPrivateAttributes: globalPrivateAttributes); return json; } diff --git a/packages/common/test/serialization/event_serialization_test.dart b/packages/common/test/serialization/event_serialization_test.dart index a88999b..0725bd9 100644 --- a/packages/common/test/serialization/event_serialization_test.dart +++ b/packages/common/test/serialization/event_serialization_test.dart @@ -88,7 +88,8 @@ void main() { context: LDContextBuilder().kind('user', 'user-key').build(), key: 'my-key'); - final json = jsonEncode(CustomEventSerialization.toJson(event)); + final json = jsonEncode(CustomEventSerialization.toJson(event, + allAttributesPrivate: false, globalPrivateAttributes: {})); final jsonAsLdValue = LDValueSerialization.fromJson(jsonDecode(json)); @@ -96,8 +97,9 @@ void main() { '"kind": "custom",' '"key": "my-key",' '"creationDate": 0,' - '"contextKeys": {' - '"user": "user-key"' + '"context": {' + '"kind": "user",' + '"key": "user-key"' '}' '}')); @@ -111,7 +113,8 @@ void main() { context: LDContextBuilder().kind('user', 'user-key').build(), key: 'my-key'); - final json = jsonEncode(CustomEventSerialization.toJson(event)); + final json = jsonEncode(CustomEventSerialization.toJson(event, + allAttributesPrivate: false, globalPrivateAttributes: {})); final jsonAsLdValue = LDValueSerialization.fromJson(jsonDecode(json)); @@ -120,8 +123,9 @@ void main() { '"metricValue": 100,' '"key": "my-key",' '"creationDate": 0,' - '"contextKeys": {' - '"user": "user-key"' + '"context": {' + '"kind": "user",' + '"key": "user-key"' '}' '}')); @@ -135,7 +139,8 @@ void main() { context: LDContextBuilder().kind('user', 'user-key').build(), key: 'my-key'); - final json = jsonEncode(CustomEventSerialization.toJson(event)); + final json = jsonEncode(CustomEventSerialization.toJson(event, + allAttributesPrivate: false, globalPrivateAttributes: {})); final jsonAsLdValue = LDValueSerialization.fromJson(jsonDecode(json)); @@ -144,8 +149,9 @@ void main() { '"key": "my-key",' '"data": {"test": "value"},' '"creationDate": 0,' - '"contextKeys": {' - '"user": "user-key"' + '"context": {' + '"kind": "user",' + '"key": "user-key"' '}' '}')); @@ -160,7 +166,8 @@ void main() { context: LDContextBuilder().kind('user', 'user-key').build(), key: 'my-key'); - final json = jsonEncode(CustomEventSerialization.toJson(event)); + final json = jsonEncode(CustomEventSerialization.toJson(event, + allAttributesPrivate: false, globalPrivateAttributes: {})); final jsonAsLdValue = LDValueSerialization.fromJson(jsonDecode(json)); @@ -170,8 +177,9 @@ void main() { '"data": {"test": "value"},' '"metricValue": 100,' '"creationDate": 0,' - '"contextKeys": {' - '"user": "user-key"' + '"context": {' + '"kind": "user",' + '"key": "user-key"' '}' '}'));