Skip to content

Commit 483c267

Browse files
committed
Merge branch 'DOC-811' of ssh://github.com/segmentio/segment-docs into DOC-811
2 parents 6808401 + 129d175 commit 483c267

File tree

1 file changed

+25
-38
lines changed
  • src/connections/sources/catalog/libraries/mobile/flutter

1 file changed

+25
-38
lines changed

src/connections/sources/catalog/libraries/mobile/flutter/index.md

Lines changed: 25 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -24,35 +24,22 @@ Some destination plugins may not support all platform functionality. Refer to in
2424
## Getting started
2525
To install Analytics-Flutter:
2626

27-
1. Manually add this package to your `pubspec.yaml` file:
27+
1. Add the core package as a dependency.
28+
29+
```bash
30+
flutter pub add segment_analytics
31+
```
2832

29-
```yml
30-
dependencies:
31-
flutter:
32-
sdk: flutter
33-
34-
# Main package
35-
analytics:
36-
git:
37-
url: https://github.com/segmentio/analytics_flutter
38-
ref: main
39-
path: packages/core
40-
```
4133
2. *(Optional)* Add any plugin that you need.
4234

43-
```yml
44-
# Plugins
45-
analytics_plugin_firebase:
46-
git:
47-
url: https://github.com/segmentio/analytics_flutter
48-
ref: main
49-
path: packages/plugins/plugin_firebase
35+
```bash
36+
flutter pub add segment_analytics_plugin_firebase
5037
```
5138

5239
3. Import the library in your Dart code.
5340

5441
```dart
55-
import 'package:analytics/client.dart';
42+
import 'package:segment_analytics/client.dart';
5643
```
5744

5845
4. Add permissions to `AndroidManifest.xml`. Add the line below between the `` tags.
@@ -312,12 +299,12 @@ You can pass `autoAddSegmentDestination = false` in the options when setting up
312299
You can add a plugin at any time through the Add method.
313300
314301
```dart
315-
import 'package:analytics/client.dart';
316-
import 'package:analytics/event.dart';
317-
import 'package:analytics/state.dart';
318-
import 'package:analytics_plugin_advertising_id/plugin_advertising_id.dart';
319-
import 'package:analytics_plugin_idfa/plugin_idfa.dart';
320-
import 'package:analytics_plugin_firebase/plugin_firebase.dart'
302+
import 'package:segment_analytics/client.dart';
303+
import 'package:segment_analytics/event.dart';
304+
import 'package:segment_analytics/state.dart';
305+
import 'package:segment_analytics_plugin_advertising_id/plugin_advertising_id.dart';
306+
import 'package:segment_analytics_plugin_idfa/plugin_idfa.dart';
307+
import 'package:segment_analytics_plugin_firebase/plugin_firebase.dart'
321308
show FirebaseDestination;
322309
323310
const writeKey = 'SEGMENT_API_KEY';
@@ -355,10 +342,10 @@ You can them customize the functionality by overriding different methods on the
355342
```dart
356343
import 'dart:convert';
357344
358-
import 'package:analytics/analytics.dart';
359-
import 'package:analytics/event.dart';
360-
import 'package:analytics/plugin.dart';
361-
import 'package:analytics/logger.dart';
345+
import 'package:segment_analytics/analytics.dart';
346+
import 'package:segment_analytics/event.dart';
347+
import 'package:segment_analytics/plugin.dart';
348+
import 'package:segment_analytics/logger.dart';
362349
363350
class EventLogger extends DestinationPlugin {
364351
var logKind = LogFilterKind.debug;
@@ -403,8 +390,8 @@ A flush policy defines the strategy for deciding when to flush. This can be on a
403390
To make use of flush policies, you can set them in the configuration of the client:
404391
405392
```dart
406-
import 'package:analytics/flush_policies/count_flush_policy.dart';
407-
import 'package:analytics/flush_policies/timer_flush_policy.dart';
393+
import 'package:segment_analytics/flush_policies/count_flush_policy.dart';
394+
import 'package:segment_analytics/flush_policies/timer_flush_policy.dart';
408395
409396
final analytics = createClient(Configuration(/*...*/, flushPolicies: [
410397
CountFlushPolicy(10),
@@ -449,8 +436,8 @@ A `FlushPolicy` can optionally implement:
449436
The `FlushPolicy` should have a `shouldFlush` boolean value. When this is set to true, the client attempts to upload events. Each policy should reset this value to `false` according to its own logic, although it's pretty common to do it inside the `reset` method.
450437
451438
```dart
452-
import 'package:analytics/event.dart';
453-
import 'package:analytics/flush_policies/flush_policy.dart';
439+
import 'package:segment_analytics/event.dart';
440+
import 'package:segment_analytics/flush_policies/flush_policy.dart';
454441
455442
class FlushOnScreenEventsPolicy extends FlushPolicy {
456443
@@ -476,7 +463,7 @@ class FlushOnScreenEventsPolicy extends FlushPolicy {
476463
By default, any logging is done through the standard Flutter logging mechanism. To customize logging, you can build your own logger, which must implement the `LogTarget` mixin. For example:
477464
478465
```dart
479-
import 'package:analytics/logger.dart';
466+
import 'package:segment_analytics/logger.dart';
480467
481468
void customDebugLog(String msg) {
482469
// ...
@@ -520,7 +507,7 @@ The error handler configuration receives a function which gets called whenever a
520507
You can use this error handling to trigger different behaviors in the client when a problem occurs. For example if the client gets rate limited, you could use the error handler to swap flush policies to be less aggressive.
521508
522509
```dart
523-
import 'package:analytics/errors.dart';
510+
import 'package:segment_analytics/errors.dart';
524511
525512
//...
526513
@@ -548,7 +535,7 @@ final analytics = createClient(Configuration(writeKey),
548535
Plugins can also report errors to the handler by using the [`.error`](https://github.com/segmentio/analytics_flutter/blob/main/packages/core/lib/analytics.dart#L52){:target="_blank"} function of the analytics client. Segment recommends you to use the `PluginError` for consistency, and to attach the `innerError` with the actual exception that was hit.
549536
550537
```dart
551-
import 'package:analytics/errors.dart';
538+
import 'package:segment_analytics/errors.dart';
552539
553540
//...
554541

0 commit comments

Comments
 (0)