@goatech/sdk-js 0.1.0 → 1.0.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.
- package/README.md +21 -83
- package/dist/boot-error.d.mts +1 -39
- package/dist/boot-error.d.ts +1 -39
- package/dist/boot-error.js +12 -32
- package/dist/boot-error.mjs +1 -2
- package/dist/experiments.d.mts +1 -29
- package/dist/experiments.d.ts +1 -29
- package/dist/experiments.js +12 -2
- package/dist/experiments.mjs +1 -2
- package/dist/flags.d.mts +1 -34
- package/dist/flags.d.ts +1 -34
- package/dist/flags.js +12 -2
- package/dist/flags.mjs +1 -2
- package/dist/index.d.mts +4 -170
- package/dist/index.d.ts +4 -170
- package/dist/index.js +18 -31
- package/dist/index.mjs +10 -3
- package/package.json +21 -24
- package/dist/chunk-6BNLBHZS.mjs +0 -2
- package/dist/chunk-BQTMRKY5.mjs +0 -32
- package/dist/chunk-X5MDWZGR.mjs +0 -3
- package/dist/types-CxAq_Cds.d.mts +0 -371
- package/dist/types-CxAq_Cds.d.ts +0 -371
package/README.md
CHANGED
|
@@ -1,99 +1,37 @@
|
|
|
1
|
-
# @goatech/sdk-js
|
|
1
|
+
# @goatech/sdk-js (deprecated)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This package is a backward-compatibility shim. The Sheepit browser SDK has moved to `@sheepit-ai/sdk-js`.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
All exports are identical — only the package name changed. Swap your dependency:
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
npm install @goatech/sdk-js
|
|
11
|
-
# or
|
|
12
|
-
pnpm add @goatech/sdk-js
|
|
13
|
-
# or
|
|
14
|
-
yarn add @goatech/sdk-js
|
|
7
|
+
```diff
|
|
8
|
+
- "@goatech/sdk-js": "^1.0.0"
|
|
9
|
+
+ "@sheepit-ai/sdk-js": "^1.0.0"
|
|
15
10
|
```
|
|
16
11
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
```ts
|
|
20
|
-
import { GoaTech } from "@goatech/sdk-js";
|
|
21
|
-
|
|
22
|
-
const gt = GoaTech.create({
|
|
23
|
-
apiKey: "lp_pub_xxx_abc123...", // publishable key — safe in browsers
|
|
24
|
-
apiUrl: "https://api.goatech.ai", // optional, defaults to prod
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
// Track an event
|
|
28
|
-
gt.track("course_viewed", { course_id: "abc-123" });
|
|
29
|
-
|
|
30
|
-
// Evaluate a flag
|
|
31
|
-
const showBeta = gt.flag("show_beta_ui", false);
|
|
32
|
-
|
|
33
|
-
// Get an experiment variant (server-bucketed, sticky per device)
|
|
34
|
-
const { variant, payload } = gt.experiment("checkout_redesign");
|
|
12
|
+
> **If you're on `^0.1.x`**: this shim publishes as `1.0.0`, so `^0.1.x` will NOT auto-resolve. Change your range to `^1.0.0` (or migrate directly to `@sheepit-ai/sdk-js@^1.0.0`).
|
|
35
13
|
|
|
36
|
-
|
|
37
|
-
gt.identify("user_abc123", { email: "jane@example.com" });
|
|
14
|
+
And update your imports:
|
|
38
15
|
|
|
39
|
-
|
|
40
|
-
|
|
16
|
+
```diff
|
|
17
|
+
- import { GoaTech } from "@goatech/sdk-js";
|
|
18
|
+
+ import { GoaTech } from "@sheepit-ai/sdk-js";
|
|
41
19
|
```
|
|
42
20
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
Use the **publishable** key (`lp_pub_*`) in browsers. It can only post events and fetch config — no admin access. Secret keys (`lp_sec_*`) are rejected at initialization if used in a browser context.
|
|
46
|
-
|
|
47
|
-
## API
|
|
48
|
-
|
|
49
|
-
### `GoaTech.create(config)`
|
|
50
|
-
|
|
51
|
-
Create an SDK instance. Required: `apiKey`. Other options:
|
|
52
|
-
|
|
53
|
-
- `apiUrl` — defaults to `https://api.goatech.ai`
|
|
54
|
-
- `debug` — enables verbose logging + local flag overrides
|
|
55
|
-
- `flushInterval` — ms between event flushes (default 5000)
|
|
56
|
-
- `flushSize` — batch size (default 20)
|
|
57
|
-
- `autoCaptureErrors` — capture `window.onerror` + `unhandledrejection` as `$error` events (default `true`; pass `false` to disable or an object to configure)
|
|
58
|
-
- `autoCaptureHttpErrors` — wrap `fetch` to emit `$http_error` on non-2xx responses (default `false`)
|
|
59
|
-
- `appVersion` — attached to every event for Release attribution
|
|
60
|
-
|
|
61
|
-
### `gt.track(eventName, properties?)`
|
|
62
|
-
|
|
63
|
-
Queue an event for batch upload. Returns immediately; events flush on a timer, on `visibilitychange`, and on `pagehide`.
|
|
64
|
-
|
|
65
|
-
### `gt.identify(userId, traits?)`
|
|
66
|
-
|
|
67
|
-
Associate the current device with a user. Subsequent events carry `user_id` + `traits`. Do **not** put PII in `traits` unless you've disclosed it.
|
|
68
|
-
|
|
69
|
-
### `gt.reset()`
|
|
70
|
-
|
|
71
|
-
Clear user identity and cached experiment assignments. Call on logout.
|
|
72
|
-
|
|
73
|
-
### `gt.flag<T>(flagKey, defaultValue?)`
|
|
74
|
-
|
|
75
|
-
Return the server-evaluated flag value, or `defaultValue` if not set. Fires a `$flag_exposure` event once per session per flag.
|
|
76
|
-
|
|
77
|
-
### `gt.experiment(experimentKey)`
|
|
78
|
-
|
|
79
|
-
Return the assigned variant for an experiment. Result is `{ variant: string; payload?: Record<string, unknown> }`. Assignments are computed server-side and remain sticky per device.
|
|
80
|
-
|
|
81
|
-
### `gt.flush()`
|
|
82
|
-
|
|
83
|
-
Force-flush queued events. Returns a promise that resolves when the batch is sent.
|
|
84
|
-
|
|
85
|
-
### `gt.destroy()`
|
|
21
|
+
The class name `GoaTech` is unchanged — only the package import path moves.
|
|
86
22
|
|
|
87
|
-
|
|
23
|
+
This shim will emit a `console.warn` on import until you migrate (once per JS realm — that's once per main thread, once per worker_thread, once per `vm.Context`). It will stop receiving updates after 2026-11-26.
|
|
88
24
|
|
|
89
|
-
|
|
25
|
+
Full migration guide: https://www.goatech.ai/docs/migrate-to-sheepit
|
|
90
26
|
|
|
91
|
-
|
|
27
|
+
---
|
|
92
28
|
|
|
93
|
-
##
|
|
29
|
+
## Publishing this shim (maintainers only)
|
|
94
30
|
|
|
95
|
-
|
|
31
|
+
Order matters. The shim depends on `@sheepit-ai/sdk-js: workspace:*`, which `pnpm publish` rewrites to a real semver range. That rewrite fails closed if the dependency isn't published yet:
|
|
96
32
|
|
|
97
|
-
|
|
33
|
+
1. `pnpm --filter @sheepit-ai/sdk-js publish --access public` — must succeed first.
|
|
34
|
+
2. `pnpm --filter @goatech/sdk-js publish --access public` — shim publishes after.
|
|
35
|
+
3. `npm deprecate "@goatech/sdk-js@<2.0.0" "Renamed to @sheepit-ai/sdk-js. See README."`
|
|
98
36
|
|
|
99
|
-
|
|
37
|
+
Reversing the order publishes the shim with a broken dep.
|
package/dist/boot-error.d.mts
CHANGED
|
@@ -1,39 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* URL the ultra-early error script posts to. Must be same-origin relative
|
|
4
|
-
* (e.g. "/api/log-boot-error") so `navigator.sendBeacon` works on page unload.
|
|
5
|
-
* Customers wire a corresponding server route that forwards to GoaTech or
|
|
6
|
-
* logs to their infra. (See README for a Next.js example.)
|
|
7
|
-
*/
|
|
8
|
-
endpoint: string;
|
|
9
|
-
/** Stack-trace length cap in chars. Default: 4096. */
|
|
10
|
-
stackLimit?: number;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Returns an IIFE string to inline in `<head>` BEFORE any bundle loads.
|
|
14
|
-
* Captures errors that happen before React / the SDK hydrates — a render
|
|
15
|
-
* crash in that window never reaches the normal event pipeline.
|
|
16
|
-
*
|
|
17
|
-
* Usage (Next.js App Router):
|
|
18
|
-
*
|
|
19
|
-
* import { getBootErrorScript } from "@goatech/sdk-js/boot-error";
|
|
20
|
-
* ...
|
|
21
|
-
* <head>
|
|
22
|
-
* <script dangerouslySetInnerHTML={{ __html: getBootErrorScript({ endpoint: "/api/log-boot-error" }) }} />
|
|
23
|
-
* </head>
|
|
24
|
-
*/
|
|
25
|
-
declare function getBootErrorScript(options: BootErrorScriptOptions): string;
|
|
26
|
-
interface BootErrorPayload {
|
|
27
|
-
reason: "uncaught_error" | "unhandled_rejection";
|
|
28
|
-
message: string;
|
|
29
|
-
source?: string | null;
|
|
30
|
-
line?: number | null;
|
|
31
|
-
col?: number | null;
|
|
32
|
-
stack?: string | null;
|
|
33
|
-
ua: string;
|
|
34
|
-
url: string;
|
|
35
|
-
pathname: string;
|
|
36
|
-
ts: number;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export { type BootErrorPayload, type BootErrorScriptOptions, getBootErrorScript };
|
|
1
|
+
export * from '@sheepit-ai/sdk-js/boot-error';
|
package/dist/boot-error.d.ts
CHANGED
|
@@ -1,39 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* URL the ultra-early error script posts to. Must be same-origin relative
|
|
4
|
-
* (e.g. "/api/log-boot-error") so `navigator.sendBeacon` works on page unload.
|
|
5
|
-
* Customers wire a corresponding server route that forwards to GoaTech or
|
|
6
|
-
* logs to their infra. (See README for a Next.js example.)
|
|
7
|
-
*/
|
|
8
|
-
endpoint: string;
|
|
9
|
-
/** Stack-trace length cap in chars. Default: 4096. */
|
|
10
|
-
stackLimit?: number;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Returns an IIFE string to inline in `<head>` BEFORE any bundle loads.
|
|
14
|
-
* Captures errors that happen before React / the SDK hydrates — a render
|
|
15
|
-
* crash in that window never reaches the normal event pipeline.
|
|
16
|
-
*
|
|
17
|
-
* Usage (Next.js App Router):
|
|
18
|
-
*
|
|
19
|
-
* import { getBootErrorScript } from "@goatech/sdk-js/boot-error";
|
|
20
|
-
* ...
|
|
21
|
-
* <head>
|
|
22
|
-
* <script dangerouslySetInnerHTML={{ __html: getBootErrorScript({ endpoint: "/api/log-boot-error" }) }} />
|
|
23
|
-
* </head>
|
|
24
|
-
*/
|
|
25
|
-
declare function getBootErrorScript(options: BootErrorScriptOptions): string;
|
|
26
|
-
interface BootErrorPayload {
|
|
27
|
-
reason: "uncaught_error" | "unhandled_rejection";
|
|
28
|
-
message: string;
|
|
29
|
-
source?: string | null;
|
|
30
|
-
line?: number | null;
|
|
31
|
-
col?: number | null;
|
|
32
|
-
stack?: string | null;
|
|
33
|
-
ua: string;
|
|
34
|
-
url: string;
|
|
35
|
-
pathname: string;
|
|
36
|
-
ts: number;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export { type BootErrorPayload, type BootErrorScriptOptions, getBootErrorScript };
|
|
1
|
+
export * from '@sheepit-ai/sdk-js/boot-error';
|
package/dist/boot-error.js
CHANGED
|
@@ -1,32 +1,12 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return {reason:r,ua:navigator.userAgent,url:location.href,ts:Date.now(),pathname:location.pathname};
|
|
14
|
-
}
|
|
15
|
-
window.addEventListener("error",function(e){
|
|
16
|
-
var p=base("uncaught_error");
|
|
17
|
-
p.message=e&&e.message?String(e.message):"(no message)";
|
|
18
|
-
p.source=e&&e.filename?String(e.filename):null;
|
|
19
|
-
p.line=e&&typeof e.lineno==="number"?e.lineno:null;
|
|
20
|
-
p.col=e&&typeof e.colno==="number"?e.colno:null;
|
|
21
|
-
p.stack=e&&e.error&&e.error.stack?String(e.error.stack).slice(0,${r}):null;
|
|
22
|
-
post(p);
|
|
23
|
-
});
|
|
24
|
-
window.addEventListener("unhandledrejection",function(e){
|
|
25
|
-
var p=base("unhandled_rejection");
|
|
26
|
-
var r=e&&e.reason;
|
|
27
|
-
p.message=r&&r.message?String(r.message):String(r);
|
|
28
|
-
p.stack=r&&r.stack?String(r.stack).slice(0,${r}):null;
|
|
29
|
-
post(p);
|
|
30
|
-
});
|
|
31
|
-
})();`}exports.getBootErrorScript=t;//# sour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c3RyaW5nIHwgbnVsbDtcbiAgdWE6IHN0cmluZztcbiAgdXJsOiBzdHJpbmc7XG4gIHBhdGhuYW1lOiBzdHJpbmc7XG4gIHRzOiBudW1iZXI7XG59XG4iXX0=
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var bootError = require('@sheepit-ai/sdk-js/boot-error');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.keys(bootError).forEach(function (k) {
|
|
8
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return bootError[k]; }
|
|
11
|
+
});
|
|
12
|
+
});
|
package/dist/boot-error.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsImZpbGUiOiJib290LWVycm9yLm1qcyJ9
|
|
1
|
+
export * from '@sheepit-ai/sdk-js/boot-error';
|
package/dist/experiments.d.mts
CHANGED
|
@@ -1,29 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { j as ExperimentConfig, l as ExperimentVariant } from './types-CxAq_Cds.mjs';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Experiments are bucketed server-side. The `/v1/config` endpoint returns
|
|
6
|
-
* `experiments: { [experimentKey]: { variant_key, payload } }` — one entry
|
|
7
|
-
* per experiment the caller's device is enrolled in. The SDK's job is to
|
|
8
|
-
* cache the assignment, emit a single exposure event per session, and
|
|
9
|
-
* surface the variant to calling code.
|
|
10
|
-
*
|
|
11
|
-
* No client-side bucketing. No traffic gates. No cumulative weights. All
|
|
12
|
-
* of that happens on the server so every platform (web, iOS, server SDK)
|
|
13
|
-
* agrees on the assignment for a given device.
|
|
14
|
-
*/
|
|
15
|
-
declare class ExperimentManager {
|
|
16
|
-
private assignments;
|
|
17
|
-
/** Persisted per-session: remembers which variant we last surfaced. */
|
|
18
|
-
private stickyAssignments;
|
|
19
|
-
private exposed;
|
|
20
|
-
constructor();
|
|
21
|
-
setAssignments(assignments: Record<string, ExperimentAssignment>): void;
|
|
22
|
-
count(): number;
|
|
23
|
-
resolve(experimentKey: string, onExposure: (key: string, variant: string) => void): ExperimentResult;
|
|
24
|
-
clearAssignments(): void;
|
|
25
|
-
private loadStickyAssignments;
|
|
26
|
-
private saveStickyAssignments;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export { ExperimentManager, ExperimentResult };
|
|
1
|
+
export * from '@sheepit-ai/sdk-js/experiments';
|
package/dist/experiments.d.ts
CHANGED
|
@@ -1,29 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { j as ExperimentConfig, l as ExperimentVariant } from './types-CxAq_Cds.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Experiments are bucketed server-side. The `/v1/config` endpoint returns
|
|
6
|
-
* `experiments: { [experimentKey]: { variant_key, payload } }` — one entry
|
|
7
|
-
* per experiment the caller's device is enrolled in. The SDK's job is to
|
|
8
|
-
* cache the assignment, emit a single exposure event per session, and
|
|
9
|
-
* surface the variant to calling code.
|
|
10
|
-
*
|
|
11
|
-
* No client-side bucketing. No traffic gates. No cumulative weights. All
|
|
12
|
-
* of that happens on the server so every platform (web, iOS, server SDK)
|
|
13
|
-
* agrees on the assignment for a given device.
|
|
14
|
-
*/
|
|
15
|
-
declare class ExperimentManager {
|
|
16
|
-
private assignments;
|
|
17
|
-
/** Persisted per-session: remembers which variant we last surfaced. */
|
|
18
|
-
private stickyAssignments;
|
|
19
|
-
private exposed;
|
|
20
|
-
constructor();
|
|
21
|
-
setAssignments(assignments: Record<string, ExperimentAssignment>): void;
|
|
22
|
-
count(): number;
|
|
23
|
-
resolve(experimentKey: string, onExposure: (key: string, variant: string) => void): ExperimentResult;
|
|
24
|
-
clearAssignments(): void;
|
|
25
|
-
private loadStickyAssignments;
|
|
26
|
-
private saveStickyAssignments;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export { ExperimentManager, ExperimentResult };
|
|
1
|
+
export * from '@sheepit-ai/sdk-js/experiments';
|
package/dist/experiments.js
CHANGED
|
@@ -1,2 +1,12 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var experiments = require('@sheepit-ai/sdk-js/experiments');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.keys(experiments).forEach(function (k) {
|
|
8
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return experiments[k]; }
|
|
11
|
+
});
|
|
12
|
+
});
|
package/dist/experiments.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsImZpbGUiOiJleHBlcmltZW50cy5tanMifQ==
|
|
1
|
+
export * from '@sheepit-ai/sdk-js/experiments';
|
package/dist/flags.d.mts
CHANGED
|
@@ -1,34 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { C as Condition, m as FlagConfig, n as FlagRule } from './types-CxAq_Cds.mjs';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* FlagManager stores server-evaluated Flag values and exposes them to SDK
|
|
6
|
-
* consumers. Evaluation happens on the API (see `/v1/config`); the SDK only
|
|
7
|
-
* caches the result and tracks exposure once per flag per session.
|
|
8
|
-
*
|
|
9
|
-
* Debug overrides take precedence over server values when debug mode is
|
|
10
|
-
* active, so developers can test different branches without touching the
|
|
11
|
-
* server. Overrides are persisted in localStorage under DEBUG_OVERRIDES_KEY.
|
|
12
|
-
*/
|
|
13
|
-
declare class FlagManager {
|
|
14
|
-
private flagValues;
|
|
15
|
-
private debugOverrides;
|
|
16
|
-
private exposed;
|
|
17
|
-
private debugMode;
|
|
18
|
-
/** Apply the latest evaluated flag values from `/v1/config`. */
|
|
19
|
-
setEvaluatedFlags(flags: Record<string, unknown>): void;
|
|
20
|
-
setDebugMode(enabled: boolean): void;
|
|
21
|
-
/** Override a flag value for local testing. Only active when debug=true. */
|
|
22
|
-
overrideFlag(key: string, value: FlagValue): void;
|
|
23
|
-
/** Clear all debug overrides. */
|
|
24
|
-
clearOverrides(): void;
|
|
25
|
-
/** Get all current debug overrides (for debug menu UI). */
|
|
26
|
-
getOverrides(): Record<string, unknown>;
|
|
27
|
-
count(): number;
|
|
28
|
-
evaluate(flagKey: string, defaultValue: FlagValue, _userId: string | null, _attributes: Record<string, unknown>, onExposure: (flagKey: string, value: FlagValue) => void): FlagValue;
|
|
29
|
-
clearExposed(): void;
|
|
30
|
-
private loadDebugOverrides;
|
|
31
|
-
private saveDebugOverrides;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export { FlagManager, FlagValue };
|
|
1
|
+
export * from '@sheepit-ai/sdk-js/flags';
|
package/dist/flags.d.ts
CHANGED
|
@@ -1,34 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { C as Condition, m as FlagConfig, n as FlagRule } from './types-CxAq_Cds.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* FlagManager stores server-evaluated Flag values and exposes them to SDK
|
|
6
|
-
* consumers. Evaluation happens on the API (see `/v1/config`); the SDK only
|
|
7
|
-
* caches the result and tracks exposure once per flag per session.
|
|
8
|
-
*
|
|
9
|
-
* Debug overrides take precedence over server values when debug mode is
|
|
10
|
-
* active, so developers can test different branches without touching the
|
|
11
|
-
* server. Overrides are persisted in localStorage under DEBUG_OVERRIDES_KEY.
|
|
12
|
-
*/
|
|
13
|
-
declare class FlagManager {
|
|
14
|
-
private flagValues;
|
|
15
|
-
private debugOverrides;
|
|
16
|
-
private exposed;
|
|
17
|
-
private debugMode;
|
|
18
|
-
/** Apply the latest evaluated flag values from `/v1/config`. */
|
|
19
|
-
setEvaluatedFlags(flags: Record<string, unknown>): void;
|
|
20
|
-
setDebugMode(enabled: boolean): void;
|
|
21
|
-
/** Override a flag value for local testing. Only active when debug=true. */
|
|
22
|
-
overrideFlag(key: string, value: FlagValue): void;
|
|
23
|
-
/** Clear all debug overrides. */
|
|
24
|
-
clearOverrides(): void;
|
|
25
|
-
/** Get all current debug overrides (for debug menu UI). */
|
|
26
|
-
getOverrides(): Record<string, unknown>;
|
|
27
|
-
count(): number;
|
|
28
|
-
evaluate(flagKey: string, defaultValue: FlagValue, _userId: string | null, _attributes: Record<string, unknown>, onExposure: (flagKey: string, value: FlagValue) => void): FlagValue;
|
|
29
|
-
clearExposed(): void;
|
|
30
|
-
private loadDebugOverrides;
|
|
31
|
-
private saveDebugOverrides;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export { FlagManager, FlagValue };
|
|
1
|
+
export * from '@sheepit-ai/sdk-js/flags';
|
package/dist/flags.js
CHANGED
|
@@ -1,2 +1,12 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var flags = require('@sheepit-ai/sdk-js/flags');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.keys(flags).forEach(function (k) {
|
|
8
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return flags[k]; }
|
|
11
|
+
});
|
|
12
|
+
});
|
package/dist/flags.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsImZpbGUiOiJmbGFncy5tanMifQ==
|
|
1
|
+
export * from '@sheepit-ai/sdk-js/flags';
|
package/dist/index.d.mts
CHANGED
|
@@ -1,170 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Public API surface of a GoaTech client instance.
|
|
7
|
-
* Use this type when you need to pass around a client reference
|
|
8
|
-
* without depending on the concrete GoaTech class.
|
|
9
|
-
*/
|
|
10
|
-
interface IGoaTech {
|
|
11
|
-
track(eventName: string, properties?: Record<string, unknown>): void;
|
|
12
|
-
identify(userId: string, traits?: Record<string, unknown>): void;
|
|
13
|
-
reset(): void;
|
|
14
|
-
flag(flagKey: string, defaultValue?: FlagValue): FlagValue;
|
|
15
|
-
experiment(experimentKey: string): ExperimentResult;
|
|
16
|
-
/** Override a flag value for local testing. Only active when debug=true. */
|
|
17
|
-
overrideFlag(key: string, value: FlagValue): void;
|
|
18
|
-
/** Clear all debug overrides. */
|
|
19
|
-
clearOverrides(): void;
|
|
20
|
-
/** Get all current debug overrides (for debug menu UI). */
|
|
21
|
-
getOverrides(): Record<string, unknown>;
|
|
22
|
-
flush(): Promise<void>;
|
|
23
|
-
/** Notify the SDK of a route change in a single-page app. Emits a
|
|
24
|
-
* synthetic `$page_leave` for the prior route (if any) and resets
|
|
25
|
-
* the page-leave timer for the new path. */
|
|
26
|
-
recordPageView(path: string): void;
|
|
27
|
-
status(): SDKStatus;
|
|
28
|
-
destroy(): void;
|
|
29
|
-
/** Access the diagnostic event bus for runtime subscribe/unsubscribe. */
|
|
30
|
-
diagnostics(): DiagnosticBus;
|
|
31
|
-
/** Get buffered recent diagnostic events. */
|
|
32
|
-
getRecentDiagnostics(): DiagnosticEvent[];
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
declare class GoaTech implements IGoaTech {
|
|
36
|
-
private static instance;
|
|
37
|
-
private readonly cfg;
|
|
38
|
-
private readonly log;
|
|
39
|
-
private readonly bus;
|
|
40
|
-
private readonly context;
|
|
41
|
-
private readonly queue;
|
|
42
|
-
private readonly flagManager;
|
|
43
|
-
private readonly experimentManager;
|
|
44
|
-
private readonly identityManager;
|
|
45
|
-
private readonly configSync;
|
|
46
|
-
private readonly transport;
|
|
47
|
-
private readonly offlineQueue;
|
|
48
|
-
private readonly connectivity;
|
|
49
|
-
private readonly lifecycle;
|
|
50
|
-
private readonly errorCapture;
|
|
51
|
-
private readonly httpErrorCapture;
|
|
52
|
-
private readonly clickFrustrationCapture;
|
|
53
|
-
private flushTimer;
|
|
54
|
-
private destroyed;
|
|
55
|
-
private constructor();
|
|
56
|
-
/**
|
|
57
|
-
* Create a new, independent GoaTech instance.
|
|
58
|
-
* The caller owns the instance lifecycle — no global state.
|
|
59
|
-
* Preferred for React apps (pass instance to Context).
|
|
60
|
-
*/
|
|
61
|
-
static create(config: GoaTechConfig): GoaTech;
|
|
62
|
-
/**
|
|
63
|
-
* Create a singleton instance. Returns existing instance if already
|
|
64
|
-
* initialized (logs a warning). Call `destroy()` first to re-initialize.
|
|
65
|
-
*
|
|
66
|
-
* For React apps, prefer `GoaTech.create()` + Context instead.
|
|
67
|
-
*/
|
|
68
|
-
static init(config: GoaTechConfig): GoaTech;
|
|
69
|
-
/** Get the singleton instance. Throws if `init()` was never called. */
|
|
70
|
-
static getInstance(): GoaTech;
|
|
71
|
-
/**
|
|
72
|
-
* Returns true if the singleton has been initialized via `init()`.
|
|
73
|
-
* Useful for HMR guards and conditional initialization.
|
|
74
|
-
*/
|
|
75
|
-
static isInitialized(): boolean;
|
|
76
|
-
/**
|
|
77
|
-
* Queue an analytics event. Auto-flushes when the queue reaches
|
|
78
|
-
* `flushSize` (default 20) or when the periodic flush timer fires.
|
|
79
|
-
*
|
|
80
|
-
* @example
|
|
81
|
-
* gt.track("course_viewed", { course_id: "c_123", source: "catalog" });
|
|
82
|
-
*/
|
|
83
|
-
track(eventName: string, properties?: Record<string, unknown>): void;
|
|
84
|
-
/**
|
|
85
|
-
* Resolve a feature flag for the current device + identity. Reads
|
|
86
|
-
* the cached server-evaluated value from `/v1/config` (refreshed on
|
|
87
|
-
* `configRefreshInterval`). Fires `$flag_exposure` once per session
|
|
88
|
-
* per flag.
|
|
89
|
-
*
|
|
90
|
-
* @example
|
|
91
|
-
* if (gt.flag("new_checkout_flow", false)) {
|
|
92
|
-
* renderNewCheckout();
|
|
93
|
-
* }
|
|
94
|
-
*/
|
|
95
|
-
flag(flagKey: string, defaultValue?: FlagValue): FlagValue;
|
|
96
|
-
overrideFlag(key: string, value: FlagValue): void;
|
|
97
|
-
clearOverrides(): void;
|
|
98
|
-
getOverrides(): Record<string, unknown>;
|
|
99
|
-
/**
|
|
100
|
-
* Resolve the bucketed variant + payload for an experiment. Sticky
|
|
101
|
-
* per device. Fires `$experiment_exposure` once per session per
|
|
102
|
-
* experiment.
|
|
103
|
-
*
|
|
104
|
-
* @example
|
|
105
|
-
* const { variant, payload } = gt.experiment("hero_h1_copy_v1");
|
|
106
|
-
* if (variant !== "control") setHeadline((payload as { headline: string }).headline);
|
|
107
|
-
*/
|
|
108
|
-
experiment(experimentKey: string): ExperimentResult;
|
|
109
|
-
/**
|
|
110
|
-
* Tie the current device to a stable user id and merge traits onto
|
|
111
|
-
* the GoaTech user record. Re-identifying with a different userId
|
|
112
|
-
* clears the cached experiment assignments so the new identity
|
|
113
|
-
* gets fresh buckets.
|
|
114
|
-
*
|
|
115
|
-
* @example
|
|
116
|
-
* await api.login(form);
|
|
117
|
-
* gt.identify("user_abc123", { email: "jane@example.com", plan: "pro" });
|
|
118
|
-
*/
|
|
119
|
-
identify(userId: string, traits?: Record<string, unknown>): void;
|
|
120
|
-
/**
|
|
121
|
-
* Forget the current identity + experiment assignments and start a
|
|
122
|
-
* fresh anonymous session. Call on logout.
|
|
123
|
-
*
|
|
124
|
-
* @example
|
|
125
|
-
* await api.logout();
|
|
126
|
-
* gt.reset();
|
|
127
|
-
*/
|
|
128
|
-
reset(): void;
|
|
129
|
-
/**
|
|
130
|
-
* Drain any queued events to the GoaTech ingest endpoint. Useful
|
|
131
|
-
* before navigation in single-page apps and required before
|
|
132
|
-
* Vercel/Lambda function exits.
|
|
133
|
-
*
|
|
134
|
-
* @example
|
|
135
|
-
* router.beforeEach(async () => {
|
|
136
|
-
* await gt.flush();
|
|
137
|
-
* });
|
|
138
|
-
*/
|
|
139
|
-
flush(): Promise<void>;
|
|
140
|
-
/**
|
|
141
|
-
* Notify the SDK of a route change. The first call starts a page-leave
|
|
142
|
-
* timer; subsequent calls emit a synthetic `$page_leave` for the prior
|
|
143
|
-
* route (with `exit_kind: "spa_nav"`) before resetting state. Wire
|
|
144
|
-
* this into your router — for Next.js, use `<PageViewTracker>` from
|
|
145
|
-
* `@goatech/react`, which calls this for you.
|
|
146
|
-
*
|
|
147
|
-
* Idempotent for repeat calls with the same path.
|
|
148
|
-
*/
|
|
149
|
-
recordPageView(path: string): void;
|
|
150
|
-
status(): SDKStatus;
|
|
151
|
-
diagnostics(): DiagnosticBus;
|
|
152
|
-
getRecentDiagnostics(): DiagnosticEvent[];
|
|
153
|
-
/**
|
|
154
|
-
* Stop all timers, drain remaining events, and tear down auto-error
|
|
155
|
-
* + lifecycle listeners. After `destroy()` further `track()` /
|
|
156
|
-
* `flag()` calls are no-ops. Idempotent.
|
|
157
|
-
*
|
|
158
|
-
* @example
|
|
159
|
-
* // Replacing the SDK instance (rare; usually just call once)
|
|
160
|
-
* const old = GoaTech.getInstance();
|
|
161
|
-
* old.destroy();
|
|
162
|
-
* const fresh = GoaTech.init({ apiKey: nextKey });
|
|
163
|
-
*/
|
|
164
|
-
destroy(): void;
|
|
165
|
-
private start;
|
|
166
|
-
private applyConfig;
|
|
167
|
-
private postIdentityResolve;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
export { DiagnosticBus, DiagnosticEvent, ExperimentResult, FlagValue, GoaTech, GoaTechConfig, type IGoaTech, SDKStatus };
|
|
1
|
+
export * from '@sheepit-ai/sdk-js';
|
|
2
|
+
import '@sheepit-ai/sdk-js/boot-error';
|
|
3
|
+
import '@sheepit-ai/sdk-js/flags';
|
|
4
|
+
import '@sheepit-ai/sdk-js/experiments';
|