@power-seo/tracking 1.0.10 → 1.0.12
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/README.md +52 -53
- package/package.json +30 -15
package/README.md
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
# @power-seo/tracking
|
|
2
2
|
|
|
3
|
-

|
|
4
4
|
|
|
5
5
|
Consent-aware analytics script builders and GDPR consent management for TypeScript — GA4, Microsoft Clarity, PostHog, Plausible, and Fathom with a unified `shouldLoad(consentState)` API and React components.
|
|
6
6
|
|
|
7
7
|
[](https://www.npmjs.com/package/@power-seo/tracking)
|
|
8
8
|
[](https://www.npmjs.com/package/@power-seo/tracking)
|
|
9
9
|
[](https://socket.dev/npm/package/@power-seo/tracking)
|
|
10
|
-
[](https://github.com/CyberCraftBD/power-seo/actions)
|
|
11
10
|
[](https://opensource.org/licenses/MIT)
|
|
12
11
|
[](https://www.typescriptlang.org/)
|
|
13
12
|
[](https://bundlephobia.com/package/@power-seo/tracking)
|
|
@@ -30,7 +29,13 @@ Consent-aware analytics script builders and GDPR consent management for TypeScri
|
|
|
30
29
|
| Performance | ❌ Scripts block LCP before user interaction | ✅ Lazy loading strategy prevents render blocking |
|
|
31
30
|
| TypeScript | ❌ Loose config objects with no type checking | ✅ Typed `ScriptConfig`, `ConsentState`, `ConsentManager` |
|
|
32
31
|
|
|
33
|
-

|
|
33
|
+
|
|
34
|
+
<p align="left">
|
|
35
|
+
<a href="https://www.buymeacoffee.com/ccbd.dev" target="_blank">
|
|
36
|
+
<img src="https://img.buymeacoffee.com/button-api/?text=Buy%20me%20a%20coffee&emoji=&slug=ccbd.dev&button_colour=FFDD00&font_colour=000000&font_family=Cookie&outline_colour=000000&coffee_colour=ffffff" />
|
|
37
|
+
</a>
|
|
38
|
+
</p>
|
|
34
39
|
|
|
35
40
|
---
|
|
36
41
|
|
|
@@ -50,7 +55,7 @@ Consent-aware analytics script builders and GDPR consent management for TypeScri
|
|
|
50
55
|
- **Full TypeScript support** — typed config interfaces, consent state, and response shapes for every provider
|
|
51
56
|
- **Tree-shakeable** — import only the providers you use; zero dead code in your bundle
|
|
52
57
|
|
|
53
|
-

|
|
54
59
|
|
|
55
60
|
---
|
|
56
61
|
|
|
@@ -67,7 +72,7 @@ Consent-aware analytics script builders and GDPR consent management for TypeScri
|
|
|
67
72
|
| TypeScript-first | ❌ | ❌ | ❌ | ✅ |
|
|
68
73
|
| React components | ⚠️ | ❌ | ✅ | ✅ |
|
|
69
74
|
|
|
70
|
-

|
|
71
76
|
|
|
72
77
|
---
|
|
73
78
|
|
|
@@ -118,7 +123,7 @@ const nowToLoad = scripts.filter((s) => s.shouldLoad(consent.getState()));
|
|
|
118
123
|
// nowToLoad → [GA4Script1, GA4Script2, PlausibleScript]
|
|
119
124
|
```
|
|
120
125
|
|
|
121
|
-

|
|
122
127
|
|
|
123
128
|
---
|
|
124
129
|
|
|
@@ -213,18 +218,12 @@ export function CookieBanner() {
|
|
|
213
218
|
import { createGA4Client, createPlausibleClient } from '@power-seo/tracking';
|
|
214
219
|
|
|
215
220
|
// Query GA4 reports
|
|
216
|
-
const ga4 = createGA4Client(
|
|
217
|
-
measurementId: 'G-XXXXXXX',
|
|
218
|
-
apiSecret: process.env.GA4_API_SECRET!,
|
|
219
|
-
});
|
|
221
|
+
const ga4 = createGA4Client(process.env.GA4_ACCESS_TOKEN!);
|
|
220
222
|
|
|
221
223
|
// Query Plausible stats
|
|
222
|
-
const plausible = createPlausibleClient(
|
|
223
|
-
domain: 'example.com',
|
|
224
|
-
apiKey: process.env.PLAUSIBLE_API_KEY!,
|
|
225
|
-
});
|
|
224
|
+
const plausible = createPlausibleClient(process.env.PLAUSIBLE_API_KEY!);
|
|
226
225
|
|
|
227
|
-
const stats = await plausible.getAggregate(
|
|
226
|
+
const stats = await plausible.getAggregate('your-site-id', '7d');
|
|
228
227
|
console.log(stats.visitors, stats.pageviews);
|
|
229
228
|
```
|
|
230
229
|
|
|
@@ -268,12 +267,16 @@ export function AnalyticsLoader() {
|
|
|
268
267
|
|
|
269
268
|
### `ScriptConfig`
|
|
270
269
|
|
|
271
|
-
| Prop
|
|
272
|
-
|
|
|
273
|
-
| `
|
|
274
|
-
| `
|
|
275
|
-
| `
|
|
276
|
-
| `
|
|
270
|
+
| Prop | Type | Description |
|
|
271
|
+
| ----------------- | ------------------------------------- | -------------------------------------- |
|
|
272
|
+
| `id` | `string` | Unique script identifier |
|
|
273
|
+
| `src` | `string \| undefined` | External script URL |
|
|
274
|
+
| `innerHTML` | `string \| undefined` | Inline JavaScript content |
|
|
275
|
+
| `async` | `boolean \| undefined` | Load asynchronously |
|
|
276
|
+
| `defer` | `boolean \| undefined` | Defer execution |
|
|
277
|
+
| `consentCategory` | `ConsentCategory` | Required consent category for loading |
|
|
278
|
+
| `attributes` | `Record<string, string> \| undefined` | Additional script attributes |
|
|
279
|
+
| `shouldLoad` | `(consent: ConsentState) => boolean` | Returns `true` if this script may load |
|
|
277
280
|
|
|
278
281
|
### `createConsentManager(initialState)`
|
|
279
282
|
|
|
@@ -284,17 +287,18 @@ export function AnalyticsLoader() {
|
|
|
284
287
|
| `grantAll` | `() => void` | Grant all non-necessary categories |
|
|
285
288
|
| `revokeAll` | `() => void` | Revoke all non-necessary categories |
|
|
286
289
|
| `getState` | `() => ConsentState` | Get the current consent snapshot |
|
|
290
|
+
| `isGranted` | `(category: ConsentCategory) => boolean` | Check if a category is granted |
|
|
287
291
|
| `onChange` | `(cb: ConsentChangeCallback) => () => void` | Subscribe to changes; returns unsubscribe |
|
|
288
292
|
|
|
289
293
|
### API Clients
|
|
290
294
|
|
|
291
|
-
| Function |
|
|
292
|
-
| ----------------------- |
|
|
293
|
-
| `createGA4Client` | `
|
|
294
|
-
| `createClarityClient` | `
|
|
295
|
-
| `createPostHogClient` | `
|
|
296
|
-
| `createPlausibleClient` | `
|
|
297
|
-
| `createFathomClient` | `
|
|
295
|
+
| Function | Parameters | Returns | Description |
|
|
296
|
+
| ----------------------- | --------------------------------- | ----------------- | --------------------------- |
|
|
297
|
+
| `createGA4Client` | `(accessToken: string)` | `GA4Client` | Google Analytics 4 Data API |
|
|
298
|
+
| `createClarityClient` | `(apiKey: string)` | `ClarityClient` | Microsoft Clarity API |
|
|
299
|
+
| `createPostHogClient` | `(apiKey: string, host?: string)` | `PostHogClient` | PostHog API |
|
|
300
|
+
| `createPlausibleClient` | `(apiKey: string)` | `PlausibleClient` | Plausible Stats API |
|
|
301
|
+
| `createFathomClient` | `(apiKey: string)` | `FathomClient` | Fathom Analytics API |
|
|
298
302
|
|
|
299
303
|
### React Components
|
|
300
304
|
|
|
@@ -305,23 +309,25 @@ export function AnalyticsLoader() {
|
|
|
305
309
|
|
|
306
310
|
### Types
|
|
307
311
|
|
|
308
|
-
| Type | Description
|
|
309
|
-
| ----------------------- |
|
|
310
|
-
| `ConsentCategory` | `'necessary' \| 'analytics' \| 'marketing' \| 'preferences'`
|
|
311
|
-
| `ConsentState` | `{ necessary
|
|
312
|
-
| `ConsentManager` | Store with grant/revoke/grantAll/revokeAll/getState/onChange
|
|
313
|
-
| `ConsentChangeCallback` | `(state: ConsentState) => void`
|
|
314
|
-
| `ScriptConfig` | `{ src?,
|
|
315
|
-
| `GA4Config` | `{ measurementId
|
|
316
|
-
| `
|
|
317
|
-
| `
|
|
318
|
-
| `
|
|
319
|
-
| `
|
|
320
|
-
| `
|
|
321
|
-
| `
|
|
322
|
-
| `
|
|
323
|
-
| `
|
|
324
|
-
| `
|
|
312
|
+
| Type | Description |
|
|
313
|
+
| ----------------------- | ------------------------------------------------------------------------------------ |
|
|
314
|
+
| `ConsentCategory` | `'necessary' \| 'analytics' \| 'marketing' \| 'preferences'` |
|
|
315
|
+
| `ConsentState` | `{ necessary, analytics, marketing, preferences }` all boolean |
|
|
316
|
+
| `ConsentManager` | Store with grant/revoke/grantAll/revokeAll/getState/isGranted/onChange |
|
|
317
|
+
| `ConsentChangeCallback` | `(state: ConsentState) => void` |
|
|
318
|
+
| `ScriptConfig` | `{ id, src?, innerHTML?, async?, defer?, consentCategory, attributes?, shouldLoad }` |
|
|
319
|
+
| `GA4Config` | `{ measurementId, consentModeV2?, anonymizeIp?, sendPageView? }` |
|
|
320
|
+
| `GA4ReportRequest` | `{ startDate, endDate, metrics, dimensions?, limit? }` |
|
|
321
|
+
| `GA4ReportResponse` | `{ rows, rowCount, metadata? }` |
|
|
322
|
+
| `GA4Client` | Methods: queryReport, getRealtimeReport, getMetadata |
|
|
323
|
+
| `ClarityConfig` | `{ projectId: string }` |
|
|
324
|
+
| `ClarityClient` | Methods: getProjects, getInsights, getHeatmapData |
|
|
325
|
+
| `PostHogConfig` | `{ apiKey: string, host?: string }` |
|
|
326
|
+
| `PostHogClient` | Methods: queryEvents, getTrends, getFunnels |
|
|
327
|
+
| `PlausibleConfig` | `{ domain: string, selfHostedUrl?: string }` |
|
|
328
|
+
| `PlausibleClient` | Methods: getTimeseries, getBreakdown, getAggregate |
|
|
329
|
+
| `FathomConfig` | `{ siteId: string }` |
|
|
330
|
+
| `FathomClient` | Methods: getSites, getPageviews, getReferrers |
|
|
325
331
|
|
|
326
332
|
---
|
|
327
333
|
|
|
@@ -356,7 +362,6 @@ export function AnalyticsLoader() {
|
|
|
356
362
|
- No install scripts (`postinstall`, `preinstall`)
|
|
357
363
|
- No runtime network access outside of analytics API calls
|
|
358
364
|
- No `eval` or dynamic code execution
|
|
359
|
-
- npm provenance enabled — every release is signed via Sigstore through GitHub Actions
|
|
360
365
|
- CI-signed builds — all releases published via verified `github.com/CyberCraftBD/power-seo` workflow
|
|
361
366
|
- Safe for SSR, Edge, and browser environments
|
|
362
367
|
|
|
@@ -371,7 +376,7 @@ All 17 packages are independently installable — use only what you need.
|
|
|
371
376
|
| [`@power-seo/core`](https://www.npmjs.com/package/@power-seo/core) | `npm i @power-seo/core` | Framework-agnostic utilities, types, validators, and constants |
|
|
372
377
|
| [`@power-seo/react`](https://www.npmjs.com/package/@power-seo/react) | `npm i @power-seo/react` | React SEO components — meta, Open Graph, Twitter Card, breadcrumbs |
|
|
373
378
|
| [`@power-seo/meta`](https://www.npmjs.com/package/@power-seo/meta) | `npm i @power-seo/meta` | SSR meta helpers for Next.js App Router, Remix v2, and generic SSR |
|
|
374
|
-
| [`@power-seo/schema`](https://www.npmjs.com/package/@power-seo/schema) | `npm i @power-seo/schema` | Type-safe JSON-LD structured data — 23 builders +
|
|
379
|
+
| [`@power-seo/schema`](https://www.npmjs.com/package/@power-seo/schema) | `npm i @power-seo/schema` | Type-safe JSON-LD structured data — 23 builders + 22 React components |
|
|
375
380
|
| [`@power-seo/content-analysis`](https://www.npmjs.com/package/@power-seo/content-analysis) | `npm i @power-seo/content-analysis` | Yoast-style SEO content scoring engine with React components |
|
|
376
381
|
| [`@power-seo/readability`](https://www.npmjs.com/package/@power-seo/readability) | `npm i @power-seo/readability` | Readability scoring — Flesch-Kincaid, Gunning Fog, Coleman-Liau, ARI |
|
|
377
382
|
| [`@power-seo/preview`](https://www.npmjs.com/package/@power-seo/preview) | `npm i @power-seo/preview` | SERP, Open Graph, and Twitter/X Card preview generators |
|
|
@@ -388,12 +393,6 @@ All 17 packages are independently installable — use only what you need.
|
|
|
388
393
|
|
|
389
394
|
---
|
|
390
395
|
|
|
391
|
-
## Keywords
|
|
392
|
-
|
|
393
|
-
analytics · ga4 · google-analytics · microsoft-clarity · posthog · plausible · fathom · gdpr · consent-management · cookie-consent · typescript · react · nextjs · privacy · script-loader · analytics-api · tracking · seo-analytics · consent-banner · gdpr-compliance
|
|
394
|
-
|
|
395
|
-
---
|
|
396
|
-
|
|
397
396
|
## About [CyberCraft Bangladesh](https://ccbd.dev)
|
|
398
397
|
|
|
399
398
|
**[CyberCraft Bangladesh](https://ccbd.dev)** is a Bangladesh-based enterprise-grade software development and Full Stack SEO service provider company specializing in ERP system development, AI-powered SaaS and business applications, full-stack SEO services, custom website development, and scalable eCommerce platforms. We design and develop intelligent, automation-driven SaaS and enterprise solutions that help startups, SMEs, NGOs, educational institutes, and large organizations streamline operations, enhance digital visibility, and accelerate growth through modern cloud-native technologies.
|
package/package.json
CHANGED
|
@@ -1,7 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@power-seo/tracking",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"description": "Analytics platform integration with script builders, consent management, and React components",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"seo",
|
|
7
|
+
"analytics",
|
|
8
|
+
"ga4",
|
|
9
|
+
"google-analytics",
|
|
10
|
+
"clarity",
|
|
11
|
+
"microsoft-clarity",
|
|
12
|
+
"posthog",
|
|
13
|
+
"plausible",
|
|
14
|
+
"fathom",
|
|
15
|
+
"tracking",
|
|
16
|
+
"gdpr",
|
|
17
|
+
"consent-management",
|
|
18
|
+
"cookie-consent",
|
|
19
|
+
"consent",
|
|
20
|
+
"react",
|
|
21
|
+
"nextjs",
|
|
22
|
+
"privacy",
|
|
23
|
+
"script-loader",
|
|
24
|
+
"gdpr-compliance",
|
|
25
|
+
"typescript"
|
|
26
|
+
],
|
|
5
27
|
"license": "MIT",
|
|
6
28
|
"type": "module",
|
|
7
29
|
"exports": {
|
|
@@ -20,8 +42,14 @@
|
|
|
20
42
|
"module": "./dist/index.js",
|
|
21
43
|
"types": "./dist/index.d.ts",
|
|
22
44
|
"files": [
|
|
23
|
-
"dist"
|
|
45
|
+
"dist",
|
|
46
|
+
"LICENSE"
|
|
24
47
|
],
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">=18.0.0",
|
|
50
|
+
"npm": ">=9.0.0",
|
|
51
|
+
"pnpm": ">=8.0.0"
|
|
52
|
+
},
|
|
25
53
|
"peerDependencies": {
|
|
26
54
|
"react": "^18.0.0 || ^19.0.0"
|
|
27
55
|
},
|
|
@@ -41,19 +69,6 @@
|
|
|
41
69
|
"typescript": "^5.7.0",
|
|
42
70
|
"vitest": "^2.1.0"
|
|
43
71
|
},
|
|
44
|
-
"keywords": [
|
|
45
|
-
"seo",
|
|
46
|
-
"analytics",
|
|
47
|
-
"ga4",
|
|
48
|
-
"clarity",
|
|
49
|
-
"posthog",
|
|
50
|
-
"plausible",
|
|
51
|
-
"fathom",
|
|
52
|
-
"tracking",
|
|
53
|
-
"consent",
|
|
54
|
-
"react",
|
|
55
|
-
"typescript"
|
|
56
|
-
],
|
|
57
72
|
"sideEffects": false,
|
|
58
73
|
"author": "CyberCraft Bangladesh <info@ccbd.dev>",
|
|
59
74
|
"repository": {
|