New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ngx-matomo-client

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ngx-matomo-client - npm Package Compare versions

Comparing version 5.0.0-next.2 to 5.0.0

schematics/utils/ast-utils.d.ts

9

lib/ngx-matomo-providers.d.ts

@@ -65,4 +65,9 @@ import { EnvironmentProviders, Provider, Type } from '@angular/core';

export declare function withRouterInterceptors(interceptors: Type<MatomoRouterInterceptor>[]): MatomoFeature;
/** Enable retrieval of tracking information from route data */
export declare function withRouteData(): MatomoFeature;
/**
* Enable retrieval of tracking information from route data
*
* @see MatomoRouteData
* @param key A custom key to get lookup route data - default is 'matomo'
*/
export declare function withRouteData(key?: string): MatomoFeature;
export {};
import { ModuleWithProviders } from '@angular/core';
import { MatomoOptOutFormComponent } from './directives/matomo-opt-out-form.component';
import { MatomoTrackClickDirective } from './directives/matomo-track-click.directive';
import { MatomoTrackerDirective } from './directives/matomo-tracker.directive';
import { MatomoConfiguration } from './tracker/configuration';

@@ -8,2 +11,3 @@ import { MatomoScriptFactory } from './tracker/script-factory';

import * as i3 from "./directives/matomo-opt-out-form.component";
export declare const MATOMO_DIRECTIVES: readonly [typeof MatomoTrackerDirective, typeof MatomoTrackClickDirective, typeof MatomoOptOutFormComponent];
export declare class NgxMatomoModule {

@@ -10,0 +14,0 @@ static forRoot(config: MatomoConfiguration, scriptFactory?: MatomoScriptFactory): ModuleWithProviders<NgxMatomoModule>;

@@ -1,2 +0,3 @@

import { ActivatedRouteSnapshot, Router } from '@angular/router';
import { InjectionToken } from '@angular/core';
import { ActivatedRouteSnapshot } from '@angular/router';
import { Observable } from 'rxjs';

@@ -7,2 +8,5 @@ import { MatomoECommerceView, MatomoTracker } from '../../tracker/matomo-tracker.service';

export declare const DEFAULT_DATA_KEY = "matomo";
/** Token to define the route's data key to be looked-up by `MatomoRouteDataInterceptor` */
export declare const MATOMO_ROUTE_DATA_KEY: InjectionToken<string>;
/** Standard properties that may be read from route data */
export interface MatomoRouteData {

@@ -60,2 +64,3 @@ title?: string;

* @see MatomoRouteInterceptorBase
* @see MatomoRouteData
*/

@@ -65,3 +70,2 @@ export declare class MatomoRouteDataInterceptor extends MatomoRouteInterceptorBase<MatomoRouteData | undefined> {

protected readonly dataKey: string;
constructor(tracker: MatomoTracker, router: Router);
protected extractRouteData(route: ActivatedRouteSnapshot): MatomoRouteData | undefined;

@@ -68,0 +72,0 @@ protected processRouteData(data: MatomoRouteData | undefined): Observable<void> | Promise<void> | void;

@@ -11,3 +11,2 @@ import { ActivatedRouteSnapshot, NavigationEnd, Router } from '@angular/router';

protected readonly router: Router;
protected constructor(router: Router);
beforePageTrack(event: NavigationEnd): Observable<void> | Promise<void> | void;

@@ -14,0 +13,0 @@ protected getRoute(event: NavigationEnd): ActivatedRouteSnapshot;

import { InjectionToken } from '@angular/core';
/** Internal marker token to detect that router has been enabled */
export declare const MATOMO_ROUTER_ENABLED: InjectionToken<boolean>;
/** Injection token for {@link MatomoConfiguration} */

@@ -20,3 +22,3 @@ export declare const MATOMO_CONFIGURATION: InjectionToken<MatomoConfiguration>;

/**
* Automatically inject matomo script when deferred tracker configuration is provided using `MatomoDeferredInitializerService.init`.
* Automatically inject matomo script when deferred tracker configuration is provided using `MatomoInitializerService.initializeTracker()`.
*/

@@ -23,0 +25,0 @@ AUTO_DEFERRED = 2

@@ -6,3 +6,3 @@ import { AutoMatomoConfiguration, MatomoInitializationMode } from './configuration';

initialize(): void;
initializeTracker(_: AutoMatomoConfiguration<MatomoInitializationMode.AUTO | MatomoInitializationMode.AUTO_DEFERRED>): void;
initializeTracker(_: AutoMatomoConfiguration<MatomoInitializationMode.AUTO_DEFERRED>): void;
}

@@ -9,0 +9,0 @@ export declare class MatomoInitializerService {

{
"name": "ngx-matomo-client",
"version": "5.0.0-next.2",
"version": "5.0.0",
"author": "Emmanuel Roux (https://github.com/EmmanuelRoux)",

@@ -5,0 +5,0 @@ "description": "Matomo (fka. Piwik) client for Angular applications",

@@ -1,2 +0,2 @@

export { NgxMatomoModule, NgxMatomoTrackerModule } from './lib/ngx-matomo.module';
export { NgxMatomoModule, NgxMatomoTrackerModule, MATOMO_DIRECTIVES, } from './lib/ngx-matomo.module';
export { provideMatomo, withScriptFactory, withRouter, withRouterInterceptors, withRouteData, MatomoFeatureKind, MatomoFeature, } from './lib/ngx-matomo-providers';

@@ -16,2 +16,2 @@ export { MatomoTracker, MatomoECommerceItem, MatomoECommerceView, MatomoECommerceItemView, MatomoECommerceCategoryView, PagePerformanceTimings, } from './lib/tracker/matomo-tracker.service';

export { MatomoRouteInterceptorBase } from './lib/router/interceptors/route-interceptor-base';
export { MatomoRouteData, MatomoRouteDataInterceptor, } from './lib/router/interceptors/route-data-interceptor';
export { MatomoRouteData, MatomoRouteDataInterceptor, MATOMO_ROUTE_DATA_KEY, } from './lib/router/interceptors/route-data-interceptor';

@@ -1,12 +0,10 @@

# <img src="https://static.matomo.org/wp-content/uploads/2018/11/DefaultIcon.png" alt="matomo-logo" style="height: 38px; vertical-align: middle;" /> ngx-matomo-client&nbsp;&nbsp;—&nbsp;&nbsp;Matomo Analytics client for Angular
<h1 align="center">
<p><img src="https://github.com/EmmanuelRoux/ngx-matomo/blob/73fd7ede3ad8bc5adcce06d28bc45ec1f0c3810c/logo-small.png" alt="matomo-logo" style="height: 38px; vertical-align: middle;" /> ngx-matomo-client</p>
<p>Matomo Analytics client for Angular</p>
</h1>
<h3 align="center">
<div align="center">
<br>
<img src="https://static.matomo.org/wp-content/uploads/2020/03/matomo-logo-winner-mobile3-366x50.png" alt="matomo-logo" style="height: 24px; vertical-align: middle;" />
&nbsp;/&nbsp;
<img src="https://brandslogos.com/wp-content/uploads/images/large/angular-logo-1.png" style="height: 32px; vertical-align: middle;">
<br>
</h3>
<p align="center">
<div><img src="https://github.com/EmmanuelRoux/ngx-matomo/blob/73fd7ede3ad8bc5adcce06d28bc45ec1f0c3810c/logo-large.png" alt="matomo-logo" style="height: 24px; vertical-align: middle;" />
</div>
<i>

@@ -22,3 +20,3 @@ Matomo is the Google Analytics alternative that protects your data and your customers' privacy.

<br>
</p>
</div>

@@ -45,7 +43,8 @@ <p align="center">

**Note: this library was previously distributed as `@ngx-matomo/tracker` and `@ngx-matomo/router` packages.
Since version 5, it is now distributed as a single package `ngx-matomo-client`.
**Note: this library was previously distributed as `@ngx-matomo/tracker` and `@ngx-matomo/router` packages. Since version 5, it is now distributed as a single package `ngx-matomo-client`.
Follow [instructions below](#migration-from-version--4-ngx-matomotracker-and-ngx-matomorouter) for how to
easily migrate.**
[![NPM version](https://img.shields.io/npm/v/@ngx-matomo/tracker/latest.svg?logo=npm&logoColor=fff&label=Legacy+NPM+package&color=limegreen)](https://www.npmjs.com/package/@ngx-matomo/tracker)
<hr>

@@ -79,8 +78,9 @@

* [Low-level API](#low-level-api)
- [Migration from version <= 4 (`@ngx-matomo/tracker` and `@ngx-matomo/router`)](#migration-from-version--4-ngx-matomotracker-and-ngx-matomorouter)
- [Migration from `@ngx-matomo/tracker` and `@ngx-matomo/router` (version <= 4)](#migration-from-ngx-matomotracker-and-ngx-matomorouter-version--4)
- [Configuration reference](#configuration-reference)
- [FAQ](#faq)
* [How to set a page title?](#how-to-set-a-page-title)
* [How to set page title?](#how-to-set-page-title)
* [Should I include the tracking code provided by Matomo?](#should-i-include-the-tracking-code-provided-by-matomo)
* [How to disable tracking in some environments?](#how-to-disable-tracking-in-some-environments)
* [How to exclude some routes from tracking](#how-to-exclude-some-routes-from-tracking)
* [How can I customize the inserted script tag?](#how-can-i-customize-the-inserted-script-tag)

@@ -91,2 +91,3 @@ * [Can I use `ngx-matomo-client` with Server-side rendering (SSR) / Angular Universal?](#can-i-use-ngx-matomo-client-with-server-side-rendering-ssr--angular-universal)

- [Roadmap](#roadmap)
- [Contributing](#contributing)
- [Launch demo app](#launch-demo-app)

@@ -105,4 +106,4 @@

This command will set up basic configuration into your root `AppModule` (
use `ng add ngx-matomo-client --module [module]` to specify a different root module). You can then take a look
This command will set up basic configuration into your root `AppModule`
(use `ng add ngx-matomo-client --module [module]` to specify a different root module). You can then take a look
at [configuration reference](#configuration-reference) for fine-grained set-up.

@@ -114,4 +115,51 @@

Run `npm install --save ngx-matomo-client` or `yarn add ngx-matomo-client` then
manually [update your application configuration](#configuration-reference).
manually import Matomo into your Angular application:
<table>
<tr>
<th>Classic apps</th>
<th><a href="https://angular.io/guide/standalone-components">Standalone</a> apps</th>
</tr>
<tr>
<td valign="top">
```ts
import { NgxMatomoModule } from 'ngx-matomo-client';
@NgModule({
imports: [
NgxMatomoModule.forRoot({
// Your base configuration
siteId: 1,
trackerUrl: 'http://my-matomo-instance',
}),
],
})
export class AppModule {}
```
</td>
<td valign="top">
```ts
import { provideMatomo } from 'ngx-matomo-client';
@NgModule({
providers: [
provideMatomo({
// Your base configuration
siteId: 1,
trackerUrl: 'http://my-matomo-instance',
}),
],
})
export class AppModule {}
```
</td>
</tr>
</table>
Take a look at [configuration reference](#configuration-reference) for all available configuration properties.
</details>

@@ -123,9 +171,44 @@

Enable automatic page view tracking by adding `withRouter()` feature:
Enable automatic page view tracking by adding following configuration:
<table>
<tr>
<th>Classic apps</th>
<th><a href="https://angular.io/guide/standalone-components">Standalone</a> apps</th>
</tr>
<tr>
<td valign="top">
<!-- prettier-ignore -->
```ts
import {
NgxMatomoModule,
NgxMatomoRouterModule
} from 'ngx-matomo-client';
@NgModule({
imports: [
NgxMatomoModule.forRoot({
// Your configuration
}),
NgxMatomoRouterModule,
],
})
export class AppModule {}
```
</td>
<td valign="top">
<!-- prettier-ignore -->
```ts
import {
provideMatomo,
withRouter
} from 'ngx-matomo-client';
@NgModule({
providers: [
provideMatomo(
{}, // Your base configuration
{}, // Your configuration
withRouter()

@@ -138,2 +221,6 @@ ),

</td>
</tr>
</table>
This will track every page view (using Angular Router) with basic info such as page title and page url.

@@ -145,3 +232,2 @@

```typescript
import { Component, inject, OnInit } from '@angular/core';
import { MatomoTracker } from 'ngx-matomo-client';

@@ -158,2 +244,3 @@

ngOnInit() {
// Using current page's title
this.tracker.trackPageView();

@@ -171,3 +258,3 @@

Add `withRouteData()` feature to ask `ngx-matomo-client` to read some configuration from route data under `matomo` key.
1. First, declare route data under `matomo` key:

@@ -199,11 +286,30 @@ ```ts

];
```
2. Then configure `ngx-matomo-client` as following:
<table>
<tr>
<th>Classic apps</th>
<th><a href="https://angular.io/guide/standalone-components">Standalone</a> apps</th>
</tr>
<tr>
<td valign="top">
<!-- prettier-ignore -->
```ts
import {
NgxMatomoModule,
NgxMatomoRouterModule,
MatomoRouteDataInterceptor,
} from 'ngx-matomo-client';
@NgModule({
imports: [RouterModule.forRoot(routes)],
providers: [
provideMatomo(
{}, // Your base configuration
withRouter(),
withRouteData() // Add this feature
),
imports: [
NgxMatomoModule.forRoot({
// Your configuration
}),
NgxMatomoRouterModule.forRoot({
interceptors: [MatomoRouteDataInterceptor],
}),
],

@@ -214,8 +320,15 @@ })

#### Using custom interceptor
</td>
<td valign="top">
If you need custom logic to extract data, provide a custom interceptor implementation:
<!-- prettier-ignore -->
```ts
import {
provideMatomo,
withRouter,
withRouteData
} from 'ngx-matomo-client';
```typescript
@NgModule({
imports: [RouterModule.forRoot(routes)],
providers: [

@@ -225,3 +338,3 @@ provideMatomo(

withRouter(),
withRouterInterceptors([MySimpleInterceptor, MyAsyncInterceptor]) // Add this feature
withRouteData() // Add this feature
),

@@ -231,3 +344,16 @@ ],

export class AppModule {}
```
</td>
</tr>
</table>
#### Using custom interceptor
If you need custom logic to extract data, define a custom interceptor implementation:
```ts
import { MatomoRouterInterceptor, MatomoRouteInterceptorBase } from 'ngx-matomo-client';
/** An interceptor only needs to implement `MatomoRouterInterceptor` */
@Injectable()

@@ -243,7 +369,9 @@ export class MySimpleInterceptor implements MatomoRouterInterceptor {

/**
* It is also possible to extend `MatomoRouteInterceptorBase` for easy access
* to activated route snapshot
*/
@Injectable()
export class MyAsyncInterceptor extends MatomoRouteInterceptorBase<string> {
constructor(private readonly tracker: MatomoTracker, router: Router) {
super(router);
}
private readonly tracker = inject(MatomoTracker);

@@ -262,2 +390,67 @@ protected extractRouteData(route: ActivatedRouteSnapshot): string {

And provide it in your application:
<table>
<tr>
<th>Classic apps</th>
<th><a href="https://angular.io/guide/standalone-components">Standalone</a> apps</th>
</tr>
<tr>
<td valign="top">
<!-- prettier-ignore -->
```ts
import {
NgxMatomoModule,
NgxMatomoRouterModule,
MatomoRouteDataInterceptor,
} from 'ngx-matomo-client';
@NgModule({
imports: [
NgxMatomoModule.forRoot({
// Your configuration
}),
NgxMatomoRouterModule.forRoot({
// Add interceptors here:
interceptors: [
MySimpleInterceptor,
MyAsyncInterceptor
],
}),
],
})
export class AppModule {}
```
</td>
<td valign="top">
<!-- prettier-ignore -->
```typescript
import {
withRouterInterceptors,
MatomoRouterInterceptor
} from 'ngx-matomo-client';
@NgModule({
providers: [
provideMatomo(
{}, // Your base configuration
withRouter(),
// Add interceptors here:
withRouterInterceptors([
MySimpleInterceptor,
MyAsyncInterceptor
])
),
],
})
export class AppModule {}
```
</td>
</tr>
</table>
### Tracking events

@@ -326,2 +519,5 @@

_**Note for standalone components users:** all `ngx-matomo-client` components and directives are standalone
and can be imported where you need them. You may also want to import all of them at once using `MATOMO_DIRECTIVES`._
### Managing user consent: opt-in/opt-out for tracking & cookies

@@ -336,6 +532,6 @@

The _do not track_ feature is supported, just set the `acceptDoNotTrack` configuration option.
_Do not track_ feature is supported, just set `acceptDoNotTrack` configuration option.
Please note that _do-not-track_ setting is configured server-side! You should likely set this setting here to match you
server-side configuration. In case users opt-in for _do-not-track_:
Please note that _do-not-track_ setting is also configured server-side! You should likely set this setting here to match
your server-side configuration. In case users opt-in for _do-not-track_:

@@ -368,5 +564,5 @@ - If set to `true` here, users will not be tracked, independently of you server-side setting.

- `hasRememberedConsent()` / `areCookiesEnabled()`
- `getRememberedConsent()`
- `getRememberedConsent()` / `getRememberedCookieConsent()`
See also example below on how to create a consent form. Example below is about creating an opt-in form, but it may be
See also example below on how to create a consent form. Example below is about creating an opt-out form, but it may be
easily adapted using methods listed above.

@@ -455,3 +651,3 @@

## Migration from version <= 4 (`@ngx-matomo/tracker` and `@ngx-matomo/router`)
## Migration from `@ngx-matomo/tracker` and `@ngx-matomo/router` (version <= 4)

@@ -469,4 +665,4 @@ Starting from version 5, this library is distributed as a single package named `ngx-matomo-client` instead

Also, we encourage you to use the new way of providing `ngx-matomo-client` using `provideMatomo()` function instead of
importing `NgxMatomoTrackerModule` and `NgxMatomoRouterModule`.
Also, feel free to use the new `NgModule`-free way of providing `ngx-matomo-client` using `provideMatomo()` function instead of
importing `NgxMatomoModule` and `NgxMatomoRouterModule`.

@@ -479,13 +675,13 @@ ## Configuration reference

### How to set a page title?
### How to set page title?
If automatic page view tracking is enabled, then you probably have nothing to do: the page title will be detected and
sent
to Matomo.
sent to Matomo.
As of Angular 14, and as long as you don't set `withRouter({ delay: -1})`, customizing page title by setting `title`
As of Angular 14, and as long as you don't set router `delay` option to `-1`, customizing page title by setting `title`
property of Angular route config is natively supported. See Angular tutorial
here: [Setting the page title](https://angular.io/guide/router#setting-the-page-title).
If you're not using automatic page view tracking, then call `tracker.setDocumentTitle(title)` or `tracker.trackPageView(title)`.
If you're not using automatic page view tracking, then call `tracker.setDocumentTitle(title)`
or `tracker.trackPageView(title)`.

@@ -497,4 +693,6 @@ ### Should I include the tracking code provided by Matomo?

If you are not using the default configuration and set the initialization mode to `MatomoInitializationMode.MANUAL`, then
you must include the tracking code yourself [as explained on official guide](https://developer.matomo.org/guides/tracking-javascript-guide).
If you are not using the default configuration and set the initialization mode to `MatomoInitializationMode.MANUAL`,
then
you must include the tracking code
yourself [as explained on official guide](https://developer.matomo.org/guides/tracking-javascript-guide).

@@ -506,14 +704,12 @@ ### How to disable tracking in some environments?

To do so just set the `disabled` configuration switch:
To do so just set the `disabled` property to `true` in your main configuration.
For example:
```typescript
import { NgModule } from '@angular/core';
import { provideMatomo } from 'ngx-matomo-client';
import { environment } from './environment';
@NgModule({
providers: [
provideMatomo({
imports: [
NgxMatomoModule.forRoot({
/* ... */
disabled: !environment.production,
// include here your normal Matomo config
}),

@@ -525,2 +721,50 @@ ],

### How to exclude some routes from tracking
If you are using automatic route tracking and want to ignore some routes, use
the `exclude` option of router configuration:
<table>
<tr>
<th>Classic apps</th>
<th><a href="https://angular.io/guide/standalone-components">Standalone</a> apps</th>
</tr>
<tr>
<td valign="top">
```ts
@NgModule({
imports: [
NgxMatomoModule.forRoot({
/* ... */
}),
NgxMatomoRouterModule.forRoot({
exclude: [/some-pattern$/],
}),
],
})
export class AppModule {}
```
</td>
<td valign="top">
```ts
@NgModule({
providers: [
provideMatomo(
{}, // Your base configuration
withRouter({
exclude: [/some-pattern$/],
})
),
],
})
export class AppModule {}
```
</td>
</tr>
</table>
### How can I customize the inserted script tag?

@@ -531,3 +775,3 @@

To customize this script tag, provide a custom factory function:
To customize this script tag, define a custom factory function:

@@ -550,5 +794,47 @@ ```ts

}
```
And provide it to your application:
<table>
<tr>
<th>Classic apps</th>
<th><a href="https://angular.io/guide/standalone-components">Standalone</a> apps</th>
</tr>
<tr>
<td valign="top">
<!-- prettier-ignore -->
```ts
import {
MATOMO_SCRIPT_FACTORY
} from 'ngx-matomo-client';
@NgModule({
imports: [
NgxMatomoModule.forRoot({
/* ... */
}),
],
providers: [
{
provide: MATOMO_SCRIPT_FACTORY,
useValue: myScriptFactory
}
],
})
export class AppModule {}
```
</td>
<td valign="top">
<!-- prettier-ignore -->
```ts
import {
withScriptFactory
} from 'ngx-matomo-client';
@NgModule({
providers: [
provideMatomo(

@@ -560,6 +846,9 @@ { ... }, // Configuration

})
export class AppModule {
}
export class AppModule { }
```
</td>
</tr>
</table>
### Can I use `ngx-matomo-client` with Server-side rendering (SSR) / Angular Universal?

@@ -576,11 +865,9 @@

Your configuration should look like that:
Your configuration may look like that:
```typescript
import { NgModule } from '@angular/core';
import { provideMatomo } from 'ngx-matomo-client';
```ts
@NgModule({
providers: [
provideMatomo({
imports: [
NgxMatomoModule({
/* ... */
scriptUrl: 'YOUR_MATOMO_SCRIPT_URL', // your Matomo's script url

@@ -600,7 +887,9 @@ }),

@NgModule({
providers: [
provideMatomo({
imports: [
NgxMatomoModule.forRoot({
/* ... */
mode: MatomoInitializationMode.AUTO_DEFERRED,
}),
],
providers: [
// Example: use an APP_INITIALIZER

@@ -639,2 +928,6 @@ {

## Contributing
[See guide here](./CONTRIBUTING.md)
## Launch demo app

@@ -641,0 +934,0 @@

@@ -5,3 +5,3 @@ {

"ng-add": {
"description": "Add ngx-matomo tracker",
"description": "Add ngx-matomo-client library",
"factory": "./ng-add/index#ngAdd",

@@ -8,0 +8,0 @@ "schema": "./ng-add/schema.json"

@@ -15,10 +15,6 @@ "use strict";

const tasks_1 = require("@angular-devkit/schematics/tasks");
const ast_utils_1 = require("@schematics/angular/utility/ast-utils");
const change_1 = require("@schematics/angular/utility/change");
const dependencies_1 = require("@schematics/angular/utility/dependencies");
const find_module_1 = require("@schematics/angular/utility/find-module");
const workspace_1 = require("@schematics/angular/utility/workspace");
const ts = require("typescript");
const typescript_1 = require("typescript");
const schematics_utils_1 = require("../schematics-utils");
const utils_1 = require("../utils");
const version_1 = require("../version");

@@ -29,3 +25,3 @@ /***********************************************************************************/

function checkRequiredRouterDependency(host, context) {
const ngRouter = (0, dependencies_1.getPackageJsonDependency)(host, '@angular/router');
const ngRouter = (0, utils_1.getPackageJsonDependency)(host, '@angular/router');
if (!ngRouter) {

@@ -35,3 +31,3 @@ throw new schematics_1.SchematicsException(`You chose to automatically track page view, but this requires @angular/router as a dependency.\n` +

}
if (ngRouter.type !== dependencies_1.NodeDependencyType.Default) {
if (ngRouter.type !== utils_1.NodeDependencyType.Default) {
context.logger.warn(`You chose to automatically track page view, but @angular/router is listed as "${ngRouter.type}" dependency.`);

@@ -42,7 +38,11 @@ }

return (host, context) => {
(0, dependencies_1.addPackageJsonDependency)(host, {
type: dependencies_1.NodeDependencyType.Default,
(0, utils_1.addPackageJsonDependency)(host, {
type: utils_1.NodeDependencyType.Default,
name: 'ngx-matomo-client',
version: version_1.version,
});
if (!options.skipLegacyPackageMigration) {
(0, utils_1.removePackageJsonDependency)(host, '@ngx-matomo/tracker');
(0, utils_1.removePackageJsonDependency)(host, '@ngx-matomo/router');
}
if (options.router) {

@@ -82,3 +82,3 @@ checkRequiredRouterDependency(host, context);

const recorder = host.beginUpdate(modulePath);
(0, change_1.applyToUpdateRecorder)(recorder, changes);
(0, utils_1.applyToUpdateRecorder)(recorder, changes);
host.commitUpdate(recorder);

@@ -93,7 +93,7 @@ }

function findRelevantImports(source, predicate) {
const allImports = (0, ast_utils_1.findNodes)(source, ts.SyntaxKind.ImportDeclaration);
const allImports = (0, utils_1.findNodes)(source, ts.SyntaxKind.ImportDeclaration);
return allImports.filter(node => ts.isStringLiteral(node.moduleSpecifier) && predicate(node.moduleSpecifier.text));
}
function hasLegacyModuleDeclaration(source) {
const result = (0, ast_utils_1.getDecoratorMetadata)(source, 'NgModule', '@angular/core');
const result = (0, utils_1.getDecoratorMetadata)(source, 'NgModule', '@angular/core');
const node = result[0];

@@ -103,3 +103,3 @@ if (!node || !ts.isObjectLiteralExpression(node)) {

}
const matchingProperties = (0, ast_utils_1.getMetadataField)(node, 'imports');
const matchingProperties = (0, utils_1.getMetadataField)(node, 'imports');
if (!matchingProperties) {

@@ -132,3 +132,3 @@ return false;

//
// Maybe in the future a schematics can be provided to migrate old NgModule
// Maybe in the future a schematics can be provided to migrate legacy NgModule
// setup to new providers-style setup.

@@ -177,13 +177,13 @@ const imports = findRelevantImports(source, isRelevantImportPath);

if (hasLegacyModuleDeclaration(source)) {
context.logger.warn('Your configuration is using legacy configuration with NgModule imports. ' +
'While this is still supported, it is recommended to migrate your code to use the new provideMatomo() setup (see README > Installation)');
context.logger.info('Your configuration is using classic configuration with NgModule imports. ' +
'While this is still fully supported, you may want to take a look at the new NgModule-free setup using provideMatomo() (see README > Installation)');
if (!mainModuleImported) {
changes.push((0, ast_utils_1.insertImport)(source, modulePath, mainModuleIdentifier, 'ngx-matomo-client'));
changes.push((0, utils_1.insertImport)(source, modulePath, mainModuleIdentifier, 'ngx-matomo-client'));
}
changes.push(...(0, ast_utils_1.addSymbolToNgModuleMetadata)(source, modulePath, 'imports', `${mainModuleIdentifier}.forRoot(${trackerConfig})`));
changes.push(...(0, utils_1.addSymbolToNgModuleMetadata)(source, modulePath, 'imports', `${mainModuleIdentifier}.forRoot(${trackerConfig})`));
if (options.router) {
if (!routerModuleImported) {
changes.push((0, ast_utils_1.insertImport)(source, modulePath, routerModuleIdentifier, 'ngx-matomo-client'));
changes.push((0, utils_1.insertImport)(source, modulePath, routerModuleIdentifier, 'ngx-matomo-client'));
}
changes.push(...(0, ast_utils_1.addSymbolToNgModuleMetadata)(source, modulePath, 'imports', routerModuleIdentifier));
changes.push(...(0, utils_1.addSymbolToNgModuleMetadata)(source, modulePath, 'imports', routerModuleIdentifier));
}

@@ -193,8 +193,8 @@ }

const provideMatomoArgs = [trackerConfig];
changes.push((0, ast_utils_1.insertImport)(source, modulePath, 'provideMatomo', 'ngx-matomo-client'));
changes.push((0, utils_1.insertImport)(source, modulePath, 'provideMatomo', 'ngx-matomo-client'));
if (options.router) {
changes.push((0, ast_utils_1.insertImport)(source, modulePath, 'withRouter', 'ngx-matomo-client'));
changes.push((0, utils_1.insertImport)(source, modulePath, 'withRouter', 'ngx-matomo-client'));
provideMatomoArgs.push(`withRouter()`);
}
changes.push(...(0, ast_utils_1.addSymbolToNgModuleMetadata)(source, modulePath, 'providers', `provideMatomo(${provideMatomoArgs.join(', ')})`));
changes.push(...(0, utils_1.addSymbolToNgModuleMetadata)(source, modulePath, 'providers', `provideMatomo(${provideMatomoArgs.join(', ')})`));
}

@@ -208,3 +208,3 @@ applyChanges(host, modulePath, changes);

if (!options.skipLegacyPackageMigration) {
context.logger.info('Migrating imports from old @ngx-matomo/* packages...');
context.logger.info('Migrating imports from legacy @ngx-matomo/* packages...');
host.visit(path => {

@@ -230,3 +230,3 @@ // if (options.module && path.endsWith(options.module) && !options.skipImport) {

const newFullText = fullText.replace(text, 'ngx-matomo-client');
changes.push(new change_1.ReplaceChange(path, pos, fullText, newFullText));
changes.push(new utils_1.ReplaceChange(path, pos, fullText, newFullText));
}

@@ -245,5 +245,5 @@ }

if (options.path === undefined) {
options.path = yield (0, workspace_1.createDefaultPath)(host, options.project);
options.path = yield (0, utils_1.createDefaultPath)(host, options.project);
}
options.module = (0, find_module_1.findModuleFromOptions)(host, {
options.module = (0, utils_1.findModuleFromOptions)(host, {
skipImport: options.skipImport,

@@ -250,0 +250,0 @@ path: options.path,

@@ -1,1 +0,1 @@

export declare const version = "^5.0.0-next.2";
export declare const version = "^5.0.0";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = void 0;
exports.version = '^5.0.0-next.2';
exports.version = '^5.0.0';
//# sourceMappingURL=version.js.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc