UNPKG

ngx-matomo-client

Version:

Matomo (fka. Piwik) client for Angular applications

57 lines (56 loc) 2.08 kB
import { EnvironmentProviders, Provider } from '@angular/core'; import { MatomoConfiguration } from './tracker/configuration'; import { MatomoScriptFactory } from './tracker/script-factory'; declare const PRIVATE_MATOMO_PROVIDERS: unique symbol; declare const PRIVATE_MATOMO_CHECKS: unique symbol; export type MatomoFeatureKind = unknown; /** * Additional Matomo features kind */ export declare const enum CoreMatomoFeatureKind { /** @see withScriptFactory */ ScriptFactory = "ScriptFactory" } export interface MatomoFeature { readonly kind: MatomoFeatureKind; [PRIVATE_MATOMO_PROVIDERS]: Provider[]; [PRIVATE_MATOMO_CHECKS]?: (features: MatomoFeatureKind[]) => void; } export declare function createMatomoFeature(kind: MatomoFeatureKind, providers: Provider[], checks?: (features: MatomoFeatureKind[]) => void): MatomoFeature; /** * Return Matomo providers (typically added to an application's root module) * * Additional features may be provided as additional arguments, like this: * @example * // Simple configuration * providers: [ provideMatomo({ siteId: 1, trackerUrl: '...' }) ] * * // With additional features * providers: [ * provideMatomo( * { siteId: 1, trackerUrl: '...' }, * withScriptFactory(...), * ) * ] * * // With advanced config factory function * providers: [ * provideMatomo( * () => inject(MyService).getMatomoConfig(), * withScriptFactory(...), * ) * ] * * @param config Matomo configuration (or configuration factory, which can use `inject`) * @param features Optional additional features to enable * * @see MatomoConfiguration * @see withScriptFactory * @see withRouter * @see withRouterInterceptors * @see withRouteData */ export declare function provideMatomo(config: MatomoConfiguration | (() => MatomoConfiguration), ...features: MatomoFeature[]): EnvironmentProviders; /** Add a custom script factory to use for Matomo's script element */ export declare function withScriptFactory(scriptFactory: MatomoScriptFactory): MatomoFeature; export {};