22// SPDX-License-Identifier: Apache-2.0
33
44import 'package:clickstream_analytics/clickstream_analytics.dart' ;
5+ import 'package:clickstream_analytics/clickstream_analytics_item.dart' ;
56import 'package:flutter/foundation.dart' ;
67import 'package:flutter/material.dart' ;
78
@@ -54,10 +55,18 @@ class _MyAppState extends State<MyApp> {
5455 minLeadingWidth: 0 ,
5556 ),
5657 ListTile (
57- leading: const Icon (Icons .touch_app ),
58- title: const Text ('recordEvent ' ),
58+ leading: const Icon (Icons .circle ),
59+ title: const Text ('recordEventWithName ' ),
5960 onTap: () async {
6061 analytics.record (name: "testEventWithName" );
62+ log ("recorded testEvent with testEventWithName" );
63+ },
64+ minLeadingWidth: 0 ,
65+ ),
66+ ListTile (
67+ leading: const Icon (Icons .touch_app),
68+ title: const Text ('recordEventWithAttributes' ),
69+ onTap: () async {
6170 analytics.record (name: "testEvent" , attributes: {
6271 "category" : 'shoes' ,
6372 "currency" : 'CNY' ,
@@ -67,7 +76,47 @@ class _MyAppState extends State<MyApp> {
6776 "boolValue" : true ,
6877 "value" : 279.9
6978 });
70- log ("recorded testEvent and testEventWithName" );
79+ log ("recorded testEvent and attributes" );
80+ },
81+ minLeadingWidth: 0 ,
82+ ),
83+ ListTile (
84+ leading: const Icon (Icons .touch_app_outlined),
85+ title: const Text ('recordEventWithItem' ),
86+ onTap: () async {
87+ var testItem1 = ClickstreamItem (
88+ id: "1" ,
89+ name: "testName1" ,
90+ brand: "Google" ,
91+ currency: "CNY" ,
92+ category: "book" ,
93+ locationId: "1" ,
94+ attributes: {
95+ "intValue" : 21 ,
96+ "longValue" : 888888888813991919 ,
97+ "doubleValue" : 11.1234567890121213 ,
98+ "boolValue" : true ,
99+ "value" : 279.9
100+ });
101+ var testItem2 = ClickstreamItem (
102+ id: "2" ,
103+ name: "testName2" ,
104+ brand: "Sumsang" ,
105+ currency: "USD" ,
106+ category: "shoes" ,
107+ locationId: "2" ,
108+ attributes: {
109+ "intValue" : 13 ,
110+ "longValue" : 9999999913991919 ,
111+ "doubleValue" : 22.1234567890121213 ,
112+ "boolValue" : true ,
113+ "value" : 379.9
114+ });
115+ analytics.record (
116+ name: "testRecordItem" ,
117+ attributes: {"testKey" : "testValue" },
118+ items: [testItem1, testItem2]);
119+ log ("recorded testEvent with item" );
71120 },
72121 minLeadingWidth: 0 ,
73122 ),
@@ -76,6 +125,14 @@ class _MyAppState extends State<MyApp> {
76125 title: const Text ('setUserId' ),
77126 onTap: () async {
78127 analytics.setUserId ("12345" );
128+ log ("setUserId" );
129+ },
130+ minLeadingWidth: 0 ,
131+ ),
132+ ListTile (
133+ leading: const Icon (Icons .no_accounts),
134+ title: const Text ('setUserIdToNull' ),
135+ onTap: () async {
79136 analytics.setUserId (null );
80137 log ("setUserId" );
81138 },
0 commit comments