@maestro_io/maestro-web-sdk 2.2.2 → 2.2.3

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.
@@ -1,4 +1,3 @@
1
- import { BaseMetadata } from '../../../services/AnalyticsService/types';
2
1
  /**
3
2
  * Valid bet types as specified in the analytics spec
4
3
  */
@@ -7,19 +6,3 @@ export type BetType = 'straight' | 'parlay' | 'parlay_plus' | 'teaser' | 'boost'
7
6
  * Valid card types for bets module
8
7
  */
9
8
  export type BetCardType = '6-pack' | 'my bets > live' | 'my bets > settled' | 'my bets > upcoming' | 'hot-props' | 'promo' | 'disclaimer';
10
- /**
11
- * Metadata for bet panel view events
12
- */
13
- export interface BetPanelViewMetadata extends BaseMetadata {
14
- in_game_bets: number;
15
- total_bets: number;
16
- }
17
- /**
18
- * Metadata for bet card click events
19
- */
20
- export interface BetCardClickMetadata extends BaseMetadata {
21
- card: BetCardType;
22
- in_game_bets: number;
23
- total_bets: number;
24
- bet_type: BetType | null;
25
- }
@@ -138,10 +138,6 @@ export declare class BetsViewModel extends ViewModel {
138
138
  * Track card click event
139
139
  */
140
140
  trackCardClick(cardType: BetCardType, betType?: BetType | null): Promise<void>;
141
- /**
142
- * Get base metadata for analytics events
143
- */
144
- private getBaseMetadata;
145
141
  /**
146
142
  * Get user bet counts for analytics
147
143
  */
@@ -4,6 +4,7 @@ import { DrivePlay, Team } from '../interfaces/IStats';
4
4
  import { AthletesStatisticsItem } from '../view/components/AthletesStatistics/AthletesStatistics';
5
5
  import StatsService from '@/services/StatsService';
6
6
  import IMaestroEventDelegate from '@/interfaces/IMaestroEventDelegate';
7
+ import { TestUseCase } from '@/interfaces/IMaestroEvent';
7
8
  import AnalyticsService from '@/services/AnalyticsService/AnalyticsService';
8
9
  declare const STATS_ERROR_STATE: {
9
10
  readonly NONE: "none";
@@ -166,6 +167,10 @@ export declare class StatsViewModel extends ViewModel {
166
167
  private parseGameLeaders;
167
168
  private parseActiveAthletes;
168
169
  private getActiveAthletesTeamInfo;
170
+ /**
171
+ * Simulate a use case using mock StatsApiResponse data
172
+ */
173
+ simulateUseCase<T = any>(_useCase: TestUseCase, testData?: T): void;
169
174
  /**
170
175
  * Stop polling for bet data
171
176
  */
@@ -1,31 +1,20 @@
1
1
  import InsightsPayloadBuilder from '../InsightsService/InsightsPayloadBuilder';
2
2
  import InsightsService from '../InsightsService/InsightsService';
3
- import { Metadata } from './types';
3
+ import { PageConfig } from '../PageService/types';
4
+ import { BaseMetadata } from './types';
4
5
  type KeyPlaysClickedAction = {
5
- panel_id: string;
6
- panel_name: string;
7
- panel_type: string;
6
+ type: 'espnKeyPlays';
8
7
  name: 'key_play_clicked';
9
8
  metadata: {
10
- league: string;
11
- event: string;
12
- airing: string;
13
- sport: string;
14
9
  action: string;
15
10
  clip: string;
16
11
  key_play: string;
17
12
  };
18
13
  };
19
14
  type BetsItemClickedAction = {
20
- panel_id: string;
21
- panel_name: string;
22
- panel_type: string;
15
+ type: 'espnBet';
23
16
  name: 'bets_item_clicked';
24
17
  metadata: {
25
- league: string;
26
- event: string;
27
- airing: string;
28
- sport: string;
29
18
  card: string;
30
19
  bet_type: string | null;
31
20
  in_game_bets: number;
@@ -33,25 +22,18 @@ type BetsItemClickedAction = {
33
22
  };
34
23
  };
35
24
  type StatsItemClickedAction = {
36
- panel_id: string;
37
- panel_name: string;
38
- panel_type: string;
25
+ type: 'espnStats';
39
26
  name: 'stats_item_clicked';
40
27
  metadata: {
41
- league: string;
42
- event: string;
43
- airing: string;
44
- sport: string;
45
28
  card: string[];
46
29
  game_state: string[];
47
30
  };
48
31
  };
49
32
  type PanelClickPayload = KeyPlaysClickedAction | BetsItemClickedAction | StatsItemClickedAction;
50
- type PanelViewPayload = {
33
+ type PanelData = {
51
34
  panel_type: string;
52
35
  panel_id: string;
53
36
  panel_name: string;
54
- metadata: Metadata;
55
37
  };
56
38
  declare class AnalyticsService {
57
39
  insightsService: InsightsService;
@@ -59,7 +41,9 @@ declare class AnalyticsService {
59
41
  constructor();
60
42
  private trackAction;
61
43
  private trackImpression;
62
- panelView({ panel_type, panel_id, panel_name, metadata, }: PanelViewPayload): Promise<void>;
63
- panelClick({ panel_type, panel_id, panel_name, metadata, name, }: PanelClickPayload): Promise<void>;
44
+ panelView(panelType: 'espnStats' | 'espnKeyPlays' | 'espnBet', metadata?: Record<string, any>): Promise<void>;
45
+ panelClick({ type, metadata, name }: PanelClickPayload): Promise<void>;
46
+ getBaseMetadataFromPageConfig(pageConfig: PageConfig | null): BaseMetadata;
47
+ getPanelDataFromPageConfig(type: 'espnBet' | 'espnStats' | 'espnKeyPlays', pageConfig: PageConfig | null): PanelData;
64
48
  }
65
49
  export default AnalyticsService;
@@ -1,5 +1,6 @@
1
1
  import { ICacheManager } from '@/external/ports/cacheManager';
2
2
  import InsightsService from './InsightsService';
3
+ import { PageConfig } from '../PageService/types';
3
4
  type EventData = {
4
5
  url?: string;
5
6
  metadata?: Record<string, unknown>;
@@ -18,6 +19,7 @@ export default class InsightsPayloadBuilder {
18
19
  serverOffsetTime: number;
19
20
  insightsService: InsightsService;
20
21
  cacheManager: ICacheManager;
22
+ pageConfig: PageConfig | null;
21
23
  constructor();
22
24
  getPayload(event: EventData): Promise<{
23
25
  /**
@@ -128,12 +130,12 @@ export default class InsightsPayloadBuilder {
128
130
  * @description Site domain.
129
131
  * @example site.settings.domain.url. 'maestro.tv/site_slug'
130
132
  */
131
- si_d: string;
133
+ si_d: string | undefined;
132
134
  /**
133
135
  * @description Site ID.
134
136
  * @example site._id
135
137
  */
136
- si_id: string;
138
+ si_id: string | undefined;
137
139
  /**
138
140
  * @description Site package ID.
139
141
  * @example `${site.package.id}-sapphire`
@@ -183,7 +185,7 @@ export default class InsightsPayloadBuilder {
183
185
  * @description Unique identifier for the insights ID. Stored in site's document.
184
186
  * @example site.settings.services.insights_id
185
187
  */
186
- i_id: string;
188
+ i_id: string | null | undefined;
187
189
  /**
188
190
  * @description Device created timestamp. You might wanna keep this fixed for the device you're in using a local storage or something related
189
191
  * @example new Date().getTime()
@@ -242,22 +244,22 @@ export default class InsightsPayloadBuilder {
242
244
  * @description MongoDB page document ID (e.g. 'pageId')
243
245
  * @example object._id
244
246
  */
245
- p_id: string;
247
+ p_id: string | undefined;
246
248
  /**
247
249
  * @description MongoDB page name (e.g. 'Home', 'Product Page')
248
250
  * @example object.data.name || object.seo.title
249
251
  */
250
- p_n: string;
252
+ p_n: string | undefined;
251
253
  /**
252
254
  * @description MongoDB page slug (e.g. 'home', 'product-page')
253
255
  * @example object.slug
254
256
  */
255
- p_s: string;
257
+ p_s: string | undefined;
256
258
  /**
257
259
  * @description MongoDB page type (e.g. 'landing', 'channel')
258
260
  * @example object.type
259
261
  */
260
- p_t: string;
262
+ p_t: string | undefined;
261
263
  }>;
262
264
  private getEventInsights;
263
265
  private getPageInsights;
@@ -0,0 +1,8 @@
1
+ import { Observable } from '../../helpers/Observable';
2
+ import { PageConfig } from './types';
3
+ export default class PageService {
4
+ configObservable: Observable<PageConfig | null>;
5
+ private client;
6
+ constructor();
7
+ fetchPageConfig(siteId: string, eventId: string): Promise<PageConfig | null>;
8
+ }
@@ -0,0 +1,2 @@
1
+ import PageService from './PageService';
2
+ export default PageService;
@@ -0,0 +1,2 @@
1
+ import { PageConfig } from './types';
2
+ export declare const MOCK_PAGE_CONFIG: PageConfig;
@@ -0,0 +1,53 @@
1
+ import ITheme from '@/models/ITheme';
2
+ interface PageConfigPanel {
3
+ _id: string;
4
+ slug: string;
5
+ panel_name?: string;
6
+ panel_type?: string;
7
+ icon_name?: string;
8
+ }
9
+ export type PageMetadata = {
10
+ /**
11
+ * Event ID or Airing ID
12
+ */
13
+ external_field_1?: string;
14
+ /**
15
+ * Sport guid
16
+ */
17
+ external_field_2?: string;
18
+ /**
19
+ * League guid
20
+ */
21
+ external_field_3?: string;
22
+ /**
23
+ * External field 1 identifier. Can be either 'airing' or 'event'.
24
+ */
25
+ external_field_4?: 'airing' | 'event';
26
+ /**
27
+ * A stringified JSON object containing additional metadata.
28
+ */
29
+ external_field_5?: string;
30
+ };
31
+ export interface PageConfig {
32
+ panels: PageConfigPanel[];
33
+ page: {
34
+ _id: string;
35
+ slug: string;
36
+ type: string;
37
+ name?: string;
38
+ metadata?: PageMetadata;
39
+ };
40
+ insights: {
41
+ _id: string | null;
42
+ };
43
+ site: {
44
+ _id: string;
45
+ domainUrl: string;
46
+ package: {
47
+ version: string;
48
+ id: string;
49
+ };
50
+ };
51
+ theme?: ITheme | null;
52
+ }
53
+ export {};
@@ -1,5 +1,9 @@
1
1
  import { Observable } from '../helpers/Observable';
2
2
  import { MaestroPanelType } from '../models/IPanel';
3
+ export type PanelInfo = {
4
+ type: MaestroPanelType;
5
+ title: string;
6
+ };
3
7
  export declare class PanelManagerViewModel {
4
8
  private _panels;
5
9
  private _currentPanel;
@@ -7,6 +11,7 @@ export declare class PanelManagerViewModel {
7
11
  private settingsManager;
8
12
  private settingsUnsubscribe;
9
13
  private readonly ALL_PANELS;
14
+ private getAvailablePanelsFromConfig;
10
15
  constructor();
11
16
  /**
12
17
  * Initialize panels based on current settings
@@ -17,9 +22,10 @@ export declare class PanelManagerViewModel {
17
22
  */
18
23
  private subscribeToSettingsChanges;
19
24
  /**
20
- * Filter panels based on user settings
25
+ * Filter panels based on user settings and page config
21
26
  */
22
- private filterPanelsBasedOnSettings;
27
+ private filterPanels;
28
+ private updateActivePanel;
23
29
  /**
24
30
  * Update panels when settings change
25
31
  */
@@ -28,11 +34,11 @@ export declare class PanelManagerViewModel {
28
34
  * Cleanup subscriptions
29
35
  */
30
36
  cleanup(): void;
31
- get panels(): MaestroPanelType[];
32
- get panelsObservable(): Observable<MaestroPanelType[]>;
33
- get currentPanel(): MaestroPanelType;
34
- set currentPanel(value: MaestroPanelType);
35
- get currentPanelObservable(): Observable<MaestroPanelType>;
37
+ get panels(): PanelInfo[];
38
+ get panelsObservable(): Observable<PanelInfo[]>;
39
+ get currentPanel(): MaestroPanelType | null;
40
+ set currentPanel(value: MaestroPanelType | null);
41
+ get currentPanelObservable(): Observable<MaestroPanelType | null>;
36
42
  get newlyFocusedPanel(): MaestroPanelType | null;
37
43
  set newlyFocusedPanel(value: MaestroPanelType | null);
38
44
  getIndex(forPanelType: MaestroPanelType): number | null;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@maestro_io/maestro-web-sdk",
3
3
  "private": false,
4
- "version": "2.2.2",
4
+ "version": "2.2.3",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "main": "dist/maestro-web-sdk.umd.js",