@arkadiuminc/sdk 2.78.8 → 2.79.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.
@@ -15,7 +15,8 @@ export declare enum GameConfigProperty {
15
15
  hasEagle = "hasEagle",
16
16
  slug = "slug",
17
17
  gameServerSettings = "gameServerSettings",
18
- debugMenu = "debugMenu"
18
+ debugMenu = "debugMenu",
19
+ version = "version"
19
20
  }
20
21
  export declare type DebugMenuConfig = {
21
22
  isEnabled: boolean;
@@ -38,6 +39,12 @@ declare type GamePlatformFilterEntry = {
38
39
  };
39
40
  declare type LifecycleBlacklistEntry = GamePlatformFilterEntry;
40
41
  export declare type AdBlockerDetectionEntry = GamePlatformFilterEntry;
42
+ export declare type MonitoringConfig = {
43
+ isEnabled: boolean;
44
+ tracesSampleRate: number;
45
+ messagesSampleRate: number;
46
+ exceptionsSampleRate: number;
47
+ };
41
48
  declare type LifecycleEventConfig = {
42
49
  blacklists: LifecycleBlacklistEntry[];
43
50
  };
@@ -72,6 +79,7 @@ export interface ConfigSchema {
72
79
  }>;
73
80
  adBlockerDetection: AdBlockerDetectionEntry[];
74
81
  };
82
+ monitoring: MonitoringConfig;
75
83
  }
76
84
  export { defaultConfigJson };
77
85
  export declare const schema: {
@@ -290,6 +298,25 @@ export declare const schema: {
290
298
  required: string[];
291
299
  additionalProperties: boolean;
292
300
  };
301
+ monitoring: {
302
+ type: string;
303
+ properties: {
304
+ isEnabled: {
305
+ type: string;
306
+ };
307
+ tracesSampleRate: {
308
+ type: string;
309
+ };
310
+ messagesSampleRate: {
311
+ type: string;
312
+ };
313
+ exceptionsSampleRate: {
314
+ type: string;
315
+ };
316
+ };
317
+ required: string[];
318
+ additionalProperties: boolean;
319
+ };
293
320
  };
294
321
  required: string[];
295
322
  additionalProperties: boolean;
@@ -0,0 +1,77 @@
1
+ import { BrowserClient, Span, Scope } from '@sentry/browser';
2
+ import { ApiEnv } from '../../arkadium-arena-sdk';
3
+ import { HostArena } from '../features/host';
4
+
5
+ declare global {
6
+ interface Window {
7
+ __ark_sentry?: {
8
+ createIsolatedClient: (options: IsolatedSentryClientOptionsType) => IsolatedSentryClientHandleType;
9
+ };
10
+ }
11
+ }
12
+ export declare enum MonitoringSource {
13
+ GAME = "game",
14
+ SDK = "sdk"
15
+ }
16
+ export declare enum MonitoringMetricType {
17
+ GAUGE = "gauge",
18
+ COUNT = "count",
19
+ DISTRIBUTION = "distribution"
20
+ }
21
+ declare type IsolatedSentryClientOptionsType = {
22
+ dsn: string;
23
+ release?: string;
24
+ environment?: string;
25
+ tracesSampleRate?: number;
26
+ tags?: Record<string, string>;
27
+ };
28
+ export declare type IsolatedSentrySpanOptionsType = {
29
+ name: string;
30
+ op?: string;
31
+ attributes?: Record<string, string | number | boolean>;
32
+ };
33
+ export declare type IsolatedSentryInactiveSpanOptionsType = {
34
+ name: string;
35
+ op?: string;
36
+ parentSpan?: Span;
37
+ };
38
+ export declare type IsolatedSentryMetricOptionsType = {
39
+ unit?: string;
40
+ attributes?: Record<string, string | number | boolean>;
41
+ };
42
+ export declare type IsolatedSentryMetricsType = {
43
+ count: (name: string, value?: number, metric?: IsolatedSentryMetricOptionsType) => void;
44
+ gauge: (name: string, value: number, metric?: IsolatedSentryMetricOptionsType) => void;
45
+ distribution: (name: string, value: number, metric?: IsolatedSentryMetricOptionsType) => void;
46
+ };
47
+ export declare type IsolatedSentrySpanType = Span & {
48
+ setMeasurement: (name: string, value: number, unit: string) => void;
49
+ startInactiveSpan: (span: IsolatedSentryInactiveSpanOptionsType) => IsolatedSentrySpanType;
50
+ };
51
+ declare type IsolatedSentryClientHandleType = {
52
+ client: BrowserClient;
53
+ scope: Scope;
54
+ setTag: (key: string, value: string) => void;
55
+ setTags: (tags: Record<string, string>) => void;
56
+ captureException: (error: unknown) => string;
57
+ captureMessage: (message: string) => string;
58
+ metrics: IsolatedSentryMetricsType;
59
+ startSpan: <T>(span: IsolatedSentrySpanOptionsType, callback: () => T) => T;
60
+ startInactiveSpan: (span: IsolatedSentryInactiveSpanOptionsType) => IsolatedSentrySpanType;
61
+ close: (timeout?: number) => PromiseLike<boolean>;
62
+ };
63
+ export declare class MonitoringProvider {
64
+ private static _instance;
65
+ private host;
66
+ private isInited;
67
+ private sentryProxy;
68
+ private constructor();
69
+ init(env: ApiEnv, host: HostArena): void;
70
+ static get Instance(): MonitoringProvider;
71
+ private setDefaultTags;
72
+ captureMessage(message: string, source: MonitoringSource): void;
73
+ captureException(error: unknown, source: MonitoringSource): void;
74
+ sendMetric(name: string, value: number, metricType: MonitoringMetricType): void;
75
+ sendMetrics(metrics: Record<string, number>, metricType: MonitoringMetricType): void;
76
+ }
77
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -6,6 +6,27 @@ import { DebugProvider } from '../../core/debug-provider';
6
6
  import { AuthArena } from '../auth';
