@su-labs/visit-tracker 21.0.4 β 21.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/README.md +139 -22
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [21.0.5] - 2026-02-04
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
- Update README.md
|
|
12
|
+
|
|
8
13
|
## [21.0.4] - 2026-02-03
|
|
9
14
|
|
|
10
15
|
### Changed
|
package/README.md
CHANGED
|
@@ -1,7 +1,43 @@
|
|
|
1
1
|
# SuVisitTrackerService
|
|
2
2
|
|
|
3
|
+
`@su-labs/visit-tracker`
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
9
|
+

|
|
10
|
+

|
|
11
|
+

|
|
12
|
+

|
|
13
|
+
|
|
3
14
|
A lightweight Angular service to track user visits. Provides reactive signals for visit count, last visit date, and milestone visits.
|
|
4
15
|
|
|
16
|
+
## π Table of Contents
|
|
17
|
+
|
|
18
|
+
- [Why Use This Library?](#-why-use-this-library)
|
|
19
|
+
- [Features](#features)
|
|
20
|
+
- [Installation](#installation)
|
|
21
|
+
- [Quick Start](#-quick-start)
|
|
22
|
+
- [Usage](#usage)
|
|
23
|
+
- [API Reference](#-api-reference)
|
|
24
|
+
- [Configuration Options](#configuration-options)
|
|
25
|
+
- [Browser Compatibility](#-browser-compatibility)
|
|
26
|
+
- [Related Libraries](#-related-libraries)
|
|
27
|
+
- [Troubleshooting](#-troubleshooting)
|
|
28
|
+
- [Support](#-support)
|
|
29
|
+
- [Contributing](#contributing)
|
|
30
|
+
- [License](#license)
|
|
31
|
+
|
|
32
|
+
## π‘ Why Use This Library?
|
|
33
|
+
|
|
34
|
+
- π― **Lightweight** - Only ~5KB minified
|
|
35
|
+
- β‘ **Reactive** - Built with Angular Signals
|
|
36
|
+
- π **Type-Safe** - Full TypeScript support
|
|
37
|
+
- π¦ **Zero Dependencies** - No bloat
|
|
38
|
+
- π§ͺ **Well Tested** - Comprehensive test coverage
|
|
39
|
+
- π **Well Documented** - Clear examples and API docs
|
|
40
|
+
|
|
5
41
|
## Features
|
|
6
42
|
|
|
7
43
|
* Tracks number of visits per user.
|
|
@@ -24,15 +60,34 @@ npm install @su-labs/visit-tracker
|
|
|
24
60
|
This library requires the following peer dependencies:
|
|
25
61
|
|
|
26
62
|
```sh
|
|
27
|
-
npm install @angular/common@^
|
|
63
|
+
npm install @angular/common@^21 @angular/core@^21
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## π Quick Start
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
// 1. Install
|
|
70
|
+
npm install @su-labs/visit-tracker
|
|
71
|
+
|
|
72
|
+
// 2. Inject in your component
|
|
73
|
+
import { Component, inject } from '@angular/core';
|
|
74
|
+
import { SuVisitTrackerService } from '@su-labs/visit-tracker';
|
|
75
|
+
|
|
76
|
+
@Component({
|
|
77
|
+
selector: 'app-root',
|
|
78
|
+
template: `<p>Visits: {{ visitService.count() }}</p>`
|
|
79
|
+
})
|
|
80
|
+
export class AppComponent {
|
|
81
|
+
visitService = inject(SuVisitTrackerService);
|
|
82
|
+
}
|
|
28
83
|
```
|
|
29
84
|
|
|
30
85
|
## Usage
|
|
86
|
+
|
|
31
87
|
### Example 1: Basic initialization
|
|
32
88
|
The service should be provided at the root level. To use it in a component, simply inject it:
|
|
33
89
|
|
|
34
90
|
```TypeScript
|
|
35
|
-
|
|
36
91
|
import { Component, inject } from '@angular/core';
|
|
37
92
|
import { CommonModule, DatePipe } from '@angular/common';
|
|
38
93
|
import { SuVisitTrackerService } from '@su-labs/visit-tracker';
|
|
@@ -60,14 +115,13 @@ export class AppComponent {
|
|
|
60
115
|
You can reactively check if a milestone visit has been reached:
|
|
61
116
|
|
|
62
117
|
```HTML
|
|
118
|
+
@if(visitService.isTenthVisit()){
|
|
119
|
+
<p>π Congratulations on your 10th visit!</p>
|
|
120
|
+
}
|
|
63
121
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
@if(visitService.isHundredthVisit()){
|
|
69
|
-
<p>π 100 visits! You're a power user!</p>
|
|
70
|
-
}
|
|
122
|
+
@if(visitService.isHundredthVisit()){
|
|
123
|
+
<p>π 100 visits! You're a power user!</p>
|
|
124
|
+
}
|
|
71
125
|
```
|
|
72
126
|
|
|
73
127
|
Signals `isTenthVisit` and `isHundredthVisit` update automatically on service initialization.
|
|
@@ -76,7 +130,6 @@ Signals `isTenthVisit` and `isHundredthVisit` update automatically on service in
|
|
|
76
130
|
For standalone apps, use provideAppInitializer to initialize the tracker with a custom storage key or milestones:
|
|
77
131
|
|
|
78
132
|
```TypeScript
|
|
79
|
-
|
|
80
133
|
import { provideAppInitializer, inject } from '@angular/core';
|
|
81
134
|
import { SuVisitTrackerService, SuVisitTrackerConfig } from '@su-labs/visit-tracker';
|
|
82
135
|
|
|
@@ -93,24 +146,49 @@ export const appConfig = {
|
|
|
93
146
|
}),
|
|
94
147
|
],
|
|
95
148
|
};
|
|
96
|
-
|
|
97
149
|
```
|
|
150
|
+
|
|
98
151
|
β
Allows overriding the localStorage key and defining custom milestone visits.
|
|
99
152
|
|
|
100
|
-
###
|
|
153
|
+
### Example 4: Using last visit date
|
|
101
154
|
|
|
102
155
|
```HTML
|
|
103
|
-
|
|
104
156
|
@if(visitService.lastVisit() as last) {
|
|
105
157
|
<p>
|
|
106
158
|
Your last visit was on {{ last | date:'fullDate' }} at {{ last | date:'shortTime' }}
|
|
107
159
|
</p>
|
|
108
|
-
|
|
160
|
+
}
|
|
109
161
|
```
|
|
110
162
|
|
|
111
163
|
The service stores last visit as an ISO string (e.g., "2025-08-25T12:34:56.789Z"), so it can easily be used in Angular date pipes.
|
|
112
164
|
|
|
113
|
-
##
|
|
165
|
+
## π API Reference
|
|
166
|
+
|
|
167
|
+
### Signals
|
|
168
|
+
|
|
169
|
+
| Signal | Type | Description |
|
|
170
|
+
|--------|------|-------------|
|
|
171
|
+
| `count()` | `number` | Current visit count |
|
|
172
|
+
| `lastVisit()` | `string \| null` | ISO string of last visit date |
|
|
173
|
+
| `isTenthVisit()` | `boolean` | True if current count is 10 |
|
|
174
|
+
| `isHundredthVisit()` | `boolean` | True if current count is 100 |
|
|
175
|
+
|
|
176
|
+
### Methods
|
|
177
|
+
|
|
178
|
+
| Method | Parameters | Description |
|
|
179
|
+
|--------|------------|-------------|
|
|
180
|
+
| `init(config?)` | `SuVisitTrackerConfig` | Initialize with custom configuration |
|
|
181
|
+
|
|
182
|
+
### Types
|
|
183
|
+
|
|
184
|
+
```typescript
|
|
185
|
+
interface SuVisitTrackerConfig {
|
|
186
|
+
storageKey?: string; // Default: 'su:visits'
|
|
187
|
+
milestoneVisits?: number[]; // Default: [10, 100]
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Configuration Options
|
|
114
192
|
|
|
115
193
|
The service can be configured to fit your application's needs. You can customize the storage key and milestone values by passing a configuration object to the `init()` method.
|
|
116
194
|
|
|
@@ -119,15 +197,55 @@ The service can be configured to fit your application's needs. You can customize
|
|
|
119
197
|
| `storageKey` | The key used to persist the visit data in `localStorage`. | `'su:visits'` |
|
|
120
198
|
| `milestoneVisits` | An array of numbers representing visits to track as milestones. | `[10, 100]` |
|
|
121
199
|
|
|
122
|
-
##
|
|
200
|
+
## π Browser Compatibility
|
|
201
|
+
|
|
202
|
+
Works in all modern browsers that support:
|
|
203
|
+
- β
localStorage API
|
|
204
|
+
- β
Angular 21+
|
|
205
|
+
- β
ES2022+
|
|
206
|
+
|
|
207
|
+
| Browser | Version |
|
|
208
|
+
|---------|---------|
|
|
209
|
+
| Chrome | β₯ 90 |
|
|
210
|
+
| Firefox | β₯ 88 |
|
|
211
|
+
| Safari | β₯ 14 |
|
|
212
|
+
| Edge | β₯ 90 |
|
|
123
213
|
|
|
124
|
-
|
|
214
|
+
## π Related Libraries
|
|
125
215
|
|
|
126
|
-
|
|
216
|
+
Part of the **@su-labs** suite:
|
|
127
217
|
|
|
128
|
-
-
|
|
218
|
+
- π¨ [@su-labs/theme](https://www.npmjs.com/package/@su-labs/theme) - Theme management with dark mode support
|
|
219
|
+
- π [@su-labs/notifications](https://www.npmjs.com/package/@su-labs/notifications) - Toast notification system
|
|
220
|
+
- π [@su-labs/scroll-spy](https://www.npmjs.com/package/@su-labs/scroll-spy) - Scroll position tracking
|
|
221
|
+
- π [@su-labs/font-size](https://www.npmjs.com/package/@su-labs/font-size) - Accessible font size controls
|
|
129
222
|
|
|
130
|
-
|
|
223
|
+
## π§ Troubleshooting
|
|
224
|
+
|
|
225
|
+
### Visit count not persisting?
|
|
226
|
+
|
|
227
|
+
Make sure localStorage is enabled in your browser and not blocked by privacy settings.
|
|
228
|
+
|
|
229
|
+
### Milestone signals not updating?
|
|
230
|
+
|
|
231
|
+
Milestones are only checked during service initialization. Call `init()` to recalculate.
|
|
232
|
+
|
|
233
|
+
### TypeScript errors?
|
|
234
|
+
|
|
235
|
+
Ensure you have Angular 21+ and TypeScript 5.7+ installed.
|
|
236
|
+
|
|
237
|
+
## π¬ Support
|
|
238
|
+
|
|
239
|
+
- π Found a bug? [Open an issue](https://github.com/Greezaaa/settings-utils-lib/issues)
|
|
240
|
+
- π‘ Have a feature request? [Start a discussion](https://github.com/Greezaaa/settings-utils-lib/discussions)
|
|
241
|
+
- β Like this library? [Give it a star!](https://github.com/Greezaaa/settings-utils-lib)
|
|
242
|
+
|
|
243
|
+
## Notes
|
|
244
|
+
|
|
245
|
+
- **Signals-based API**: Perfect for standalone components and reactive Angular templates.
|
|
246
|
+
- **Persistence**: Visit count and last visit are automatically stored in localStorage.
|
|
247
|
+
- **Lightweight**: No external dependencies and minimal memory footprint.
|
|
248
|
+
- **Custom milestones**: Track any number of user visit milestones reactively.
|
|
131
249
|
|
|
132
250
|
## Contributing
|
|
133
251
|
|
|
@@ -137,5 +255,4 @@ To contribute code, please ensure your changes include unit tests to maintain co
|
|
|
137
255
|
|
|
138
256
|
## License
|
|
139
257
|
|
|
140
|
-
This project is licensed under the MIT License. See the [**LICENSE**](https://github.com/Greezaaa/settings-utils-lib/blob/main/projects/su-labs/visit-tracker/LICENSE) file for details.
|
|
141
|
-
|
|
258
|
+
This project is licensed under the MIT License. See the [**LICENSE**](https://github.com/Greezaaa/settings-utils-lib/blob/main/projects/su-labs/visit-tracker/LICENSE) file for details.
|