2
2
// SPDX-License-Identifier: Apache-2.0
3
3
4
4
import 'package:clickstream_analytics/clickstream_analytics.dart' ;
5
+ import 'package:clickstream_analytics/clickstream_analytics_item.dart' ;
5
6
import 'package:flutter/foundation.dart' ;
6
7
import 'package:flutter/material.dart' ;
7
8
@@ -54,10 +55,18 @@ class _MyAppState extends State<MyApp> {
54
55
minLeadingWidth: 0 ,
55
56
),
56
57
ListTile (
57
- leading: const Icon (Icons .touch_app ),
58
- title: const Text ('recordEvent ' ),
58
+ leading: const Icon (Icons .circle ),
59
+ title: const Text ('recordEventWithName ' ),
59
60
onTap: () async {
60
61
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 {
61
70
analytics.record (name: "testEvent" , attributes: {
62
71
"category" : 'shoes' ,
63
72
"currency" : 'CNY' ,
@@ -67,7 +76,47 @@ class _MyAppState extends State<MyApp> {
67
76
"boolValue" : true ,
68
77
"value" : 279.9
69
78
});
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" );
71
120
},
72
121
minLeadingWidth: 0 ,
73
122
),
@@ -76,6 +125,14 @@ class _MyAppState extends State<MyApp> {
76
125
title: const Text ('setUserId' ),
77
126
onTap: () async {
78
127
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 {
79
136
analytics.setUserId (null );
80
137
log ("setUserId" );
81
138
},
0 commit comments