@deltabreen/analytics-angular 0.0.0-stage → 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 DeltaBreen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,33 @@
1
- # Temporary Holding Version
1
+ # @deltabreen/analytics-angular
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Analytics by DeltaBreen for Angular 19 and later, with or without zone.js and server rendering. It loads the same
4
+ per-site script as the `<script>` tag, so pageviews (route changes included), heatmaps, errors, Web Vitals,
5
+ experiments, recordings and surveys all work the same. On a server it does nothing.
6
+
7
+ ```bash
8
+ npm install @deltabreen/analytics-angular
9
+ ```
10
+
11
+ ```ts
12
+ // app.config.ts
13
+ import { provideAnalytics } from '@deltabreen/analytics-angular';
14
+
15
+ export const appConfig: ApplicationConfig = { providers: [provideAnalytics({ siteKey: 'ans_YOUR_KEY' })] };
16
+ ```
17
+
18
+ ```ts
19
+ import { injectVariant, injectFlag, track } from '@deltabreen/analytics-angular';
20
+
21
+ @Component({ selector: 'app-hero', template: `<h1 (click)="clicked()">{{ variant() === 'b' ? 'Ship faster' : 'Build better' }}</h1>` })
22
+ export class Hero {
23
+ variant = injectVariant('hero-copy'); // a read-only signal; call it where inject() works
24
+ beta = injectFlag('beta');
25
+ clicked() { track('Hero clicked'); }
26
+ }
27
+ ```
28
+
29
+ `provideAnalytics` takes `origin: '/stats'` to load and send through your own domain (see the proxy docs) and
30
+ `consent: 'tcf'` to follow a consent banner on the IAB's framework. Both signals start at the original and change only
31
+ after the first render in a browser, so a server render and hydration agree.
32
+
33
+ Docs: https://analytics.deltabreen.eu/docs/install
package/index.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import type { EnvironmentProviders, Signal } from '@angular/core';
2
+ import type { InitOptions } from '@deltabreen/analytics';
3
+ export * from '@deltabreen/analytics';
4
+ /** Loads the tracker as the app starts: in bootstrapApplication's or app.config's providers. */
5
+ export function provideAnalytics(options: InitOptions): EnvironmentProviders;
6
+ /** The variant this person sees, or null for the original until the first render and the tracker has loaded. */
7
+ export function injectVariant(key: string): Signal<string | null>;
8
+ /** Whether a feature flag is on for this person, false until the first render and the tracker has loaded. */
9
+ export function injectFlag(key: string): Signal<boolean>;
package/index.js ADDED
@@ -0,0 +1,25 @@
1
+ // Angular helpers: provideAnalytics({ siteKey: 'ans_…' }) in the app's providers, and injectVariant / injectFlag, called
2
+ // where inject() works (a field or constructor), for signals of a variant and a flag. Both start at the original
3
+ // (null / false) and change only after the first render in a browser, so a server render and hydration agree.
4
+ // Plain functions, no decorators: nothing needs Angular's compiler. Navigations are counted by the tracker itself.
5
+ import { afterNextRender, makeEnvironmentProviders, provideEnvironmentInitializer, signal } from '@angular/core';
6
+ import { flag, init, ready, variant } from '@deltabreen/analytics';
7
+
8
+ export * from '@deltabreen/analytics';
9
+
10
+ /** Loads the tracker as the app starts (nothing on a server). */
11
+ export function provideAnalytics(options) {
12
+ return makeEnvironmentProviders([provideEnvironmentInitializer(() => init(options))]);
13
+ }
14
+
15
+ function injectTracker(read, initial, key) {
16
+ const value = signal(initial);
17
+ afterNextRender(() => {
18
+ value.set(read(key));
19
+ ready().then(() => value.set(read(key)));
20
+ });
21
+ return value.asReadonly();
22
+ }
23
+
24
+ export const injectVariant = (key) => injectTracker(variant, null, key);
25
+ export const injectFlag = (key) => injectTracker(flag, false, key);
package/package.json CHANGED
@@ -1,6 +1,43 @@
1
1
  {
2
2
  "name": "@deltabreen/analytics-angular",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Analytics by DeltaBreen for Angular: a provider and signals for experiment variants and feature flags.",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./index.d.ts",
9
+ "default": "./index.js"
10
+ },
11
+ "./package.json": "./package.json"
12
+ },
13
+ "files": [
14
+ "index.js",
15
+ "index.d.ts",
16
+ "README.md",
17
+ "LICENSE"
18
+ ],
19
+ "sideEffects": false,
20
+ "dependencies": {
21
+ "@deltabreen/analytics": "^0.2.0"
22
+ },
23
+ "peerDependencies": {
24
+ "@angular/core": ">=19"
25
+ },
26
+ "engines": {
27
+ "node": ">=18"
28
+ },
29
+ "license": "MIT",
30
+ "scripts": {
31
+ "test": "node --test test/*.test.mjs"
32
+ },
33
+ "keywords": [
34
+ "analytics",
35
+ "cookieless",
36
+ "heatmaps",
37
+ "ab-testing",
38
+ "feature-flags",
39
+ "deltabreen",
40
+ "angular"
41
+ ],
42
+ "homepage": "https://analytics.deltabreen.eu/docs/install"
43
+ }