@flagship.io/react-sdk 2.2.0-beta.6 → 3.0.2-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/README.md +2 -2
- 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/FlagshipContext.js +0 -243
- package/dist/es/FlagshipHooks.js +0 -341
- package/dist/es/index.js +0 -3
- package/dist/es/utils.js +0 -46
- package/dist/esm/FlagshipContext.js +0 -265
- package/dist/esm/FlagshipHooks.js +0 -481
- package/dist/esm/index.js +0 -3
- package/dist/esm/utils.js +0 -46
- package/dist/index.browser.js +0 -2
- package/dist/index.browser.js.map +0 -1
- package/dist/types/FlagshipContext.d.ts +0 -79
- package/dist/types/FlagshipHooks.d.ts +0 -91
- package/dist/types/utils.d.ts +0 -5
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode, Dispatch, SetStateAction } from 'react';
|
|
2
|
-
import { BucketingDTO, CampaignDTO, IFlagshipConfig, Modification, 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, Modification>;
|
|
30
|
-
status: FsStatus;
|
|
31
|
-
initialCampaigns?: CampaignDTO[];
|
|
32
|
-
initialModifications?: Map<string, Modification> | Modification[];
|
|
33
|
-
}
|
|
34
|
-
interface FsContext {
|
|
35
|
-
state: FsState;
|
|
36
|
-
setState?: Dispatch<SetStateAction<FsState>>;
|
|
37
|
-
}
|
|
38
|
-
interface FlagshipProviderProps extends IFlagshipConfig {
|
|
39
|
-
visitorData: {
|
|
40
|
-
id: string;
|
|
41
|
-
context?: Record<string, primitive>;
|
|
42
|
-
isAuthenticated?: boolean;
|
|
43
|
-
hasConsented?: boolean;
|
|
44
|
-
};
|
|
45
|
-
envId: string;
|
|
46
|
-
apiKey: string;
|
|
47
|
-
loadingComponent?: ReactNode;
|
|
48
|
-
children?: ReactNode;
|
|
49
|
-
/**
|
|
50
|
-
* If value is other than production , it will also display Debug logs.
|
|
51
|
-
*/
|
|
52
|
-
nodeEnv?: string;
|
|
53
|
-
/**
|
|
54
|
-
* Callback function called when the SDK starts initialization.
|
|
55
|
-
*/
|
|
56
|
-
onInitStart?(): void;
|
|
57
|
-
/**
|
|
58
|
-
* Callback function called when the SDK ends initialization.
|
|
59
|
-
*/
|
|
60
|
-
onInitDone?(): void;
|
|
61
|
-
/**
|
|
62
|
-
* Callback function called when the SDK is updated. For example, after a synchronize is triggered or visitor context has changed.
|
|
63
|
-
*/
|
|
64
|
-
onUpdate?(params: {
|
|
65
|
-
fsModifications: Map<string, Modification>;
|
|
66
|
-
config: IFlagshipConfig;
|
|
67
|
-
status: FsStatus;
|
|
68
|
-
}): void;
|
|
69
|
-
initialBucketing?: BucketingDTO;
|
|
70
|
-
initialCampaigns?: CampaignDTO[];
|
|
71
|
-
initialModifications?: Map<string, Modification> | Modification[];
|
|
72
|
-
/**
|
|
73
|
-
* If true, it'll automatically call synchronizeModifications when the bucketing file has updated
|
|
74
|
-
*/
|
|
75
|
-
synchronizeOnBucketingUpdated?: boolean;
|
|
76
|
-
}
|
|
77
|
-
export declare const FlagshipContext: React.Context<FsContext>;
|
|
78
|
-
export declare const FlagshipProvider: React.FC<FlagshipProviderProps>;
|
|
79
|
-
export {};
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { HitAbstract, HitShape, 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
|
-
*/
|
|
6
|
-
export declare const useFsModifications: <T extends unknown>(params: modificationsRequested<T>[], activateAll?: boolean | undefined) => Record<string, T>;
|
|
7
|
-
/**
|
|
8
|
-
* 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.
|
|
9
|
-
*/
|
|
10
|
-
export declare const useFsModification: {
|
|
11
|
-
<T>(params: modificationsRequested<T>): T;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Get the campaign modification information value matching the given key.
|
|
15
|
-
* @param {string} key key which identify the modification.
|
|
16
|
-
*/
|
|
17
|
-
export declare const useFsModificationInfo: {
|
|
18
|
-
(key: string): Modification | null;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* This function calls the decision api and update all the campaigns modifications from the server according to the visitor context.
|
|
22
|
-
*/
|
|
23
|
-
export declare const useFsSynchronizeModifications: () => Promise<void>;
|
|
24
|
-
/**
|
|
25
|
-
* Report this user has seen this modification. Report this user has seen these modifications.
|
|
26
|
-
* @param params
|
|
27
|
-
* @returns
|
|
28
|
-
*/
|
|
29
|
-
export declare const useFsActivate: {
|
|
30
|
-
(keys: {
|
|
31
|
-
key: string;
|
|
32
|
-
}[]): Promise<void>;
|
|
33
|
-
(keys: string[]): Promise<void>;
|
|
34
|
-
};
|
|
35
|
-
export declare type UseFlagshipParams<T> = {
|
|
36
|
-
modifications: {
|
|
37
|
-
requested: modificationsRequested<T>[];
|
|
38
|
-
activateAll?: boolean;
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
export declare type UseFlagshipOutput = {
|
|
42
|
-
modifications: Modification[];
|
|
43
|
-
status: FsStatus;
|
|
44
|
-
getModifications<T>(params: modificationsRequested<T>[], activateAll?: boolean): Record<string, T>;
|
|
45
|
-
getModificationInfo(key: string): Modification | null;
|
|
46
|
-
synchronizeModifications(): Promise<void>;
|
|
47
|
-
activateModification: {
|
|
48
|
-
(keys: {
|
|
49
|
-
key: string;
|
|
50
|
-
}[]): Promise<void>;
|
|
51
|
-
(keys: string[]): Promise<void>;
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* Update the visitor context values, matching the given keys, used for targeting.
|
|
55
|
-
* A new context value associated with this key will be created if there is no previous matching value.
|
|
56
|
-
* Context keys must be String, and values types must be one of the following : Number, Boolean, String.
|
|
57
|
-
* @param context collection of keys, values.
|
|
58
|
-
*/
|
|
59
|
-
updateContext(context: Record<string, primitive>): void;
|
|
60
|
-
/**
|
|
61
|
-
* clear the actual visitor context
|
|
62
|
-
*/
|
|
63
|
-
clearContext(): void;
|
|
64
|
-
/**
|
|
65
|
-
* Authenticate anonymous visitor
|
|
66
|
-
* @param visitorId
|
|
67
|
-
*/
|
|
68
|
-
authenticate(visitorId: string): void;
|
|
69
|
-
/**
|
|
70
|
-
* This hook change authenticated Visitor to anonymous visitor
|
|
71
|
-
* @param visitorId
|
|
72
|
-
*/
|
|
73
|
-
unauthenticate(): void;
|
|
74
|
-
hit: {
|
|
75
|
-
send: {
|
|
76
|
-
(hit: HitAbstract): Promise<void>;
|
|
77
|
-
(hit: IHit): Promise<void>;
|
|
78
|
-
(hit: HitShape): Promise<void>;
|
|
79
|
-
(hit: HitAbstract | IHit | HitShape): Promise<void>;
|
|
80
|
-
};
|
|
81
|
-
sendMultiple: {
|
|
82
|
-
(hit: HitAbstract[]): Promise<void>;
|
|
83
|
-
(hit: IHit[]): Promise<void>;
|
|
84
|
-
(hit: HitShape[]): Promise<void>;
|
|
85
|
-
(hit: HitAbstract[] | IHit[] | HitShape[]): Promise<void>;
|
|
86
|
-
};
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
|
-
export declare const useFlagship: () => UseFlagshipOutput;
|
|
90
|
-
export declare const noVisitorMessage = "sdk not correctly initialized... Make sure fsVisitor is ready.";
|
|
91
|
-
export declare const noVisitorDefault = "fsVisitor not initialized, returns default value";
|
package/dist/types/utils.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { CampaignDTO, IFlagshipConfig, Modification } from '@flagship.io/js-sdk';
|
|
2
|
-
export declare function logError(config: IFlagshipConfig | undefined, message: string, tag: string): void;
|
|
3
|
-
export declare function logInfo(config: IFlagshipConfig | undefined, message: string, tag: string): void;
|
|
4
|
-
export declare function logWarn(config: IFlagshipConfig | undefined, message: string, tag: string): void;
|
|
5
|
-
export declare const getModificationsFromCampaigns: (campaigns: Array<CampaignDTO>) => Map<string, Modification>;
|