Flutter - Dart
Use Native HTTP Request in Dart
Create a Class EvntalyClient
EvntalyClient
import 'package:http/http.dart' as http;
import 'dart:convert';
class EvntalyClient {
final String token;
final String developerSecret;
final String baseUrl = 'https://app.evntaly.com/prod';
EvntalyClient(this.token, this.developerSecret);
}
Track Event
Future<void> sendEvent() async {
final url = Uri.parse('$baseUrl/api/v1/register/event');
final payload = {
"title": "Account License Upgraded",
"description": "User upgraded their license to Pro",
"message": "take care.",
"data": {
"user_id": "67890",
"timestamp": "2025-01-08T09:30:00Z",
"referrer": "social_media",
"email_verified": false
},
"tags": [],
"notify": true,
"icon": "โคด๏ธ",
"apply_rule_only": false,
"user": {"id": "0f6934fd-99c0-41ca-84f4"},
"type": "Page View",
"sessionID": "20750ebc-dabf-4fd4-9498-443bf30d6095_bsd",
"feature": "Backend API",
"topic": "@api"
};
await http.post(url,
headers: {
'Content-Type': 'application/json',
'pat': token,
'secret' : developerSecret
},
body: jsonEncode(payload),
);
}
Identify User
Future<void> identifyUser() async {
final url = Uri.parse('$baseUrl/api/v1/register/user');
final payload = {
"id": "0f6934fd-99c0-41ca-3333",
"email": "Alameer@evntaly.com",
"full_name": "Alameer Ashraf",
"organization": "Evntaly",
"data": {
"id": "Alameer-023",
"email": "Alameer@evntaly.com",
"Location": "Egypt",
"timezone": "Africa/Cairo"
}
};
await http.post(url,
headers: {
'Content-Type': 'application/json',
'pat': token,
'secret': developerSecret
},
body: jsonEncode(payload),
);
}
For additional help, contact support at support@evntaly.com.
Last updated