@smartico/public-api 0.0.354 → 0.0.355

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartico/public-api",
3
- "version": "0.0.354",
3
+ "version": "0.0.355",
4
4
  "description": "Smartico public API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -150,7 +150,7 @@ const DEFAULT_LANG_EN = 'EN';
150
150
  interface Tracker {
151
151
  label_api_key: string;
152
152
  userPublicProps: any;
153
- params: { brand_key?: string };
153
+ params?: { brand_key?: string };
154
154
  on: (callBackKey: ClassId, func: (data: any) => void) => void;
155
155
  getLabelSetting: (key: PublicLabelSettings) => any;
156
156
  triggerExternalCallBack: (callBackKey: string, payload: any) => void;
@@ -200,11 +200,14 @@ class SmarticoAPI {
200
200
  this.publicUrl = SmarticoAPI.getPublicUrl(label_api_key);
201
201
  this.wsUrl = SmarticoAPI.getPublicWsUrl(label_api_key);
202
202
 
203
- this.baseRgApiParams = {
204
- env_id: String(SmarticoAPI.getEnvId(label_api_key)),
205
- label_api_key: label_api_key,
206
- brand_key: options.brand_api_key || this.tracker.params.brand_key,
207
- hash: IntUtils.uuid(),
203
+ if (this.tracker) {
204
+ // available only for real users
205
+ this.baseRgApiParams = {
206
+ env_id: String(SmarticoAPI.getEnvId(label_api_key)),
207
+ label_api_key: label_api_key,
208
+ brand_key: options.brand_api_key || this.tracker.params.brand_key,
209
+ hash: IntUtils.uuid(),
210
+ }
208
211
  }
209
212
 
210
213
  this.avatarDomain = SmarticoAPI.getAvatarUrl(label_api_key || options.tracker?.label_api_key);
@@ -1297,6 +1300,11 @@ class SmarticoAPI {
1297
1300
  }
1298
1301
 
1299
1302
  private async sendGamesApi<T>({ method, params, usePost = false }: { method: string, params: Record<string, any>, usePost?: boolean }): Promise<GamesApiResponse<T>> {
1303
+
1304
+ if (!this.tracker) {
1305
+ throw new Error(`MatchX and Quiz APIs are not available in the visitor mode`);
1306
+ }
1307
+
1300
1308
  const baseParams = this.buildGamesApiParams();
1301
1309
  const queryString = Object.entries(baseParams).map(([k, v]) => `${k}=${encodeURIComponent(v)}`).join('&');
1302
1310
  let url = `${GAMES_API_URL}/${method}?${queryString}`;