@streamlayer/react 0.40.3 → 0.41.1

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.
@@ -28,10 +28,78 @@ declare module "../../sdk-web-types/src/sl-types" {
28
28
  export type Question = PlainMessage<IQuestion>;
29
29
  export type ExtendedQuestion = PlainMessage<IExtendedQuestion>;
30
30
  export { SdkOverlayType as FeatureType, SdkOverlaySettings, GamesOverlaySettings, } from '@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb';
31
+ export { InvitationFrom } from '@streamlayer/sl-eslib/analytics/v1/invitations/invitations_pb';
31
32
  }
32
33
  declare module "../../sdk-web-types/src/index" {
33
34
  export * from "../../sdk-web-types/src/sl-types";
34
35
  }
36
+ declare module "../../sdk-web-logger/src/index" {
37
+ import { pino, ChildLoggerOptions } from 'pino';
38
+ export const createLogger: (name: string, options?: ChildLoggerOptions) => pino.Logger<never>;
39
+ export type Logger = ReturnType<typeof createLogger>;
40
+ }
41
+ declare module "../../sdk-web-interfaces/src/event-bus/index" {
42
+ import { InvitationFrom, QuestionType } from '../../sdk-web-types/src/index.ts';
43
+ const EventBusActions: {
44
+ notification: {
45
+ received: string;
46
+ opened: string;
47
+ rendered: string;
48
+ closed: string;
49
+ };
50
+ invitation: {
51
+ accepted: string;
52
+ sent: string;
53
+ };
54
+ interactions: {
55
+ tap: string;
56
+ scroll: string;
57
+ };
58
+ poll: {
59
+ voted: string;
60
+ navigated: string;
61
+ opened: string;
62
+ received: string;
63
+ onboardingPassed: string;
64
+ };
65
+ };
66
+ export type EventBusActionPayload = {
67
+ notification: {
68
+ eventId?: string;
69
+ questionId?: string;
70
+ questionType?: QuestionType;
71
+ };
72
+ invitation: {
73
+ from?: InvitationFrom;
74
+ };
75
+ interactions: unknown;
76
+ poll: {
77
+ questionId?: string;
78
+ questionType?: QuestionType;
79
+ questionOpenedFrom?: 'list' | 'notification';
80
+ };
81
+ };
82
+ type EventBusActionsKeys = keyof typeof EventBusActions;
83
+ type EventBusActions<T> = T extends EventBusActionsKeys ? keyof (typeof EventBusActions)[T] : never;
84
+ export type EventBusData<T extends EventBusActionsKeys = EventBusActionsKeys> = {
85
+ type: T;
86
+ action: EventBusActions<T>;
87
+ payload: EventBusActionPayload[T];
88
+ };
89
+ export class EventBusEvent<T extends EventBusActionsKeys = EventBusActionsKeys> extends Event {
90
+ slEventBus?: EventBusData<T>;
91
+ constructor(name: string, payload?: EventBusData<T>);
92
+ }
93
+ export class EventBus {
94
+ private name;
95
+ private listeners;
96
+ constructor(name?: string);
97
+ emit: <K extends "notification" | "invitation" | "interactions" | "poll" = "notification" | "invitation" | "interactions" | "poll">(type: K, payload: Omit<EventBusData<K>, "type">) => void;
98
+ listen<T extends EventBusActionsKeys>(listener: (event: EventBusEvent<T>) => void): () => void;
99
+ off<T extends EventBusActionsKeys>(listener: (event: EventBusEvent<T>) => void): void;
100
+ destroy: () => void;
101
+ }
102
+ }
35
103
  declare module "../../sdk-web-interfaces/src/auth" {
36
104
  export abstract class AbstractAuthenticationProvider {
37
105
  abstract login(...args: unknown[]): Promise<unknown>;
@@ -41,7 +109,7 @@ declare module "../../sdk-web-interfaces/src/auth" {
41
109
  }
42
110
  }
43
111
  declare module "../../sdk-web-interfaces/src/store/abstract" {
44
- import type { AnyStore } from 'nanostores';
112
+ import { type AnyStore } from 'nanostores';
45
113
  global {
46
114
  interface Window {
47
115
  slStore: any;
@@ -88,7 +156,7 @@ declare module "../../sdk-web-interfaces/src/store/abstract" {
88
156
  export const mergeStores: <T extends Record<string, AbstractStore<AnyStore>>, K = { [Index in keyof T]: ReturnType<T[Index]["getStore"]>["value"]; }>(stores: T) => import("nanostores").ReadableAtom<K>;
89
157
  }
90
158
  declare module "../../sdk-web-interfaces/src/store/map" {
91
- import type { MapStoreKeys, MapStore as NMapStore } from 'nanostores';
159
+ import { type MapStoreKeys, type MapStore as NMapStore } from 'nanostores';
92
160
  import { AbstractStore } from "../../sdk-web-interfaces/src/store/abstract";
93
161
  /**
94
162
  * Wrapper for nanostores MapStore
@@ -154,7 +222,7 @@ declare module "../../sdk-web-interfaces/src/feature" {
154
222
  }
155
223
  }
156
224
  declare module "../../sdk-web-interfaces/src/store/single" {
157
- import type { StoreValue, WritableAtom } from 'nanostores';
225
+ import { type StoreValue, type WritableAtom } from 'nanostores';
158
226
  import { AbstractStore } from "../../sdk-web-interfaces/src/store/abstract";
159
227
  /**
160
228
  * Wrapper for nanostores WritableAtom
@@ -199,6 +267,7 @@ declare module "../../sdk-web-interfaces/src/store/api" {
199
267
  }
200
268
  declare module "../../sdk-web-interfaces/src/index" {
201
269
  import { FeatureType } from '../../sdk-web-types/src/index.ts';
270
+ import { EventBus, EventBusEvent, EventBusData, EventBusActionPayload } from "../../sdk-web-interfaces/src/event-bus/index";
202
271
  export { AbstractAuthenticationProvider } from "../../sdk-web-interfaces/src/auth";
203
272
  export { AbstractFeature, FeatureSource, type FeatureProps, FeatureStatus } from "../../sdk-web-interfaces/src/feature";
204
273
  export { MapStore, createMapStore } from "../../sdk-web-interfaces/src/store/map";
@@ -206,7 +275,10 @@ declare module "../../sdk-web-interfaces/src/index" {
206
275
  export { SingleStore, createSingleStore, createComputedStore } from "../../sdk-web-interfaces/src/store/single";
207
276
  export { AbstractStore, mergeStores } from "../../sdk-web-interfaces/src/store/abstract";
208
277
  export { ApiStore } from "../../sdk-web-interfaces/src/store/api";
278
+ export type CancelMountCb = () => void;
279
+ export type OnMountCb = () => CancelMountCb;
209
280
  export interface StreamLayerSDK {
281
+ onMount: (cb: OnMountCb) => void;
210
282
  closeFeature: (destroy?: boolean) => void;
211
283
  openFeature: (featureType: FeatureType) => void;
212
284
  }
@@ -215,15 +287,12 @@ declare module "../../sdk-web-interfaces/src/index" {
215
287
  }
216
288
  type DoneFn = Function;
217
289
  export type StreamLayerPlugin = (instance: StreamLayerContext, opts: unknown, done: DoneFn) => void;
290
+ export const eventBus: EventBus;
291
+ export type { EventBusEvent, EventBusData, EventBusActionPayload };
218
292
  }
219
293
  declare module "../../sdk-web-api/src/utils/devtools" {
220
294
  export const __GRPC_DEVTOOLS_EXTENSION__: any;
221
295
  }
222
- declare module "../../sdk-web-logger/src/index" {
223
- import { pino, ChildLoggerOptions } from 'pino';
224
- export const createLogger: (name: string, options?: ChildLoggerOptions) => pino.Logger<never>;
225
- export type Logger = ReturnType<typeof createLogger>;
226
- }
227
296
  declare module "../../sdk-web-api/src/grpc/retry" {
228
297
  import { type Interceptor } from '@connectrpc/connect';
229
298
  /**
@@ -276,17 +345,18 @@ declare module "../../sdk-web-api/src/grpc/retry" {
276
345
  export const retry: Interceptor;
277
346
  }
278
347
  declare module "../../sdk-web-api/src/grpc/transport" {
348
+ import { MapStore } from '../../sdk-web-interfaces/src/index.ts';
279
349
  import { createRouterTransport, ConnectRouter, Interceptor, PromiseClient, UnaryRequest, StreamRequest } from '@connectrpc/connect';
280
350
  import type { ServiceType, Message, PlainMessage } from '@bufbuild/protobuf';
281
351
  import { createGrpcWebTransport } from '@connectrpc/connect-web';
282
- import type { KeyInput } from '@nanostores/query';
283
- import { nanoquery } from '@nanostores/query';
352
+ import { type KeyInput, nanoquery } from '@nanostores/query';
284
353
  import { Atom } from 'nanostores';
285
354
  import { ServerStreamSubscription, type ServerStreamSubscriptionOptions } from "../../sdk-web-api/src/grpc/subscription";
286
355
  type KnownHeaders = {
287
356
  authorization?: string;
288
357
  sdk?: string;
289
358
  'sl-device-id': string;
359
+ 'sl-device-os': string;
290
360
  'sl-user-id'?: string;
291
361
  } & Record<string, string>;
292
362
  export type GrpcTransport = Transport['transport'];
@@ -322,10 +392,10 @@ declare module "../../sdk-web-api/src/grpc/transport" {
322
392
  readonly streamTransport: ReturnType<typeof createGrpcWebTransport>;
323
393
  readonly nanoquery: NanoqueryObjectType;
324
394
  readonly host: string;
395
+ readonly $headers: MapStore<KnownHeaders>;
325
396
  protected interceptors: Interceptor[];
326
- private readonly $headers;
327
397
  private clients;
328
- private callbackClients;
398
+ private streamClients;
329
399
  private subscriptions;
330
400
  constructor(host: string);
331
401
  addSubscription: <T extends ServiceType, Req extends Message<Req>, Res extends Message<Res>>(method: { [P in keyof PromiseClient<T> as T["methods"][P] extends import("@bufbuild/protobuf").MethodInfoServerStreaming<any, any> ? P : never]: T["methods"][P] extends import("@bufbuild/protobuf").MethodInfoServerStreaming<any, any> ? PromiseClient<T>[P] : never; }[keyof { [P in keyof PromiseClient<T> as T["methods"][P] extends import("@bufbuild/protobuf").MethodInfoServerStreaming<any, any> ? P : never]: T["methods"][P] extends import("@bufbuild/protobuf").MethodInfoServerStreaming<any, any> ? PromiseClient<T>[P] : never; }], params: PlainMessage<Req> | Atom<PlainMessage<Req>>, options: ServerStreamSubscriptionOptions) => ServerStreamSubscription<ServiceType, Message<import("@bufbuild/protobuf").AnyMessage>, Message<import("@bufbuild/protobuf").AnyMessage>, never, never> | ServerStreamSubscription<T, Req, Res, keyof { [P in keyof PromiseClient<T> as T["methods"][P] extends import("@bufbuild/protobuf").MethodInfoServerStreaming<any, any> ? P : never]: T["methods"][P] extends import("@bufbuild/protobuf").MethodInfoServerStreaming<any, any> ? PromiseClient<T>[P] : never; }, { [P in keyof PromiseClient<T> as T["methods"][P] extends import("@bufbuild/protobuf").MethodInfoServerStreaming<any, any> ? P : never]: T["methods"][P] extends import("@bufbuild/protobuf").MethodInfoServerStreaming<any, any> ? PromiseClient<T>[P] : never; }[keyof { [P in keyof PromiseClient<T> as T["methods"][P] extends import("@bufbuild/protobuf").MethodInfoServerStreaming<any, any> ? P : never]: T["methods"][P] extends import("@bufbuild/protobuf").MethodInfoServerStreaming<any, any> ? PromiseClient<T>[P] : never; }]>;
@@ -489,11 +559,13 @@ declare module "../../sdk-web-api/src/index" {
489
559
  }
490
560
  interface StreamLayerContext {
491
561
  transport: Transport;
562
+ analyticsTransport: Transport;
492
563
  }
493
564
  }
494
565
  export const transport: (instance: StreamLayerContext, opts: {
495
566
  sdkKey: string;
496
567
  host: string;
568
+ analyticsHost: string;
497
569
  version?: string;
498
570
  }, done: () => void) => void;
499
571
  }
@@ -692,8 +764,7 @@ declare module "../../sdk-web-core/src/store/store" {
692
764
  };
693
765
  }
694
766
  declare module "../../sdk-web-core/src/deepLink/index" {
695
- import { StreamLayerContext } from '../../sdk-web-interfaces/src/index.ts';
696
- import { MapStore } from '../../sdk-web-interfaces/src/index.ts';
767
+ import { MapStore, StreamLayerContext } from '../../sdk-web-interfaces/src/index.ts';
697
768
  type DeepLinkContextData = {
698
769
  handled?: boolean;
699
770
  parsed?: boolean;
@@ -870,7 +941,7 @@ declare module "../../sdk-web-core/src/index" {
870
941
  import { StreamLayerContext } from '../../sdk-web-interfaces/src/index.ts';
871
942
  export { bypass, storage } from "../../sdk-web-core/src/auth/index";
872
943
  export { store } from "../../sdk-web-core/src/store/index";
873
- export { deepLink, type DeepLinkUrlParams, type DeepLinkCallback, DEEP_LINK_PREFIX, DEEP_LINK_USER_ID, DEEP_LINK_EVENT_ID, DEEP_LINK_EXTERNAL_EVENT_ID, } from "../../sdk-web-core/src/deepLink/index";
944
+ export { deepLink, type DeepLinkUrlParams, type DeepLinkCallback, type DeepLinkContext, DEEP_LINK_PREFIX, DEEP_LINK_USER_ID, DEEP_LINK_EVENT_ID, DEEP_LINK_EXTERNAL_EVENT_ID, } from "../../sdk-web-core/src/deepLink/index";
874
945
  export { videoPlayer, type VideoPlayerCallback } from "../../sdk-web-core/src/videoPlayer/index";
875
946
  import "../../sdk-web-core/src/store/index";
876
947
  import "../../sdk-web-core/src/auth/index";
@@ -883,6 +954,9 @@ declare module "../../sdk-web-core/src/index" {
883
954
  disableApp: () => void;
884
955
  createEventSession: (providerStreamId: string) => void;
885
956
  }
957
+ interface StreamLayerContext {
958
+ ready: () => void;
959
+ }
886
960
  }
887
961
  /**
888
962
  * The main application instance is the core of a application. It includes:
@@ -923,7 +997,7 @@ declare module "../../sdk-web-notifications/src/queue/index" {
923
997
  addToQueue: (notification: Notification) => void;
924
998
  tickWaitingQueue: () => void;
925
999
  tickActiveQueue: (notificationId: string) => void;
926
- closeNotification: (notificationId: string) => void;
1000
+ closeNotification: (notificationId: string) => Notification | undefined;
927
1001
  }
928
1002
  }
929
1003
  declare module "../../sdk-web-notifications/src/storage" {
@@ -939,6 +1013,7 @@ declare module "../../sdk-web-notifications/src/notifications" {
939
1013
  import { InstantView, QuestionType, GameSettings, TweetHistory } from '../../sdk-web-types/src/index.ts';
940
1014
  import { NotificationsQueue, NotificationsQueueOptions } from "../../sdk-web-notifications/src/queue/index";
941
1015
  export type NotificationData = {
1016
+ questionId: string;
942
1017
  questionType: QuestionType;
943
1018
  question?: {
944
1019
  title: string;
@@ -978,6 +1053,7 @@ declare module "../../sdk-web-notifications/src/notifications" {
978
1053
  action?: (...args: unknown[]) => void;
979
1054
  close?: (...args: unknown[]) => void;
980
1055
  methods?: M;
1056
+ emitEvent?: boolean;
981
1057
  data: NotificationData;
982
1058
  id: string;
983
1059
  persistent?: boolean;
@@ -991,6 +1067,7 @@ declare module "../../sdk-web-notifications/src/notifications" {
991
1067
  constructor(options?: Partial<NotificationsQueueOptions>);
992
1068
  add: (notification: Notification) => void;
993
1069
  close: (notificationId: string, markAsViewed?: boolean) => void;
1070
+ getActiveNotification: () => Notification | null;
994
1071
  getQueueStore: () => import("nanostores").WritableAtom<Map<string, Notification> | undefined>;
995
1072
  markAsViewed: (notificationId: string) => void;
996
1073
  }
@@ -1008,6 +1085,7 @@ declare module "../../sdk-web-notifications/src/index" {
1008
1085
  }
1009
1086
  interface StreamLayerSDK {
1010
1087
  getNotificationsStore: Notifications['getQueueStore'];
1088
+ getActiveNotification: Notifications['getActiveNotification'];
1011
1089
  }
1012
1090
  }
1013
1091
  /**
@@ -1367,7 +1445,7 @@ declare module "../../feature-gamification/src/queries/index" {
1367
1445
  }, QuestionSubscriptionRequest, QuestionSubscriptionResponse, "subscription" | "votingSubscription" | "questionSubscription" | "feedSubscription", ((request: import("@bufbuild/protobuf").PartialMessage<SubscriptionRequest>, options?: import("@connectrpc/connect").CallOptions | undefined) => AsyncIterable<SubscriptionResponse>) | ((request: import("@bufbuild/protobuf").PartialMessage<VotingSubscriptionRequest>, options?: import("@connectrpc/connect").CallOptions | undefined) => AsyncIterable<VotingSubscriptionResponse>) | ((request: import("@bufbuild/protobuf").PartialMessage<QuestionSubscriptionRequest>, options?: import("@connectrpc/connect").CallOptions | undefined) => AsyncIterable<QuestionSubscriptionResponse>) | ((request: import("@bufbuild/protobuf").PartialMessage<import("@streamlayer/sl-eslib/interactive/feed/interactive.feed_pb").FeedSubscriptionRequest>, options?: import("@connectrpc/connect").CallOptions | undefined) => AsyncIterable<import("@streamlayer/sl-eslib/interactive/feed/interactive.feed_pb").FeedSubscriptionResponse>)>;
1368
1446
  export const getQuestionByUser: (questionId: string, transport: Transport) => Promise<import("@streamlayer/sl-eslib/interactive/interactive.common_pb").ExtendedQuestion | undefined>;
1369
1447
  export const getQuestionDetail: (questionId: string, transport: Transport) => Promise<import("@streamlayer/sl-eslib/interactive/interactive.common_pb").Question | undefined>;
1370
- export const $questionByUser: ($questionId: ReadableAtom<string | undefined>, transport: Transport) => import("@nanostores/query").FetcherStore<import("@streamlayer/sl-eslib/interactive/interactive.common_pb").ExtendedQuestion | undefined, any>;
1448
+ export const $questionByUser: ($questionId: ReadableAtom<string | undefined> | string, transport: Transport) => import("@nanostores/query").FetcherStore<import("@bufbuild/protobuf").PlainMessage<import("@streamlayer/sl-eslib/interactive/interactive.common_pb").ExtendedQuestion>, any>;
1371
1449
  export const $pickHistory: (slStreamId: ReadableAtom<string | undefined>, transport: Transport) => import("@nanostores/query").FetcherStore<(import("@streamlayer/sl-eslib/interactive/feed/interactive.feed_pb").PickHistory | undefined)[], any>;
1372
1450
  export const $feedList: ($slStreamId: ReadableAtom<string | undefined>, $interactiveAllowed: ReadableAtom<InteractiveAllowed>, transport: Transport) => import("@nanostores/query").FetcherStore<import("@streamlayer/sl-eslib/interactive/feed/interactive.feed_pb").FeedItem[], any>;
1373
1451
  export { $userSummary, $leaderboardList } from "../../feature-gamification/src/queries/leaderboard";
@@ -1379,17 +1457,16 @@ declare module "../../feature-gamification/src/detail" {
1379
1457
  import { FeedItem, ExtendedQuestion } from '../../sdk-web-types/src/index.ts';
1380
1458
  import { ReadableAtom } from 'nanostores';
1381
1459
  import { type GamificationBackground } from "../../feature-gamification/src/background";
1382
- type ExtendedQuestionStore = {
1383
- data?: ExtendedQuestion;
1384
- loading?: boolean;
1385
- error?: string;
1386
- };
1387
1460
  export const detail: (transport: Transport, $openedQuestionId: ReadableAtom<{
1388
1461
  questionId: string;
1389
- question?: FeedItem;
1462
+ question?: FeedItem & {
1463
+ openedFrom?: 'list' | 'notification';
1464
+ };
1390
1465
  } | undefined>, $feedList: ReturnType<GamificationBackground['feedList']['getStore']>) => {
1391
- $store: import("nanostores").WritableAtom<import("@bufbuild/protobuf").PlainMessage<import("@streamlayer/sl-eslib/interactive/feed/interactive.feed_pb").FeedItem> | undefined>;
1392
- $extendedStore: import("nanostores").MapStore<ExtendedQuestionStore>;
1466
+ $store: ReadableAtom<import("@streamlayer/sl-eslib/interactive/feed/interactive.feed_pb").FeedItem | (import("@bufbuild/protobuf").PlainMessage<import("@streamlayer/sl-eslib/interactive/feed/interactive.feed_pb").FeedItem> & {
1467
+ openedFrom?: "list" | "notification" | undefined;
1468
+ }) | undefined>;
1469
+ $extendedStore: import("@nanostores/query").FetcherStore<import("@bufbuild/protobuf").PlainMessage<import("@streamlayer/sl-eslib/interactive/interactive.common_pb").ExtendedQuestion>, any>;
1393
1470
  updateExtendedQuestion: (question: ExtendedQuestion | undefined) => void;
1394
1471
  };
1395
1472
  }
@@ -1423,7 +1500,9 @@ declare module "../../feature-gamification/src/background" {
1423
1500
  /** opened question, using to download statistics */
1424
1501
  openedQuestionId: WritableAtom<{
1425
1502
  questionId: string;
1426
- question?: FeedItem;
1503
+ question?: FeedItem & {
1504
+ openedFrom?: 'list' | 'notification';
1505
+ };
1427
1506
  } | undefined>;
1428
1507
  /** opened question statistics */
1429
1508
  openedQuestion: ReturnType<typeof detail>;
@@ -1440,6 +1519,7 @@ declare module "../../feature-gamification/src/background" {
1440
1519
  questionSubscription?: ReturnType<typeof queries.questionSubscription>;
1441
1520
  private notifications;
1442
1521
  private log;
1522
+ private transport;
1443
1523
  constructor(instance: StreamLayerContext);
1444
1524
  /**
1445
1525
  * Get id for notifications and link with current session
@@ -1460,13 +1540,21 @@ declare module "../../feature-gamification/src/background" {
1460
1540
  /**
1461
1541
  * Open question and mark notification for this question as viewed
1462
1542
  */
1463
- openQuestion: (questionId: string, question?: FeedItem) => void;
1543
+ openQuestion: (questionId: string, question?: FeedItem & {
1544
+ openedFrom?: 'list' | 'notification';
1545
+ }) => void;
1464
1546
  /**
1465
1547
  * Close question and mark notification for this question as viewed
1466
1548
  */
1467
1549
  closeQuestion: (questionId?: string) => void;
1468
1550
  }
1469
1551
  }
1552
+ declare module "../../feature-gamification/src/constants" {
1553
+ export enum ERROR {
1554
+ UNKNOWN = "unknown",
1555
+ ALREADY_VOTED = "already_voted"
1556
+ }
1557
+ }
1470
1558
  declare module "../../feature-gamification/src/queries/actions" {
1471
1559
  import type { Transport } from '../../sdk-web-api/src/index.ts';
1472
1560
  export const submitAnswer: (transport: Transport, data: {
@@ -1610,20 +1698,25 @@ declare module "../../feature-gamification/src/gamification" {
1610
1698
  openedUser: WritableAtom<LeaderboardItem | undefined>;
1611
1699
  closeFeature: () => void;
1612
1700
  openFeature: () => void;
1701
+ feedSubscription: GamificationBackground['feedSubscription'];
1702
+ activeQuestionId: GamificationBackground['activeQuestionId'];
1703
+ openedQuestionId: GamificationBackground['openedQuestionId'];
1613
1704
  private notifications;
1614
1705
  private transport;
1615
1706
  /** gamification background class, handle subscriptions and notifications for closed overlay */
1616
1707
  private background;
1617
1708
  /** Browser cache */
1618
1709
  private storage;
1710
+ private submitAnswerTimeout;
1619
1711
  constructor(config: FeatureProps, source: FeatureSource, instance: StreamLayerContext);
1620
1712
  get isInteractiveAllowed(): boolean;
1621
1713
  checkInteractiveFlag: () => void;
1622
- connect: (transport: StreamLayerContext['transport']) => void;
1714
+ connect: () => void;
1623
1715
  disconnect: () => void;
1624
1716
  submitAnswer: (questionId: string, answerId: string) => Promise<void>;
1625
- skipQuestion: (questionId: string) => Promise<void>;
1626
- openQuestion: (questionId: string, question?: FeedItem) => void;
1717
+ openQuestion: (questionId: string, question?: FeedItem & {
1718
+ openedFrom?: 'list' | 'notification';
1719
+ }) => void;
1627
1720
  closeQuestion: (questionId?: string) => void;
1628
1721
  openUser: (userId: string) => void;
1629
1722
  closeUser: () => void;
@@ -1677,9 +1770,190 @@ declare module "../../sdk-web-features/src/index" {
1677
1770
  }
1678
1771
  export const features: (instance: StreamLayerContext, opts: unknown, done: () => void) => void;
1679
1772
  }
1773
+ declare module "../../sdk-web-analytics/src/invitation" {
1774
+ import { InvitationFrom } from '@streamlayer/sl-eslib/analytics/v1/invitations/invitations_pb';
1775
+ import { Analytics } from "../../sdk-web-analytics/src/analytics";
1776
+ export class InvitationAnalytics {
1777
+ private analytics;
1778
+ constructor(analytics: Analytics);
1779
+ accepted: () => void;
1780
+ sent: ({ from }: {
1781
+ from?: InvitationFrom | undefined;
1782
+ }) => void;
1783
+ }
1784
+ }
1785
+ declare module "../../sdk-web-analytics/src/interactions" {
1786
+ import { Analytics } from "../../sdk-web-analytics/src/analytics";
1787
+ export class InteractionsAnalytics {
1788
+ private analytics;
1789
+ constructor(analytics: Analytics);
1790
+ tap: () => void;
1791
+ scroll: () => void;
1792
+ }
1793
+ }
1794
+ declare module "../../sdk-web-analytics/src/constants" {
1795
+ import { TopicType, Category } from '@streamlayer/sl-eslib/analytics/v1/common/analytics.common_pb';
1796
+ import { NotificationKind } from '@streamlayer/sl-eslib/analytics/v1/notifications/notifications_pb';
1797
+ export const AllowedCases: {
1798
+ games: string;
1799
+ notification: string;
1800
+ invitation: string;
1801
+ eventOpened: string;
1802
+ interactions: string;
1803
+ };
1804
+ export const TOPIC_TYPE_MAP: {
1805
+ 0: TopicType;
1806
+ 4: TopicType;
1807
+ 1: TopicType;
1808
+ 3: TopicType;
1809
+ 6: TopicType;
1810
+ 2: TopicType;
1811
+ 5: TopicType;
1812
+ };
1813
+ export const QUESTION_NOTIFICATION_KIND_MAP: {
1814
+ 0: NotificationKind;
1815
+ 4: NotificationKind;
1816
+ 1: NotificationKind;
1817
+ 3: NotificationKind;
1818
+ 6: NotificationKind;
1819
+ 2: NotificationKind;
1820
+ 5: NotificationKind;
1821
+ };
1822
+ export const CATEGORY_TYPE_MAP: {
1823
+ 0: Category;
1824
+ 1: Category;
1825
+ 2: Category;
1826
+ 3: Category;
1827
+ 4: Category;
1828
+ 5: Category;
1829
+ 6: Category;
1830
+ 7: Category;
1831
+ 8: Category;
1832
+ 9: Category;
1833
+ 10: Category;
1834
+ 11: Category;
1835
+ 12: Category;
1836
+ 13: Category;
1837
+ 14: Category;
1838
+ 15: Category;
1839
+ };
1840
+ }
1841
+ declare module "../../sdk-web-analytics/src/notifications" {
1842
+ import { Analytics } from "../../sdk-web-analytics/src/analytics";
1843
+ export class NotificationsAnalytics {
1844
+ private analytics;
1845
+ constructor(analytics: Analytics);
1846
+ private received;
1847
+ private opened;
1848
+ }
1849
+ }
1850
+ declare module "../../sdk-web-analytics/src/polls" {
1851
+ import { QuestionType } from '../../sdk-web-types/src/index.ts';
1852
+ import { Analytics } from "../../sdk-web-analytics/src/analytics";
1853
+ /**
1854
+ * PollsAnalytics is a class that is used to send analytics events related to polls.
1855
+ * It is used to send events when a poll is received, opened, voted, onboarding passed, or navigated.
1856
+ */
1857
+ export class PollsAnalytics {
1858
+ private analytics;
1859
+ constructor(analytics: Analytics);
1860
+ received: ({ questionId, questionType }: {
1861
+ questionId?: string | undefined;
1862
+ questionType?: QuestionType | undefined;
1863
+ }) => void;
1864
+ opened: ({ questionId, questionType, questionOpenedFrom, }: {
1865
+ questionId?: string | undefined;
1866
+ questionType?: QuestionType | undefined;
1867
+ questionOpenedFrom?: "list" | "notification" | undefined;
1868
+ }) => void;
1869
+ voted: ({ questionId, questionType }: {
1870
+ questionId?: string | undefined;
1871
+ questionType?: QuestionType | undefined;
1872
+ }) => void;
1873
+ onboardingPassed: () => void;
1874
+ navigated: () => void;
1875
+ }
1876
+ }
1877
+ declare module "../../sdk-web-analytics/src/heartbeat" {
1878
+ import { Transport } from '../../sdk-web-api/src/index.ts';
1879
+ import { Analytics } from "../../sdk-web-analytics/src/analytics";
1880
+ type IHeartbeat = {
1881
+ transport: Transport;
1882
+ $commonStore: Analytics['commonStore'];
1883
+ };
1884
+ export const heartbeat: ({ transport, $commonStore }: IHeartbeat) => {
1885
+ enable: () => void;
1886
+ disable: () => void;
1887
+ mount: () => void;
1888
+ unmount: () => void;
1889
+ };
1890
+ }
1891
+ declare module "../../sdk-web-analytics/src/analytics" {
1892
+ import { MapStore, StreamLayerContext, OnMountCb } from '../../sdk-web-interfaces/src/index.ts';
1893
+ import { Logger } from '../../sdk-web-logger/src/index.ts';
1894
+ import { GamesMessage, NotificationMessage, SendInvitationsMessage, EventOpenedMessage, SendInteractionsMessage, CommonData } from '@streamlayer/sl-eslib/analytics/v2/streaming/streaming_pb';
1895
+ import { PlainMessage } from '@bufbuild/protobuf';
1896
+ import { InvitationAnalytics } from "../../sdk-web-analytics/src/invitation";
1897
+ import { InteractionsAnalytics } from "../../sdk-web-analytics/src/interactions";
1898
+ import { NotificationsAnalytics } from "../../sdk-web-analytics/src/notifications";
1899
+ import { PollsAnalytics } from "../../sdk-web-analytics/src/polls";
1900
+ import '@streamlayer/sdk-web-features';
1901
+ type AnalyticsMessages = {
1902
+ games?: PlainMessage<GamesMessage>;
1903
+ notification?: PlainMessage<NotificationMessage>;
1904
+ invitation?: PlainMessage<SendInvitationsMessage>;
1905
+ eventOpened?: PlainMessage<EventOpenedMessage>;
1906
+ interactions?: PlainMessage<SendInteractionsMessage>;
1907
+ common: PlainMessage<CommonData>;
1908
+ };
1909
+ export const logger: Logger;
1910
+ /**
1911
+ * analytics events
1912
+ * 1. start (on start we should send heartbeats, generate session id)
1913
+ * 2. overlay open (on open we should update store, create overlay session id)
1914
+ * 3. overlay close (on close we should update store, remove overlay session id)
1915
+ * 4. switch event
1916
+ * 5. on update screen orientation
1917
+ * 6. on open question we should update topicId, topicType (???parentTopicId, ???topicSubType)
1918
+ * 7. on close question we should clear topicId, topicType
1919
+ */
1920
+ export class Analytics {
1921
+ readonly commonStore: MapStore<AnalyticsMessages['common']>;
1922
+ readonly notifications: NotificationsAnalytics;
1923
+ readonly polls: PollsAnalytics;
1924
+ readonly invitation: InvitationAnalytics;
1925
+ readonly interactions: InteractionsAnalytics;
1926
+ private heartbeat;
1927
+ private analyticsClient;
1928
+ private listeners;
1929
+ private listenersCancels;
1930
+ private connected;
1931
+ constructor(instance: StreamLayerContext);
1932
+ connect: () => void;
1933
+ disconnect: () => void;
1934
+ write: <T extends "notification" | "invitation" | "interactions" | "games" | "eventOpened" = "notification" | "invitation" | "interactions" | "games" | "eventOpened">(key: T, value: AnalyticsMessages[T]) => void;
1935
+ writeCommon: <T extends "eventId" | "category" | "kind" | "screenOrientation" | "sessionId" | "overlaySessionId" | "topicId" | "topicType" | "parentTopicId" | "parentTopicType" | "participantsCount" | "routeMap" | "trackTimestamp" | "topicSubType" | "country" = "eventId" | "category" | "kind" | "screenOrientation" | "sessionId" | "overlaySessionId" | "topicId" | "topicType" | "parentTopicId" | "parentTopicType" | "participantsCount" | "routeMap" | "trackTimestamp" | "topicSubType" | "country">(key: T, value: PlainMessage<CommonData>[T]) => void;
1936
+ onConnect: (cb: OnMountCb) => void;
1937
+ private connectToSDK;
1938
+ }
1939
+ }
1940
+ declare module "../../sdk-web-analytics/src/index" {
1941
+ import { type StreamLayerContext } from '../../sdk-web-interfaces/src/index.ts';
1942
+ import type { DeepLinkContext } from '../../sdk-web-core/src/index.ts';
1943
+ import { Transport } from '../../sdk-web-api/src/index.ts';
1944
+ import { Analytics } from "../../sdk-web-analytics/src/analytics";
1945
+ module '@streamlayer/sdk-web-interfaces' {
1946
+ interface StreamLayerContext {
1947
+ analytics: Analytics;
1948
+ deepLink: DeepLinkContext;
1949
+ analyticsTransport: Transport;
1950
+ }
1951
+ }
1952
+ export const analytics: (instance: StreamLayerContext, opts: unknown, done: Function) => void;
1953
+ }
1680
1954
  declare module "../../sdk-web/src/index" {
1681
1955
  import { StreamLayerContext } from '../../sdk-web-interfaces/src/index.ts';
1682
- import type { DeepLinkCallback, VideoPlayerCallback } from '../../sdk-web-core/src/index.ts';
1956
+ import { type DeepLinkCallback, type VideoPlayerCallback } from '../../sdk-web-core/src/index.ts';
1683
1957
  import avvio from 'avvio';
1684
1958
  import './polyfills/raf';
1685
1959
  export type StreamLayerInstance = avvio.mixedInstance<StreamLayerContext>;