-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1 parent
84d6b83
commit 89f9344
Showing
57 changed files
with
310 additions
and
244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './public-api'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"$schema": "../../../node_modules/ng-packagr/ng-package.schema.json", | ||
"lib": { | ||
"entryFile": "public-api.ts" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export { runOnce as ɵrunOnce } from './utils/function'; | ||
export { MATOMO_ROUTER_ENABLED as ɵMATOMO_ROUTER_ENABLED } from './tracker/configuration'; | ||
export { | ||
createMatomoFeature as ɵcreateMatomoFeature, | ||
MatomoFeatureKind as ɵMatomoFeatureKind, | ||
MatomoFeature as ɵMatomoFeature, | ||
} from './providers'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { ApplicationInitStatus, InjectionToken } from '@angular/core'; | ||
import { TestBed, TestModuleMetadata } from '@angular/core/testing'; | ||
import { provideMatomo, withScriptFactory } from './providers'; | ||
import { MATOMO_CONFIGURATION, MatomoConfiguration } from './tracker/configuration'; | ||
import { MatomoInitializerService } from './tracker/matomo-initializer.service'; | ||
import { MatomoTracker } from './tracker/matomo-tracker.service'; | ||
import { createDefaultMatomoScriptElement } from './tracker/script-factory'; | ||
|
||
describe('providers', () => { | ||
async function setUp(providers: TestModuleMetadata['providers']): Promise<void> { | ||
TestBed.configureTestingModule({ | ||
providers: providers, | ||
}); | ||
|
||
// https://github.com/angular/angular/issues/24218 | ||
await TestBed.inject(ApplicationInitStatus).donePromise; | ||
} | ||
|
||
it('should provide basic Matomo providers with static configuration', async () => { | ||
const fakeInitializer = jasmine.createSpyObj<MatomoInitializerService>(['initialize']); | ||
const config: MatomoConfiguration = { trackerUrl: 'my-tracker', siteId: 42 }; | ||
|
||
await setUp([ | ||
{ | ||
provide: MatomoInitializerService, | ||
useValue: fakeInitializer, | ||
}, | ||
provideMatomo(config), | ||
]); | ||
|
||
expect(TestBed.inject(MatomoTracker)).toEqual(jasmine.any(MatomoTracker)); | ||
expect(TestBed.inject(MATOMO_CONFIGURATION)).toEqual(config); | ||
expect(fakeInitializer.initialize).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
it('should provide basic Matomo providers with configuration factory', async () => { | ||
const fakeInitializer = jasmine.createSpyObj<MatomoInitializerService>(['initialize']); | ||
const trackerUrl = 'my-tracker'; | ||
const config: MatomoConfiguration = { trackerUrl, siteId: 42 }; | ||
const trackerUrlToken = new InjectionToken<string>('trackerUrl'); | ||
|
||
await setUp([ | ||
{ | ||
provide: MatomoInitializerService, | ||
useValue: fakeInitializer, | ||
}, | ||
{ | ||
provide: trackerUrlToken, | ||
useValue: trackerUrl, | ||
}, | ||
provideMatomo(() => ({ trackerUrl: TestBed.inject(trackerUrlToken), siteId: 42 })), | ||
]); | ||
|
||
expect(TestBed.inject(MatomoTracker)).toEqual(jasmine.any(MatomoTracker)); | ||
expect(TestBed.inject(MATOMO_CONFIGURATION)).toEqual(config); | ||
expect(fakeInitializer.initialize).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
it('should provide basic Matomo providers with custom script factory', async () => { | ||
const scriptFactory = jasmine | ||
.createSpy('scriptFactory') | ||
.and.callFake(createDefaultMatomoScriptElement); | ||
|
||
await setUp([ | ||
provideMatomo({ trackerUrl: 'my-tracker', siteId: 42 }, withScriptFactory(scriptFactory)), | ||
]); | ||
|
||
expect(TestBed.inject(MatomoTracker)).toEqual(jasmine.any(MatomoTracker)); | ||
expect(scriptFactory).toHaveBeenCalledTimes(1); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Public API Surface of tracker | ||
*/ | ||
|
||
export * from './private-api'; | ||
|
||
export { NgxMatomoModule, NgxMatomoTrackerModule, MATOMO_DIRECTIVES } from './ngx-matomo.module'; | ||
export { provideMatomo, withScriptFactory, MatomoFeatureKind, MatomoFeature } from './providers'; | ||
export { | ||
MatomoTracker, | ||
MatomoECommerceItem, | ||
MatomoECommerceView, | ||
MatomoECommerceItemView, | ||
MatomoECommerceCategoryView, | ||
PagePerformanceTimings, | ||
} from './tracker/matomo-tracker.service'; | ||
export { MatomoInitializerService } from './tracker/matomo-initializer.service'; | ||
export { | ||
MatomoConfiguration, | ||
MATOMO_CONFIGURATION, | ||
AutoMatomoConfiguration, | ||
MatomoInitializationMode, | ||
MatomoConsentMode, | ||
InternalMatomoConfiguration, | ||
INTERNAL_MATOMO_CONFIGURATION, | ||
} from './tracker/configuration'; | ||
export { | ||
MATOMO_SCRIPT_FACTORY, | ||
MatomoScriptFactory, | ||
createDefaultMatomoScriptElement, | ||
} from './tracker/script-factory'; | ||
export { MatomoTrackerDirective } from './directives/matomo-tracker.directive'; | ||
export { MatomoTrackClickDirective } from './directives/matomo-track-click.directive'; | ||
export { MatomoOptOutFormComponent } from './directives/matomo-opt-out-form.component'; |
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...racker/matomo-initializer.service.spec.ts → ...racker/matomo-initializer.service.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 1 addition & 4 deletions
5
...mo-client/src/lib/router/configuration.ts → ...ngx-matomo-client/router/configuration.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './public-api'; |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...er/interceptors/route-data-interceptor.ts → ...er/interceptors/route-data-interceptor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"$schema": "../../../node_modules/ng-packagr/ng-package.schema.json", | ||
"lib": { | ||
"entryFile": "public-api.ts" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
.../src/lib/router/page-url-provider.spec.ts → ...o-client/router/page-url-provider.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { | ||
ɵcreateMatomoFeature as createMatomoFeature, | ||
ɵMATOMO_ROUTER_ENABLED as MATOMO_ROUTER_ENABLED, | ||
ɵMatomoFeature as MatomoFeature, | ||
ɵMatomoFeatureKind as MatomoFeatureKind, | ||
} from 'ngx-matomo-client/core'; | ||
import { ENVIRONMENT_INITIALIZER, inject, Provider, Type } from '@angular/core'; | ||
import { MATOMO_ROUTER_CONFIGURATION, MatomoRouterConfiguration } from './configuration'; | ||
import { MatomoRouter } from './matomo-router.service'; | ||
import { | ||
MATOMO_ROUTE_DATA_KEY, | ||
MatomoRouteDataInterceptor, | ||
} from './interceptors/route-data-interceptor'; | ||
import { MatomoRouterInterceptor, provideInterceptor, provideInterceptors } from './interceptor'; | ||
|
||
/** Enable automatic page views tracking */ | ||
export function withRouter(config?: MatomoRouterConfiguration): MatomoFeature { | ||
const providers = [ | ||
{ provide: MATOMO_ROUTER_ENABLED, useValue: true }, | ||
{ provide: MATOMO_ROUTER_CONFIGURATION, useValue: config }, | ||
{ | ||
provide: ENVIRONMENT_INITIALIZER, | ||
multi: true, | ||
useValue() { | ||
inject(MatomoRouter).initialize(); | ||
}, | ||
}, | ||
]; | ||
|
||
return createMatomoFeature(MatomoFeatureKind.Router, providers); | ||
} | ||
|
||
/** Add some matomo router interceptors */ | ||
export function withRouterInterceptors( | ||
interceptors: Type<MatomoRouterInterceptor>[] | ||
): MatomoFeature { | ||
return createMatomoFeature( | ||
MatomoFeatureKind.RouterInterceptors, | ||
provideInterceptors(interceptors) | ||
); | ||
} | ||
|
||
/** | ||
* Enable retrieval of tracking information from route data | ||
* | ||
* @see MatomoRouteData | ||
* @param key A custom key to get lookup route data - default is 'matomo' | ||
*/ | ||
export function withRouteData(key?: string): MatomoFeature { | ||
const providers: Provider[] = [provideInterceptor(MatomoRouteDataInterceptor)]; | ||
|
||
if (key) { | ||
providers.push({ provide: MATOMO_ROUTE_DATA_KEY, useValue: key }); | ||
} | ||
|
||
return createMatomoFeature(MatomoFeatureKind.BuiltInRouteDataInterceptor, providers); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Public API Surface of tracker | ||
*/ | ||
|
||
export { withRouter, withRouterInterceptors, withRouteData } from './providers'; | ||
export { NgxMatomoRouterModule } from './ngx-matomo-router.module'; | ||
export { | ||
MatomoRouterConfiguration, | ||
MATOMO_ROUTER_CONFIGURATION, | ||
ExclusionConfig, | ||
MatomoRouterConfigurationWithInterceptors, | ||
} from './configuration'; | ||
export { PageTitleProvider, MATOMO_PAGE_TITLE_PROVIDER } from './page-title-providers'; | ||
export { PageUrlProvider, MATOMO_PAGE_URL_PROVIDER } from './page-url-provider'; | ||
export { | ||
MatomoRouterInterceptor, | ||
MATOMO_ROUTER_INTERCEPTORS, | ||
provideInterceptor, | ||
provideInterceptors, | ||
} from './interceptor'; | ||
export { MatomoRouteInterceptorBase } from './interceptors/route-interceptor-base'; | ||
export { | ||
MatomoRouteData, | ||
MatomoRouteDataInterceptor, | ||
MATOMO_ROUTE_DATA_KEY, | ||
} from './interceptors/route-data-interceptor'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './public-api'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters