Skip to content

Commit a746838

Browse files
author
Alex Ross
committed
2 parents 1a792be + 00a2b94 commit a746838

1 file changed

Lines changed: 6 additions & 24 deletions

File tree

README.md

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66
[![devDependency Status](https://david-dm.org/aleross/angular-segment-analytics/dev-status.png)](https://david-dm.org/aleross/angular-segment-analytics/dev-status.png)
77
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/aleross/angular-segment-analytics/blob/master/LICENSE)
88

9-
A highly configurable module for adding Segment analytics to any Angular app.
9+
A highly configurable module for easily adding Segment analytics to any Angular app.
1010

1111
## Table of Contents
1212
- [Get Started](#get-started)
1313
- [Usage](#usage)
1414
- [Configuration](#configuration)
1515
- [Provider](#provider)
1616
- [Constant](#constant)
17-
- [Service](#service)
1817
- [API Documentation](#api-documentation)
1918
- [Examples](#examples)
2019

@@ -42,17 +41,17 @@ segmentProvider.setKey('abc');
4241
Most Segment methods (see [Analytics.js](https://segment.com/docs/libraries/analytics.js/)) are available on the `segment` service created by ngSegment.
4342

4443
```js
45-
segment.track('action', { prop: 'value' });
44+
segment.track('event', { prop: 'value' });
4645
```
4746

4847
Continue reading about the configuration options, or jump to the [Examples](#examples).
4948

5049

5150
## Configuration
5251

53-
ngSegment can be configured in any of 3 ways: using a provider, constant or service. These 3 options are available so you can pick the mechanism that fits your application best. The provider or constant are recommended because typically it's best to configure 3rd party libraries in the config phase of your application.
52+
ngSegment provides two configuration mechanisms: using a provider or constant. These options are available so you can pick the mechanism that fits your application best.
5453

55-
It is not recommended to mix configuration mechanisms, but if you do they're applied in the order listed in this documentation (provider, constant then service) and conflicting settings will be overridden.
54+
It is not recommended to mix configuration mechanisms, but if you do configuration via constant will take precedence.
5655

5756
### Provider
5857

@@ -93,26 +92,9 @@ angular.module('myApp').constant('segmentConfig', {
9392

9493
Read more about [AngularJS constants](https://docs.angularjs.org/api/auto/service/$provide#constant).
9594

96-
### Service
97-
98-
If your API key or other configuration parameters are only available in the run phase of your application then you can load Analytics.js using `segmentLoader.load(apiKey)`, and configure using the `segment` service:
99-
```js
100-
angular.module('myApp').controller(function (segment, segmentLoader) {
101-
segment.setCondition(function ($rootScope) {
102-
return $rootScope.isProduction;
103-
});
104-
105-
// If you don't set the API key using the provider or constant
106-
// then you need to manually load Analytics.js
107-
segmentLoader.load('abc');
108-
});
109-
```
110-
111-
Typically you should configure 3rd party libraries before the `run()` phase of your AngularJS application, so it's recommended that you use the **provider** or **constant** mechanism for configuring `ngSegment` instead of the service.
112-
11395
## API Documentation
11496

115-
The configuration API is available on the `segmentProvider` and `segment` service. For configuring via a constant, see [`defaultSegmentConfig`](https://github.com/aleross/angular-segment-analytics/blob/master/src/config.js) for the property names to override.
97+
The configuration API is available on the `segmentProvider`. For configuring via a constant, see [`defaultSegmentConfig`](https://github.com/aleross/angular-segment-analytics/blob/master/src/config.js) for the property names to override.
11698

11799
All configuration methods are chainable:
118100
```js
@@ -150,7 +132,7 @@ segmentProvider.setCondition(function ($rootScope, method, arguments) {
150132
### setAutoload(boolean)
151133
**Default:** `true`
152134

153-
ngSegment autoloads Segment's Analytics.js before the AngularJS `.run()` phase if an API key has been set. Set autoload to false if you're including analytics.js in your build script.
135+
ngSegment autoloads Segment's Analytics.js before the AngularJS `.run()` phase if an API key has been set. Set autoload to false if you already include analytics.js in your build script.
154136

155137
If you need to load the Segment analytics.js script on-demand, you can use the `segmentLoader` or `segmentLoaderProvider`:
156138

0 commit comments

Comments
 (0)