Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,10 @@ doc/ @DataDog/documentation @DataDog/rum-mobile
docs/ @DataDog/documentation @DataDog/rum-mobile
*README.md @DataDog/documentation @DataDog/rum-mobile
*CONTRIBUTING.md @DataDog/documentation @DataDog/rum-mobile

## Feature Flagging

packages/datadog_flags/ @DataDog/rum-mobile @DataDog/feature-flagging-and-experimentation-sdk
packages/datadog_flags/README.md @DataDog/documentation @DataDog/rum-mobile @DataDog/feature-flagging-and-experimentation-sdk
examples/simple_example/lib/flags/ @DataDog/rum-mobile @DataDog/feature-flagging-and-experimentation-sdk
examples/simple_example/lib/screens/flags_screen.dart @DataDog/rum-mobile @DataDog/feature-flagging-and-experimentation-sdk
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
<application
android:label="test_app"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
android:icon="@mipmap/ic_launcher"
android:networkSecurityConfig="@xml/network_security_config">
<activity
android:name=".MainActivity"
android:exported="true"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain>localhost</domain>
<domain>127.0.0.1</domain>
<domain>10.0.2.2</domain>
</domain-config>
</network-security-config>
4 changes: 4 additions & 0 deletions examples/simple_example/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ org.gradle.jvmargs=-Xmx3000M
android.useAndroidX=true
android.enableJetifier=true
kotlin_version=2.1.0
# This builtInKotlin flag was added automatically by Flutter migrator
android.builtInKotlin=false
# This newDsl flag was added automatically by Flutter migrator
android.newDsl=false
55 changes: 31 additions & 24 deletions examples/simple_example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ PODS:
- DatadogWebViewTracking (~> 3)
- Flutter
- webview_flutter_wkwebview
- DatadogCore (3.9.1):
- DatadogInternal (= 3.9.1)
- DatadogCrashReporting (3.9.1):
- DatadogInternal (= 3.9.1)
- DatadogCore (3.11.1):
- DatadogInternal (= 3.11.1)
- DatadogCrashReporting (3.11.1):
- DatadogInternal (= 3.11.1)
- KSCrash/Filters (= 2.5.0)
- KSCrash/Recording (= 2.5.0)
- DatadogInternal (3.9.1)
- DatadogLogs (3.9.1):
- DatadogInternal (= 3.9.1)
- DatadogRUM (3.9.1):
- DatadogInternal (= 3.9.1)
- DatadogWebViewTracking (3.9.1):
- DatadogInternal (= 3.9.1)
- DatadogInternal (3.11.1)
- DatadogLogs (3.11.1):
- DatadogInternal (= 3.11.1)
- DatadogRUM (3.11.1):
- DatadogInternal (= 3.11.1)
- DatadogWebViewTracking (3.11.1):
- DatadogInternal (= 3.11.1)
- DictionaryCoder (1.2.0)
- Flutter (1.0.0)
- KSCrash/Core (2.5.0)
Expand All @@ -49,6 +49,9 @@ PODS:
- path_provider_foundation (0.0.1):
- Flutter
- FlutterMacOS
- shared_preferences_foundation (0.0.1):
- Flutter
- FlutterMacOS
- webview_flutter_wkwebview (0.0.1):
- Flutter
- FlutterMacOS
Expand All @@ -61,6 +64,7 @@ DEPENDENCIES:
- Flutter (from `Flutter`)
- objective_c (from `.symlinks/plugins/objective_c/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
- webview_flutter_wkwebview (from `.symlinks/plugins/webview_flutter_wkwebview/darwin`)

SPEC REPOS:
Expand Down Expand Up @@ -89,26 +93,29 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/objective_c/ios"
path_provider_foundation:
:path: ".symlinks/plugins/path_provider_foundation/darwin"
shared_preferences_foundation:
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
webview_flutter_wkwebview:
:path: ".symlinks/plugins/webview_flutter_wkwebview/darwin"

SPEC CHECKSUMS:
connectivity_plus: 18382e7311ba19efcaee94442b23b32507b20695
datadog_flutter_plugin: 64adc7ef089a1328c78fd4fab24e49afa09d95a5
datadog_session_replay: 8e4f4a520f20feb2916c623c011a53ba63f8d77f
datadog_webview_tracking: 58ffca1b06ba88e0bd6dc0d0d1dada0e60e6d3d5
DatadogCore: e27bba3c2f490ae41ac17d41aecadee85475fe6d
DatadogCrashReporting: 23da244e20c2af0d159097dd10cc9ce8ef954bcc
DatadogInternal: e9ff671207d5a14354364101d32d60897c48d13a
DatadogLogs: 664dbb3598f95817429db0025575289c1f63efbf
DatadogRUM: dd30158552e5b48898cc2e6084eda1754c03ad6e
DatadogWebViewTracking: b8c35c23ac90ee4ba2b3879577451e27ec86ebcd
connectivity_plus: 2256d3e20624a7749ed21653aafe291a46446fee
datadog_flutter_plugin: ece4fa34fdd699f4c36547df450da4417f904580
datadog_session_replay: 29f1e456d30632bb22ad1dd0eceb15811d2fbc6c
datadog_webview_tracking: d92b870c96d7e646ac838f9c4a79d5fd70468139
DatadogCore: ac5ffe0cb500e4c826fa08e63767ab3b4434c380
DatadogCrashReporting: 699c20e4af5798a39b14c81e26c0e92293d86a36
DatadogInternal: 4ee2f5bab0371f161c8010637fff5331f49542d7
DatadogLogs: 9f7f10c34ea9cc4c6699f98ab2420da843f78f4b
DatadogRUM: 14a5f96c465e85d56ec501508d728b7aea9c2980
DatadogWebViewTracking: 99631d80d34cb30cf6be9b620dc6659f7f5bd15f
DictionaryCoder: f7115fcd074c8301e91f2eb862da1ea7d0385e61
Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467
KSCrash: 80e1e24eaefbe5134934ae11ca8d7746586bc2ed
objective_c: 77e887b5ba1827970907e10e832eec1683f3431d
path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
webview_flutter_wkwebview: a4af96a051138e28e29f60101d094683b9f82188
objective_c: 89e720c30d716b036faf9c9684022048eee1eee2
path_provider_foundation: 080d55be775b7414fd5a5ef3ac137b97b097e564
shared_preferences_foundation: 7036424c3d8ec98dfe75ff1667cb0cd531ec82bb
webview_flutter_wkwebview: 1821ceac936eba6f7984d89a9f3bcb4dea99ebb2

PODFILE CHECKSUM: cc1f88378b4bfcf93a6ce00d2c587857c6008d3b

Expand Down
18 changes: 0 additions & 18 deletions examples/simple_example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
50E793F5A550121A16F6AF72 /* [CP] Embed Pods Frameworks */,
C5A6A31AA8D394C2AA220E42 /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -269,23 +268,6 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
};
C5A6A31AA8D394C2AA220E42 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Copy Pods Resources";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand Down
5 changes: 5 additions & 0 deletions examples/simple_example/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
<string>????</string>
<key>CFBundleVersion</key>
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsLocalNetworking</key>
<true/>
</dict>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
Expand Down
84 changes: 48 additions & 36 deletions examples/simple_example/lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,21 @@ import 'package:go_router/go_router.dart';
import 'package:graphql_flutter/graphql_flutter.dart';

import 'main_screen.dart';
import 'flags/flags_demo_runtime.dart';
import 'screens/flags_screen.dart';
import 'screens/crash_screen.dart';
import 'screens/graph_ql_screen.dart';
import 'screens/network_screen.dart';

class MyApp extends StatefulWidget {
final GraphQLClient graphQLClient;
final FlagsDemoRuntime flagsRuntime;

const MyApp({super.key, required this.graphQLClient});
const MyApp({
super.key,
required this.graphQLClient,
required this.flagsRuntime,
});

@override
State<MyApp> createState() => _MyAppState();
Expand All @@ -25,41 +32,46 @@ class MyApp extends StatefulWidget {
class _MyAppState extends State<MyApp> {
var captureKey = GlobalKey();

final router = GoRouter(
observers: [DatadogNavigationObserver(datadogSdk: DatadogSdk.instance)],
routes: [
GoRoute(
path: '/',
builder: (context, state) {
return const MainScreen();
},
),
GoRoute(
path: '/home',
builder: (context, state) {
return const MyHomePage(title: 'Home');
},
),
GoRoute(
path: '/network',
builder: (context, state) {
return const NetworkScreen();
},
),
GoRoute(
path: '/graphql',
builder: (context, state) {
return const GraphQlScreen();
},
),
GoRoute(
path: '/crash',
builder: (context, state) {
return const CrashTestScreen();
},
),
],
);
late final router = GoRouter(observers: [
DatadogNavigationObserver(datadogSdk: DatadogSdk.instance)
], routes: [
GoRoute(
path: '/',
builder: (context, state) {
return const MainScreen();
},
),
GoRoute(
path: '/home',
builder: (context, state) {
return const MyHomePage(title: 'Home');
},
),
GoRoute(
path: '/network',
builder: (context, state) {
return const NetworkScreen();
},
),
GoRoute(
path: '/graphql',
builder: (context, state) {
return const GraphQlScreen();
},
),
GoRoute(
path: '/crash',
builder: (context, state) {
return const CrashTestScreen();
},
),
GoRoute(
path: '/flags',
builder: (context, state) {
return FlagsScreen(runtime: widget.flagsRuntime);
},
),
]);

@override
Widget build(BuildContext context) {
Expand Down
117 changes: 117 additions & 0 deletions examples/simple_example/lib/flags/flags_demo_runtime.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0. This product includes software
// developed at Datadog (https://www.datadoghq.com/).
// Copyright 2019-Present Datadog, Inc.

import 'package:datadog_flags/datadog_flags.dart';
import 'package:datadog_flutter_plugin/datadog_flutter_plugin.dart';

import 'flags_request_counter.dart';
import 'forwarding_flags_counter.dart';

const _externalFlagsEndpoint = String.fromEnvironment('FLAGS_ENDPOINT');
const _externalExposureEndpoint =
String.fromEnvironment('FLAGS_EXPOSURE_ENDPOINT');
const _externalEvaluationEndpoint =
String.fromEnvironment('FLAGS_EVALUATION_ENDPOINT');
const _countRequests =
bool.fromEnvironment('FLAGS_COUNT_REQUESTS', defaultValue: true);

class FlagsDemoRuntime {
final FlagsRequestCounter? counter;
final DatadogFlagsConfiguration configuration;

const FlagsDemoRuntime._({
required this.counter,
required this.configuration,
});

Future<void> stop() async {
await counter?.stop();
}

static Future<FlagsDemoRuntime> create({
String? clientToken,
String? env,
String? siteName,
String? applicationId,
}) async {
final externalFlagsEndpoint = _uriFromEnvironment(_externalFlagsEndpoint);
final externalExposureEndpoint =
_uriFromEnvironment(_externalExposureEndpoint);
final externalEvaluationEndpoint =
_uriFromEnvironment(_externalEvaluationEndpoint);

final useDatad0g = siteName == 'datad0g.com';
final counter = _countRequests ? ForwardingFlagsCounter.create() : null;

return FlagsDemoRuntime._(
counter: counter,
configuration: DatadogFlagsConfiguration(
customFlagsEndpoint: externalFlagsEndpoint ??
(useDatad0g
? Uri.https(
'preview.ff-cdn.datad0g.com',
'/precompute-assignments',
)
: null),
customExposureEndpoint: externalExposureEndpoint ??
(useDatad0g
? Uri.parse(
'https://browser-intake-datad0g.com/api/v2/exposures?ddsource=flutter',
)
: null),
customEvaluationEndpoint: externalEvaluationEndpoint ??
(useDatad0g
? Uri.parse(
'https://browser-intake-datad0g.com/api/v2/flagevaluation?ddsource=flutter',
)
: null),
httpClient:
counter is ForwardingFlagsCounter ? counter.httpClient : null,
datadogContext: _datadogContext(
useDatad0g: useDatad0g,
clientToken: clientToken,
env: env,
applicationId: applicationId,
),
evaluationFlushInterval: const Duration(seconds: 1),
),
);
}
}

DatadogFlagsContext? _datadogContext({
required bool useDatad0g,
required String? clientToken,
required String? env,
required String? applicationId,
}) {
if (!useDatad0g) {
return null;
}

return DatadogFlagsContext(
clientToken: clientToken ?? '',
env: env ?? 'staging',
site: DatadogSite.us1,
service: 'simple-example',
version: '1.0.0',
applicationId: _emptyToNull(applicationId),
sdkVersion: DatadogSdk.sdkVersion,
);
}

Uri? _uriFromEnvironment(String value) {
if (value.isEmpty) {
return null;
}
return Uri.parse(value);
}

String? _emptyToNull(String? value) {
if (value == null || value.isEmpty) {
return null;
}
return value;
}
Loading