@rudderstack/analytics-js 3.31.8 → 3.32.0-beta.pr.3194.9b9fe31
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/CHANGELOG.md +16 -0
- package/README.md +6 -3
- package/dist/npm/index.d.cts +110 -46
- package/dist/npm/index.d.mts +110 -46
- package/dist/npm/legacy/bundled/cjs/index.cjs +149 -67
- package/dist/npm/legacy/bundled/esm/index.mjs +149 -67
- package/dist/npm/legacy/bundled/umd/index.js +149 -67
- package/dist/npm/legacy/cjs/index.cjs +149 -67
- package/dist/npm/legacy/content-script/cjs/index.cjs +149 -67
- package/dist/npm/legacy/content-script/esm/index.mjs +149 -67
- package/dist/npm/legacy/content-script/umd/index.js +149 -67
- package/dist/npm/legacy/esm/index.mjs +149 -67
- package/dist/npm/legacy/lite/cjs/index.cjs +149 -67
- package/dist/npm/legacy/lite/esm/index.mjs +149 -67
- package/dist/npm/legacy/lite/umd/index.js +149 -67
- package/dist/npm/legacy/umd/index.js +149 -67
- package/dist/npm/modern/bundled/cjs/index.cjs +146 -64
- package/dist/npm/modern/bundled/esm/index.mjs +146 -64
- package/dist/npm/modern/bundled/umd/index.js +146 -64
- package/dist/npm/modern/cjs/index.cjs +147 -64
- package/dist/npm/modern/content-script/cjs/index.cjs +146 -64
- package/dist/npm/modern/content-script/esm/index.mjs +146 -64
- package/dist/npm/modern/content-script/umd/index.js +146 -64
- package/dist/npm/modern/esm/index.mjs +147 -64
- package/dist/npm/modern/lite/cjs/index.cjs +146 -64
- package/dist/npm/modern/lite/esm/index.mjs +146 -64
- package/dist/npm/modern/lite/umd/index.js +146 -64
- package/dist/npm/modern/umd/index.js +147 -64
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [3.32.0](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js@3.31.8...@rudderstack/analytics-js@3.32.0) (2026-08-24)
|
|
6
|
+
|
|
7
|
+
### Dependency Updates
|
|
8
|
+
|
|
9
|
+
* `@rudderstack/analytics-js-cookies` updated to version `0.5.13`
|
|
10
|
+
* `@rudderstack/analytics-js-common` updated to version `3.28.4`
|
|
11
|
+
* `@rudderstack/analytics-js-plugins` updated to version `3.15.13`
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* sdk-5054 add state-backed custom context store ([#3129](https://github.com/rudderlabs/rudder-sdk-js/issues/3129)) ([b5ef16f](https://github.com/rudderlabs/rudder-sdk-js/commit/b5ef16fbc71bbdd21fbbdeb38ae98133cf7a7b4b))
|
|
16
|
+
* sdk-5055 seed load-time custom context ([#3132](https://github.com/rudderlabs/rudder-sdk-js/issues/3132)) ([fdda1e0](https://github.com/rudderlabs/rudder-sdk-js/commit/fdda1e046bbdb108f022f550e991a3b8e6c5e6e2))
|
|
17
|
+
* sdk-5056 enrich events with custom context ([#3133](https://github.com/rudderlabs/rudder-sdk-js/issues/3133)) ([fafbd52](https://github.com/rudderlabs/rudder-sdk-js/commit/fafbd5265fb61bdae844f4df1307fd8c11b9d6f1))
|
|
18
|
+
* sdk-5057 add custom context validation foundation ([#3128](https://github.com/rudderlabs/rudder-sdk-js/issues/3128)) ([a197998](https://github.com/rudderlabs/rudder-sdk-js/commit/a19799864f80357f6e67d9e8b0a0d3d065d483aa))
|
|
19
|
+
* sdk-5058 expose custom context public api ([#3131](https://github.com/rudderlabs/rudder-sdk-js/issues/3131)) ([08686ce](https://github.com/rudderlabs/rudder-sdk-js/commit/08686ce687069c5f344c15653691dc35879bc63a))
|
|
20
|
+
|
|
5
21
|
## [3.31.8](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js@3.31.7...@rudderstack/analytics-js@3.31.8) (2026-08-19)
|
|
6
22
|
|
|
7
23
|
### Dependency Updates
|
package/README.md
CHANGED
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
<p align="center">
|
|
4
4
|
<a href="https://rudderstack.com/">
|
|
5
|
-
<
|
|
5
|
+
<picture>
|
|
6
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/rudderlabs/rudder-sdk-js/develop/assets/rs-logo-full-dark.png">
|
|
7
|
+
<img alt="RudderStack" width="512" src="https://raw.githubusercontent.com/rudderlabs/rudder-sdk-js/develop/assets/rs-logo-full-light.jpg">
|
|
8
|
+
</picture>
|
|
6
9
|
</a>
|
|
7
10
|
<br />
|
|
8
11
|
<caption>The Customer Data Platform for Developers</caption>
|
|
@@ -91,8 +94,8 @@ RudderStack JS SDK [service worker](https://www.npmjs.com/package/@rudderstack/a
|
|
|
91
94
|
|
|
92
95
|
For more details, see:
|
|
93
96
|
|
|
94
|
-
- [Vercel Edge Usage](https://github.com/rudderlabs/rudder-sdk-js/blob/main/examples/serverless/USAGE.md)
|
|
95
|
-
- [Cloudflare Worker Usage](https://github.com/rudderlabs/rudder-sdk-js/blob/main/examples/serverless/USAGE.md)
|
|
97
|
+
- [Vercel Edge Usage](https://github.com/rudderlabs/rudder-sdk-js/blob/main/examples/serverless/USAGE.md#vercel-edge)
|
|
98
|
+
- [Cloudflare Worker Usage](https://github.com/rudderlabs/rudder-sdk-js/blob/main/examples/serverless/USAGE.md#cloudflare-worker)
|
|
96
99
|
|
|
97
100
|
## License
|
|
98
101
|
|
package/dist/npm/index.d.cts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Signal } from '@preact/signals-core';
|
|
2
|
+
|
|
1
3
|
type LoggerProvider$1 = Record<Exclude<Lowercase<LogLevel>, Lowercase<'NONE'>>, (...data: any[]) => void>;
|
|
2
4
|
interface ILogger {
|
|
3
5
|
minLogLevel: number;
|
|
@@ -202,6 +204,15 @@ type ConsentOptions = {
|
|
|
202
204
|
trackConsent?: boolean;
|
|
203
205
|
};
|
|
204
206
|
|
|
207
|
+
type CustomContextValue = string | number | boolean | Date | CustomContext | CustomContextValue[];
|
|
208
|
+
interface CustomContext {
|
|
209
|
+
[key: string]: CustomContextValue;
|
|
210
|
+
}
|
|
211
|
+
type InputCustomContextValue = string | number | boolean | Date | null | undefined | InputCustomContext | InputCustomContextValue[];
|
|
212
|
+
interface InputCustomContext {
|
|
213
|
+
[key: string]: InputCustomContextValue;
|
|
214
|
+
}
|
|
215
|
+
|
|
205
216
|
type UaChTrackLevel = 'none' | 'default' | 'full';
|
|
206
217
|
/**
|
|
207
218
|
* Represents the options parameter for anonymousId
|
|
@@ -265,9 +276,22 @@ type DestinationsQueueOpts = {
|
|
|
265
276
|
};
|
|
266
277
|
type OnLoadedCallback = (analytics: any) => void;
|
|
267
278
|
type DeliveryType = 'immediate' | 'buffer';
|
|
279
|
+
/**
|
|
280
|
+
* @deprecated Use the `storage` load API option to control what is persisted before consent is given. It will be removed in the next major version.
|
|
281
|
+
*/
|
|
268
282
|
type StorageStrategy = 'none' | 'session' | 'anonymousId';
|
|
269
283
|
type PreConsentStorageOptions = {
|
|
270
|
-
|
|
284
|
+
/**
|
|
285
|
+
* Applies the `storage` load API option during the pre-consent phase, taking precedence over
|
|
286
|
+
* `strategy`. When it is not enabled, `strategy` decides what is persisted instead, and with
|
|
287
|
+
* neither of them nothing is persisted before consent is given. Defaults to false.
|
|
288
|
+
*/
|
|
289
|
+
enabled?: boolean;
|
|
290
|
+
/**
|
|
291
|
+
* Only applies when `enabled` is not set. Defaults to persisting nothing.
|
|
292
|
+
* @deprecated Enable `storage` in the pre-consent options and use the `storage` load API option instead. It will be removed in the next major version.
|
|
293
|
+
*/
|
|
294
|
+
strategy?: StorageStrategy;
|
|
271
295
|
};
|
|
272
296
|
type PreConsentEventsOptions = {
|
|
273
297
|
delivery: DeliveryType;
|
|
@@ -305,6 +329,7 @@ type SourceConfigurationOverride = {
|
|
|
305
329
|
* Represents the options parameter in the load API
|
|
306
330
|
*/
|
|
307
331
|
type LoadOptions = {
|
|
332
|
+
context?: InputCustomContext;
|
|
308
333
|
logLevel?: LogLevel;
|
|
309
334
|
integrations?: IntegrationOpts;
|
|
310
335
|
configUrl?: string;
|
|
@@ -456,6 +481,38 @@ type ScreenInfo = {
|
|
|
456
481
|
};
|
|
457
482
|
type UTMParameters = Record<string, string>;
|
|
458
483
|
|
|
484
|
+
type PageCallOptions = {
|
|
485
|
+
category?: string;
|
|
486
|
+
name?: string;
|
|
487
|
+
properties?: Nullable<ApiObject>;
|
|
488
|
+
options?: Nullable<ApiOptions>;
|
|
489
|
+
callback?: ApiCallback;
|
|
490
|
+
};
|
|
491
|
+
type TrackCallOptions = {
|
|
492
|
+
name: string;
|
|
493
|
+
properties?: Nullable<ApiObject>;
|
|
494
|
+
options?: Nullable<ApiOptions>;
|
|
495
|
+
callback?: ApiCallback;
|
|
496
|
+
};
|
|
497
|
+
type IdentifyCallOptions = {
|
|
498
|
+
userId?: Nullable<string>;
|
|
499
|
+
traits?: Nullable<IdentifyTraits>;
|
|
500
|
+
options?: Nullable<ApiOptions>;
|
|
501
|
+
callback?: ApiCallback;
|
|
502
|
+
};
|
|
503
|
+
type AliasCallOptions = {
|
|
504
|
+
to: string;
|
|
505
|
+
from?: string;
|
|
506
|
+
options?: Nullable<ApiOptions>;
|
|
507
|
+
callback?: ApiCallback;
|
|
508
|
+
};
|
|
509
|
+
type GroupCallOptions = {
|
|
510
|
+
groupId?: Nullable<string>;
|
|
511
|
+
traits?: Nullable<ApiObject>;
|
|
512
|
+
options?: Nullable<ApiOptions>;
|
|
513
|
+
callback?: ApiCallback;
|
|
514
|
+
};
|
|
515
|
+
|
|
459
516
|
type PageLifecycle = {
|
|
460
517
|
pageViewId: string;
|
|
461
518
|
};
|
|
@@ -682,6 +739,18 @@ interface IRudderAnalytics<T = any> {
|
|
|
682
739
|
* To get group traits set in the SDK
|
|
683
740
|
*/
|
|
684
741
|
getGroupTraits(): Nullable<ApiObject> | undefined;
|
|
742
|
+
/**
|
|
743
|
+
* Merge fields into the in-memory custom context for subsequent event calls.
|
|
744
|
+
*/
|
|
745
|
+
setCustomContext(context: InputCustomContext): void;
|
|
746
|
+
/**
|
|
747
|
+
* Get a defensive snapshot of the current in-memory custom context.
|
|
748
|
+
*/
|
|
749
|
+
getCustomContext(): CustomContext;
|
|
750
|
+
/**
|
|
751
|
+
* Clear the complete in-memory custom context.
|
|
752
|
+
*/
|
|
753
|
+
clearCustomContext(): void;
|
|
685
754
|
/**
|
|
686
755
|
* To manually start user session in the SDK
|
|
687
756
|
*/
|
|
@@ -717,7 +786,7 @@ type RSAnalytics = Pick<IRudderAnalytics, 'track' | 'page' | 'identify' | 'group
|
|
|
717
786
|
* For now, it is the same as the base destination config
|
|
718
787
|
* but in the future, it can be extended to include more properties
|
|
719
788
|
*/
|
|
720
|
-
type CustomDestinationConfig = BaseDestinationConfig
|
|
789
|
+
type CustomDestinationConfig = BaseDestinationConfig;
|
|
721
790
|
/**
|
|
722
791
|
* Type for the custom integration to be used in addCustomIntegration API
|
|
723
792
|
* Defines the contract that all custom integrations must implement
|
|
@@ -921,38 +990,6 @@ interface IInMemoryStorageOptions {
|
|
|
921
990
|
enabled?: boolean;
|
|
922
991
|
}
|
|
923
992
|
|
|
924
|
-
type PageCallOptions = {
|
|
925
|
-
category?: string;
|
|
926
|
-
name?: string;
|
|
927
|
-
properties?: Nullable<ApiObject>;
|
|
928
|
-
options?: Nullable<ApiOptions>;
|
|
929
|
-
callback?: ApiCallback;
|
|
930
|
-
};
|
|
931
|
-
type TrackCallOptions = {
|
|
932
|
-
name: string;
|
|
933
|
-
properties?: Nullable<ApiObject>;
|
|
934
|
-
options?: Nullable<ApiOptions>;
|
|
935
|
-
callback?: ApiCallback;
|
|
936
|
-
};
|
|
937
|
-
type IdentifyCallOptions = {
|
|
938
|
-
userId?: Nullable<string>;
|
|
939
|
-
traits?: Nullable<IdentifyTraits>;
|
|
940
|
-
options?: Nullable<ApiOptions>;
|
|
941
|
-
callback?: ApiCallback;
|
|
942
|
-
};
|
|
943
|
-
type AliasCallOptions = {
|
|
944
|
-
to: string;
|
|
945
|
-
from?: string;
|
|
946
|
-
options?: Nullable<ApiOptions>;
|
|
947
|
-
callback?: ApiCallback;
|
|
948
|
-
};
|
|
949
|
-
type GroupCallOptions = {
|
|
950
|
-
groupId?: Nullable<string>;
|
|
951
|
-
traits?: Nullable<ApiObject>;
|
|
952
|
-
options?: Nullable<ApiOptions>;
|
|
953
|
-
callback?: ApiCallback;
|
|
954
|
-
};
|
|
955
|
-
|
|
956
993
|
/**
|
|
957
994
|
* A buffer queue to serve as a store for any type of data
|
|
958
995
|
*/
|
|
@@ -1024,6 +1061,18 @@ declare class Store implements IStore {
|
|
|
1024
1061
|
onError(error: unknown, customMessage?: string, groupingHash?: string): void;
|
|
1025
1062
|
}
|
|
1026
1063
|
|
|
1064
|
+
type StatsCollection = {
|
|
1065
|
+
errors: {
|
|
1066
|
+
enabled: boolean;
|
|
1067
|
+
provider?: string;
|
|
1068
|
+
};
|
|
1069
|
+
metrics: {
|
|
1070
|
+
enabled: boolean;
|
|
1071
|
+
};
|
|
1072
|
+
};
|
|
1073
|
+
|
|
1074
|
+
type CustomContextState = Signal<CustomContext>;
|
|
1075
|
+
|
|
1027
1076
|
interface IUserSessionManager {
|
|
1028
1077
|
storeManager?: IStoreManager;
|
|
1029
1078
|
init(): void;
|
|
@@ -1046,16 +1095,6 @@ interface IUserSessionManager {
|
|
|
1046
1095
|
setAuthToken(token: Nullable<string>): void;
|
|
1047
1096
|
}
|
|
1048
1097
|
|
|
1049
|
-
type StatsCollection = {
|
|
1050
|
-
errors: {
|
|
1051
|
-
enabled: boolean;
|
|
1052
|
-
provider?: string;
|
|
1053
|
-
};
|
|
1054
|
-
metrics: {
|
|
1055
|
-
enabled: boolean;
|
|
1056
|
-
};
|
|
1057
|
-
};
|
|
1058
|
-
|
|
1059
1098
|
type DestinationDefinition = {
|
|
1060
1099
|
name: string;
|
|
1061
1100
|
displayName: string;
|
|
@@ -1130,7 +1169,7 @@ interface IConfigManager {
|
|
|
1130
1169
|
|
|
1131
1170
|
interface IEventManager {
|
|
1132
1171
|
init(): void;
|
|
1133
|
-
addEvent(event: APIEvent): void;
|
|
1172
|
+
addEvent(event: APIEvent, customContext: CustomContext): void;
|
|
1134
1173
|
resume(): void;
|
|
1135
1174
|
}
|
|
1136
1175
|
|
|
@@ -1151,6 +1190,15 @@ type RudderAnalyticsPreloader = {
|
|
|
1151
1190
|
[index: string]: (...args: any[]) => any;
|
|
1152
1191
|
};
|
|
1153
1192
|
|
|
1193
|
+
declare class CustomContextStore {
|
|
1194
|
+
private readonly state;
|
|
1195
|
+
private readonly logger;
|
|
1196
|
+
constructor(state: CustomContextState, logger: ILogger);
|
|
1197
|
+
set(context: unknown): void;
|
|
1198
|
+
get(): CustomContext;
|
|
1199
|
+
clear(): void;
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1154
1202
|
interface IAnalytics {
|
|
1155
1203
|
preloadBuffer: BufferQueue<PreloadedEventCall>;
|
|
1156
1204
|
initialized: boolean;
|
|
@@ -1165,6 +1213,7 @@ interface IAnalytics {
|
|
|
1165
1213
|
userSessionManager?: IUserSessionManager;
|
|
1166
1214
|
pluginsManager?: IPluginsManager;
|
|
1167
1215
|
clientDataStore?: Store;
|
|
1216
|
+
customContextStore: CustomContextStore;
|
|
1168
1217
|
/**
|
|
1169
1218
|
* Start application lifecycle if not already started
|
|
1170
1219
|
*/
|
|
@@ -1278,6 +1327,18 @@ interface IAnalytics {
|
|
|
1278
1327
|
* To get group traits set in the SDK
|
|
1279
1328
|
*/
|
|
1280
1329
|
getGroupTraits(): Nullable<ApiObject> | undefined;
|
|
1330
|
+
/**
|
|
1331
|
+
* Merge fields into the current custom context
|
|
1332
|
+
*/
|
|
1333
|
+
setCustomContext(context: InputCustomContext): void;
|
|
1334
|
+
/**
|
|
1335
|
+
* Get a defensive snapshot of the current custom context
|
|
1336
|
+
*/
|
|
1337
|
+
getCustomContext(): CustomContext;
|
|
1338
|
+
/**
|
|
1339
|
+
* Clear the current custom context
|
|
1340
|
+
*/
|
|
1341
|
+
clearCustomContext(): void;
|
|
1281
1342
|
/**
|
|
1282
1343
|
* To manually start user session in the SDK
|
|
1283
1344
|
*/
|
|
@@ -1439,6 +1500,9 @@ declare class RudderAnalytics implements IRudderAnalytics<IAnalytics> {
|
|
|
1439
1500
|
getUserTraits(): Nullable<ApiObject> | undefined;
|
|
1440
1501
|
getGroupId(): Nullable<string> | undefined;
|
|
1441
1502
|
getGroupTraits(): Nullable<ApiObject> | undefined;
|
|
1503
|
+
setCustomContext(context: InputCustomContext): void;
|
|
1504
|
+
getCustomContext(): CustomContext;
|
|
1505
|
+
clearCustomContext(): void;
|
|
1442
1506
|
startSession(sessionId?: number): void;
|
|
1443
1507
|
endSession(): void;
|
|
1444
1508
|
getSessionId(): Nullable<number> | undefined;
|
|
@@ -1454,4 +1518,4 @@ declare global {
|
|
|
1454
1518
|
}
|
|
1455
1519
|
|
|
1456
1520
|
export { RudderAnalytics };
|
|
1457
|
-
export type { AnonymousIdOptions, ApiCallback, ApiObject, ApiOptions, BeaconQueueOpts, ConsentOptions, CookieSameSite, CustomDestinationConfig, DestinationsQueueOpts, IdentifyTraits, IntegrationOpts, LoadOptions, LogLevel, PluginName, PreloadedEventCall, QueueOpts, RSACustomIntegration, RSAEvent, RSALogger, RSAnalytics, RudderAnalyticsPreloader, SessionOpts, UaChTrackLevel };
|
|
1521
|
+
export type { AnonymousIdOptions, ApiCallback, ApiObject, ApiOptions, BeaconQueueOpts, ConsentOptions, CookieSameSite, CustomContext, CustomContextValue, CustomDestinationConfig, DestinationsQueueOpts, IdentifyTraits, InputCustomContext, InputCustomContextValue, IntegrationOpts, LoadOptions, LogLevel, PluginName, PreloadedEventCall, QueueOpts, RSACustomIntegration, RSAEvent, RSALogger, RSAnalytics, RudderAnalyticsPreloader, SessionOpts, UaChTrackLevel };
|
package/dist/npm/index.d.mts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Signal } from '@preact/signals-core';
|
|
2
|
+
|
|
1
3
|
type LoggerProvider$1 = Record<Exclude<Lowercase<LogLevel>, Lowercase<'NONE'>>, (...data: any[]) => void>;
|
|
2
4
|
interface ILogger {
|
|
3
5
|
minLogLevel: number;
|
|
@@ -202,6 +204,15 @@ type ConsentOptions = {
|
|
|
202
204
|
trackConsent?: boolean;
|
|
203
205
|
};
|
|
204
206
|
|
|
207
|
+
type CustomContextValue = string | number | boolean | Date | CustomContext | CustomContextValue[];
|
|
208
|
+
interface CustomContext {
|
|
209
|
+
[key: string]: CustomContextValue;
|
|
210
|
+
}
|
|
211
|
+
type InputCustomContextValue = string | number | boolean | Date | null | undefined | InputCustomContext | InputCustomContextValue[];
|
|
212
|
+
interface InputCustomContext {
|
|
213
|
+
[key: string]: InputCustomContextValue;
|
|
214
|
+
}
|
|
215
|
+
|
|
205
216
|
type UaChTrackLevel = 'none' | 'default' | 'full';
|
|
206
217
|
/**
|
|
207
218
|
* Represents the options parameter for anonymousId
|
|
@@ -265,9 +276,22 @@ type DestinationsQueueOpts = {
|
|
|
265
276
|
};
|
|
266
277
|
type OnLoadedCallback = (analytics: any) => void;
|
|
267
278
|
type DeliveryType = 'immediate' | 'buffer';
|
|
279
|
+
/**
|
|
280
|
+
* @deprecated Use the `storage` load API option to control what is persisted before consent is given. It will be removed in the next major version.
|
|
281
|
+
*/
|
|
268
282
|
type StorageStrategy = 'none' | 'session' | 'anonymousId';
|
|
269
283
|
type PreConsentStorageOptions = {
|
|
270
|
-
|
|
284
|
+
/**
|
|
285
|
+
* Applies the `storage` load API option during the pre-consent phase, taking precedence over
|
|
286
|
+
* `strategy`. When it is not enabled, `strategy` decides what is persisted instead, and with
|
|
287
|
+
* neither of them nothing is persisted before consent is given. Defaults to false.
|
|
288
|
+
*/
|
|
289
|
+
enabled?: boolean;
|
|
290
|
+
/**
|
|
291
|
+
* Only applies when `enabled` is not set. Defaults to persisting nothing.
|
|
292
|
+
* @deprecated Enable `storage` in the pre-consent options and use the `storage` load API option instead. It will be removed in the next major version.
|
|
293
|
+
*/
|
|
294
|
+
strategy?: StorageStrategy;
|
|
271
295
|
};
|
|
272
296
|
type PreConsentEventsOptions = {
|
|
273
297
|
delivery: DeliveryType;
|
|
@@ -305,6 +329,7 @@ type SourceConfigurationOverride = {
|
|
|
305
329
|
* Represents the options parameter in the load API
|
|
306
330
|
*/
|
|
307
331
|
type LoadOptions = {
|
|
332
|
+
context?: InputCustomContext;
|
|
308
333
|
logLevel?: LogLevel;
|
|
309
334
|
integrations?: IntegrationOpts;
|
|
310
335
|
configUrl?: string;
|
|
@@ -456,6 +481,38 @@ type ScreenInfo = {
|
|
|
456
481
|
};
|
|
457
482
|
type UTMParameters = Record<string, string>;
|
|
458
483
|
|
|
484
|
+
type PageCallOptions = {
|
|
485
|
+
category?: string;
|
|
486
|
+
name?: string;
|
|
487
|
+
properties?: Nullable<ApiObject>;
|
|
488
|
+
options?: Nullable<ApiOptions>;
|
|
489
|
+
callback?: ApiCallback;
|
|
490
|
+
};
|
|
491
|
+
type TrackCallOptions = {
|
|
492
|
+
name: string;
|
|
493
|
+
properties?: Nullable<ApiObject>;
|
|
494
|
+
options?: Nullable<ApiOptions>;
|
|
495
|
+
callback?: ApiCallback;
|
|
496
|
+
};
|
|
497
|
+
type IdentifyCallOptions = {
|
|
498
|
+
userId?: Nullable<string>;
|
|
499
|
+
traits?: Nullable<IdentifyTraits>;
|
|
500
|
+
options?: Nullable<ApiOptions>;
|
|
501
|
+
callback?: ApiCallback;
|
|
502
|
+
};
|
|
503
|
+
type AliasCallOptions = {
|
|
504
|
+
to: string;
|
|
505
|
+
from?: string;
|
|
506
|
+
options?: Nullable<ApiOptions>;
|
|
507
|
+
callback?: ApiCallback;
|
|
508
|
+
};
|
|
509
|
+
type GroupCallOptions = {
|
|
510
|
+
groupId?: Nullable<string>;
|
|
511
|
+
traits?: Nullable<ApiObject>;
|
|
512
|
+
options?: Nullable<ApiOptions>;
|
|
513
|
+
callback?: ApiCallback;
|
|
514
|
+
};
|
|
515
|
+
|
|
459
516
|
type PageLifecycle = {
|
|
460
517
|
pageViewId: string;
|
|
461
518
|
};
|
|
@@ -682,6 +739,18 @@ interface IRudderAnalytics<T = any> {
|
|
|
682
739
|
* To get group traits set in the SDK
|
|
683
740
|
*/
|
|
684
741
|
getGroupTraits(): Nullable<ApiObject> | undefined;
|
|
742
|
+
/**
|
|
743
|
+
* Merge fields into the in-memory custom context for subsequent event calls.
|
|
744
|
+
*/
|
|
745
|
+
setCustomContext(context: InputCustomContext): void;
|
|
746
|
+
/**
|
|
747
|
+
* Get a defensive snapshot of the current in-memory custom context.
|
|
748
|
+
*/
|
|
749
|
+
getCustomContext(): CustomContext;
|
|
750
|
+
/**
|
|
751
|
+
* Clear the complete in-memory custom context.
|
|
752
|
+
*/
|
|
753
|
+
clearCustomContext(): void;
|
|
685
754
|
/**
|
|
686
755
|
* To manually start user session in the SDK
|
|
687
756
|
*/
|
|
@@ -717,7 +786,7 @@ type RSAnalytics = Pick<IRudderAnalytics, 'track' | 'page' | 'identify' | 'group
|
|
|
717
786
|
* For now, it is the same as the base destination config
|
|
718
787
|
* but in the future, it can be extended to include more properties
|
|
719
788
|
*/
|
|
720
|
-
type CustomDestinationConfig = BaseDestinationConfig
|
|
789
|
+
type CustomDestinationConfig = BaseDestinationConfig;
|
|
721
790
|
/**
|
|
722
791
|
* Type for the custom integration to be used in addCustomIntegration API
|
|
723
792
|
* Defines the contract that all custom integrations must implement
|
|
@@ -921,38 +990,6 @@ interface IInMemoryStorageOptions {
|
|
|
921
990
|
enabled?: boolean;
|
|
922
991
|
}
|
|
923
992
|
|
|
924
|
-
type PageCallOptions = {
|
|
925
|
-
category?: string;
|
|
926
|
-
name?: string;
|
|
927
|
-
properties?: Nullable<ApiObject>;
|
|
928
|
-
options?: Nullable<ApiOptions>;
|
|
929
|
-
callback?: ApiCallback;
|
|
930
|
-
};
|
|
931
|
-
type TrackCallOptions = {
|
|
932
|
-
name: string;
|
|
933
|
-
properties?: Nullable<ApiObject>;
|
|
934
|
-
options?: Nullable<ApiOptions>;
|
|
935
|
-
callback?: ApiCallback;
|
|
936
|
-
};
|
|
937
|
-
type IdentifyCallOptions = {
|
|
938
|
-
userId?: Nullable<string>;
|
|
939
|
-
traits?: Nullable<IdentifyTraits>;
|
|
940
|
-
options?: Nullable<ApiOptions>;
|
|
941
|
-
callback?: ApiCallback;
|
|
942
|
-
};
|
|
943
|
-
type AliasCallOptions = {
|
|
944
|
-
to: string;
|
|
945
|
-
from?: string;
|
|
946
|
-
options?: Nullable<ApiOptions>;
|
|
947
|
-
callback?: ApiCallback;
|
|
948
|
-
};
|
|
949
|
-
type GroupCallOptions = {
|
|
950
|
-
groupId?: Nullable<string>;
|
|
951
|
-
traits?: Nullable<ApiObject>;
|
|
952
|
-
options?: Nullable<ApiOptions>;
|
|
953
|
-
callback?: ApiCallback;
|
|
954
|
-
};
|
|
955
|
-
|
|
956
993
|
/**
|
|
957
994
|
* A buffer queue to serve as a store for any type of data
|
|
958
995
|
*/
|
|
@@ -1024,6 +1061,18 @@ declare class Store implements IStore {
|
|
|
1024
1061
|
onError(error: unknown, customMessage?: string, groupingHash?: string): void;
|
|
1025
1062
|
}
|
|
1026
1063
|
|
|
1064
|
+
type StatsCollection = {
|
|
1065
|
+
errors: {
|
|
1066
|
+
enabled: boolean;
|
|
1067
|
+
provider?: string;
|
|
1068
|
+
};
|
|
1069
|
+
metrics: {
|
|
1070
|
+
enabled: boolean;
|
|
1071
|
+
};
|
|
1072
|
+
};
|
|
1073
|
+
|
|
1074
|
+
type CustomContextState = Signal<CustomContext>;
|
|
1075
|
+
|
|
1027
1076
|
interface IUserSessionManager {
|
|
1028
1077
|
storeManager?: IStoreManager;
|
|
1029
1078
|
init(): void;
|
|
@@ -1046,16 +1095,6 @@ interface IUserSessionManager {
|
|
|
1046
1095
|
setAuthToken(token: Nullable<string>): void;
|
|
1047
1096
|
}
|
|
1048
1097
|
|
|
1049
|
-
type StatsCollection = {
|
|
1050
|
-
errors: {
|
|
1051
|
-
enabled: boolean;
|
|
1052
|
-
provider?: string;
|
|
1053
|
-
};
|
|
1054
|
-
metrics: {
|
|
1055
|
-
enabled: boolean;
|
|
1056
|
-
};
|
|
1057
|
-
};
|
|
1058
|
-
|
|
1059
1098
|
type DestinationDefinition = {
|
|
1060
1099
|
name: string;
|
|
1061
1100
|
displayName: string;
|
|
@@ -1130,7 +1169,7 @@ interface IConfigManager {
|
|
|
1130
1169
|
|
|
1131
1170
|
interface IEventManager {
|
|
1132
1171
|
init(): void;
|
|
1133
|
-
addEvent(event: APIEvent): void;
|
|
1172
|
+
addEvent(event: APIEvent, customContext: CustomContext): void;
|
|
1134
1173
|
resume(): void;
|
|
1135
1174
|
}
|
|
1136
1175
|
|
|
@@ -1151,6 +1190,15 @@ type RudderAnalyticsPreloader = {
|
|
|
1151
1190
|
[index: string]: (...args: any[]) => any;
|
|
1152
1191
|
};
|
|
1153
1192
|
|
|
1193
|
+
declare class CustomContextStore {
|
|
1194
|
+
private readonly state;
|
|
1195
|
+
private readonly logger;
|
|
1196
|
+
constructor(state: CustomContextState, logger: ILogger);
|
|
1197
|
+
set(context: unknown): void;
|
|
1198
|
+
get(): CustomContext;
|
|
1199
|
+
clear(): void;
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1154
1202
|
interface IAnalytics {
|
|
1155
1203
|
preloadBuffer: BufferQueue<PreloadedEventCall>;
|
|
1156
1204
|
initialized: boolean;
|
|
@@ -1165,6 +1213,7 @@ interface IAnalytics {
|
|
|
1165
1213
|
userSessionManager?: IUserSessionManager;
|
|
1166
1214
|
pluginsManager?: IPluginsManager;
|
|
1167
1215
|
clientDataStore?: Store;
|
|
1216
|
+
customContextStore: CustomContextStore;
|
|
1168
1217
|
/**
|
|
1169
1218
|
* Start application lifecycle if not already started
|
|
1170
1219
|
*/
|
|
@@ -1278,6 +1327,18 @@ interface IAnalytics {
|
|
|
1278
1327
|
* To get group traits set in the SDK
|
|
1279
1328
|
*/
|
|
1280
1329
|
getGroupTraits(): Nullable<ApiObject> | undefined;
|
|
1330
|
+
/**
|
|
1331
|
+
* Merge fields into the current custom context
|
|
1332
|
+
*/
|
|
1333
|
+
setCustomContext(context: InputCustomContext): void;
|
|
1334
|
+
/**
|
|
1335
|
+
* Get a defensive snapshot of the current custom context
|
|
1336
|
+
*/
|
|
1337
|
+
getCustomContext(): CustomContext;
|
|
1338
|
+
/**
|
|
1339
|
+
* Clear the current custom context
|
|
1340
|
+
*/
|
|
1341
|
+
clearCustomContext(): void;
|
|
1281
1342
|
/**
|
|
1282
1343
|
* To manually start user session in the SDK
|
|
1283
1344
|
*/
|
|
@@ -1439,6 +1500,9 @@ declare class RudderAnalytics implements IRudderAnalytics<IAnalytics> {
|
|
|
1439
1500
|
getUserTraits(): Nullable<ApiObject> | undefined;
|
|
1440
1501
|
getGroupId(): Nullable<string> | undefined;
|
|
1441
1502
|
getGroupTraits(): Nullable<ApiObject> | undefined;
|
|
1503
|
+
setCustomContext(context: InputCustomContext): void;
|
|
1504
|
+
getCustomContext(): CustomContext;
|
|
1505
|
+
clearCustomContext(): void;
|
|
1442
1506
|
startSession(sessionId?: number): void;
|
|
1443
1507
|
endSession(): void;
|
|
1444
1508
|
getSessionId(): Nullable<number> | undefined;
|
|
@@ -1454,4 +1518,4 @@ declare global {
|
|
|
1454
1518
|
}
|
|
1455
1519
|
|
|
1456
1520
|
export { RudderAnalytics };
|
|
1457
|
-
export type { AnonymousIdOptions, ApiCallback, ApiObject, ApiOptions, BeaconQueueOpts, ConsentOptions, CookieSameSite, CustomDestinationConfig, DestinationsQueueOpts, IdentifyTraits, IntegrationOpts, LoadOptions, LogLevel, PluginName, PreloadedEventCall, QueueOpts, RSACustomIntegration, RSAEvent, RSALogger, RSAnalytics, RudderAnalyticsPreloader, SessionOpts, UaChTrackLevel };
|
|
1521
|
+
export type { AnonymousIdOptions, ApiCallback, ApiObject, ApiOptions, BeaconQueueOpts, ConsentOptions, CookieSameSite, CustomContext, CustomContextValue, CustomDestinationConfig, DestinationsQueueOpts, IdentifyTraits, InputCustomContext, InputCustomContextValue, IntegrationOpts, LoadOptions, LogLevel, PluginName, PreloadedEventCall, QueueOpts, RSACustomIntegration, RSAEvent, RSALogger, RSAnalytics, RudderAnalyticsPreloader, SessionOpts, UaChTrackLevel };
|