Skip to content

Commit f7a0f35

Browse files
committed
Remove useAssignment hook
1 parent c23b7d7 commit f7a0f35

File tree

2 files changed

+2
-29
lines changed

2 files changed

+2
-29
lines changed
Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
1-
import React, { createContext, useContext, useRef } from 'react';
1+
import React, { createContext, useRef } from 'react';
22
import type { types } from '@mongodb-js/mdb-experiment-js';
3-
import type { typesReact } from '@mongodb-js/mdb-experiment-js/react';
43
import type { ExperimentTestName } from './growth-experiments';
54

6-
type UseAssignmentHook = (
7-
experimentName: ExperimentTestName,
8-
trackIsInSample: boolean,
9-
options?: typesReact.UseAssignmentOptions<types.TypeData>
10-
) => typesReact.UseAssignmentResponse<types.TypeData>;
11-
125
type AssignExperimentFn = (
136
experimentName: ExperimentTestName,
147
options?: types.AssignOptions<string>
@@ -21,22 +14,11 @@ type GetAssignmentFn = (
2114
) => Promise<types.SDKAssignment<ExperimentTestName, string> | null>;
2215

2316
interface CompassExperimentationProviderContextValue {
24-
useAssignment: UseAssignmentHook;
2517
assignExperiment: AssignExperimentFn;
2618
getAssignment: GetAssignmentFn;
2719
}
2820

2921
const initialContext: CompassExperimentationProviderContextValue = {
30-
useAssignment() {
31-
return {
32-
assignment: null,
33-
asyncStatus: null,
34-
error: null,
35-
isLoading: false,
36-
isError: false,
37-
isSuccess: true,
38-
};
39-
},
4022
assignExperiment() {
4123
return Promise.resolve(null);
4224
},
@@ -51,18 +33,15 @@ export const ExperimentationContext =
5133
// Provider component that accepts MMS experiment utils as props
5234
export const CompassExperimentationProvider: React.FC<{
5335
children: React.ReactNode;
54-
useAssignment: UseAssignmentHook;
5536
assignExperiment: AssignExperimentFn;
5637
getAssignment: GetAssignmentFn;
57-
}> = ({ children, useAssignment, assignExperiment, getAssignment }) => {
38+
}> = ({ children, assignExperiment, getAssignment }) => {
5839
// Use useRef to keep the functions up-to-date; Use mutation pattern to maintain the
5940
// same object reference to prevent unnecessary re-renders of consuming components
6041
const { current: contextValue } = useRef({
61-
useAssignment,
6242
assignExperiment,
6343
getAssignment,
6444
});
65-
contextValue.useAssignment = useAssignment;
6645
contextValue.assignExperiment = assignExperiment;
6746
contextValue.getAssignment = getAssignment;
6847

@@ -72,8 +51,3 @@ export const CompassExperimentationProvider: React.FC<{
7251
</ExperimentationContext.Provider>
7352
);
7453
};
75-
76-
// Hook for components to access experiment assignment
77-
export const useAssignment = (...args: Parameters<UseAssignmentHook>) => {
78-
return useContext(ExperimentationContext).useAssignment(...args);
79-
};

packages/compass-telemetry/src/provider.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,3 @@ export const useFireExperimentViewed = ({
162162

163163
export type { TrackFunction };
164164
export { ExperimentTestName, ExperimentTestGroup } from './growth-experiments';
165-
export { useAssignment } from './experimentation-provider';

0 commit comments

Comments
 (0)