fansunited-frontend-core 0.0.74 → 0.0.76

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 CHANGED
@@ -33,6 +33,7 @@ in particular **no `@mui/*` package has to be installed**.
33
33
  - Shared utilities and helper functions
34
34
  - React providers and hooks
35
35
  - Component primitives
36
+ - Typed analytics events for tag-manager and analytics integrations
36
37
 
37
38
  ## Core Exports
38
39
 
@@ -119,6 +120,8 @@ import {
119
120
  BetslipProps,
120
121
  BetslipState,
121
122
  PredictorBetslipConfig,
123
+ PredictorCallbacks,
124
+ ComponentEvent,
122
125
  } from "fansunited-frontend-core";
123
126
  ```
124
127
 
@@ -158,6 +161,14 @@ import {
158
161
  SelectionStatus,
159
162
  OddsFormat,
160
163
  PredictorBetslipTrigger,
164
+
165
+ // Component analytics events
166
+ ComponentEvent,
167
+ ComponentEventParams,
168
+ PredictorComponentEvent,
169
+ PredictorCallbacks,
170
+ PredictorAnalyticsContext,
171
+ PredictorAnalyticsEventName,
161
172
  } from "fansunited-frontend-core";
162
173
  ```
163
174
 
@@ -354,6 +365,44 @@ function MatchCard({ eventId, market, outcome }) {
354
365
  }
355
366
  ```
356
367
 
368
+ ### Component Events Bus
369
+
370
+ `componentEvents` is a singleton bus carrying analytics events emitted by the components —
371
+ `widget_view`, `prediction_submitted`, `private_league_joined` and the rest. Use it when you cannot
372
+ reach the component's JSX: a tag manager, a separately-bundled script, anything loading after mount.
373
+
374
+ > **Important:** import `componentEvents` from `fansunited-frontend-components`, not from
375
+ > `fansunited-frontend-core` — same reason as `betslipApi`. The components package bundles its own
376
+ > copy of the bus, so importing from there guarantees you get the singleton the components emit on.
377
+ > The **types** below come from core.
378
+
379
+ ```tsx
380
+ import { componentEvents } from "fansunited-frontend-components";
381
+ import type { ComponentEvent } from "fansunited-frontend-core";
382
+
383
+ const unsubscribe = componentEvents.subscribe((event: ComponentEvent) => {
384
+ if (event.component !== "predictor") return;
385
+ console.log(event.name, event.params, event.context);
386
+ });
387
+ ```
388
+
389
+ `subscribe` returns an unsubscribe function. It **replays recent events** to a new subscriber (the
390
+ last 50, within the last 5 minutes), so a listener that attaches after the component mounted still
391
+ sees `widget_view` and anything else it missed.
392
+
393
+ The bus is **subscribe-only**: there is no public emit, so nothing else on the page can forge events
394
+ into your analytics. `ComponentEvent` is discriminated on `component` — narrow it before reading
395
+ `name` / `context`, and code keeps compiling when more components start emitting.
396
+
397
+ Payloads are flat primitives and carry **no personal data** — no profile id, email, display name or
398
+ token; only `context.userIsLoggedIn`. Identifiers in the payloads (`match_id`, `home_team_id`, …) are
399
+ canonical and provider-agnostic, so they are the fields to join on; team *names* are localised by the
400
+ `language` prop and are for display only.
401
+
402
+ Emitting components: `Predictor` today. See the `Predictor` section of the
403
+ [`fansunited-frontend-components` README](https://www.npmjs.com/package/fansunited-frontend-components)
404
+ for the full event catalogue and the tag-manager setup.
405
+
357
406
  ## Call-to-Action (CTA) Interfaces
358
407
 
359
408
  The package provides several CTA interfaces for different use cases:
@@ -0,0 +1,17 @@
1
+ import { ComponentEvent } from '../interfaces/interfaces';
2
+
3
+ type Listener = (event: ComponentEvent) => void;
4
+ /** What consumers get. Deliberately read-only — see `componentEventsEmitter`. */
5
+ export interface ComponentEventsApi {
6
+ /** Observe every component event. Returns an unsubscribe function. */
7
+ subscribe(listener: Listener): () => void;
8
+ }
9
+ /** @internal Emit side, for the component packages only. Never expose this on a global. */
10
+ export interface ComponentEventsEmitter {
11
+ emit(event: ComponentEvent): void;
12
+ }
13
+ export declare const componentEvents: ComponentEventsApi;
14
+ /** @internal Not re-exported from `fansunited-frontend-components`. */
15
+ export declare const componentEventsEmitter: ComponentEventsEmitter;
16
+ export {};
17
+ //# sourceMappingURL=componentEvents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"componentEvents.d.ts","sourceRoot":"","sources":["../../src/api/componentEvents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,KAAK,QAAQ,GAAG,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;AAahD,iFAAiF;AACjF,MAAM,WAAW,kBAAkB;IACjC,sEAAsE;IACtE,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,IAAI,CAAC;CAC3C;AAED,2FAA2F;AAC3F,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI,CAAC;CACnC;AA8DD,eAAO,MAAM,eAAe,EAAE,kBAAwB,CAAC;AAEvD,uEAAuE;AACvE,eAAO,MAAM,sBAAsB,EAAE,sBAA4B,CAAC"}
package/index.d.ts CHANGED
@@ -2,6 +2,8 @@ export declare const version: string;
2
2
  export * from './constants/constants';
3
3
  export { betslipApi } from './api/betslipApi';
4
4
  export type { BetslipState } from './api/betslipApi';
5
+ export { componentEvents, componentEventsEmitter } from './api/componentEvents';
6
+ export type { ComponentEventsApi, ComponentEventsEmitter, } from './api/componentEvents';
5
7
  export * from './functions/functions';
6
8
  export * from './interfaces/interfaces';
7
9
  export * from './types/types';
package/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,EAAE,MAAyB,CAAC;AAEhD,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,YAAY,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,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