Skip to content

Commit

Permalink
fix(ga): expose ga settings in ga provider #87 (#281)
Browse files Browse the repository at this point in the history
- **What kind of change does this PR introduce?**
* Add a feature to the ga provider.
- **What is the current behavior? Link to open issue?**
* No way to set `additionalAccountNames` on `settings` config object. #87 
- **What is the new behavior?**
* A new method in the google analytics provider that allows a user to set a list of additional account names. These account names are used in any subsequent tracking events, exceptions, etc.

closes #87
  • Loading branch information
Ross Edfort authored and scttcper committed Aug 30, 2018
1 parent a548540 commit 53b7213
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/lib/providers/ga/ga.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,14 @@ describe('Angulartics2GoogleAnalytics', () => {
),
);

it('should allow modification of GA specific settings',
fakeAsync(inject([Angulartics2, Angulartics2GoogleAnalytics],
(angulartics2: Angulartics2, angulartics2GoogleAnalytics: Angulartics2GoogleAnalytics) => {
const additionalAccountNames: string[] = ['additionalAccountNameOne', 'additionalAccountNameTwo'];
angulartics2GoogleAnalytics.settings.additionalAccountNames = additionalAccountNames;
expect(angulartics2.settings.ga.additionalAccountNames).toEqual(additionalAccountNames);
}),
),
);

});
2 changes: 2 additions & 0 deletions src/lib/providers/ga/ga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export class GoogleAnalyticsDefaults implements GoogleAnalyticsSettings {
@Injectable({ providedIn: 'root' })
export class Angulartics2GoogleAnalytics {
dimensionsAndMetrics = [];
settings: Partial<GoogleAnalyticsSettings>;

constructor(private angulartics2: Angulartics2) {
const defaults = new GoogleAnalyticsDefaults();
Expand All @@ -29,6 +30,7 @@ export class Angulartics2GoogleAnalytics {
...defaults,
...this.angulartics2.settings.ga,
};
this.settings = this.angulartics2.settings.ga;
this.angulartics2.setUsername.subscribe((x: string) => this.setUsername(x));
this.angulartics2.setUserProperties.subscribe(x => this.setUserProperties(x));
}
Expand Down

0 comments on commit 53b7213

Please sign in to comment.