lemnisk_plugin 0.0.7 lemnisk_plugin: ^0.0.7 copied to clipboard
The Lemnisk Flutter SDK allows you to track user event data from your Android app. The SDK can be easily imported into any Android or iOS app. Based on the data it receives from the user activity, it [...]
import 'package:flutter/material.dart';
import 'package:lemnisk_plugin/AttributeBuilder.dart';
import 'package:lemnisk_plugin/LemniskFlutterCore.dart';
import 'package:lemnisk_plugin/LemniskHelper.dart';
void main() {
//lemnisk server requirements
String SERVER_URL = "xyz";
String WRITE_KEY = "xyz";
//firebase analytics requirements
LemniskFirebaseCore lemniskFirebaseCore = LemniskFirebaseCore(
projectName: "xxx",
enable: false,
appId: "xxx",
apiKey: "xxx",
projectId: "xxx",
messagingSenderId: "xxx",
);
//apps flyer requirements
LemniskApsflyerCore lemniskApsflyer = LemniskApsflyerCore(
enable: false,
afAppId: "xxx",
afDevKey: "xxx",
);
LemniskHelper.configure(SERVER_URL, WRITE_KEY, lemniskFirebaseCore, lemniskApsflyer);
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
}
void getIdentify() {
AttributeBuilder attributeBuilder = AttributeBuilder();
attributeBuilder.properties['key1'] = 'value1';
attributeBuilder.properties['key2'] = 'value2';
OtherBuilder otherBuilder = OtherBuilder();
otherBuilder.otherid['otherId'] = 'otherId_value';
LemniskHelper.identify("user_id", attributeBuilder, otherBuilder);
}
void getScreen() {
AttributeBuilder attributeBuilder = AttributeBuilder();
attributeBuilder.properties['key1'] = 'value1';
attributeBuilder.properties['key2'] = 'value2';
OtherBuilder otherBuilder = OtherBuilder();
otherBuilder.otherid['otherId'] = 'otherId_value';
LemniskHelper.screen("MainActivity", attributeBuilder, otherBuilder);
}
void getTrack() {
AttributeBuilder attributeBuilder = AttributeBuilder();
attributeBuilder.properties['properties'] = 'material';
attributeBuilder.properties['button'] = 'Track event from different app';
OtherBuilder otherBuilder = OtherBuilder();
otherBuilder.otherid['trackerId'] = '6791c47a-0178-47bc-8711-86a2c67b2255';
LemniskHelper.track("MainDartFile", attributeBuilder, otherBuilder);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Lemnisk Flutter SDK'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
ElevatedButton(
child: Text('Track'),
onPressed: () {
getTrack();
},
style: ElevatedButton.styleFrom(
primary: Colors.blue,
padding: EdgeInsets.symmetric(horizontal: 35, vertical: 10),
textStyle: TextStyle(fontSize: 15, fontWeight: FontWeight.bold),
),
),
SizedBox(
height: 20,
),
ElevatedButton(
child: Text('Screen'),
onPressed: () {
getScreen();
},
style: ElevatedButton.styleFrom(
primary: Colors.blue,
padding: EdgeInsets.symmetric(horizontal: 30, vertical: 10),
textStyle: TextStyle(fontSize: 15, fontWeight: FontWeight.bold),
),
),
SizedBox(
height: 20,
),
ElevatedButton(
child: Text('Identify'),
onPressed: () {
getIdentify();
},
style: ElevatedButton.styleFrom(
primary: Colors.blue,
padding: EdgeInsets.symmetric(horizontal: 30, vertical: 10),
textStyle: TextStyle(fontSize: 15, fontWeight: FontWeight.bold),
),
),
],
),
),
),
);
}
}