From 3739a413510c03466a2a32b70b8d19d7f78aa4d8 Mon Sep 17 00:00:00 2001 From: Calise Cheung Date: Thu, 21 Sep 2023 13:48:00 -0700 Subject: [PATCH 01/17] Update Edge workflow info for track APIs doc and migration doc Update Edge workflow info for track APIs doc and migration doc. --- docs/migration.md | 13 +++++++++---- plugins/flutter_aepcore/README.md | 7 +++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/docs/migration.md b/docs/migration.md index 7345126..c64f5d3 100644 --- a/docs/migration.md +++ b/docs/migration.md @@ -18,6 +18,15 @@ dependencies: Updated plugins can be found in this repository under [plugins/](https://github.com/adobe/aepsdk_flutter/tree/main/plugins/). If they are not there, they are currently not supported. +| Flutter (ACP) | Flutter (AEP) | +| :--- | :--- | +| flutter_acpcore | flutter_aepcore | +| flutter_assurance | flutter_aepassurance | +| flutter_acpuserprofile | flutter_aepuserprofile | +| flutter_acpanalytics | NA, Analytics workflows supported through [Edge Network](https://github.com/adobe/aepsdk_flutter/tree/main/plugins/flutter_aepedge) or [Edge Bridge](https://github.com/adobe/aepsdk_flutter/tree/main/plugins/flutter_aepedgebridge) extensions. | +| Place Services| NA | +| Place Monitor | NA | + ## Update SDK initialization Remove the deprecated registration code and the extensions that are not supported in AEP Flutter libraries. @@ -54,9 +63,7 @@ public class MyApplication extends FlutterApplication { - Assurance.registerExtension(); - UserProfile.registerExtension(); - Analytics.registerExtension(); -- Target.registerExtension(); - Places.registerExtension(); -- Campaign.registerExtension(); - MobileCore.start(new AdobeCallback () { - @Override - public void call(Object o) { @@ -114,8 +121,6 @@ public class MyApplication extends FlutterApplication { // [ACPLifecycle registerExtension]; // [ACPSignal registerExtension]; // [ACPAnalytics registerExtension]; - // [ACPCampaign registerExtension]; - // [ACPTarget registerExtension]; // const UIApplicationState appState = application.applicationState; // [ACPCore start:^{ diff --git a/plugins/flutter_aepcore/README.md b/plugins/flutter_aepcore/README.md index c2c9776..27a6558 100644 --- a/plugins/flutter_aepcore/README.md +++ b/plugins/flutter_aepcore/README.md @@ -130,10 +130,17 @@ MobileCore.resetIdentities() ``` ##### Track app actions + +> [!IMPORTANT] +> trackAction is supported through [Edge Bridge](https://github.com/adobe/aepsdk_flutter/tree/main/plugins/flutter_aepedgebridge) and [Edge Network](https://github.com/adobe/aepsdk_flutter/tree/main/plugins/flutter_aepedge) extensions. + ```dart MobileCore.trackAction("myAction", data: {"key1": "value1"}); ``` ##### Track app states +> [!IMPORTANT] +> trackState is supported through [Edge Bridge](https://github.com/adobe/aepsdk_flutter/tree/main/plugins/flutter_aepedgebridge) and [Edge Network](https://github.com/adobe/aepsdk_flutter/tree/main/plugins/flutter_aepedge) extensions. + ```dart MobileCore.trackState("myState", data: {"key1": "value1"}); ``` From 144c14570c660b8c84a7d61064b92a15c2b1835c Mon Sep 17 00:00:00 2001 From: Calise Cheung Date: Thu, 25 Apr 2024 17:07:43 -0700 Subject: [PATCH 02/17] Update readme with the supported platforms info Update readme with the supported platforms info --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 27864f6..8deb4e9 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,9 @@ This repository is a monorepo. It contains a collection of Adobe Experience Plat | [UserProfile](plugins/flutter_aepuserprofile/README.md) | [![pub package](https://img.shields.io/pub/v/flutter_aepuserprofile.svg)](https://pub.dartlang.org/packages/flutter_aepuserprofile) | | [Messaging](plugins/flutter_aepmessaging/README.md) | [![pub package](https://img.shields.io/pub/v/flutter_aepmessaging.svg)](https://pub.dartlang.org/packages/flutter_aepmessaging) | +> [!NOTE] +> The Flutter plugins within this repository are specifically designed to support the Android and iOS platforms only. + ## iOS Privacy Manifest > [!IMPORTANT] From eb7b54bdbed7c72c5154f76bd2e0dde8490c4510 Mon Sep 17 00:00:00 2001 From: Calise Cheung Date: Tue, 30 Apr 2024 17:55:02 -0700 Subject: [PATCH 03/17] Add Datastream override feature to Edge plugin Add Datastream override feature to Edge plugin. --- example/lib/edge.dart | 65 +++++++++++++- plugins/flutter_aepedge/README.md | 87 +++++++++++++++---- .../FlutterAEPEdgeDataBridge.java | 35 +++++--- .../ios/Classes/FlutterAEPEdgeDataBridge.m | 11 ++- .../lib/src/aepedge_experienceevent.dart | 13 ++- 5 files changed, 181 insertions(+), 30 deletions(-) diff --git a/example/lib/edge.dart b/example/lib/edge.dart index ca02a93..5cd05cb 100644 --- a/example/lib/edge.dart +++ b/example/lib/edge.dart @@ -72,6 +72,58 @@ class _MyAppState extends State { }); } + Future sendEventDataIdOverride() async { + late List result; + Map xdmData = {"eventType": "SampleEventType"}; + Map data = {"free": "form", "data": "example"}; + + final ExperienceEvent experienceEvent = ExperienceEvent( + {"xdmData": xdmData, "data": data, "datastreamIdOverride": "sampleDatastreamID"}); + + result = await Edge.sendEvent(experienceEvent); + + if (!mounted) { + log('Failed to setState, widget is not mounted'); + return; + } + + setState(() { + _edgeEventHandleResponse = result; + print("result info " + result.toString()); + }); + } + + Future sendEventDataStreamConfigOverride() async { + late List result; + Map xdmData = {"eventType": "SampleEventType"}; + Map data = {"free": "form", "data": "example"}; + Map configOverrides = {"config": { + "com_adobe_experience_platform": { + "datasets": { + "event": { + "datasetId": "sampleDatasetID" + } + } + } + }}; + + final ExperienceEvent experienceEvent = ExperienceEvent( + {"xdmData": xdmData, "data": data, "datastreamConfOverride": configOverrides}); + + result = await Edge.sendEvent(experienceEvent); + + if (!mounted) { + log('Failed to setState, widget is not mounted'); + return; + } + + setState(() { + _edgeEventHandleResponse = result; + print("result info " + result.toString()); + }); + } + + Future getLocationHint() async { String? result = null; @@ -96,14 +148,22 @@ class _MyAppState extends State { appBar: AppBar(title: Text("Edge Screen")), body: Center( child: ListView(shrinkWrap: true, children: [ - getRichText('AEPEdge extension version: ', '$_edgeVersion\n'), + getRichText('AEPEdge extension version: ', '$_edgeVersion\n'), ElevatedButton( child: Text("sentEvent(...)"), onPressed: () => sendEvent(), ), ElevatedButton( child: Text("sentEvent to Dataset"), - onPressed: () => sendEvent('datasetIdExample'), + onPressed: () => sendEvent('datasetId_example'), + ), + ElevatedButton( + child: Text("sentEvent with datastreamIdOverride"), + onPressed: () => sendEventDataStreamIdOverride(), + ), + ElevatedButton( + child: Text("sentEvent with datastreamConfOverride"), + onPressed: () => sendEventDataConfigOverride(), ), getRichText( 'Response event handles: = ', '$_edgeEventHandleResponse\n'), @@ -123,3 +183,4 @@ class _MyAppState extends State { ]), )); } + diff --git a/plugins/flutter_aepedge/README.md b/plugins/flutter_aepedge/README.md index 9e82f03..d15ba84 100644 --- a/plugins/flutter_aepedge/README.md +++ b/plugins/flutter_aepedge/README.md @@ -174,23 +174,69 @@ final ExperienceEvent experienceEvent = ExperienceEvent({ }); List result = await Edge.sendEvent(experienceEvent); ``` + +**Example with Datastream ID override** +```dart +Map xdmData = {"eventType": "SampleEventType"}; +final ExperienceEvent experienceEvent = ExperienceEvent({ + "xdmData": xdmData, + "datastreamIdOverride": "SampleDataStreamId" +}); +List result = await Edge.sendEvent(experienceEvent); +``` + +**Example with Datastream confg override** +```dart +Map xdmData = {"eventType": "SampleEventType"}; +Map configOverrides = {"config": { + "com_adobe_experience_platform": { + "datasets": { + "event": { + "datasetId": "sampleDatasetID" + } + } + } + }}; +final ExperienceEvent experienceEvent = ExperienceEvent({ + "xdmData": xdmData, + "datastreamConfigOverride": configOverrides +}); +List result = await Edge.sendEvent(experienceEvent); +``` ------ ### Public classes #### ExperienceEvent Experience Event is the event to be sent to Adobe Experience Platform Edge Network. The XDM data is required for any Experience Event being sent using the Edge extension. -##### Create Experience Event from Dictionary: - +**Usage** ```dart -Map xdmData = {"eventType": "SampleEventType"}; +// set free form data to the Experience event: +final ExperienceEvent experienceEvent = ExperienceEvent({ + "xdmData": xdmData, + "data": data +}); + +// Set free form data and datastream id override to the current Experience event: +final ExperienceEvent experienceEvent = ExperienceEvent({ + "xdmData": xdmData, + "data": data, + "datastreamIdOverride": "sampleDatastreamID" +}); + +// Set free form data and datastream config override to the current Experience event: final ExperienceEvent experienceEvent = ExperienceEvent({ - "xdmData": xdmData + "xdmData": xdmData, + "data": data, + "datastreamConfOverride": configOverrides }); + ``` -##### Add free form data to the Experience event: +**Example** ```dart +// example 1 +// set free form data to the Experience event: Map xdmData = {"eventType": "SampleEventType"}; Map data = {"free": "form", "data": "example"}; final ExperienceEvent experienceEvent = ExperienceEvent({ @@ -199,27 +245,36 @@ final ExperienceEvent experienceEvent = ExperienceEvent({ }); ``` -##### Set the destination Dataset identifier to the current Experience event: - ```dart +// example 2 +// Set free form data and datastream id override to the current Experience event: Map xdmData = {"eventType": "SampleEventType"}; -final ExperienceEvent experienceevent = ExperienceEvent({ +Map data = {"free": "form", "data": "example"}; +final ExperienceEvent experienceEvent = ExperienceEvent({ "xdmData": xdmData, - "data": null, - "datasetIdentifier": "datasetIdExample" + "data": data, + "datastreamIdOverride": "sampleDatastreamID" }); ``` -##### Create Experience Event with xdmdata, free form data and the destination Dataset identifier: - ```dart +// example 3 +// Set datastream config override to the current Experience event: Map xdmData = {"eventType": "SampleEventType"}; -Map data = {"free": "form", "data": "example"}; +Map configOverrides = {"config": { + "com_adobe_experience_platform": { + "datasets": { + "event": { + "datasetId": "sampleDatasetID" + } + } + } + } +} final ExperienceEvent experienceEvent = ExperienceEvent({ "xdmData": xdmData, - "data": data, - "datasetIdentifier": "datasetIdExample" + "datastreamConfOverride": configOverrides }); ``` #### EventHandle @@ -229,6 +284,8 @@ The EventHandle is a response fragment from Adobe Experience Platform Edge Netwo static const String _type = 'type'; static const String _payload = 'payload'; ``` +## Next steps - Schemas setup and validation with Assurance +For examples on XDM schemas and datasets setup and tips on validating with Assurance, refer to the [Edge Network tutorial](https://github.com/adobe/aepsdk-edge-ios/blob/main/Documentation/Tutorials). ## Contributing See [CONTRIBUTING](https://github.com/adobe/aepsdk_flutter/blob/main/CONTRIBUTING.md) diff --git a/plugins/flutter_aepedge/android/src/main/java/com/adobe/marketing/mobile/flutter/flutter_aepedge/FlutterAEPEdgeDataBridge.java b/plugins/flutter_aepedge/android/src/main/java/com/adobe/marketing/mobile/flutter/flutter_aepedge/FlutterAEPEdgeDataBridge.java index 48ef1cb..0221e97 100644 --- a/plugins/flutter_aepedge/android/src/main/java/com/adobe/marketing/mobile/flutter/flutter_aepedge/FlutterAEPEdgeDataBridge.java +++ b/plugins/flutter_aepedge/android/src/main/java/com/adobe/marketing/mobile/flutter/flutter_aepedge/FlutterAEPEdgeDataBridge.java @@ -34,6 +34,8 @@ class FlutterAEPEdgeDataBridge { private final static String XDM_DATA_KEY = "xdmData"; private final static String DATA_KEY = "data"; private final static String DATASET_IDENTIFIER_KEY = "datasetIdentifier"; + private static final String DATASTREAM_ID_OVERRIDE_KEY = "datastreamIdOverride"; + private static final String DATASTREAM_CONFIG_OVERRIDE_KEY = "datastreamConfigOverride"; private final static String TYPE_KEY = "type"; private final static String PAYLOAD_KEY = "payload"; private final static String TAG = "FlutterAEPEdgeDataBridge"; @@ -50,23 +52,36 @@ protected static ExperienceEvent eventFromMap(final Map map) { return null; } - Map xdmData = getNullableMap(map, XDM_DATA_KEY); String datasetId = null; + String datastreamIdOverride = null; + Map xdmData = getNullableMap(map, XDM_DATA_KEY); - if (xdmData != null) { + if (xdmData != null) { Map data = getNullableMap(map, DATA_KEY); - - datasetId = getNullableString(map, DATASET_IDENTIFIER_KEY); - - ExperienceEvent event = new ExperienceEvent.Builder().setXdmSchema(xdmData, datasetId).setData(data).build(); - + Map datastreamConfigOverride = getNullableMap(map, DATASTREAM_CONFIG_OVERRIDE_KEY); + + + try { + datasetId = getNullableString(map, DATASET_IDENTIFIER_KEY); + datastreamIdOverride = getNullableString(map, DATASTREAM_ID_OVERRIDE_KEY); + } catch (Exception e) { + Log.d(TAG, "experienceEventFromReadableMap: " + e); + } + + ExperienceEvent event; + if (datastreamIdOverride != null || datastreamConfigOverride != null) { + event = new ExperienceEvent.Builder().setXdmSchema(xdmData, datasetId).setData(data).setDatastreamIdOverride(datastreamIdOverride).setDatastreamConfigOverride(datastreamConfigOverride).build(); + } else { + event = new ExperienceEvent.Builder().setXdmSchema(xdmData, datasetId).setData(data).build(); + } return event; } - Log.d(TAG, "eventFromMap - XDM data is required, but it is currently null."); - return null; - } + + Log.d(TAG, "eventFromMap - XDM data is required, but it is currently null."); + return null; +} /** * Converts a {@link EdgeEventHandle} into a {@link Map} diff --git a/plugins/flutter_aepedge/ios/Classes/FlutterAEPEdgeDataBridge.m b/plugins/flutter_aepedge/ios/Classes/FlutterAEPEdgeDataBridge.m index 40093e9..bc0bf61 100644 --- a/plugins/flutter_aepedge/ios/Classes/FlutterAEPEdgeDataBridge.m +++ b/plugins/flutter_aepedge/ios/Classes/FlutterAEPEdgeDataBridge.m @@ -16,6 +16,8 @@ @implementation FlutterAEPEdgeDataBridge static NSString* const XDM_DATA_KEY = @"xdmData"; static NSString* const DATA_KEY = @"data"; static NSString* const DATASET_IDENTIFIER_KEY = @"datasetIdentifier"; +static NSString* const DATASTREAM_ID_OVERRIDE_KEY = @"datastreamIdOverride"; +static NSString* const DATASTREAM_CONFIG_OVERRIDE_KEY = @"datastreamConfigOverride"; static NSString* const TYPE_KEY = @"type"; static NSString* const PAYLOAD_KEY = @"payload"; @@ -31,9 +33,14 @@ + (AEPExperienceEvent *)experienceEventFromDictionary: (nonnull NSDictionary *) NSDictionary *data = [[dict objectForKey:DATA_KEY] isKindOfClass:[NSDictionary class]] ? [dict objectForKey:DATA_KEY] : nil; NSString *datasetIdentifier = [[dict objectForKey:DATASET_IDENTIFIER_KEY] isKindOfClass:[NSString class]] ? [dict objectForKey:DATASET_IDENTIFIER_KEY] : nil; + NSString *datastreamIdOverride = [[dict objectForKey:DATASTREAM_ID_OVERRIDE_KEY] isKindOfClass:[NSString class]] ? [dict objectForKey:DATASTREAM_ID_OVERRIDE_KEY] : nil; + NSDictionary *datastreamConfigOverride = [[dict objectForKey:DATASTREAM_CONFIG_OVERRIDE_KEY] isKindOfClass:[NSDictionary class]] ? [dict objectForKey:DATASTREAM_CONFIG_OVERRIDE_KEY] : nil; - return [[AEPExperienceEvent alloc] initWithXdm:xdmData data:data datasetIdentifier:datasetIdentifier]; - + if (datastreamIdOverride || datastreamConfigOverride) { + return [[AEPExperienceEvent alloc] initWithXdm:xdmData data:data datastreamIdOverride:datastreamIdOverride datastreamConfigOverride:datastreamConfigOverride]; + } else { + return [[AEPExperienceEvent alloc] initWithXdm:xdmData data:data datasetIdentifier:datasetIdentifier]; + } } + (NSArray *)dictionaryFromEdgeEventHandler: (NSArray *) experienceEventHandle { diff --git a/plugins/flutter_aepedge/lib/src/aepedge_experienceevent.dart b/plugins/flutter_aepedge/lib/src/aepedge_experienceevent.dart index c256255..9d0041d 100644 --- a/plugins/flutter_aepedge/lib/src/aepedge_experienceevent.dart +++ b/plugins/flutter_aepedge/lib/src/aepedge_experienceevent.dart @@ -14,6 +14,9 @@ class ExperienceEvent { static const String _xdmDataKey = 'xdmData'; static const String _dataKey = 'data'; static const String _dataIdentifierKey = 'dataIdentifier'; + static const String _datastreamIdOverrideKey = 'datastreamIdOverride'; + static const String _datastreamConfigOverrideKey = 'datastreamConfigOverride'; + ExperienceEvent(this.eventData); @@ -22,7 +25,9 @@ class ExperienceEvent { final Map experienceEventConstructorData = { _xdmDataKey: xdmData, _dataKey: data, - _dataIdentifierKey: datasetIdentifier + _dataIdentifierKey: datasetIdentifier, + _datastreamIdOverrideKey: datastreamIdOverride, + _datastreamConfigOverrideKey: datastreamConfigOverride }; this.eventData = experienceEventConstructorData; } @@ -38,4 +43,10 @@ class ExperienceEvent { /// The identifier for the Dataset this event belongs to. String? get datasetIdentifier => eventData[_dataIdentifierKey]; + + /// The override datastream id for this event. + String? get datastreamIdOverride => eventData[_datastreamIdOverrideKey]; + + /// The override datastream conf for this event. + Map? get datastreamConfigOverride => eventData[_datastreamConfigOverrideKey]; } From 88deef5cc8d9616b56867c819c0012eb133a0ff0 Mon Sep 17 00:00:00 2001 From: Calise Cheung Date: Tue, 30 Apr 2024 17:59:55 -0700 Subject: [PATCH 04/17] remove extra line remove extra line --- example/lib/edge.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/example/lib/edge.dart b/example/lib/edge.dart index 5cd05cb..ca58104 100644 --- a/example/lib/edge.dart +++ b/example/lib/edge.dart @@ -183,4 +183,3 @@ class _MyAppState extends State { ]), )); } - From bc4c869e79b3d2d57737982ee062b0e5b16579d9 Mon Sep 17 00:00:00 2001 From: Calise Cheung Date: Wed, 1 May 2024 11:00:24 -0700 Subject: [PATCH 05/17] Fix the typo for the method name in sample app Fix the typo for the method name in sample app --- example/lib/edge.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/lib/edge.dart b/example/lib/edge.dart index ca58104..6577378 100644 --- a/example/lib/edge.dart +++ b/example/lib/edge.dart @@ -72,7 +72,7 @@ class _MyAppState extends State { }); } - Future sendEventDataIdOverride() async { + Future sendEventDataStreamIdOverride() async { late List result; Map xdmData = {"eventType": "SampleEventType"}; Map data = {"free": "form", "data": "example"}; From 07c5544d4a88093cb38edf23c7b8851e3f3f4749 Mon Sep 17 00:00:00 2001 From: Calise Cheung Date: Wed, 1 May 2024 15:44:49 -0700 Subject: [PATCH 06/17] Fix typo in sample app Fix typo in sample app --- example/lib/edge.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/lib/edge.dart b/example/lib/edge.dart index 6577378..9bf53fb 100644 --- a/example/lib/edge.dart +++ b/example/lib/edge.dart @@ -93,7 +93,7 @@ class _MyAppState extends State { }); } - Future sendEventDataStreamConfigOverride() async { + Future sendEventDataConfigOverride() async { late List result; Map xdmData = {"eventType": "SampleEventType"}; Map data = {"free": "form", "data": "example"}; From 508593af27ed40ac55c0435e21b0aa9c2786f32b Mon Sep 17 00:00:00 2001 From: Calise Cheung Date: Thu, 2 May 2024 15:04:08 -0700 Subject: [PATCH 07/17] Update experienceEvent dart code to use two classes Update experienceEvent dart code to use two classes --- .../lib/src/aepedge_experienceevent.dart | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/plugins/flutter_aepedge/lib/src/aepedge_experienceevent.dart b/plugins/flutter_aepedge/lib/src/aepedge_experienceevent.dart index 9d0041d..7d93db9 100644 --- a/plugins/flutter_aepedge/lib/src/aepedge_experienceevent.dart +++ b/plugins/flutter_aepedge/lib/src/aepedge_experienceevent.dart @@ -13,27 +13,40 @@ governing permissions and limitations under the License. class ExperienceEvent { static const String _xdmDataKey = 'xdmData'; static const String _dataKey = 'data'; - static const String _dataIdentifierKey = 'dataIdentifier'; + static const String _dataIdentifierKey = 'datasetIdentifier'; static const String _datastreamIdOverrideKey = 'datastreamIdOverride'; static const String _datastreamConfigOverrideKey = 'datastreamConfigOverride'; + /// The data in this experience event. + late Map eventData; - ExperienceEvent(this.eventData); + ExperienceEvent(this.eventData) { + if (eventData[_dataIdentifierKey] != null && (eventData[_datastreamIdOverrideKey] != null || eventData[_datastreamConfigOverrideKey] != null)) { + print('Warning: Using both datasetIdentifier and datastreamIdOverride, or datasetIdentifier and datastreamConfigOverride simultaneously is not supported. It defaults to using the input of datastreamIdOverride or datastreamConfigOverride.'); + } + } ExperienceEvent.createEvent(final Map xdmData, [final Map? data, final String? datasetIdentifier]) { final Map experienceEventConstructorData = { _xdmDataKey: xdmData, _dataKey: data, - _dataIdentifierKey: datasetIdentifier, + _dataIdentifierKey: datasetIdentifier + }; + this.eventData = experienceEventConstructorData; + } + + ExperienceEvent.createEventWithOverrides(final Map xdmData, + [final Map? data, final String? datastreamIdOverride, final Map? datastreamConfigOverride]) { + final Map experienceEventConstructorData = { + _xdmDataKey: xdmData, + _dataKey: data, _datastreamIdOverrideKey: datastreamIdOverride, _datastreamConfigOverrideKey: datastreamConfigOverride }; this.eventData = experienceEventConstructorData; } - /// The data in this experience event. - late Map eventData; /// The XDM data for this event. Map get xdmData => eventData[_xdmDataKey] ?? {}; @@ -49,4 +62,4 @@ class ExperienceEvent { /// The override datastream conf for this event. Map? get datastreamConfigOverride => eventData[_datastreamConfigOverrideKey]; -} +} \ No newline at end of file From 26fde5fcd99da96ea88989e4f70a8641189ec214 Mon Sep 17 00:00:00 2001 From: Calise Cheung Date: Fri, 3 May 2024 06:38:37 -0700 Subject: [PATCH 08/17] Update readme and unit test Update readme and unit test --- plugins/flutter_aepedge/README.md | 21 ++++ .../test/flutter_aepedge_test.dart | 97 ++++++++++++++++++- 2 files changed, 117 insertions(+), 1 deletion(-) diff --git a/plugins/flutter_aepedge/README.md b/plugins/flutter_aepedge/README.md index d15ba84..912b181 100644 --- a/plugins/flutter_aepedge/README.md +++ b/plugins/flutter_aepedge/README.md @@ -208,8 +208,12 @@ List result = await Edge.sendEvent(experienceEvent); #### ExperienceEvent Experience Event is the event to be sent to Adobe Experience Platform Edge Network. The XDM data is required for any Experience Event being sent using the Edge extension. +You can invoke Experience Event either by using dictionaries or by utilizing convenience constructors. + **Usage** ```dart +//Invoke Experience Event by using dictionaries + // set free form data to the Experience event: final ExperienceEvent experienceEvent = ExperienceEvent({ "xdmData": xdmData, @@ -230,10 +234,27 @@ final ExperienceEvent experienceEvent = ExperienceEvent({ "datastreamConfOverride": configOverrides }); +//Invoke Experience Event by using constructors + +// set free form data to the Experience event: +final ExperienceEvent experienceEvent = + ExperienceEvent.createEventWithOverrides(xdmData, data); + +// Set free form data and datastream id override to the current Experience event: +final ExperienceEvent experienceEvent = + ExperienceEvent.createEventWithOverrides(xdmData, data, "sampleDatastreamID"); + +// Set free form data and datastream config override to the current Experience event: +final ExperienceEvent experienceEvent = + ExperienceEvent.createEventWithOverrides(xdmData, data, null, configOverrides); + + ``` **Example** +Examples of Invoking Experience Event Using Dictionaries. + ```dart // example 1 // set free form data to the Experience event: diff --git a/plugins/flutter_aepedge/test/flutter_aepedge_test.dart b/plugins/flutter_aepedge/test/flutter_aepedge_test.dart index a26c88a..0c1d3c5 100644 --- a/plugins/flutter_aepedge/test/flutter_aepedge_test.dart +++ b/plugins/flutter_aepedge/test/flutter_aepedge_test.dart @@ -45,7 +45,7 @@ void main() { }); }); - group('sendEvent', () { + group('sendEventUsingDictionary', () { final Map xdmData = {"eventType": "SampleEventType"}; final Map data = {"free": "form", "data": "example"}; @@ -100,6 +100,101 @@ void main() { }); }); + group('sendEventUsingDatasetIdentifierConstructor', () { + final Map xdmData = {"eventType": "SampleEventType"}; + final Map data = {"free": "form", "data": "example"}; + + //setup experienceEvent + final ExperienceEvent experienceEvent = + ExperienceEvent.createEvent(xdmData, data, "sampleDatasetID"); + + test('returns correct result', () async { + expect(experienceEvent.xdmData, equals(xdmData)); + expect(experienceEvent.data, equals(data)); + expect(experienceEvent.datasetIdentifier, equals("sampleDatasetID")); + }); + }); + + group('sendEventUsingDatastreamIdOverrideConstructor', () { + final Map xdmData = {"eventType": "SampleEventType"}; + final Map data = {"free": "form", "data": "example"}; + + //setup experienceEvent + final ExperienceEvent experienceEvent = + ExperienceEvent.createEventWithOverrides(xdmData, data, "sampleDatastreamID"); + + test('returns correct result', () async { + expect(experienceEvent.xdmData, equals(xdmData)); + expect(experienceEvent.data, equals(data)); + expect(experienceEvent.datastreamIdOverride, equals("sampleDatastreamID")); + }); + }); + + group('sendEventUsingDatasetConfigConstructor', () { + final Map xdmData = {"eventType": "SampleEventType"}; + final Map data = {"free": "form", "data": "example"}; + final Map configOverrides = {"config": { + "com_adobe_experience_platform": { + "datasets": { + "event": { + "datasetId": "sampleDatasetID" + } + } + } + }}; + + //setup experienceEvent + final ExperienceEvent experienceEvent = + ExperienceEvent.createEventWithOverrides(xdmData, data, "sampleDatastreamID", configOverrides); + + test('returns correct result', () async { + expect(experienceEvent.xdmData, equals(xdmData)); + expect(experienceEvent.data, equals(data)); + expect(experienceEvent.datastreamIdOverride, equals("sampleDatastreamID")); + expect(experienceEvent.datastreamConfigOverride, equals(configOverrides)); + }); + }); + + group('sendEventUsingDatasetConfigConstructorWithDataAndIdNull', () { + final Map xdmData = {"eventType": "SampleEventType"}; + final Map configOverrides = {"config": { + "com_adobe_experience_platform": { + "datasets": { + "event": { + "datasetId": "sampleDatasetID" + } + } + } + }}; + + //setup experienceEvent + final ExperienceEvent experienceEvent = + ExperienceEvent.createEventWithOverrides(xdmData, null, null, configOverrides); + + test('returns correct result', () async { + expect(experienceEvent.xdmData, equals(xdmData)); + expect(experienceEvent.data, equals({})); + expect(experienceEvent.datastreamIdOverride, equals(null)); + expect(experienceEvent.datastreamConfigOverride, equals(configOverrides)); + }); + }); + + group('sendEventUsingDatasetConfigConstructorWithNull', () { + final Map xdmData = {"eventType": "SampleEventType"}; + + //setup experienceEvent + final ExperienceEvent experienceEvent = + ExperienceEvent.createEventWithOverrides(xdmData, null, null, null); + + test('returns correct result', () async { + expect(experienceEvent.xdmData, equals(xdmData)); + expect(experienceEvent.data, equals({})); + expect(experienceEvent.datastreamIdOverride, equals(null)); + expect(experienceEvent.datastreamConfigOverride, equals(null)); + }); + }); + + group('sendEvent with nested data and multiple response handles', () { final Map mapValue = {"keySample": "keyValue"}; final Map dataValue = {"keySample1": "keyValue1"}; From 70ec16a56674d604303a7050538b838834b317f8 Mon Sep 17 00:00:00 2001 From: Calise Cheung Date: Fri, 3 May 2024 09:41:00 -0700 Subject: [PATCH 09/17] Update test app Update test app --- example/lib/edge.dart | 118 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 104 insertions(+), 14 deletions(-) diff --git a/example/lib/edge.dart b/example/lib/edge.dart index 9bf53fb..5d7630d 100644 --- a/example/lib/edge.dart +++ b/example/lib/edge.dart @@ -51,7 +51,8 @@ class _MyAppState extends State { }); } - Future sendEvent([datasetId]) async { + //Using Dictionaries method + Future sendEventWithDictionary([datasetId]) async { late List result; Map xdmData = {"eventType": "SampleEventType"}; Map data = {"free": "form", "data": "example"}; @@ -72,13 +73,17 @@ class _MyAppState extends State { }); } - Future sendEventDataStreamIdOverride() async { + Future sendEventWithDictionaryDataStreamIdOverride() async { late List result; Map xdmData = {"eventType": "SampleEventType"}; Map data = {"free": "form", "data": "example"}; final ExperienceEvent experienceEvent = ExperienceEvent( - {"xdmData": xdmData, "data": data, "datastreamIdOverride": "sampleDatastreamID"}); + { + "xdmData": xdmData, + "data": data, + "datastreamIdOverride": "sampleDatastreamID", + }); result = await Edge.sendEvent(experienceEvent); @@ -93,7 +98,7 @@ class _MyAppState extends State { }); } - Future sendEventDataConfigOverride() async { + Future sendEventWithDictionaryDataConfigOverride() async { late List result; Map xdmData = {"eventType": "SampleEventType"}; Map data = {"free": "form", "data": "example"}; @@ -108,7 +113,81 @@ class _MyAppState extends State { }}; final ExperienceEvent experienceEvent = ExperienceEvent( - {"xdmData": xdmData, "data": data, "datastreamConfOverride": configOverrides}); + { + "xdmData": xdmData, + "data": data, + "datastreamConfigOverride": configOverrides, + }); + + result = await Edge.sendEvent(experienceEvent); + + if (!mounted) { + log('Failed to setState, widget is not mounted'); + return; + } + + setState(() { + _edgeEventHandleResponse = result; + print("result info " + result.toString()); + }); + } + + //Using Constructors + Future sendEventWithConstructor([datasetId]) async { + late List result; + Map xdmData = {"eventType": "SampleEventType"}; + Map data = {"free": "form", "data": "example"}; + + final ExperienceEvent experienceEvent = ExperienceEvent.createEvent(xdmData, data, datasetId); + + result = await Edge.sendEvent(experienceEvent); + + if (!mounted) { + log('Failed to setState, widget is not mounted'); + return; + } + + setState(() { + _edgeEventHandleResponse = result; + print("result info " + result.toString()); + }); + } + + Future sendEventWithConstructorDataStreamIdOverride() async { + late List result; + Map xdmData = {"eventType": "SampleEventType"}; + Map data = {"free": "form", "data": "example"}; + + final ExperienceEvent experienceEvent = ExperienceEvent.createEventWithOverrides(xdmData, data, "sampleDatastreamID"); + + result = await Edge.sendEvent(experienceEvent); + + if (!mounted) { + log('Failed to setState, widget is not mounted'); + return; + } + + setState(() { + _edgeEventHandleResponse = result; + print("result info " + result.toString()); + }); + } + + Future sendEventWithConstructorDataConfigOverride() async { + late List result; + Map xdmData = {"eventType": "SampleEventType"}; + Map data = {"free": "form", "data": "example"}; + Map configOverrides = {"config": { + "com_adobe_experience_platform": { + "datasets": { + "event": { + "datasetId": "sampleDatasetID" + } + } + } + }}; + + final ExperienceEvent experienceEvent = ExperienceEvent.createEventWithOverrides(xdmData, data, null, configOverrides); result = await Edge.sendEvent(experienceEvent); @@ -122,7 +201,6 @@ class _MyAppState extends State { print("result info " + result.toString()); }); } - Future getLocationHint() async { String? result = null; @@ -150,20 +228,32 @@ class _MyAppState extends State { child: ListView(shrinkWrap: true, children: [ getRichText('AEPEdge extension version: ', '$_edgeVersion\n'), ElevatedButton( - child: Text("sentEvent(...)"), - onPressed: () => sendEvent(), + child: Text("sendEventWithDictionary"), + onPressed: () => sendEventWithDictionary(), + ), + ElevatedButton( + child: Text("sendEventWithDictionary to Dataset"), + onPressed: () => sendEventWithDictionary('datasetId_example'), + ), + ElevatedButton( + child: Text("sendEventWithDictionary with datastreamIdOverride"), + onPressed: () => sendEventWithDictionaryDataStreamIdOverride(), ), ElevatedButton( - child: Text("sentEvent to Dataset"), - onPressed: () => sendEvent('datasetId_example'), + child: Text("sendEventWithDictionary with datastreamConfigOverride"), + onPressed: () => sendEventWithDictionaryDataConfigOverride(), + ), + ElevatedButton( + child: Text("sendEventWithConstructor to Dataset"), + onPressed: () => sendEventWithConstructor('datasetId_example'), ), ElevatedButton( - child: Text("sentEvent with datastreamIdOverride"), - onPressed: () => sendEventDataStreamIdOverride(), + child: Text("sendEventWithDictionary with datastreamIdOverride"), + onPressed: () => sendEventWithConstructorDataStreamIdOverride(), ), ElevatedButton( - child: Text("sentEvent with datastreamConfOverride"), - onPressed: () => sendEventDataConfigOverride(), + child: Text("sendEventWithDictionary with datastreamConfigOverride"), + onPressed: () => sendEventWithConstructorDataConfigOverride(), ), getRichText( 'Response event handles: = ', '$_edgeEventHandleResponse\n'), From f19a71f7dbffb4acfb6c95cc65151dbeaf878da5 Mon Sep 17 00:00:00 2001 From: Calise Cheung Date: Fri, 3 May 2024 10:55:20 -0700 Subject: [PATCH 10/17] Update typo in sample app Update typo in sample app --- example/lib/edge.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/example/lib/edge.dart b/example/lib/edge.dart index 5d7630d..978a179 100644 --- a/example/lib/edge.dart +++ b/example/lib/edge.dart @@ -236,11 +236,11 @@ class _MyAppState extends State { onPressed: () => sendEventWithDictionary('datasetId_example'), ), ElevatedButton( - child: Text("sendEventWithDictionary with datastreamIdOverride"), + child: Text("sendEventWithDictionary datastreamIdOverride"), onPressed: () => sendEventWithDictionaryDataStreamIdOverride(), ), ElevatedButton( - child: Text("sendEventWithDictionary with datastreamConfigOverride"), + child: Text("sendEventWithDictionary datastreamConfigOverride"), onPressed: () => sendEventWithDictionaryDataConfigOverride(), ), ElevatedButton( @@ -248,11 +248,11 @@ class _MyAppState extends State { onPressed: () => sendEventWithConstructor('datasetId_example'), ), ElevatedButton( - child: Text("sendEventWithDictionary with datastreamIdOverride"), + child: Text("sendEventWithConstructor datastreamIdOverride"), onPressed: () => sendEventWithConstructorDataStreamIdOverride(), ), ElevatedButton( - child: Text("sendEventWithDictionary with datastreamConfigOverride"), + child: Text("sendEventWithConstructor datastreamConfigOverride"), onPressed: () => sendEventWithConstructorDataConfigOverride(), ), getRichText( From 980d8aa2d4e5a7869bce2c131841f1b306e326bf Mon Sep 17 00:00:00 2001 From: Calise Cheung Date: Fri, 3 May 2024 16:02:29 -0700 Subject: [PATCH 11/17] fix typo in readme fix typo in readme --- plugins/flutter_aepedge/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/flutter_aepedge/README.md b/plugins/flutter_aepedge/README.md index 912b181..87fe6a8 100644 --- a/plugins/flutter_aepedge/README.md +++ b/plugins/flutter_aepedge/README.md @@ -231,7 +231,7 @@ final ExperienceEvent experienceEvent = ExperienceEvent({ final ExperienceEvent experienceEvent = ExperienceEvent({ "xdmData": xdmData, "data": data, - "datastreamConfOverride": configOverrides + "datastreamConfigOverride": configOverrides }); //Invoke Experience Event by using constructors @@ -295,7 +295,7 @@ Map configOverrides = {"config": { final ExperienceEvent experienceEvent = ExperienceEvent({ "xdmData": xdmData, - "datastreamConfOverride": configOverrides + "datastreamConfigOverride": configOverrides }); ``` #### EventHandle From 9069723950e8011e278fd640e01aa61872ddc481 Mon Sep 17 00:00:00 2001 From: Calise Cheung Date: Wed, 8 May 2024 22:13:00 -0700 Subject: [PATCH 12/17] update with review comments update with review comments --- example/lib/edge.dart | 29 ++++++------ plugins/flutter_aepedge/README.md | 31 ++++++++----- .../FlutterAEPEdgeDataBridge.java | 45 +++++++++---------- 3 files changed, 57 insertions(+), 48 deletions(-) diff --git a/example/lib/edge.dart b/example/lib/edge.dart index 978a179..829324c 100644 --- a/example/lib/edge.dart +++ b/example/lib/edge.dart @@ -52,13 +52,13 @@ class _MyAppState extends State { } //Using Dictionaries method - Future sendEventWithDictionary([datasetId]) async { + Future sendEventWithDictionaryDatasetId([datasetId]) async { late List result; Map xdmData = {"eventType": "SampleEventType"}; Map data = {"free": "form", "data": "example"}; final ExperienceEvent experienceEvent = ExperienceEvent( - {"xdmData": xdmData, "data": data, "datasetIdentifier": datasetId}); + {"xdmData": xdmData, "data": data, "datasetIdentifier": datasetId,"datastreamIdOverride": "sampleDatastreamID",}); result = await Edge.sendEvent(experienceEvent); @@ -73,7 +73,7 @@ class _MyAppState extends State { }); } - Future sendEventWithDictionaryDataStreamIdOverride() async { + Future sendEventWithDictionaryDatastreamIdOverride() async { late List result; Map xdmData = {"eventType": "SampleEventType"}; Map data = {"free": "form", "data": "example"}; @@ -98,7 +98,7 @@ class _MyAppState extends State { }); } - Future sendEventWithDictionaryDataConfigOverride() async { + Future sendEventWithDictionaryDatastreamConfigOverride() async { late List result; Map xdmData = {"eventType": "SampleEventType"}; Map data = {"free": "form", "data": "example"}; @@ -133,7 +133,7 @@ class _MyAppState extends State { } //Using Constructors - Future sendEventWithConstructor([datasetId]) async { + Future sendEventWithConstructorDatasetId([datasetId]) async { late List result; Map xdmData = {"eventType": "SampleEventType"}; Map data = {"free": "form", "data": "example"}; @@ -153,7 +153,7 @@ class _MyAppState extends State { }); } - Future sendEventWithConstructorDataStreamIdOverride() async { + Future sendEventWithConstructorDatastreamIdOverride() async { late List result; Map xdmData = {"eventType": "SampleEventType"}; Map data = {"free": "form", "data": "example"}; @@ -173,10 +173,11 @@ class _MyAppState extends State { }); } - Future sendEventWithConstructorDataConfigOverride() async { + Future sendEventWithConstructorDatastreamConfigOverride() async { late List result; Map xdmData = {"eventType": "SampleEventType"}; Map data = {"free": "form", "data": "example"}; + //To override eventDataset using datastream config overrides Map configOverrides = {"config": { "com_adobe_experience_platform": { "datasets": { @@ -229,31 +230,31 @@ class _MyAppState extends State { getRichText('AEPEdge extension version: ', '$_edgeVersion\n'), ElevatedButton( child: Text("sendEventWithDictionary"), - onPressed: () => sendEventWithDictionary(), + onPressed: () => sendEventWithDictionaryDatasetId(), ), ElevatedButton( child: Text("sendEventWithDictionary to Dataset"), - onPressed: () => sendEventWithDictionary('datasetId_example'), + onPressed: () => sendEventWithDictionaryDatasetId('datasetId_example'), ), ElevatedButton( child: Text("sendEventWithDictionary datastreamIdOverride"), - onPressed: () => sendEventWithDictionaryDataStreamIdOverride(), + onPressed: () => sendEventWithDictionaryDatastreamIdOverride(), ), ElevatedButton( child: Text("sendEventWithDictionary datastreamConfigOverride"), - onPressed: () => sendEventWithDictionaryDataConfigOverride(), + onPressed: () => sendEventWithDictionaryDatastreamConfigOverride(), ), ElevatedButton( child: Text("sendEventWithConstructor to Dataset"), - onPressed: () => sendEventWithConstructor('datasetId_example'), + onPressed: () => sendEventWithConstructorDatasetId('datasetId_example'), ), ElevatedButton( child: Text("sendEventWithConstructor datastreamIdOverride"), - onPressed: () => sendEventWithConstructorDataStreamIdOverride(), + onPressed: () => sendEventWithConstructorDatastreamIdOverride(), ), ElevatedButton( child: Text("sendEventWithConstructor datastreamConfigOverride"), - onPressed: () => sendEventWithConstructorDataConfigOverride(), + onPressed: () => sendEventWithConstructorDatastreamConfigOverride(), ), getRichText( 'Response event handles: = ', '$_edgeEventHandleResponse\n'), diff --git a/plugins/flutter_aepedge/README.md b/plugins/flutter_aepedge/README.md index 87fe6a8..2acb1e5 100644 --- a/plugins/flutter_aepedge/README.md +++ b/plugins/flutter_aepedge/README.md @@ -180,7 +180,7 @@ List result = await Edge.sendEvent(experienceEvent); Map xdmData = {"eventType": "SampleEventType"}; final ExperienceEvent experienceEvent = ExperienceEvent({ "xdmData": xdmData, - "datastreamIdOverride": "SampleDataStreamId" + "datastreamIdOverride": "SampleDatastreamId" }); List result = await Edge.sendEvent(experienceEvent); ``` @@ -208,12 +208,22 @@ List result = await Edge.sendEvent(experienceEvent); #### ExperienceEvent Experience Event is the event to be sent to Adobe Experience Platform Edge Network. The XDM data is required for any Experience Event being sent using the Edge extension. -You can invoke Experience Event either by using dictionaries or by utilizing convenience constructors. +You can create Experience Event either by using dictionaries or by utilizing convenience constructors. -**Usage** +**Syntax** ```dart -//Invoke Experience Event by using dictionaries +//Create Experience Event from Dictionary +ExperienceEvent(this.eventData) +//Create Experience event using convenience constructor +ExperienceEvent.createEventWithOverrides(final Map xdmData, + [final Map? data, final String? datastreamIdOverride, final Map? datastreamConfigOverride]) + +``` + +**Usage** +##### Create Experience Event from Dictionaries: +```dart // set free form data to the Experience event: final ExperienceEvent experienceEvent = ExperienceEvent({ "xdmData": xdmData, @@ -224,7 +234,7 @@ final ExperienceEvent experienceEvent = ExperienceEvent({ final ExperienceEvent experienceEvent = ExperienceEvent({ "xdmData": xdmData, "data": data, - "datastreamIdOverride": "sampleDatastreamID" + "datastreamIdOverride": "sampleDatastreamId" }); // Set free form data and datastream config override to the current Experience event: @@ -233,16 +243,17 @@ final ExperienceEvent experienceEvent = ExperienceEvent({ "data": data, "datastreamConfigOverride": configOverrides }); +``` -//Invoke Experience Event by using constructors - +##### Create Experience event using convenience constructors: +```dart // set free form data to the Experience event: final ExperienceEvent experienceEvent = ExperienceEvent.createEventWithOverrides(xdmData, data); // Set free form data and datastream id override to the current Experience event: final ExperienceEvent experienceEvent = - ExperienceEvent.createEventWithOverrides(xdmData, data, "sampleDatastreamID"); + ExperienceEvent.createEventWithOverrides(xdmData, data, "sampleDatastreamId"); // Set free form data and datastream config override to the current Experience event: final ExperienceEvent experienceEvent = @@ -253,7 +264,7 @@ final ExperienceEvent experienceEvent = **Example** -Examples of Invoking Experience Event Using Dictionaries. +Examples of Creating Experience Event Using Dictionaries. ```dart // example 1 @@ -274,7 +285,7 @@ Map data = {"free": "form", "data": "example"}; final ExperienceEvent experienceEvent = ExperienceEvent({ "xdmData": xdmData, "data": data, - "datastreamIdOverride": "sampleDatastreamID" + "datastreamIdOverride": "sampleDatastreamId" }); ``` diff --git a/plugins/flutter_aepedge/android/src/main/java/com/adobe/marketing/mobile/flutter/flutter_aepedge/FlutterAEPEdgeDataBridge.java b/plugins/flutter_aepedge/android/src/main/java/com/adobe/marketing/mobile/flutter/flutter_aepedge/FlutterAEPEdgeDataBridge.java index 0221e97..9aec6c3 100644 --- a/plugins/flutter_aepedge/android/src/main/java/com/adobe/marketing/mobile/flutter/flutter_aepedge/FlutterAEPEdgeDataBridge.java +++ b/plugins/flutter_aepedge/android/src/main/java/com/adobe/marketing/mobile/flutter/flutter_aepedge/FlutterAEPEdgeDataBridge.java @@ -48,39 +48,36 @@ class FlutterAEPEdgeDataBridge { */ @SuppressLint("LongLogTag") protected static ExperienceEvent eventFromMap(final Map map) { - if (map == null) { - return null; - } - - String datasetId = null; - String datastreamIdOverride = null; + if (map == null) { + Log.e(TAG, "eventFromMap() - Cannot create Experience event, passed map is null."); + return null; + } Map xdmData = getNullableMap(map, XDM_DATA_KEY); + if(xdmData == null) { + Log.e(TAG, "eventFromMap() - Cannot create Experience event, xdmData is null."); + return null; + } + + Map data = getNullableMap(map, DATA_KEY); + + String datasetId = getNullableString(map, DATASET_IDENTIFIER_KEY); - if (xdmData != null) { - Map data = getNullableMap(map, DATA_KEY); - Map datastreamConfigOverride = getNullableMap(map, DATASTREAM_CONFIG_OVERRIDE_KEY); + String datastreamIdOverride = getNullableString(map, DATASTREAM_ID_OVERRIDE_KEY); + Map datastreamConfigOverride = getNullableMap(map, DATASTREAM_CONFIG_OVERRIDE_KEY); - try { - datasetId = getNullableString(map, DATASET_IDENTIFIER_KEY); - datastreamIdOverride = getNullableString(map, DATASTREAM_ID_OVERRIDE_KEY); - } catch (Exception e) { - Log.d(TAG, "experienceEventFromReadableMap: " + e); - } + if (datastreamIdOverride != null || datastreamConfigOverride != null) { + ExperienceEvent event = new ExperienceEvent.Builder().setXdmSchema(xdmData, datasetId).setData(data).setDatastreamIdOverride(datastreamIdOverride).setDatastreamConfigOverride(datastreamConfigOverride).build(); + + return event; + } else { + ExperienceEvent event = new ExperienceEvent.Builder().setXdmSchema(xdmData, datasetId).setData(data).build(); - ExperienceEvent event; - if (datastreamIdOverride != null || datastreamConfigOverride != null) { - event = new ExperienceEvent.Builder().setXdmSchema(xdmData, datasetId).setData(data).setDatastreamIdOverride(datastreamIdOverride).setDatastreamConfigOverride(datastreamConfigOverride).build(); - } else { - event = new ExperienceEvent.Builder().setXdmSchema(xdmData, datasetId).setData(data).build(); - } return event; } - - Log.d(TAG, "eventFromMap - XDM data is required, but it is currently null."); - return null; + } /** From efee6d9de7b4ae59235bf214254e832344a58d80 Mon Sep 17 00:00:00 2001 From: Calise Cheung Date: Thu, 9 May 2024 15:44:10 -0700 Subject: [PATCH 13/17] fix configOverrides format, and other review comments fix configOverrides format, and other review comments --- example/lib/edge.dart | 14 +++++++------- .../flutter_aepedge/FlutterAEPEdgeDataBridge.java | 2 +- .../flutter_aepedge/test/flutter_aepedge_test.dart | 14 +++++++------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/example/lib/edge.dart b/example/lib/edge.dart index 829324c..b69e91b 100644 --- a/example/lib/edge.dart +++ b/example/lib/edge.dart @@ -58,7 +58,7 @@ class _MyAppState extends State { Map data = {"free": "form", "data": "example"}; final ExperienceEvent experienceEvent = ExperienceEvent( - {"xdmData": xdmData, "data": data, "datasetIdentifier": datasetId,"datastreamIdOverride": "sampleDatastreamID",}); + {"xdmData": xdmData, "data": data, "datasetIdentifier": datasetId,"datastreamIdOverride": "sampleDatastreamId",}); result = await Edge.sendEvent(experienceEvent); @@ -82,7 +82,7 @@ class _MyAppState extends State { { "xdmData": xdmData, "data": data, - "datastreamIdOverride": "sampleDatastreamID", + "datastreamIdOverride": "sampleDatastreamId", }); result = await Edge.sendEvent(experienceEvent); @@ -102,7 +102,7 @@ class _MyAppState extends State { late List result; Map xdmData = {"eventType": "SampleEventType"}; Map data = {"free": "form", "data": "example"}; - Map configOverrides = {"config": { + Map configOverrides = { "com_adobe_experience_platform": { "datasets": { "event": { @@ -110,7 +110,7 @@ class _MyAppState extends State { } } } - }}; + }; final ExperienceEvent experienceEvent = ExperienceEvent( { @@ -158,7 +158,7 @@ class _MyAppState extends State { Map xdmData = {"eventType": "SampleEventType"}; Map data = {"free": "form", "data": "example"}; - final ExperienceEvent experienceEvent = ExperienceEvent.createEventWithOverrides(xdmData, data, "sampleDatastreamID"); + final ExperienceEvent experienceEvent = ExperienceEvent.createEventWithOverrides(xdmData, data, "sampleDatastreamId"); result = await Edge.sendEvent(experienceEvent); @@ -178,7 +178,7 @@ class _MyAppState extends State { Map xdmData = {"eventType": "SampleEventType"}; Map data = {"free": "form", "data": "example"}; //To override eventDataset using datastream config overrides - Map configOverrides = {"config": { + Map configOverrides = { "com_adobe_experience_platform": { "datasets": { "event": { @@ -186,7 +186,7 @@ class _MyAppState extends State { } } } - }}; + }; final ExperienceEvent experienceEvent = ExperienceEvent.createEventWithOverrides(xdmData, data, null, configOverrides); diff --git a/plugins/flutter_aepedge/android/src/main/java/com/adobe/marketing/mobile/flutter/flutter_aepedge/FlutterAEPEdgeDataBridge.java b/plugins/flutter_aepedge/android/src/main/java/com/adobe/marketing/mobile/flutter/flutter_aepedge/FlutterAEPEdgeDataBridge.java index 9aec6c3..2e7901b 100644 --- a/plugins/flutter_aepedge/android/src/main/java/com/adobe/marketing/mobile/flutter/flutter_aepedge/FlutterAEPEdgeDataBridge.java +++ b/plugins/flutter_aepedge/android/src/main/java/com/adobe/marketing/mobile/flutter/flutter_aepedge/FlutterAEPEdgeDataBridge.java @@ -69,7 +69,7 @@ protected static ExperienceEvent eventFromMap(final Map map) { Map datastreamConfigOverride = getNullableMap(map, DATASTREAM_CONFIG_OVERRIDE_KEY); if (datastreamIdOverride != null || datastreamConfigOverride != null) { - ExperienceEvent event = new ExperienceEvent.Builder().setXdmSchema(xdmData, datasetId).setData(data).setDatastreamIdOverride(datastreamIdOverride).setDatastreamConfigOverride(datastreamConfigOverride).build(); + ExperienceEvent event = new ExperienceEvent.Builder().setXdmSchema(xdmData).setData(data).setDatastreamIdOverride(datastreamIdOverride).setDatastreamConfigOverride(datastreamConfigOverride).build(); return event; } else { diff --git a/plugins/flutter_aepedge/test/flutter_aepedge_test.dart b/plugins/flutter_aepedge/test/flutter_aepedge_test.dart index 0c1d3c5..a33d461 100644 --- a/plugins/flutter_aepedge/test/flutter_aepedge_test.dart +++ b/plugins/flutter_aepedge/test/flutter_aepedge_test.dart @@ -121,19 +121,19 @@ void main() { //setup experienceEvent final ExperienceEvent experienceEvent = - ExperienceEvent.createEventWithOverrides(xdmData, data, "sampleDatastreamID"); + ExperienceEvent.createEventWithOverrides(xdmData, data, "sampleDatastreamId"); test('returns correct result', () async { expect(experienceEvent.xdmData, equals(xdmData)); expect(experienceEvent.data, equals(data)); - expect(experienceEvent.datastreamIdOverride, equals("sampleDatastreamID")); + expect(experienceEvent.datastreamIdOverride, equals("sampleDatastreamId")); }); }); group('sendEventUsingDatasetConfigConstructor', () { final Map xdmData = {"eventType": "SampleEventType"}; final Map data = {"free": "form", "data": "example"}; - final Map configOverrides = {"config": { + final Map configOverrides = { "com_adobe_experience_platform": { "datasets": { "event": { @@ -145,19 +145,19 @@ void main() { //setup experienceEvent final ExperienceEvent experienceEvent = - ExperienceEvent.createEventWithOverrides(xdmData, data, "sampleDatastreamID", configOverrides); + ExperienceEvent.createEventWithOverrides(xdmData, data, "sampleDatastreamId", configOverrides); test('returns correct result', () async { expect(experienceEvent.xdmData, equals(xdmData)); expect(experienceEvent.data, equals(data)); - expect(experienceEvent.datastreamIdOverride, equals("sampleDatastreamID")); + expect(experienceEvent.datastreamIdOverride, equals("sampleDatastreamId")); expect(experienceEvent.datastreamConfigOverride, equals(configOverrides)); }); }); group('sendEventUsingDatasetConfigConstructorWithDataAndIdNull', () { final Map xdmData = {"eventType": "SampleEventType"}; - final Map configOverrides = {"config": { + final Map configOverrides = { "com_adobe_experience_platform": { "datasets": { "event": { @@ -165,7 +165,7 @@ void main() { } } } - }}; + }; //setup experienceEvent final ExperienceEvent experienceEvent = From 853fed5122bd5730f05f04be0a4367be23b4fae2 Mon Sep 17 00:00:00 2001 From: Calise Cheung Date: Thu, 9 May 2024 15:50:29 -0700 Subject: [PATCH 14/17] fix text format fix text format --- example/lib/edge.dart | 4 ++-- plugins/flutter_aepedge/test/flutter_aepedge_test.dart | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/example/lib/edge.dart b/example/lib/edge.dart index b69e91b..43a1dce 100644 --- a/example/lib/edge.dart +++ b/example/lib/edge.dart @@ -106,7 +106,7 @@ class _MyAppState extends State { "com_adobe_experience_platform": { "datasets": { "event": { - "datasetId": "sampleDatasetID" + "datasetId": "sampleDatasetId" } } } @@ -182,7 +182,7 @@ class _MyAppState extends State { "com_adobe_experience_platform": { "datasets": { "event": { - "datasetId": "sampleDatasetID" + "datasetId": "sampleDatasetId" } } } diff --git a/plugins/flutter_aepedge/test/flutter_aepedge_test.dart b/plugins/flutter_aepedge/test/flutter_aepedge_test.dart index a33d461..4489b2a 100644 --- a/plugins/flutter_aepedge/test/flutter_aepedge_test.dart +++ b/plugins/flutter_aepedge/test/flutter_aepedge_test.dart @@ -106,12 +106,12 @@ void main() { //setup experienceEvent final ExperienceEvent experienceEvent = - ExperienceEvent.createEvent(xdmData, data, "sampleDatasetID"); + ExperienceEvent.createEvent(xdmData, data, "sampleDatasetId"); test('returns correct result', () async { expect(experienceEvent.xdmData, equals(xdmData)); expect(experienceEvent.data, equals(data)); - expect(experienceEvent.datasetIdentifier, equals("sampleDatasetID")); + expect(experienceEvent.datasetIdentifier, equals("sampleDatasetId")); }); }); @@ -137,11 +137,11 @@ void main() { "com_adobe_experience_platform": { "datasets": { "event": { - "datasetId": "sampleDatasetID" + "datasetId": "sampleDatasetId" } } } - }}; + }; //setup experienceEvent final ExperienceEvent experienceEvent = @@ -161,7 +161,7 @@ void main() { "com_adobe_experience_platform": { "datasets": { "event": { - "datasetId": "sampleDatasetID" + "datasetId": "sampleDatasetId" } } } From 9a1c4e19238b7eedb0aa55577de23d8898af1dab Mon Sep 17 00:00:00 2001 From: Calise Cheung Date: Thu, 9 May 2024 17:07:05 -0700 Subject: [PATCH 15/17] Update Readme File Update Readme File --- plugins/flutter_aepedge/README.md | 49 +++++++++++++++---------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/plugins/flutter_aepedge/README.md b/plugins/flutter_aepedge/README.md index 2acb1e5..a0d3bb4 100644 --- a/plugins/flutter_aepedge/README.md +++ b/plugins/flutter_aepedge/README.md @@ -185,10 +185,10 @@ final ExperienceEvent experienceEvent = ExperienceEvent({ List result = await Edge.sendEvent(experienceEvent); ``` -**Example with Datastream confg override** +**Example with Datastream config override** ```dart Map xdmData = {"eventType": "SampleEventType"}; -Map configOverrides = {"config": { +Map configOverrides = { "com_adobe_experience_platform": { "datasets": { "event": { @@ -196,7 +196,7 @@ Map configOverrides = {"config": { } } } - }}; + }; final ExperienceEvent experienceEvent = ExperienceEvent({ "xdmData": xdmData, "datastreamConfigOverride": configOverrides @@ -206,13 +206,13 @@ List result = await Edge.sendEvent(experienceEvent); ------ ### Public classes #### ExperienceEvent -Experience Event is the event to be sent to Adobe Experience Platform Edge Network. The XDM data is required for any Experience Event being sent using the Edge extension. +Experience event is the event to be sent to Adobe Experience Platform Edge Network. The XDM data is required for any Experience event being sent using the Edge extension. -You can create Experience Event either by using dictionaries or by utilizing convenience constructors. +You can create Experience event either by using dictionaries or by utilizing convenience constructors. **Syntax** ```dart -//Create Experience Event from Dictionary +//Create Experience event from Dictionary ExperienceEvent(this.eventData) //Create Experience event using convenience constructor @@ -222,22 +222,22 @@ ExperienceEvent.createEventWithOverrides(final Map xdmData, ``` **Usage** -##### Create Experience Event from Dictionaries: +##### Create Experience event from Dictionaries: ```dart -// set free form data to the Experience event: +// Create Experience event with free form data: final ExperienceEvent experienceEvent = ExperienceEvent({ "xdmData": xdmData, "data": data }); -// Set free form data and datastream id override to the current Experience event: +// Create Experience event with free form data and datastream ID override: final ExperienceEvent experienceEvent = ExperienceEvent({ "xdmData": xdmData, "data": data, "datastreamIdOverride": "sampleDatastreamId" }); -// Set free form data and datastream config override to the current Experience event: +// Create Experience event with free form data and datastream config override: final ExperienceEvent experienceEvent = ExperienceEvent({ "xdmData": xdmData, "data": data, @@ -247,15 +247,15 @@ final ExperienceEvent experienceEvent = ExperienceEvent({ ##### Create Experience event using convenience constructors: ```dart -// set free form data to the Experience event: +// Create Experience event with free form data:: final ExperienceEvent experienceEvent = ExperienceEvent.createEventWithOverrides(xdmData, data); -// Set free form data and datastream id override to the current Experience event: +// Create Experience event with free form data and datastream ID override: final ExperienceEvent experienceEvent = ExperienceEvent.createEventWithOverrides(xdmData, data, "sampleDatastreamId"); -// Set free form data and datastream config override to the current Experience event: +// Create Experience event with free form data and datastream config override: final ExperienceEvent experienceEvent = ExperienceEvent.createEventWithOverrides(xdmData, data, null, configOverrides); @@ -264,11 +264,11 @@ final ExperienceEvent experienceEvent = **Example** -Examples of Creating Experience Event Using Dictionaries. +Create Experience event using dictionaries ```dart // example 1 -// set free form data to the Experience event: +// Create Experience Event with freeform data: Map xdmData = {"eventType": "SampleEventType"}; Map data = {"free": "form", "data": "example"}; final ExperienceEvent experienceEvent = ExperienceEvent({ @@ -279,7 +279,7 @@ final ExperienceEvent experienceEvent = ExperienceEvent({ ```dart // example 2 -// Set free form data and datastream id override to the current Experience event: +// Create Experience event with free form data and datastream ID override: Map xdmData = {"eventType": "SampleEventType"}; Map data = {"free": "form", "data": "example"}; final ExperienceEvent experienceEvent = ExperienceEvent({ @@ -291,18 +291,17 @@ final ExperienceEvent experienceEvent = ExperienceEvent({ ```dart // example 3 -// Set datastream config override to the current Experience event: +// Create Experience event with free form data and datastream config override: Map xdmData = {"eventType": "SampleEventType"}; -Map configOverrides = {"config": { - "com_adobe_experience_platform": { - "datasets": { - "event": { - "datasetId": "sampleDatasetID" - } +Map configOverrides = { + "com_adobe_experience_platform": { + "datasets": { + "event": { + "datasetId": "sampleDatasetID" } } - } -} + } + } final ExperienceEvent experienceEvent = ExperienceEvent({ "xdmData": xdmData, From 4b408a99ea8b233adf2a1e65f0413a209e414502 Mon Sep 17 00:00:00 2001 From: Calise Cheung Date: Thu, 9 May 2024 17:12:50 -0700 Subject: [PATCH 16/17] add space after a comma add space after a comma --- example/lib/edge.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/lib/edge.dart b/example/lib/edge.dart index 43a1dce..53be277 100644 --- a/example/lib/edge.dart +++ b/example/lib/edge.dart @@ -58,7 +58,7 @@ class _MyAppState extends State { Map data = {"free": "form", "data": "example"}; final ExperienceEvent experienceEvent = ExperienceEvent( - {"xdmData": xdmData, "data": data, "datasetIdentifier": datasetId,"datastreamIdOverride": "sampleDatastreamId",}); + {"xdmData": xdmData, "data": data, "datasetIdentifier": datasetId, "datastreamIdOverride": "sampleDatastreamId"}); result = await Edge.sendEvent(experienceEvent); From 8220f946969281cfc219f9c68ac348bd4741af83 Mon Sep 17 00:00:00 2001 From: Calise Cheung Date: Fri, 10 May 2024 12:01:58 -0700 Subject: [PATCH 17/17] Update to _datasetIdentifierKey name Update to _datasetIdentifierKey name --- .../flutter_aepedge/lib/src/aepedge_experienceevent.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/flutter_aepedge/lib/src/aepedge_experienceevent.dart b/plugins/flutter_aepedge/lib/src/aepedge_experienceevent.dart index 7d93db9..1254733 100644 --- a/plugins/flutter_aepedge/lib/src/aepedge_experienceevent.dart +++ b/plugins/flutter_aepedge/lib/src/aepedge_experienceevent.dart @@ -13,7 +13,7 @@ governing permissions and limitations under the License. class ExperienceEvent { static const String _xdmDataKey = 'xdmData'; static const String _dataKey = 'data'; - static const String _dataIdentifierKey = 'datasetIdentifier'; + static const String _datasetIdentifierKey = 'datasetIdentifier'; static const String _datastreamIdOverrideKey = 'datastreamIdOverride'; static const String _datastreamConfigOverrideKey = 'datastreamConfigOverride'; @@ -21,7 +21,7 @@ class ExperienceEvent { late Map eventData; ExperienceEvent(this.eventData) { - if (eventData[_dataIdentifierKey] != null && (eventData[_datastreamIdOverrideKey] != null || eventData[_datastreamConfigOverrideKey] != null)) { + if (eventData[_datasetIdentifierKey] != null && (eventData[_datastreamIdOverrideKey] != null || eventData[_datastreamConfigOverrideKey] != null)) { print('Warning: Using both datasetIdentifier and datastreamIdOverride, or datasetIdentifier and datastreamConfigOverride simultaneously is not supported. It defaults to using the input of datastreamIdOverride or datastreamConfigOverride.'); } } @@ -31,7 +31,7 @@ class ExperienceEvent { final Map experienceEventConstructorData = { _xdmDataKey: xdmData, _dataKey: data, - _dataIdentifierKey: datasetIdentifier + _datasetIdentifierKey: datasetIdentifier }; this.eventData = experienceEventConstructorData; } @@ -55,7 +55,7 @@ class ExperienceEvent { Map? get data => eventData[_dataKey] ?? {}; /// The identifier for the Dataset this event belongs to. - String? get datasetIdentifier => eventData[_dataIdentifierKey]; + String? get datasetIdentifier => eventData[_datasetIdentifierKey]; /// The override datastream id for this event. String? get datastreamIdOverride => eventData[_datastreamIdOverrideKey];