Skip to content

Commit 129d175

Browse files
stayseesongoscb
andauthored
Apply suggestions from code review
Co-authored-by: Oscar Bazaldua <[email protected]>
1 parent 64395ed commit 129d175

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
@@ -21,35 +21,22 @@ Some destination plugins may not support all platform functionality. Refer to in
2121
## Getting started
2222
To install Analytics-Flutter:
2323

24-
1. Manually add this package to your `pubspec.yaml` file:
24+
1. Add the core package as a dependency.
25+
26+
```bash
27+
flutter pub add segment_analytics
28+
```
2529

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

40-
```yml
41-
# Plugins
42-
analytics_plugin_firebase:
43-
git:
44-
url: https://github.com/segmentio/analytics_flutter
45-
ref: main
46-
path: packages/plugins/plugin_firebase
32+
```bash
33+
flutter pub add segment_analytics_plugin_firebase
4734
```
4835

4936
3. Import the library in your Dart code.
5037

5138
```dart
52-
import 'package:analytics/client.dart';
39+
import 'package:segment_analytics/client.dart';
5340
```
5441

5542
4. Add permissions to `AndroidManifest.xml`. Add the line below between the `` tags.
@@ -290,12 +277,12 @@ You can pass `autoAddSegmentDestination = false` in the options when setting up
290277
You can add a plugin at any time through the Add method.
291278
292279
```dart
293-
import 'package:analytics/client.dart';
294-
import 'package:analytics/event.dart';
295-
import 'package:analytics/state.dart';
296-
import 'package:analytics_plugin_advertising_id/plugin_advertising_id.dart';
297-
import 'package:analytics_plugin_idfa/plugin_idfa.dart';
298-
import 'package:analytics_plugin_firebase/plugin_firebase.dart'
280+
import 'package:segment_analytics/client.dart';
281+
import 'package:segment_analytics/event.dart';
282+
import 'package:segment_analytics/state.dart';
283+
import 'package:segment_analytics_plugin_advertising_id/plugin_advertising_id.dart';
284+
import 'package:segment_analytics_plugin_idfa/plugin_idfa.dart';
285+
import 'package:segment_analytics_plugin_firebase/plugin_firebase.dart'
299286
show FirebaseDestination;
300287
301288
const writeKey = 'SEGMENT_API_KEY';
@@ -333,10 +320,10 @@ You can them customize the functionality by overriding different methods on the
333320
```dart
334321
import 'dart:convert';
335322
336-
import 'package:analytics/analytics.dart';
337-
import 'package:analytics/event.dart';
338-
import 'package:analytics/plugin.dart';
339-
import 'package:analytics/logger.dart';
323+
import 'package:segment_analytics/analytics.dart';
324+
import 'package:segment_analytics/event.dart';
325+
import 'package:segment_analytics/plugin.dart';
326+
import 'package:segment_analytics/logger.dart';
340327
341328
class EventLogger extends DestinationPlugin {
342329
var logKind = LogFilterKind.debug;
@@ -381,8 +368,8 @@ A flush policy defines the strategy for deciding when to flush. This can be on a
381368
To make use of flush policies, you can set them in the configuration of the client:
382369
383370
```dart
384-
import 'package:analytics/flush_policies/count_flush_policy.dart';
385-
import 'package:analytics/flush_policies/timer_flush_policy.dart';
371+
import 'package:segment_analytics/flush_policies/count_flush_policy.dart';
372+
import 'package:segment_analytics/flush_policies/timer_flush_policy.dart';
386373
387374
final analytics = createClient(Configuration(/*...*/, flushPolicies: [
388375
CountFlushPolicy(10),
@@ -427,8 +414,8 @@ A `FlushPolicy` can optionally implement:
427414
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.
428415
429416
```dart
430-
import 'package:analytics/event.dart';
431-
import 'package:analytics/flush_policies/flush_policy.dart';
417+
import 'package:segment_analytics/event.dart';
418+
import 'package:segment_analytics/flush_policies/flush_policy.dart';
432419
433420
class FlushOnScreenEventsPolicy extends FlushPolicy {
434421
@@ -454,7 +441,7 @@ class FlushOnScreenEventsPolicy extends FlushPolicy {
454441
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:
455442
456443
```dart
457-
import 'package:analytics/logger.dart';
444+
import 'package:segment_analytics/logger.dart';
458445
459446
void customDebugLog(String msg) {
460447
// ...
@@ -498,7 +485,7 @@ The error handler configuration receives a function which gets called whenever a
498485
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.
499486
500487
```dart
501-
import 'package:analytics/errors.dart';
488+
import 'package:segment_analytics/errors.dart';
502489
503490
//...
504491
@@ -526,7 +513,7 @@ final analytics = createClient(Configuration(writeKey),
526513
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.
527514
528515
```dart
529-
import 'package:analytics/errors.dart';
516+
import 'package:segment_analytics/errors.dart';
530517
531518
//...
532519

0 commit comments

Comments
 (0)