@flagship.io/react-sdk 3.0.2 → 3.0.3-alpha.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/dist/FlagshipContext.d.ts +99 -0
- package/dist/FlagshipContext.js +312 -0
- package/dist/FlagshipContext.js.map +1 -0
- package/dist/FlagshipErrorBoundary.d.ts +34 -0
- package/dist/FlagshipErrorBoundary.js +95 -0
- package/dist/FlagshipErrorBoundary.js.map +1 -0
- package/dist/FlagshipHooks.d.ts +33 -0
- package/dist/FlagshipHooks.js +198 -0
- package/dist/FlagshipHooks.js.map +1 -0
- package/dist/components/ReactErrorBoundaryContainer/index.d.ts +10 -0
- package/dist/components/ReactErrorBoundaryContainer/index.js +65 -0
- package/dist/components/ReactErrorBoundaryContainer/index.js.map +1 -0
- package/dist/{types/index.d.ts → index.d.ts} +0 -1
- package/dist/index.js +14 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/loggerHelper.d.ts +5 -0
- package/dist/lib/loggerHelper.js +14 -0
- package/dist/lib/loggerHelper.js.map +1 -0
- package/dist/lib/utils.d.ts +1 -0
- package/dist/lib/utils.js +7 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/setupTests.d.ts +1 -0
- package/dist/setupTests.js +9 -0
- package/dist/setupTests.js.map +1 -0
- package/dist/tests/mock/apiAnswers/oneModifInMoreThanOneCampaign.d.ts +3 -0
- package/dist/tests/mock/apiAnswers/oneModifInMoreThanOneCampaign.js +51 -0
- package/dist/tests/mock/apiAnswers/oneModifInMoreThanOneCampaign.js.map +1 -0
- package/dist/tests/mock/env.d.ts +5 -0
- package/dist/tests/mock/env.js +8 -0
- package/dist/tests/mock/env.js.map +1 -0
- package/dist/tests/mock/index.d.ts +74 -0
- package/dist/tests/mock/index.js +90 -0
- package/dist/tests/mock/index.js.map +1 -0
- package/package.json +2 -2
- package/dist/es/Flag.js +0 -36
- package/dist/es/FlagshipContext.js +0 -229
- package/dist/es/FlagshipHooks.js +0 -372
- package/dist/es/constants.js +0 -2
- package/dist/es/index.js +0 -3
- package/dist/es/utils.js +0 -77
- package/dist/esm/Flag.js +0 -55
- package/dist/esm/FlagshipContext.js +0 -253
- package/dist/esm/FlagshipHooks.js +0 -474
- package/dist/esm/constants.js +0 -2
- package/dist/esm/index.js +0 -3
- package/dist/esm/utils.js +0 -77
- package/dist/index.browser.js +0 -2
- package/dist/index.browser.js.map +0 -1
- package/dist/types/Flag.d.ts +0 -9
- package/dist/types/FlagshipContext.d.ts +0 -97
- package/dist/types/FlagshipHooks.d.ts +0 -130
- package/dist/types/constants.d.ts +0 -2
- package/dist/types/utils.d.ts +0 -9
package/dist/types/Flag.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { IFlag, IFlagMetadata } from '@flagship.io/js-sdk';
|
|
2
|
-
export declare class Flag<T> implements IFlag<T> {
|
|
3
|
-
private _defaultValue;
|
|
4
|
-
constructor(defaultValue: T);
|
|
5
|
-
getValue(): T;
|
|
6
|
-
exists(): boolean;
|
|
7
|
-
userExposed(): Promise<void>;
|
|
8
|
-
get metadata(): IFlagMetadata;
|
|
9
|
-
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode, Dispatch, SetStateAction } from "react";
|
|
2
|
-
import { BucketingDTO, CampaignDTO, FlagDTO, IFlagshipConfig, primitive, Visitor } from "@flagship.io/js-sdk";
|
|
3
|
-
export interface FsStatus {
|
|
4
|
-
/**
|
|
5
|
-
* Boolean. When true, the SDK is still not ready to render your App otherwise it'll use default modifications.
|
|
6
|
-
*/
|
|
7
|
-
isLoading: boolean;
|
|
8
|
-
/**
|
|
9
|
-
* Boolean. true after it has fully finished initialization tasks, false otherwise.
|
|
10
|
-
*/
|
|
11
|
-
isSdkReady: boolean;
|
|
12
|
-
lastModified?: Date;
|
|
13
|
-
/**
|
|
14
|
-
* Boolean. When true the flagship visitor instance is truthy, false otherwise.
|
|
15
|
-
*/
|
|
16
|
-
isVisitorDefined?: boolean;
|
|
17
|
-
/**
|
|
18
|
-
* String or null. The last update date occurred on the flagship visitor instance.
|
|
19
|
-
*/
|
|
20
|
-
lastRefresh?: string;
|
|
21
|
-
/**
|
|
22
|
-
* String or null. When null no initialization succeed yet. When string contains stringified date of last successful initialization.
|
|
23
|
-
*/
|
|
24
|
-
firstInitSuccess?: string;
|
|
25
|
-
}
|
|
26
|
-
export interface FsState {
|
|
27
|
-
visitor?: Visitor;
|
|
28
|
-
config?: IFlagshipConfig;
|
|
29
|
-
modifications?: Map<string, FlagDTO>;
|
|
30
|
-
status: FsStatus;
|
|
31
|
-
initialCampaigns?: CampaignDTO[];
|
|
32
|
-
initialModifications?: Map<string, FlagDTO> | FlagDTO[];
|
|
33
|
-
}
|
|
34
|
-
export declare type VisitorData = {
|
|
35
|
-
id?: string;
|
|
36
|
-
context?: Record<string, primitive>;
|
|
37
|
-
isAuthenticated?: boolean;
|
|
38
|
-
hasConsented?: boolean;
|
|
39
|
-
};
|
|
40
|
-
interface FsContext {
|
|
41
|
-
state: FsState;
|
|
42
|
-
setState?: Dispatch<SetStateAction<FsState>>;
|
|
43
|
-
}
|
|
44
|
-
interface FlagshipProviderProps extends IFlagshipConfig {
|
|
45
|
-
/**
|
|
46
|
-
* This is the data to identify the current visitor using your app
|
|
47
|
-
*/
|
|
48
|
-
visitorData: VisitorData | null;
|
|
49
|
-
envId: string;
|
|
50
|
-
apiKey: string;
|
|
51
|
-
/**
|
|
52
|
-
* This component will be rendered when Flagship is loading at first initialization only.
|
|
53
|
-
* By default, the value is undefined. It means it will display your app and it might
|
|
54
|
-
* display default modifications value for a very short moment.
|
|
55
|
-
*/
|
|
56
|
-
loadingComponent?: ReactNode;
|
|
57
|
-
children?: ReactNode;
|
|
58
|
-
/**
|
|
59
|
-
* Callback function called when the SDK starts initialization.
|
|
60
|
-
*/
|
|
61
|
-
onInitStart?(): void;
|
|
62
|
-
/**
|
|
63
|
-
* Callback function called when the SDK ends initialization.
|
|
64
|
-
*/
|
|
65
|
-
onInitDone?(): void;
|
|
66
|
-
/**
|
|
67
|
-
* Callback function called when the SDK is updated. For example, after a synchronize is triggered or visitor context has changed.
|
|
68
|
-
*/
|
|
69
|
-
onUpdate?(params: {
|
|
70
|
-
fsModifications: Map<string, FlagDTO>;
|
|
71
|
-
config: IFlagshipConfig;
|
|
72
|
-
status: FsStatus;
|
|
73
|
-
}): void;
|
|
74
|
-
/**
|
|
75
|
-
* This is an object of the data received when fetching bucketing endpoint.
|
|
76
|
-
* Providing this prop will make bucketing ready to use and the first polling will immediatly check for an update.
|
|
77
|
-
* If the shape of an element is not correct, an error log will give the reason why.
|
|
78
|
-
*/
|
|
79
|
-
initialBucketing?: BucketingDTO;
|
|
80
|
-
initialCampaigns?: CampaignDTO[];
|
|
81
|
-
/**
|
|
82
|
-
* This is a set of flag data provided to avoid the SDK to have an empty cache during the first initialization.
|
|
83
|
-
* @deprecated use initialFlagsData instead
|
|
84
|
-
*/
|
|
85
|
-
initialModifications?: Map<string, FlagDTO> | FlagDTO[];
|
|
86
|
-
/**
|
|
87
|
-
* This is a set of flag data provided to avoid the SDK to have an empty cache during the first initialization.
|
|
88
|
-
*/
|
|
89
|
-
initialFlagsData?: Map<string, FlagDTO> | FlagDTO[];
|
|
90
|
-
/**
|
|
91
|
-
* If true, it'll automatically call synchronizeModifications when the bucketing file has updated
|
|
92
|
-
*/
|
|
93
|
-
synchronizeOnBucketingUpdated?: boolean;
|
|
94
|
-
}
|
|
95
|
-
export declare const FlagshipContext: React.Context<FsContext>;
|
|
96
|
-
export declare const FlagshipProvider: React.FC<FlagshipProviderProps>;
|
|
97
|
-
export {};
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import { FlagDTO, HitAbstract, HitShape, IFlag, IHit, Modification, modificationsRequested, primitive } from '@flagship.io/js-sdk';
|
|
2
|
-
import { FsStatus } from './FlagshipContext';
|
|
3
|
-
/**
|
|
4
|
-
* Retrieve a modification value by its key. If no modification match the given key or if the stored value type and default value type do not match, default value will be returned.
|
|
5
|
-
* @deprecated use useFsGetFlag instead
|
|
6
|
-
*/
|
|
7
|
-
export declare const useFsModifications: <T extends unknown>(params: modificationsRequested<T>[], activateAll?: boolean | undefined) => Record<string, T>;
|
|
8
|
-
/**
|
|
9
|
-
* Retrieve a modification value by its key. If no modification match the given key or if the stored value type and default value type do not match, default value will be returned.
|
|
10
|
-
* @deprecated use useFsGetFlag instead
|
|
11
|
-
*/
|
|
12
|
-
export declare const useFsModification: {
|
|
13
|
-
<T>(params: modificationsRequested<T>): T;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Get the campaign modification information value matching the given key.
|
|
17
|
-
* @param {string} key key which identify the modification.
|
|
18
|
-
* @deprecated use useFsGetFlag instead
|
|
19
|
-
*/
|
|
20
|
-
export declare const useFsModificationInfo: {
|
|
21
|
-
(key: string): Modification | null;
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* This hook returns a flag object by its key. If no flag match the given key an empty flag will be returned.
|
|
25
|
-
* @param key
|
|
26
|
-
* @param defaultValue
|
|
27
|
-
* @returns
|
|
28
|
-
*/
|
|
29
|
-
export declare const useFsFlag: <T extends unknown>(key: string, defaultValue: T) => IFlag<T>;
|
|
30
|
-
/**
|
|
31
|
-
* Report this user has seen this modification. Report this user has seen these modifications.
|
|
32
|
-
* @param params
|
|
33
|
-
* @deprecated use useFsGetFlag instead
|
|
34
|
-
* @returns
|
|
35
|
-
*/
|
|
36
|
-
export declare const useFsActivate: {
|
|
37
|
-
(keys: {
|
|
38
|
-
key: string;
|
|
39
|
-
}[]): Promise<void>;
|
|
40
|
-
(keys: string[]): Promise<void>;
|
|
41
|
-
};
|
|
42
|
-
export declare type UseFlagshipParams<T> = {
|
|
43
|
-
modifications: {
|
|
44
|
-
requested: modificationsRequested<T>[];
|
|
45
|
-
activateAll?: boolean;
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
export declare type UseFlagshipOutput = {
|
|
49
|
-
visitorId?: string;
|
|
50
|
-
anonymousId?: string | null;
|
|
51
|
-
context?: Record<string, primitive>;
|
|
52
|
-
hasConsented?: boolean;
|
|
53
|
-
/**
|
|
54
|
-
* Set if visitor has consented for protected data usage.
|
|
55
|
-
* @param hasConsented True if the visitor has consented false otherwise.
|
|
56
|
-
*/
|
|
57
|
-
setConsent: (hasConsented: boolean) => void;
|
|
58
|
-
modifications: Modification[];
|
|
59
|
-
FlagsData: FlagDTO[];
|
|
60
|
-
status: FsStatus;
|
|
61
|
-
/**
|
|
62
|
-
*
|
|
63
|
-
* @param params
|
|
64
|
-
* @param activateAll
|
|
65
|
-
* @deprecated use useFsGetFlag instead
|
|
66
|
-
*/
|
|
67
|
-
getModifications<T>(params: modificationsRequested<T>[], activateAll?: boolean): Record<string, T>;
|
|
68
|
-
/**
|
|
69
|
-
*
|
|
70
|
-
* @param key
|
|
71
|
-
* @deprecated use useFsGetFlag instead
|
|
72
|
-
*/
|
|
73
|
-
getModificationInfo(key: string): Modification | null;
|
|
74
|
-
/**
|
|
75
|
-
* @deprecated use useFsFetchFlags instead
|
|
76
|
-
*/
|
|
77
|
-
synchronizeModifications(): Promise<void>;
|
|
78
|
-
/**
|
|
79
|
-
* @deprecated use useFsGetFlag instead
|
|
80
|
-
*/
|
|
81
|
-
activateModification: {
|
|
82
|
-
(keys: {
|
|
83
|
-
key: string;
|
|
84
|
-
}[]): Promise<void>;
|
|
85
|
-
(keys: string[]): Promise<void>;
|
|
86
|
-
};
|
|
87
|
-
/**
|
|
88
|
-
* Update the visitor context values, matching the given keys, used for targeting.
|
|
89
|
-
* A new context value associated with this key will be created if there is no previous matching value.
|
|
90
|
-
* Context keys must be String, and values types must be one of the following : Number, Boolean, String.
|
|
91
|
-
* @param context collection of keys, values.
|
|
92
|
-
*/
|
|
93
|
-
updateContext(context: Record<string, primitive>): void;
|
|
94
|
-
/**
|
|
95
|
-
* clear the actual visitor context
|
|
96
|
-
*/
|
|
97
|
-
clearContext(): void;
|
|
98
|
-
/**
|
|
99
|
-
* Authenticate anonymous visitor
|
|
100
|
-
* @param visitorId
|
|
101
|
-
*/
|
|
102
|
-
authenticate(visitorId: string): void;
|
|
103
|
-
/**
|
|
104
|
-
* This function change authenticated Visitor to anonymous visitor
|
|
105
|
-
* @param visitorId
|
|
106
|
-
*/
|
|
107
|
-
unauthenticate(): void;
|
|
108
|
-
hit: {
|
|
109
|
-
send: {
|
|
110
|
-
(hit: HitAbstract): Promise<void>;
|
|
111
|
-
(hit: IHit): Promise<void>;
|
|
112
|
-
(hit: HitShape): Promise<void>;
|
|
113
|
-
(hit: HitAbstract | IHit | HitShape): Promise<void>;
|
|
114
|
-
};
|
|
115
|
-
sendMultiple: {
|
|
116
|
-
(hit: HitAbstract[]): Promise<void>;
|
|
117
|
-
(hit: IHit[]): Promise<void>;
|
|
118
|
-
(hit: HitShape[]): Promise<void>;
|
|
119
|
-
(hit: HitAbstract[] | IHit[] | HitShape[]): Promise<void>;
|
|
120
|
-
};
|
|
121
|
-
};
|
|
122
|
-
/**
|
|
123
|
-
* Retrieve a Flag object by its key. If no flag match the given key an empty flag will be returned.
|
|
124
|
-
* @param key flag key
|
|
125
|
-
* @param defaultValue
|
|
126
|
-
*/
|
|
127
|
-
getFlag<T>(key: string, defaultValue: T): IFlag<T>;
|
|
128
|
-
fetchFlags: () => Promise<void>;
|
|
129
|
-
};
|
|
130
|
-
export declare const useFlagship: () => UseFlagshipOutput;
|
package/dist/types/utils.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { CampaignDTO, IFlagshipConfig, LogLevel, Modification } from '@flagship.io/js-sdk';
|
|
2
|
-
import { EffectCallback, DependencyList } from 'react';
|
|
3
|
-
export declare function logError(config: IFlagshipConfig | undefined, message: string, tag: string): void;
|
|
4
|
-
export declare function logInfo(config: IFlagshipConfig | undefined, message: string, tag: string): void;
|
|
5
|
-
export declare function logWarn(config: IFlagshipConfig | undefined, message: string, tag: string): void;
|
|
6
|
-
export declare function log(level: LogLevel, message: string, tag: string): void;
|
|
7
|
-
export declare const getModificationsFromCampaigns: (campaigns: Array<CampaignDTO>) => Map<string, Modification>;
|
|
8
|
-
export declare function uuidV4(): string;
|
|
9
|
-
export declare function useNonInitialEffect(effect: EffectCallback, deps?: DependencyList): void;
|