Skip to content

Commit

Permalink
chore: improved sample app
Browse files Browse the repository at this point in the history
  • Loading branch information
Desu Sai Venkat committed Aug 28, 2023
1 parent f1464b0 commit d8a1857
Showing 1 changed file with 45 additions and 38 deletions.
83 changes: 45 additions & 38 deletions packages/example/lib/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,16 @@ class HomeScreenState extends State<HomeScreen> {
void __initialize() {
MobileConfig mc = MobileConfig(autoCollectAdvertId: false);
RudderConfigBuilder builder = RudderConfigBuilder();
builder.withFactory(RudderIntegrationAppcenterFlutter());
builder.withFactory(RudderIntegrationFirebaseFlutter());
builder.withFactory(RudderIntegrationBrazeFlutter());
builder.withFactory(RudderIntegrationAmplitudeFlutter());
builder.withDataPlaneUrl(
dotenv.env['DATA_PLANE_URL'] ?? "https://hosted.rudderlabs.com");
builder.withMobileConfig(mc);
builder.withLogLevel(RudderLogger.VERBOSE);
builder.withDataResidencyServer(DataResidencyServer.US);
builder
..withFactory(RudderIntegrationAppcenterFlutter())
..withFactory(RudderIntegrationFirebaseFlutter())
..withFactory(RudderIntegrationBrazeFlutter())
..withFactory(RudderIntegrationAmplitudeFlutter())
..withDataPlaneUrl(
dotenv.env['DATA_PLANE_URL'] ?? "https://hosted.rudderlabs.com")
..withMobileConfig(mc)
..withLogLevel(RudderLogger.VERBOSE)
..withDataResidencyServer(DataResidencyServer.US);
String writeKey = dotenv.env['WRITE_KEY'] ?? "INVALID_WRITE_KEY";
rudderClient.initialize(writeKey, config: builder.build(), options: null);
isInitialized = true;
Expand All @@ -57,30 +58,34 @@ class HomeScreenState extends State<HomeScreen> {

void __track() {
RudderProperty property = RudderProperty();
property.put("colour", "red");
property.put("manufacturer", "hyundai");
property.put("model", "i20");
property.put("marks", [1, 2, 3, 4]);
property.put("something nested", [
{
"nest_2": [76, 78],
"nest_2_1": {"nest_2_2": "some val"}
},
{
"string_arr": ["a", "b"]
}
]);
property
..put("colour", "red")
..put("manufacturer", "hyundai")
..put("model", "i20")
..put("marks", [1, 2, 3, 4])
..put("something nested", [
{
"nest_2": [76, 78],
"nest_2_1": {"nest_2_2": "some val"}
},
{
"string_arr": ["a", "b"]
}
]);

RudderOption options = RudderOption();
options.putIntegration("All", true);
options.putIntegration("Mixpanel", false);
options.putCustomContext("address", {
"city": "kolkata",
"pin": "700091",
"state": {"name": "West Bengal", "code": "WB"},
"country": {"name": "India", "code": "IN"},
"zone": 12,
"lat": 22.5726,
});
options
..putIntegration("All", true)
..putIntegration("Mixpanel", false)
..putCustomContext("address", {
"city": "kolkata",
"pin": "700091",
"state": {"name": "West Bengal", "code": "WB"},
"country": {"name": "India", "code": "IN"},
"zone": 12,
"lat": 22.5726,
});

rudderClient.track("Went on a drive web",
properties: property, options: options);

Expand All @@ -91,8 +96,9 @@ class HomeScreenState extends State<HomeScreen> {

void __screen() {
RudderProperty screenProperty = RudderProperty();
screenProperty.put("browser", "chrome");
screenProperty.put("device", "mac book pro");
screenProperty
..put("browser", "chrome")
..put("device", "mac book pro");
rudderClient.screen("Walmart Cart web",
category: "home", properties: screenProperty, options: null);

Expand All @@ -102,10 +108,11 @@ class HomeScreenState extends State<HomeScreen> {

void __group() {
RudderTraits groupTraits = RudderTraits();
groupTraits.put("place", "kolkata");
groupTraits.put("size", "fifteen");
groupTraits.put("details", {"domain": "SDK", "type": "flutter"});
groupTraits.putValue({"key1": "value1", "key2": "value2"});
groupTraits
..put("place", "kolkata")
..put("size", "fifteen")
..put("details", {"domain": "SDK", "type": "flutter"})
..putValue({"key1": "value1", "key2": "value2"});
rudderClient.group("Integrations-Rudder", groupTraits: groupTraits);
setOutput(
"group\n\ttraits:\n\t\tplace:kolkata\n\t\tsize:fifteen\n\tid: Integrations-Rudder");
Expand Down

0 comments on commit d8a1857

Please sign in to comment.