@obelism/improve-sdk 2.2.0 → 3.1.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 +14 -8
- package/dist/base-f9lw4y65.mjs +2 -0
- package/dist/base-f9lw4y65.mjs.map +1 -0
- package/dist/base-m0tq6j54.js +2 -0
- package/dist/base-m0tq6j54.js.map +1 -0
- package/dist/client.cjs +1 -1
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.ts +9 -54
- package/dist/client.d.ts.map +1 -1
- package/dist/client.mjs +1 -1
- package/dist/client.mjs.map +1 -1
- package/dist/server.cjs +1 -1
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.ts +3 -26
- package/dist/server.d.ts.map +1 -1
- package/dist/server.mjs +1 -1
- package/dist/server.mjs.map +1 -1
- package/dist/types.d.ts +40 -10
- package/dist/types.d.ts.map +1 -1
- package/package.json +15 -12
package/dist/types.d.ts
CHANGED
|
@@ -11,6 +11,28 @@ declare const AUDIENCE_PARAMS: {
|
|
|
11
11
|
};
|
|
12
12
|
type AudienceParamKey = keyof typeof AUDIENCE_PARAMS;
|
|
13
13
|
|
|
14
|
+
declare class BaseImproveSDK {
|
|
15
|
+
#private;
|
|
16
|
+
organizationId: string;
|
|
17
|
+
environment: ImproveEnvironmentOption;
|
|
18
|
+
state: ImproveTestState;
|
|
19
|
+
config: ImproveConfiguration | null;
|
|
20
|
+
_baseUrl: undefined | string;
|
|
21
|
+
constructor({ organizationId, environment, state, config, fetchTimeout, baseUrl, configRetries, configRevalidate, disableWarnings, }: ImproveSetupArgs);
|
|
22
|
+
_fetchConfig: (config?: RequestInit) => Promise<ImproveConfiguration>;
|
|
23
|
+
loadConfig: (config: ImproveConfiguration) => void;
|
|
24
|
+
generateVisitorId: () => string;
|
|
25
|
+
getVisitorCookieName: () => string;
|
|
26
|
+
/**
|
|
27
|
+
* Emit a development warning, unless warnings were disabled via the
|
|
28
|
+
* `disableWarnings` setup option. Centralized so every SDK warning honors the
|
|
29
|
+
* same switch. No-op where `console` is unavailable.
|
|
30
|
+
*/
|
|
31
|
+
protected _warn: (message: string) => void;
|
|
32
|
+
validateTestValue: (testName: string, testValue: string) => boolean;
|
|
33
|
+
validateVisitorId: (possibleVisitorId: string) => boolean;
|
|
34
|
+
}
|
|
35
|
+
|
|
14
36
|
type ImproveEnvironmentOption = 'develop' | 'staging' | 'production';
|
|
15
37
|
type ImproveTestState = 'draft' | 'active' | 'finished' | 'archived';
|
|
16
38
|
type ImproveSetupArgs = {
|
|
@@ -91,10 +113,21 @@ type ImproveRecommendedEventName = 'page_view' | 'view_item' | 'view_item_list'
|
|
|
91
113
|
* string is accepted so you can still use your own custom event names.
|
|
92
114
|
*/
|
|
93
115
|
type ImproveEventName = ImproveRecommendedEventName | (string & {});
|
|
116
|
+
/**
|
|
117
|
+
* An event name paired with its required, freeform `scope` — the one
|
|
118
|
+
* consistent key/value identity used everywhere (SDK, dashboard, test setup):
|
|
119
|
+
* e.g. `{ event: 'button_click', scope: 'homepage_hero_login' }`. Unlike
|
|
120
|
+
* `message` in previous SDK versions, `scope` is mandatory and expected to be
|
|
121
|
+
* a stable, structured string (not display text) — see `postAnalytic`.
|
|
122
|
+
*/
|
|
123
|
+
type ImproveEventRef = {
|
|
124
|
+
event: ImproveEventName;
|
|
125
|
+
scope: string;
|
|
126
|
+
};
|
|
94
127
|
type ImproveEvents = {
|
|
95
|
-
start:
|
|
96
|
-
metrics:
|
|
97
|
-
conversion:
|
|
128
|
+
start: ImproveEventRef;
|
|
129
|
+
metrics: ImproveEventRef[];
|
|
130
|
+
conversion: ImproveEventRef;
|
|
98
131
|
/**
|
|
99
132
|
* Ordered funnel steps for the multi-step conversion view, when the test
|
|
100
133
|
* defines one. The last step is the conversion; when absent, the funnel is
|
|
@@ -104,7 +137,8 @@ type ImproveEvents = {
|
|
|
104
137
|
};
|
|
105
138
|
/**
|
|
106
139
|
* Structured payload for an analytic event, aligned with Google Analytics 4
|
|
107
|
-
* event parameters.
|
|
140
|
+
* event parameters. `event` and `scope` are passed as `postAnalytic`'s first
|
|
141
|
+
* two (required) arguments — everything here is optional extras.
|
|
108
142
|
*
|
|
109
143
|
* - `value` (with `currency`) is the numeric measure Improve aggregates into
|
|
110
144
|
* **revenue / average order value per variant** — pass an order total on your
|
|
@@ -113,19 +147,14 @@ type ImproveEvents = {
|
|
|
113
147
|
* - `params` is passed through to the GTM dataLayer and stored as JSON, but is
|
|
114
148
|
* not aggregated by Improve's own results. Use it for a GA4 `ecommerce`
|
|
115
149
|
* object (`{ ecommerce: { items: [...] } }`) or any custom event parameters.
|
|
116
|
-
* - `message` is kept for the simple single-string case.
|
|
117
150
|
* - `dedupeKey` distinguishes repeated firings of the same event name — see
|
|
118
151
|
* below.
|
|
119
|
-
*
|
|
120
|
-
* `postAnalytic` also accepts a plain string as a shorthand for `{ message }`.
|
|
121
152
|
*/
|
|
122
153
|
type ImproveAnalyticPayload = {
|
|
123
154
|
/** Numeric value of the event, e.g. an order total. GA4 `value`. */
|
|
124
155
|
value?: number;
|
|
125
156
|
/** ISO 4217 currency code for `value`, e.g. `'USD'`. GA4 `currency`. */
|
|
126
157
|
currency?: string;
|
|
127
|
-
/** A short freeform label stored alongside the event. */
|
|
128
|
-
message?: string;
|
|
129
158
|
/**
|
|
130
159
|
* Extra event parameters, spread onto the GTM dataLayer entry and stored as
|
|
131
160
|
* JSON. Provide `{ ecommerce: {...} }` for GA4 ecommerce tags; the SDK clears
|
|
@@ -182,5 +211,6 @@ type ImproveConfiguration = {
|
|
|
182
211
|
audience: ImproveAudience;
|
|
183
212
|
};
|
|
184
213
|
|
|
185
|
-
export
|
|
214
|
+
export { BaseImproveSDK };
|
|
215
|
+
export type { ImproveAnalyticPayload, ImproveAudience, ImproveAudienceValue, ImproveConfiguration, ImproveEnvironmentOption, ImproveEventName, ImproveEventRef, ImproveEvents, ImproveFlag, ImproveFlagOption, ImproveFlags, ImproveRecommendedEventName, ImproveResult, ImproveSetupArgs, ImproveTest, ImproveTestOption, ImproveTestState, ImproveTests };
|
|
186
216
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sources":["../src/config/audiences.ts","../src/types.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA,cAAc,eAAe;AAC7B,sBAAsB,aAAa;AACnC;AACA;AACA;AACA;AACA;AACA,KAAK,gBAAgB,gBAAgB,eAAe;;ACVpD,KAAK,wBAAwB;AAC7B,KAAK,gBAAgB;AACrB,KAAK,gBAAgB;AACrB;AACA,iBAAiB,wBAAwB;AACzC,YAAY,gBAAgB;AAC5B,aAAa,oBAAoB;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,iBAAiB;AACtB;AACA;AACA;AACA;AACA;AACA,KAAK,iBAAiB;AACtB;AACA;AACA;AACA;AACA;AACA,KAAK,WAAW;AAChB;AACA;AACA;AACA,aAAa,iBAAiB;AAC9B;AACA,KAAK,YAAY;AACjB,0BAA0B,WAAW;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,2BAA2B;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,gBAAgB,GAAG,2BAA2B;AACnD,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sources":["../src/config/audiences.ts","../src/base.ts","../src/types.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA,cAAc,eAAe;AAC7B,sBAAsB,aAAa;AACnC;AACA;AACA;AACA;AACA;AACA,KAAK,gBAAgB,gBAAgB,eAAe;;ACVpD,cAAc,cAAc;AAC5B;AACA;AACA,iBAAiB,wBAAwB;AACzC,WAAW,gBAAgB;AAC3B,YAAY,oBAAoB;AAChC;AACA,0IAA0I,gBAAgB;AAC1J,4BAA4B,WAAW,KAAK,OAAO,CAAC,oBAAoB;AACxE,yBAAyB,oBAAoB;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACpBA,KAAK,wBAAwB;AAC7B,KAAK,gBAAgB;AACrB,KAAK,gBAAgB;AACrB;AACA,iBAAiB,wBAAwB;AACzC,YAAY,gBAAgB;AAC5B,aAAa,oBAAoB;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,iBAAiB;AACtB;AACA;AACA;AACA;AACA;AACA,KAAK,iBAAiB;AACtB;AACA;AACA;AACA;AACA;AACA,KAAK,WAAW;AAChB;AACA;AACA;AACA,aAAa,iBAAiB;AAC9B;AACA,KAAK,YAAY;AACjB,0BAA0B,WAAW;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,2BAA2B;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,gBAAgB,GAAG,2BAA2B;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,eAAe;AACpB,WAAW,gBAAgB;AAC3B;AACA;AACA,KAAK,aAAa;AAClB,WAAW,eAAe;AAC1B,aAAa,eAAe;AAC5B,gBAAgB,eAAe;AAC/B;AACA;AACA;AACA;AACA;AACA,aAAa,gBAAgB;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,sBAAsB;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,aAAa;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,WAAW;AAChB;AACA;AACA;AACA;AACA;AACA,aAAa,iBAAiB;AAC9B,YAAY,aAAa;AACzB;AACA,KAAK,YAAY;AACjB,0BAA0B,WAAW;AACrC;AACA,KAAK,oBAAoB;AACzB,YAAY,gBAAgB;AAC5B;AACA,KAAK,eAAe;AACpB,8BAA8B,oBAAoB;AAClD;AACA,KAAK,oBAAoB;AACzB;AACA;AACA,WAAW,YAAY;AACvB,WAAW,YAAY;AACvB,cAAc,eAAe;AAC7B;;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@obelism/improve-sdk",
|
|
3
3
|
"description": "Obelism Improve SDK",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "3.1.0",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ab-tests",
|
|
7
7
|
"feature-flags",
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"author": "Obelism <hello@obelism.studio> (https://www.obelism.studio)",
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
|
-
"url": "https://github.com/Obelism/
|
|
16
|
-
"directory": "packages/
|
|
15
|
+
"url": "https://github.com/Obelism/sdk",
|
|
16
|
+
"directory": "packages/improve"
|
|
17
17
|
},
|
|
18
18
|
"sideEffects": false,
|
|
19
19
|
"files": [
|
|
@@ -54,22 +54,25 @@
|
|
|
54
54
|
"test:coverage": "vitest run --coverage",
|
|
55
55
|
"test:ci": "vitest run",
|
|
56
56
|
"lint": "npm-run-all --parallel lint:*",
|
|
57
|
-
"lint:
|
|
57
|
+
"lint:oxlint": "oxlint",
|
|
58
58
|
"lint:types": "tsc --noEmit",
|
|
59
59
|
"clean": "rm -rf ./node_modules && rm -rf ./dist && rm -rf ./.turbo"
|
|
60
60
|
},
|
|
61
|
+
"dependencies": {
|
|
62
|
+
"@obelism/numbers-sdk": "^0.1.0"
|
|
63
|
+
},
|
|
61
64
|
"peerDependencies": {
|
|
62
65
|
"ua-parser-js": "^2.0.0"
|
|
63
66
|
},
|
|
64
67
|
"devDependencies": {
|
|
65
|
-
"@obelism/
|
|
66
|
-
"@
|
|
67
|
-
"bunchee": "^
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"typescript": "^
|
|
68
|
+
"@obelism/sdk-typescript-config": "^0.0.0",
|
|
69
|
+
"@typescript/typescript6": "^6.0.2",
|
|
70
|
+
"bunchee": "^7.0.2",
|
|
71
|
+
"jsdom": "^30.1.2",
|
|
72
|
+
"npm-run-all2": "^9.0.2",
|
|
73
|
+
"oxlint": "^1.88.0",
|
|
74
|
+
"typescript": "^7.0.2",
|
|
72
75
|
"ua-parser-js": "^2.0.10",
|
|
73
|
-
"vitest": "^
|
|
76
|
+
"vitest": "^5.0.4"
|
|
74
77
|
}
|
|
75
78
|
}
|