@koolbase/core 12.3.0 → 12.4.0

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.
@@ -36,3 +36,9 @@ export declare class KoolbaseAnalytics {
36
36
  flush(): Promise<void>;
37
37
  dispose(): Promise<void>;
38
38
  }
39
+ /**
40
+ * What Koolbase.analytics is while analytics is off (the default since 12.4.0).
41
+ * Every call does nothing, and the first says once how to turn it on, so an app
42
+ * that tracks events without opting in keeps working instead of crashing.
43
+ */
44
+ export declare function disabledAnalytics(): KoolbaseAnalytics;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.KoolbaseAnalytics = void 0;
4
+ exports.disabledAnalytics = disabledAnalytics;
4
5
  const network_js_1 = require("./network.js");
5
6
  const platform_js_1 = require("./platform.js");
6
7
  const device_id_js_1 = require("./device-id.js");
@@ -129,3 +130,20 @@ class KoolbaseAnalytics {
129
130
  }
130
131
  }
131
132
  exports.KoolbaseAnalytics = KoolbaseAnalytics;
133
+ /**
134
+ * What Koolbase.analytics is while analytics is off (the default since 12.4.0).
135
+ * Every call does nothing, and the first says once how to turn it on, so an app
136
+ * that tracks events without opting in keeps working instead of crashing.
137
+ */
138
+ function disabledAnalytics() {
139
+ let told = false;
140
+ const noop = () => {
141
+ if (!told) {
142
+ told = true;
143
+ // eslint-disable-next-line no-console
144
+ console.info('[Koolbase] Analytics is off: it is opt-in since 12.4.0. Pass analyticsEnabled: true to Koolbase.initialize to send events.');
145
+ }
146
+ return Promise.resolve();
147
+ };
148
+ return new Proxy({}, { get: (_t, prop) => (prop === 'then' ? undefined : noop) });
149
+ }
@@ -14,7 +14,7 @@ export { KoolbaseFlags } from './flags.js';
14
14
  export { KoolbaseFunctions } from './functions.js';
15
15
  export { KoolbaseRealtime } from './realtime.js';
16
16
  export { KoolbaseStorage } from './storage.js';
17
- export { KoolbaseAnalytics } from './analytics.js';
17
+ export { KoolbaseAnalytics, disabledAnalytics } from './analytics.js';
18
18
  export { KoolbaseFiscal, KoolbaseFiscalError, decodeFiscalResponse, isFiscalized, isPending } from './fiscal.js';
19
19
  export type { FiscalIntentResult, FiscalStatus } from './fiscal.js';
20
20
  export { KoolbaseMessaging } from './messaging.js';
package/dist/cjs/index.js CHANGED
@@ -19,7 +19,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
19
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
20
  };
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.memoryPlatform = exports.getPlatform = exports.setPlatform = exports.RestoreResult = exports.koolbaseSdkVersion = exports.getOrCreateDeviceId = exports.KoolbaseMessaging = exports.isPending = exports.isFiscalized = exports.decodeFiscalResponse = exports.KoolbaseFiscalError = exports.KoolbaseFiscal = exports.KoolbaseAnalytics = exports.KoolbaseStorage = exports.KoolbaseRealtime = exports.KoolbaseFunctions = exports.KoolbaseFlags = exports.KoolbaseDatabase = exports.KoolbaseAuth = void 0;
22
+ exports.memoryPlatform = exports.getPlatform = exports.setPlatform = exports.RestoreResult = exports.koolbaseSdkVersion = exports.getOrCreateDeviceId = exports.KoolbaseMessaging = exports.isPending = exports.isFiscalized = exports.decodeFiscalResponse = exports.KoolbaseFiscalError = exports.KoolbaseFiscal = exports.disabledAnalytics = exports.KoolbaseAnalytics = exports.KoolbaseStorage = exports.KoolbaseRealtime = exports.KoolbaseFunctions = exports.KoolbaseFlags = exports.KoolbaseDatabase = exports.KoolbaseAuth = void 0;
23
23
  __exportStar(require("./types.js"), exports);
24
24
  __exportStar(require("./errors.js"), exports);
25
25
  __exportStar(require("./network.js"), exports);
@@ -44,6 +44,7 @@ var storage_js_1 = require("./storage.js");
44
44
  Object.defineProperty(exports, "KoolbaseStorage", { enumerable: true, get: function () { return storage_js_1.KoolbaseStorage; } });
45
45
  var analytics_js_1 = require("./analytics.js");
46
46
  Object.defineProperty(exports, "KoolbaseAnalytics", { enumerable: true, get: function () { return analytics_js_1.KoolbaseAnalytics; } });
47
+ Object.defineProperty(exports, "disabledAnalytics", { enumerable: true, get: function () { return analytics_js_1.disabledAnalytics; } });
47
48
  var fiscal_js_1 = require("./fiscal.js");
48
49
  Object.defineProperty(exports, "KoolbaseFiscal", { enumerable: true, get: function () { return fiscal_js_1.KoolbaseFiscal; } });
49
50
  Object.defineProperty(exports, "KoolbaseFiscalError", { enumerable: true, get: function () { return fiscal_js_1.KoolbaseFiscalError; } });
@@ -11,6 +11,8 @@
11
11
  */