7
7
  import { PersistenceArena } from '../persistence';
8
8
 
9
+ export declare enum AnalyticsDataCallbackType {
10
+ GAME_STATE = "gameState",
11
+ PERFORMANCE_METRICS = "performanceMetrics"
12
+ }
13
+ export declare const MAX_GAME_STATE_SIZE = 1024;
14
+ /**
15
+ * Full callback signature per {@link AnalyticsDataCallbackType}.
16
+ * Add new enum members here with their args and return type in one place.
17
+ */
18
+ export interface AnalyticsDataCallbacks {
19
+ [AnalyticsDataCallbackType.GAME_STATE]: () => Record<string, string>;
20
+ [AnalyticsDataCallbackType.PERFORMANCE_METRICS]: () => PerformanceMetricsData;
21
+ }
22
+ export declare type AnalyticsDataCallback<T extends AnalyticsDataCallbackType> = AnalyticsDataCallbacks[T];
23
+ export declare type AnalyticsDataCallbackResult<T extends AnalyticsDataCallbackType> = ReturnType<AnalyticsDataCallbacks[T]>;
24
+ export declare type PerformanceMetricsData = {
25
+ "fps": number;
26
+ "fps_total_drops": number;
27
+ "memory_used": number;
28
+ "memory_total": number;
29
+ };
9
30
  interface EnvironmentVersion {
10
31
  GameKey: string;
11
32
  GameVersion: string;
@@ -62,6 +83,7 @@ export declare class AnalyticsApiProxy implements AnalyticsApiContract {
62
83
  GOOGLE: AnalyticsProviderType;
63
84
  private dimensionValues;
64
85
  private fingerprintData;
86
+ private dataCallbacks;
65
87
  constructor(rpcProvider: RpcProvider);
66
88
  getFingerprintVisitorId(): string;
67
89
  private setFingerprintData;
@@ -227,5 +249,7 @@ export declare class AnalyticsApiProxy implements AnalyticsApiContract {
227
249
  */
228
250
  sendQuitConfirmedPageView(dimensions?: DimensionsObject): void;
229
251
  clearProviders(): void;
252
+ registerDataCallback<T extends AnalyticsDataCallbackType>(type: T, callback: AnalyticsDataCallback<T>): void;
253
+ fetchDataFromCallback<T extends AnalyticsDataCallbackType>(type: T): AnalyticsDataCallbackResult<T> | undefined;
230
254
  }
231
255
  export {};
@@ -1,5 +1,5 @@
1
1
  import { Backend } from '../backend/backend.api';
2
- import { createStore } from '../../utils/observable';
2
+ import { createStore, UnsubscribeFn } from '../../utils/observable';
3
3
  import { RpcProvider } from '../../core/rpc';
4
4
  import { IHost } from '../host';
5
5
  import { PersistenceArena } from '../persistence';
@@ -29,7 +29,7 @@ export declare abstract class Auth {
29
29
  isUserAuthorized(): Promise<boolean>;
30
30
  getToken(): Promise<string | undefined>;
31
31
  abstract getUserProfile(): Promise<UserProfile | null>;
32
- onAuthStatusChange(observer: AuthStatusObserver): () => void;
32
+ onAuthStatusChange(observer: AuthStatusObserver): UnsubscribeFn;
33
33
  openAuthForm(): Promise<void>;
34
34
  closeAuthForm(): Promise<void>;
35
35
  onOpenAuthForm(observer: AuthFormObserver): void | undefined;
@@ -1,6 +1,7 @@
1
1
  import { RpcProvider } from '../../core/rpc';
2
2
  import { IHost } from '../host';
3
3
  import { VirtualItemsApiProvider } from '../wallet';
4
+ import { AnalyticsApiProxy } from '../analytics/analytics.api';
4
5
 
5
6
  export declare enum LifecycleEvent {
6
7
  TEST_READY = 1,
@@ -53,10 +54,11 @@ export declare class GameLifecycleArena {
53
54
  }
54
55
  export declare class GameLifecycleGame {
55
56
  private rpcProvider;
57
+ private analyticsProvider;
56
58
  private eventCallbacks;
57
59
  private sentEvents;
58
60
  LifecycleEvent: typeof LifecycleEvent;
59
- constructor(rpcProvider: RpcProvider);
61
+ constructor(rpcProvider: RpcProvider, analyticsProvider: AnalyticsApiProxy);
60
62
  private onEvent;
61
63
  private getExecutionTimeLimitMs;
62
64
  dispatchEvent(event: LifecycleEvent, payload?: any): Promise<any>;
@@ -1,6 +1,6 @@
1
1
  import { DebugProvider } from '../../core/debug-provider';
2
2
  import { RpcProvider } from '../../core/rpc';
3
- import { ObserverFn } from '../../utils/observable';
3
+ import { ObserverFn, UnsubscribeFn } from '../../utils/observable';
4
4
  import { ArenaType } from './arena-type';
5
5
 
6
6
  export { ArenaType } from './arena-type';
@@ -62,7 +62,7 @@ export declare class HostArena implements IHost {
62
62
  getDetails(): Promise<WebEnvironmentDetails>;
63
63
  setDetails(p: Partial<WebEnvironmentDetails>): void;
64
64
  openPurchaseForm(pr: PurchaseRequest): Promise<void>;
65
- onOpenPurchaseForm(observer: any): () => void;
65
+ onOpenPurchaseForm(observer: ObserverFn<PurchaseRequest | undefined>): UnsubscribeFn;
66
66
  purchaseFormClosed(madePurchase: boolean): Promise<void>;
67
67
  getArenaName(): Promise<string>;
68
68
  getArenaNameSync(): string;
@@ -81,6 +81,10 @@ export declare class HostArena implements IHost {
81
81
  isEagleSupported(): Promise<boolean>;
82
82
  isAuthSupported(): Promise<boolean>;
83
83
  }
84
+ export declare type ShopWindowNotification = {
85
+ opened: boolean;
86
+ madePurchase: boolean;
87
+ };
84
88
  export declare class HostGame implements IHost {
85
89
  private rpcProvider;
86
90
  private purchaseFormState;
@@ -98,7 +102,7 @@ export declare class HostGame implements IHost {
98
102
  setGameId(id: string): void;
99
103
  getDetails(): Promise<WebEnvironmentDetails>;
100
104
  openPurchaseForm(r?: PurchaseRequest): Promise<void>;
101
- onPurchaseFormStateChange(observer: any): () => void;
105
+ onPurchaseFormStateChange(observer: ObserverFn<ShopWindowNotification | undefined>): UnsubscribeFn;
102
106
  private purchaseFormClosed;
103
107
  getArenaName(): Promise<string>;
104
108
  getArenaType(): Promise<ArenaType>;
@@ -2,14 +2,15 @@
2
2
  export declare type ObserverFn<T> = (data: T) => void;
3
3
  /** @hidden */
4
4
  export interface ReadonlyObservable<T> {
5
- subscribe: (observer: ObserverFn<T>) => any;
5
+ subscribe: (observer: ObserverFn<T>) => UnsubscribeFn;
6
6
  }
7
+ export declare type UnsubscribeFn = () => void;
7
8
  /** @hidden */
8
9
  export declare class Observable<T> {
9
10
  private lastValue;
10
11
  private observers;
11
12
  constructor(initialValue: T);
12
- subscribe(observer: ObserverFn<T>): () => void;
13
+ subscribe(observer: ObserverFn<T>): UnsubscribeFn;
13
14
  update(data: T): void;
14
15
  }
15
16
  export declare function createStore<T>(initialValue: T): Observable<T>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkadiuminc/sdk",
3
- "version": "2.78.8",
3
+ "version": "2.79.1",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "main": "dist/pkg/arkadium-sdk.umd.js",
@@ -88,6 +88,7 @@
88
88
  "@arkadium/eagle-virtual-items-api-client": "^0.1.4",
89
89
  "@commitlint/cli": "^17.8.1",
90
90
  "@commitlint/config-conventional": "^17.8.1",
91
+ "@sentry/browser": "^10.78.0",
91
92
  "@types/jest": "^29.5.11",
92
93
  "@types/node": "^18.0.6",
93
94
  "@vitest/coverage-v8": "^1.6.0",