12
12
  export declare class KoolbaseNetworkError extends TypeError {
13
13
  code: string;
14
+ /** A short message that is safe to show to people; `message` is for developers. */
15
+ readonly userMessage = "We can't connect right now. Check your connection and try again.";
14
16
  readonly url: string;
15
17
  readonly origin?: string;
16
18
  constructor(url: string, cause: unknown);
@@ -31,6 +31,8 @@ class KoolbaseNetworkError extends TypeError {
31
31
  : ' Check the network connection and the configured base URL.';
32
32
  super(message);
33
33
  this.code = 'network_error';
34
+ /** A short message that is safe to show to people; `message` is for developers. */
35
+ this.userMessage = "We can't connect right now. Check your connection and try again.";
34
36
  this.name = 'KoolbaseNetworkError';
35
37
  this.url = url;
36
38
  this.origin = origin;
@@ -36,3 +36,9 @@ export declare class KoolbaseAnalytics {
36
36
  flush(): Promise<void>;
37
37
  dispose(): Promise<void>;
38
38
  }
39
+ /**
40
+ * What Koolbase.analytics is while analytics is off (the default since 12.4.0).
41
+ * Every call does nothing, and the first says once how to turn it on, so an app
42
+ * that tracks events without opting in keeps working instead of crashing.
43
+ */
44
+ export declare function disabledAnalytics(): KoolbaseAnalytics;
@@ -125,3 +125,20 @@ export class KoolbaseAnalytics {
125
125
  await this.flush();
126
126
  }
127
127
  }
128
+ /**
129
+ * What Koolbase.analytics is while analytics is off (the default since 12.4.0).
130
+ * Every call does nothing, and the first says once how to turn it on, so an app
131
+ * that tracks events without opting in keeps working instead of crashing.
132
+ */
133
+ export function disabledAnalytics() {
134
+ let told = false;
135
+ const noop = () => {
136
+ if (!told) {
137
+ told = true;
138
+ // eslint-disable-next-line no-console
139
+ console.info('[Koolbase] Analytics is off: it is opt-in since 12.4.0. Pass analyticsEnabled: true to Koolbase.initialize to send events.');
140
+ }
141
+ return Promise.resolve();
142
+ };
143
+ return new Proxy({}, { get: (_t, prop) => (prop === 'then' ? undefined : noop) });
144
+ }
@@ -14,7 +14,7 @@ export { KoolbaseFlags } from './flags.js';
14
14
  export { KoolbaseFunctions } from './functions.js';
15
15
  export { KoolbaseRealtime } from './realtime.js';
16
16
  export { KoolbaseStorage } from './storage.js';
17
- export { KoolbaseAnalytics } from './analytics.js';
17
+ export { KoolbaseAnalytics, disabledAnalytics } from './analytics.js';
18
18
  export { KoolbaseFiscal, KoolbaseFiscalError, decodeFiscalResponse, isFiscalized, isPending } from './fiscal.js';
19
19
  export type { FiscalIntentResult, FiscalStatus } from './fiscal.js';
20
20
  export { KoolbaseMessaging } from './messaging.js';
package/dist/esm/index.js CHANGED
@@ -19,7 +19,7 @@ export { KoolbaseFlags } from './flags.js';
19
19
  export { KoolbaseFunctions } from './functions.js';
20
20
  export { KoolbaseRealtime } from './realtime.js';
21
21
  export { KoolbaseStorage } from './storage.js';
22
- export { KoolbaseAnalytics } from './analytics.js';
22
+ export { KoolbaseAnalytics, disabledAnalytics } from './analytics.js';
23
23
  export { KoolbaseFiscal, KoolbaseFiscalError, decodeFiscalResponse, isFiscalized, isPending } from './fiscal.js';
24
24
  export { KoolbaseMessaging } from './messaging.js';
25
25
  export { getOrCreateDeviceId } from './device-id.js';
@@ -11,6 +11,8 @@
11
11
  */
12
12
  export declare class KoolbaseNetworkError extends TypeError {
13
13
  code: string;
14
+ /** A short message that is safe to show to people; `message` is for developers. */
15
+ readonly userMessage = "We can't connect right now. Check your connection and try again.";
14
16
  readonly url: string;
15
17
  readonly origin?: string;
16
18
  constructor(url: string, cause: unknown);
@@ -27,6 +27,8 @@ export class KoolbaseNetworkError extends TypeError {
27
27
  : ' Check the network connection and the configured base URL.';
28
28
  super(message);
29
29
  this.code = 'network_error';
30
+ /** A short message that is safe to show to people; `message` is for developers. */
31
+ this.userMessage = "We can't connect right now. Check your connection and try again.";
30
32
  this.name = 'KoolbaseNetworkError';
31
33
  this.url = url;
32
34
  this.origin = origin;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@koolbase/core",
3
- "version": "12.3.0",
4
- "description": "Koolbase SDK core — shared behaviour behind @koolbase/react-native and @koolbase/js. Install one of those, not this.",
3
+ "version": "12.4.0",
4
+ "description": "Koolbase SDK core \u2014 shared behaviour behind @koolbase/react-native and @koolbase/js. Install one of those, not this.",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "types": "./dist/esm/index.d.ts",
7
7
  "files": [