@xylabs/sdk-react 2.12.6 → 2.12.9
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/cjs/common/ExperimentsHelper.d.ts +18 -0
- package/dist/cjs/common/ExperimentsHelper.js +101 -0
- package/dist/cjs/common/ExperimentsHelper.js.map +1 -0
- package/dist/cjs/common/index.d.ts +1 -0
- package/dist/cjs/common/index.js +5 -0
- package/dist/cjs/common/index.js.map +1 -0
- package/dist/cjs/components/Errors/ErrorsViewer.js +2 -2
- package/dist/cjs/components/Errors/ErrorsViewer.js.map +1 -1
- package/dist/cjs/components/EthAccount/EthAccountBox.js +2 -2
- package/dist/cjs/components/EthAccount/EthAccountBox.js.map +1 -1
- package/dist/cjs/components/Experiments/index.d.ts +1 -0
- package/dist/cjs/components/Experiments/index.js +1 -0
- package/dist/cjs/components/Experiments/index.js.map +1 -1
- package/dist/cjs/components/QuickTipButton/QuickTipButton.d.ts +4 -2
- package/dist/cjs/components/QuickTipButton/QuickTipButton.js +3 -3
- package/dist/cjs/components/QuickTipButton/QuickTipButton.js.map +1 -1
- package/dist/cjs/components/QuickTipButton/index.d.ts +1 -2
- package/dist/cjs/components/QuickTipButton/index.js +2 -3
- package/dist/cjs/components/QuickTipButton/index.js.map +1 -1
- package/dist/cjs/hooks/useExperiment.d.ts +8 -0
- package/dist/cjs/hooks/useExperiment.js +29 -0
- package/dist/cjs/hooks/useExperiment.js.map +1 -0
- package/dist/cjs/lib/Tracking/Drip/BaseEvent.js +1 -0
- package/dist/cjs/lib/Tracking/Drip/BaseEvent.js.map +1 -1
- package/dist/cjs/lib/Tracking/Tapjoy/StandardEvents.d.ts +1 -1
- package/dist/cjs/lib/Tracking/Tapjoy/StandardEvents.js +2 -2
- package/dist/cjs/lib/Tracking/Tapjoy/StandardEvents.js.map +1 -1
- package/dist/docs.json +29735 -19905
- package/dist/esm/common/ExperimentsHelper.d.ts +18 -0
- package/dist/esm/common/ExperimentsHelper.js +97 -0
- package/dist/esm/common/ExperimentsHelper.js.map +1 -0
- package/dist/esm/common/index.d.ts +1 -0
- package/dist/esm/common/index.js +2 -0
- package/dist/esm/common/index.js.map +1 -0
- package/dist/esm/components/Errors/ErrorsViewer.js +2 -2
- package/dist/esm/components/Errors/ErrorsViewer.js.map +1 -1
- package/dist/esm/components/EthAccount/EthAccountBox.js +2 -2
- package/dist/esm/components/EthAccount/EthAccountBox.js.map +1 -1
- package/dist/esm/components/Experiments/index.d.ts +1 -0
- package/dist/esm/components/Experiments/index.js +1 -0
- package/dist/esm/components/Experiments/index.js.map +1 -1
- package/dist/esm/components/QuickTipButton/QuickTipButton.d.ts +4 -2
- package/dist/esm/components/QuickTipButton/QuickTipButton.js +3 -4
- package/dist/esm/components/QuickTipButton/QuickTipButton.js.map +1 -1
- package/dist/esm/components/QuickTipButton/index.d.ts +1 -2
- package/dist/esm/components/QuickTipButton/index.js +1 -2
- package/dist/esm/components/QuickTipButton/index.js.map +1 -1
- package/dist/esm/hooks/useExperiment.d.ts +8 -0
- package/dist/esm/hooks/useExperiment.js +24 -0
- package/dist/esm/hooks/useExperiment.js.map +1 -0
- package/dist/esm/lib/Tracking/Drip/BaseEvent.js +1 -0
- package/dist/esm/lib/Tracking/Drip/BaseEvent.js.map +1 -1
- package/dist/esm/lib/Tracking/Tapjoy/StandardEvents.d.ts +1 -1
- package/dist/esm/lib/Tracking/Tapjoy/StandardEvents.js +2 -2
- package/dist/esm/lib/Tracking/Tapjoy/StandardEvents.js.map +1 -1
- package/package.json +25 -26
- package/src/common/ExperimentsHelper.ts +109 -0
- package/src/common/index.ts +1 -0
- package/src/components/Errors/ErrorsViewer.tsx +2 -2
- package/src/components/EthAccount/EthAccountBox.stories.tsx +1 -1
- package/src/components/EthAccount/EthAccountBox.tsx +6 -3
- package/src/components/Experiments/index.tsx +1 -0
- package/src/components/QuickTipButton/QuickTipButton.stories.tsx +6 -1
- package/src/components/QuickTipButton/QuickTipButton.tsx +7 -5
- package/src/components/QuickTipButton/index.ts +1 -3
- package/src/hooks/useExperiment.ts +30 -0
- package/src/hooks/useExperiments.stories.tsx +43 -0
- package/src/lib/Tracking/Drip/BaseEvent.ts +1 -0
- package/src/lib/Tracking/Tapjoy/StandardEvents.ts +2 -2
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Log } from '@xylabs/sdk-js';
|
|
2
|
+
import { ReactElement } from 'react';
|
|
3
|
+
import { ExperimentProps, ExperimentsData, OutcomesData, VariantData } from '../components';
|
|
4
|
+
declare const ExperimentsHelper: {
|
|
5
|
+
buildLocalStorageKey: (localStorageProp: boolean | string) => string;
|
|
6
|
+
calcTotalWeight: (variants: VariantData[]) => number;
|
|
7
|
+
calculateExperiment: (name: string, localStorageProp: string | boolean, variants: VariantData[]) => VariantData | undefined;
|
|
8
|
+
getExperiment: (name: string) => import("../components").ExperimentData;
|
|
9
|
+
getSelectedVariant: (name: string) => VariantData | undefined;
|
|
10
|
+
loadOutcomes: () => OutcomesData;
|
|
11
|
+
makeChildrenArray: (children: ReactElement<ExperimentProps>[] | ReactElement<ExperimentProps>) => ReactElement<ExperimentProps, string | import("react").JSXElementConstructor<any>>[];
|
|
12
|
+
mergeData: (data: {
|
|
13
|
+
[index: string]: string;
|
|
14
|
+
}, log?: Log | undefined) => string;
|
|
15
|
+
saveExperimentRanges: (name: string, totalWeight: number, variants: VariantData[]) => ExperimentsData;
|
|
16
|
+
saveOutcomes: () => void;
|
|
17
|
+
};
|
|
18
|
+
export { ExperimentsHelper };
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { ExperimentsLocalStorageKey, OutcomesLocalStorageKey } from '../components';
|
|
2
|
+
import { getLocalStorageObject, setLocalStorageObject } from '../lib';
|
|
3
|
+
const defaultLocalStorageKey = 'testData';
|
|
4
|
+
const experimentsTestData = {};
|
|
5
|
+
let outcomes = {}; //prevent multi-outcome
|
|
6
|
+
// TODO - some expire logic around experiments
|
|
7
|
+
const ExperimentsHelper = {
|
|
8
|
+
buildLocalStorageKey: (localStorageProp) => {
|
|
9
|
+
return localStorageProp === true ? defaultLocalStorageKey : typeof localStorageProp === 'string' ? localStorageProp ?? defaultLocalStorageKey : '';
|
|
10
|
+
},
|
|
11
|
+
calcTotalWeight: (variants) => {
|
|
12
|
+
return variants.reduce((sum, variant) => {
|
|
13
|
+
return sum + variant.weight;
|
|
14
|
+
}, 0);
|
|
15
|
+
},
|
|
16
|
+
calculateExperiment: (name, localStorageProp, variants) => {
|
|
17
|
+
//TODO - user events, it needs to be in the hook, all other compatibility should
|
|
18
|
+
ExperimentsHelper.loadOutcomes();
|
|
19
|
+
const localStorageKey = ExperimentsHelper.buildLocalStorageKey(localStorageProp);
|
|
20
|
+
const totalWeight = ExperimentsHelper.calcTotalWeight(variants);
|
|
21
|
+
ExperimentsHelper.saveExperimentRanges(name, totalWeight, variants);
|
|
22
|
+
const firstTime = name in outcomes;
|
|
23
|
+
let targetWeight = outcomes[name] ?? Math.random() * totalWeight;
|
|
24
|
+
outcomes[name] = targetWeight;
|
|
25
|
+
ExperimentsHelper.saveOutcomes();
|
|
26
|
+
for (const variant of variants) {
|
|
27
|
+
targetWeight -= variant.weight;
|
|
28
|
+
if (targetWeight > 0)
|
|
29
|
+
continue;
|
|
30
|
+
if (!variant.name) {
|
|
31
|
+
throw new Error('Experiment Elements must have Keys');
|
|
32
|
+
}
|
|
33
|
+
experimentsTestData[name] = variant.name;
|
|
34
|
+
if (firstTime) {
|
|
35
|
+
localStorage.setItem(localStorageKey, ExperimentsHelper.mergeData(experimentsTestData));
|
|
36
|
+
}
|
|
37
|
+
// if (userEvents) {
|
|
38
|
+
// forget(userEvents.testStarted({ name, variation: variant.name }))
|
|
39
|
+
// }
|
|
40
|
+
return variant;
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
getExperiment: (name) => {
|
|
44
|
+
ExperimentsHelper.loadOutcomes();
|
|
45
|
+
const experiments = getLocalStorageObject(ExperimentsLocalStorageKey) || {};
|
|
46
|
+
return experiments[name];
|
|
47
|
+
},
|
|
48
|
+
getSelectedVariant: (name) => {
|
|
49
|
+
const outcomes = ExperimentsHelper.loadOutcomes();
|
|
50
|
+
const experiment = ExperimentsHelper.getExperiment(name);
|
|
51
|
+
let total = 0;
|
|
52
|
+
if (experiment && outcomes) {
|
|
53
|
+
const targetWeight = outcomes[name];
|
|
54
|
+
for (let i = 0; i < experiment.variants.length; i++) {
|
|
55
|
+
const variant = experiment.variants[i];
|
|
56
|
+
total += variant.weight;
|
|
57
|
+
if (total >= targetWeight) {
|
|
58
|
+
return variant;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
loadOutcomes: () => {
|
|
64
|
+
outcomes = getLocalStorageObject(OutcomesLocalStorageKey);
|
|
65
|
+
return outcomes;
|
|
66
|
+
},
|
|
67
|
+
makeChildrenArray: (children) => {
|
|
68
|
+
if (Array.isArray(children)) {
|
|
69
|
+
return children;
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
return [children];
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
mergeData: (data, log) => {
|
|
76
|
+
const dataArray = [];
|
|
77
|
+
for (const key in data) {
|
|
78
|
+
dataArray.push(`${key}-${data[key]}`);
|
|
79
|
+
}
|
|
80
|
+
log?.info('MergeData', dataArray.join('|'));
|
|
81
|
+
return dataArray.join('|');
|
|
82
|
+
},
|
|
83
|
+
saveExperimentRanges: (name, totalWeight, variants) => {
|
|
84
|
+
const experiments = getLocalStorageObject(ExperimentsLocalStorageKey) || {};
|
|
85
|
+
experiments[name] = {
|
|
86
|
+
totalWeight,
|
|
87
|
+
variants,
|
|
88
|
+
};
|
|
89
|
+
setLocalStorageObject(ExperimentsLocalStorageKey, experiments);
|
|
90
|
+
return experiments;
|
|
91
|
+
},
|
|
92
|
+
saveOutcomes: () => {
|
|
93
|
+
setLocalStorageObject(OutcomesLocalStorageKey, outcomes);
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
export { ExperimentsHelper };
|
|
97
|
+
//# sourceMappingURL=ExperimentsHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExperimentsHelper.js","sourceRoot":"","sources":["../../../src/common/ExperimentsHelper.ts"],"names":[],"mappings":"AAGA,OAAO,EAAoC,0BAA0B,EAAgB,uBAAuB,EAAe,MAAM,eAAe,CAAA;AAChJ,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,QAAQ,CAAA;AAErE,MAAM,sBAAsB,GAAG,UAAU,CAAA;AACzC,MAAM,mBAAmB,GAAgC,EAAE,CAAA;AAC3D,IAAI,QAAQ,GAAiB,EAAE,CAAA,CAAC,uBAAuB;AAEvD,8CAA8C;AAC9C,MAAM,iBAAiB,GAAG;IACxB,oBAAoB,EAAE,CAAC,gBAAkC,EAAE,EAAE;QAC3D,OAAO,gBAAgB,KAAK,IAAI,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,OAAO,gBAAgB,KAAK,QAAQ,CAAC,CAAC,CAAC,gBAAgB,IAAI,sBAAsB,CAAC,CAAC,CAAC,EAAE,CAAA;IACpJ,CAAC;IAED,eAAe,EAAE,CAAC,QAAuB,EAAE,EAAE;QAC3C,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE;YACtC,OAAO,GAAG,GAAG,OAAO,CAAC,MAAM,CAAA;QAC7B,CAAC,EAAE,CAAC,CAAC,CAAA;IACP,CAAC;IAED,mBAAmB,EAAE,CAAC,IAAY,EAAE,gBAAkC,EAAE,QAAuB,EAAE,EAAE;QACjG,gFAAgF;QAChF,iBAAiB,CAAC,YAAY,EAAE,CAAA;QAChC,MAAM,eAAe,GAAG,iBAAiB,CAAC,oBAAoB,CAAC,gBAAgB,CAAC,CAAA;QAChF,MAAM,WAAW,GAAG,iBAAiB,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAA;QAC/D,iBAAiB,CAAC,o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AW,CAAC,IAAI,CAAC,GAAG;YAClB,WAAW;YACX,QAAQ;SACT,CAAA;QACD,qBAAqB,CAAC,0BAA0B,EAAE,WAAW,CAAC,CAAA;QAC9D,OAAO,WAAW,CAAA;IACpB,CAAC;IAED,YAAY,EAAE,GAAG,EAAE;QACjB,qBAAqB,CAAC,uBAAuB,EAAE,QAAQ,CAAC,CAAA;IAC1D,CAAC;CACF,CAAA;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ExperimentsHelper';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import ReplayIcon from '@mui/icons-material/Replay';
|
|
2
3
|
import { IconButton } from '@mui/material';
|
|
3
|
-
import { AiOutlineReload } from 'react-icons/ai';
|
|
4
4
|
import { FlexGrowCol } from '../FlexBox';
|
|
5
5
|
import { ErrorViewer } from './ErrorViewer';
|
|
6
6
|
const ErrorsViewer = (props) => {
|
|
7
7
|
const { onRetry, errors, ...boxProps } = props;
|
|
8
8
|
return (_jsxs(FlexGrowCol, { padding: 1, ...boxProps, children: [errors?.map((error, index) => {
|
|
9
9
|
return _jsx(ErrorViewer, { error: error }, index);
|
|
10
|
-
}), onRetry ? (_jsx(IconButton, { onClick: onRetry, children: _jsx(
|
|
10
|
+
}), onRetry ? (_jsx(IconButton, { onClick: onRetry, children: _jsx(ReplayIcon, {}) })) : null] }));
|
|
11
11
|
};
|
|
12
12
|
export { ErrorsViewer };
|
|
13
13
|
//# sourceMappingURL=ErrorsViewer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorsViewer.js","sourceRoot":"","sources":["../../../../src/components/Errors/ErrorsViewer.tsx"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ErrorsViewer.js","sourceRoot":"","sources":["../../../../src/components/Errors/ErrorsViewer.tsx"],"names":[],"mappings":";AAAA,OAAO,UAAU,MAAM,4BAA4B,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAG1C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAExC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C,MAAM,YAAY,GAAgC,CAAC,KAAK,EAAE,EAAE;IAC1D,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,GAAG,KAAK,CAAA;IAC9C,OAAO,CACL,MAAC,WAAW,IAAC,OAAO,EAAE,CAAC,KAAM,QAAQ,aAClC,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;gBAC5B,OAAO,KAAC,WAAW,IAAC,KAAK,EAAE,KAAK,IAAO,KAAK,CAAI,CAAA;YAClD,CAAC,CAAC,EACD,OAAO,CAAC,CAAC,CAAC,CACT,KAAC,UAAU,IAAC,OAAO,EAAE,OAAO,YAC1B,KAAC,UAAU,KAAG,GACH,CACd,CAAC,CAAC,CAAC,IAAI,IACI,CACf,CAAA;AACH,CAAC,CAAA;AAED,OAAO,EAAE,YAAY,EAAE,CAAA"}
|
|
@@ -6,7 +6,7 @@ import { EthersContext } from '../../contexts';
|
|
|
6
6
|
import { useMediaQuery } from '../../hooks';
|
|
7
7
|
import { FlexRow } from '../FlexBox';
|
|
8
8
|
import { Identicon } from '../Identicon';
|
|
9
|
-
export const EthAccountBox = ({ address, icon = false, iconSize = 16, iconOnly = false, shortenedLength, addressLength = 'auto', fontFamily = '"Source Code Pro",monospace', ...props }) => {
|
|
9
|
+
export const EthAccountBox = ({ address, icon = false, iconSize = 16, iconOnly = false, shortenedLength, height, addressLength = 'auto', fontFamily = '"Source Code Pro",monospace', ...props }) => {
|
|
10
10
|
const { localAddress } = useContext(EthersContext);
|
|
11
11
|
const theme = useTheme();
|
|
12
12
|
const large = useMediaQuery(theme.breakpoints.up('md'));
|
|
@@ -22,6 +22,6 @@ export const EthAccountBox = ({ address, icon = false, iconSize = 16, iconOnly =
|
|
|
22
22
|
: addressToDisplay.toShortString()
|
|
23
23
|
: '-- --';
|
|
24
24
|
// Note: We use the all zero address for spacing in case it is
|
|
25
|
-
return (_jsxs(FlexRow, { justifyContent: "space-between", alignItems: "
|
|
25
|
+
return (_jsxs(FlexRow, { height: height, justifyContent: "space-between", alignItems: "stretch", minHeight: theme.spacing(3), ...props, children: [icon ? (_jsx(Identicon, { minHeight: height ?? theme.spacing(3), minWidth: height ?? theme.spacing(3), bgcolor: theme.palette.secondary.main, size: iconSize, value: address?.toHex() })) : null, iconOnly ? null : (_jsx(Typography, { alignSelf: "center", marginLeft: icon ? 1 : 0, variant: "body1", fontFamily: fontFamily, children: textToDisplay })), isLocalAddress ? _jsx(FlexRow, { marginLeft: 0.5, children: "(You)" }) : null] }));
|
|
26
26
|
};
|
|
27
27
|
//# sourceMappingURL=EthAccountBox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthAccountBox.js","sourceRoot":"","sources":["../../../../src/components/EthAccount/EthAccountBox.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACpD,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAElC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAgB,OAAO,EAAE,MAAM,YAAY,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAGxC,MAAM,CAAC,MAA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AAuB,CAAA;AACrC,cAAc,oBAAoB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Experiments/index.tsx"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,cAAc,uBAAuB,CAAA;AACrC,cAAc,oBAAoB,CAAA;AAClC,cAAc,UAAU,CAAA"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { IconButtonProps } from '@mui/material';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
export interface QuickTipButtonProps extends IconButtonProps {
|
|
4
|
+
fontSize?: 'small' | 'medium' | 'large' | 'inherit';
|
|
5
|
+
}
|
|
6
|
+
export declare const QuickTipButton: React.FC<QuickTipButtonProps>;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import HelpOutlineIcon from '@mui/icons-material/HelpOutline';
|
|
2
3
|
import { IconButton } from '@mui/material';
|
|
3
4
|
import { useState } from 'react';
|
|
4
|
-
import { AiOutlineQuestionCircle } from 'react-icons/ai';
|
|
5
5
|
import { MessageDialog } from '../dialogs';
|
|
6
|
-
const QuickTipButton = ({ title, children, ...props }) => {
|
|
6
|
+
export const QuickTipButton = ({ fontSize = 'inherit', title, children, ...props }) => {
|
|
7
7
|
const [messageOpen, setMessageOpen] = useState(false);
|
|
8
|
-
return (_jsxs(_Fragment, { children: [_jsx(IconButton, { onClick: () => setMessageOpen(true), size: "small", ...props, children: _jsx(
|
|
8
|
+
return (_jsxs(_Fragment, { children: [_jsx(IconButton, { onClick: () => setMessageOpen(true), size: "small", ...props, children: _jsx(HelpOutlineIcon, { fontSize: fontSize }) }), _jsx(MessageDialog, { onOk: () => setMessageOpen(false), onCancel: () => setMessageOpen(false), onClose: () => setMessageOpen(false), open: messageOpen, title: title ?? '', children: children })] }));
|
|
9
9
|
};
|
|
10
|
-
export { QuickTipButton };
|
|
11
10
|
//# sourceMappingURL=QuickTipButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QuickTipButton.js","sourceRoot":"","sources":["../../../../src/components/QuickTipButton/QuickTipButton.tsx"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"QuickTipButton.js","sourceRoot":"","sources":["../../../../src/components/QuickTipButton/QuickTipButton.tsx"],"names":[],"mappings":";AAAA,OAAO,eAAe,MAAM,iCAAiC,CAAA;AAC7D,OAAO,EAAE,UAAU,EAAmB,MAAM,eAAe,CAAA;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAM1C,MAAM,CAAC,MAAM,cAAc,GAAkC,CAAC,EAAE,QAAQ,GAAG,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE;IACnH,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;IAErD,OAAO,CACL,8BACE,KAAC,UAAU,IAAC,OAAO,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,IAAI,EAAC,OAAO,KAAK,KAAK,YACrE,KAAC,eAAe,IAAC,QAAQ,EAAE,QAAQ,GAAI,GAC5B,EACb,KAAC,aAAa,IAAC,IAAI,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,IAAI,EAAE,YACjK,QAAQ,GACK,IACf,CACJ,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { QuickTipButton };
|
|
1
|
+
export * from './QuickTipButton';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/QuickTipButton/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/QuickTipButton/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { VariantData } from '../components';
|
|
3
|
+
declare const selectVariantForExperiment: (name: string, variants: Record<string, ReactNode>, defaultNode: ReactNode) => ReactNode;
|
|
4
|
+
declare const useExperiments: (name: string, experiments: VariantData[]) => {
|
|
5
|
+
experimentName: string;
|
|
6
|
+
selectVariant: (variants: Record<string, ReactNode>, defaultNode: ReactNode) => ReactNode;
|
|
7
|
+
};
|
|
8
|
+
export { selectVariantForExperiment, useExperiments };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { ExperimentsHelper } from '../common';
|
|
3
|
+
const selectVariant = (current) => (variants, defaultNode) => {
|
|
4
|
+
if (current && current in variants) {
|
|
5
|
+
return variants[current];
|
|
6
|
+
}
|
|
7
|
+
return defaultNode;
|
|
8
|
+
};
|
|
9
|
+
const selectVariantForExperiment = (name, variants, defaultNode) => {
|
|
10
|
+
const variant = ExperimentsHelper.getSelectedVariant(name);
|
|
11
|
+
if (variants[variant?.name ?? '']) {
|
|
12
|
+
return variants[variant?.name ?? ''];
|
|
13
|
+
}
|
|
14
|
+
return defaultNode;
|
|
15
|
+
};
|
|
16
|
+
const useExperiments = (name, experiments) => {
|
|
17
|
+
const [activeExperiment] = useState(ExperimentsHelper.calculateExperiment(name, true, experiments));
|
|
18
|
+
return {
|
|
19
|
+
experimentName: name,
|
|
20
|
+
selectVariant: selectVariant(activeExperiment?.name),
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export { selectVariantForExperiment, useExperiments };
|
|
24
|
+
//# sourceMappingURL=useExperiment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useExperiment.js","sourceRoot":"","sources":["../../../src/hooks/useExperiment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,QAAQ,EAAE,MAAM,OAAO,CAAA;AAE3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAG7C,MAAM,aAAa,GAAG,CAAC,OAAgB,EAAE,EAAE,CAAC,CAAC,QAAmC,EAAE,WAAsB,EAAE,EAAE;IAC1G,IAAI,OAAO,IAAI,OAAO,IAAI,QAAQ,EAAE;QAClC,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAA;KACzB;IACD,OAAO,WAAW,CAAA;AACpB,CAAC,CAAA;AAED,MAAM,0BAA0B,GAAG,CAAC,IAAY,EAAE,QAAmC,EAAE,WAAsB,EAAE,EAAE;IAC/G,MAAM,OAAO,GAAG,iBAAiB,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAA;IAC1D,IAAI,QAAQ,CAAC,OAAO,EAAE,IAAI,IAAI,EAAE,CAAC,EAAE;QACjC,OAAO,QAAQ,CAAC,OAAO,EAAE,IAAI,IAAI,EAAE,CAAC,CAAA;KACrC;IACD,OAAO,WAAW,CAAA;AACpB,CAAC,CAAA;AAED,MAAM,cAAc,GAAG,CAAC,IAAY,EAAE,WAA0B,EAAE,EAAE;IAClE,MAAM,CAAC,gBAAgB,CAAC,GAAG,QAAQ,CAAC,iBAAiB,CAAC,mBAAmB,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,CAAA;IAEnG,OAAO;QACL,cAAc,EAAE,IAAI;QACpB,aAAa,EAAE,aAAa,CAAC,gBAAgB,EAAE,IAAI,CAAC;KACrD,CAAA;AACH,CAAC,CAAA;AAED,OAAO,EAAE,0BAA0B,EAAE,cAAc,E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IAAsB,CAAA;IACtC,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StandardEvents.js","sourceRoot":"","sources":["../../../../../src/lib/Tracking/Tapjoy/StandardEvents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAErD,MAAM,oBAAoB;IACjB,
|
|
1
|
+
{"version":3,"file":"StandardEvents.js","sourceRoot":"","sources":["../../../../../src/lib/Tracking/Tapjoy/StandardEvents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAErD,MAAM,oBAAoB;IACjB,cAAc;QACnB,OAAO,IAAI,mBAAmB,CAAI,YAAY,CAAC,CAAA;IACjD,CAAC;CACF;AAED,OAAO,EAAE,oBAAoB,EAAE,CAAA"}
|
package/package.json
CHANGED
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@emotion/react": "^11.9.0",
|
|
13
13
|
"@emotion/styled": "^11.8.1",
|
|
14
|
-
"@ethersproject/abstract-signer": "^5.6.
|
|
15
|
-
"@ethersproject/providers": "^5.6.
|
|
14
|
+
"@ethersproject/abstract-signer": "^5.6.1",
|
|
15
|
+
"@ethersproject/providers": "^5.6.7",
|
|
16
16
|
"@metamask/providers": "^8.1.1",
|
|
17
|
-
"@mui/icons-material": "^5.
|
|
18
|
-
"@mui/material": "^5.
|
|
19
|
-
"@mui/styles": "^5.
|
|
17
|
+
"@mui/icons-material": "^5.8.0",
|
|
18
|
+
"@mui/material": "^5.8.1",
|
|
19
|
+
"@mui/styles": "^5.8.0",
|
|
20
20
|
"@xylabs/pixel": "^1.3.7",
|
|
21
21
|
"@xylabs/sdk-js": "^2.5.5",
|
|
22
22
|
"axios": "^0.27.2",
|
|
@@ -25,32 +25,31 @@
|
|
|
25
25
|
"numeral": "^2.0.6",
|
|
26
26
|
"query-string": "^7.1.1",
|
|
27
27
|
"react-helmet": "^6.1.0",
|
|
28
|
-
"react-icons": "^4.3.1",
|
|
29
28
|
"react-router-dom": "^6.3.0"
|
|
30
29
|
},
|
|
31
30
|
"description": "Common React library for all XY Labs projects that use React",
|
|
32
31
|
"devDependencies": {
|
|
33
|
-
"@babel/core": "^7.
|
|
34
|
-
"@babel/preset-env": "^7.
|
|
35
|
-
"@storybook/addon-actions": "^6.4
|
|
36
|
-
"@storybook/addon-docs": "^6.4
|
|
37
|
-
"@storybook/addon-essentials": "^6.4
|
|
38
|
-
"@storybook/addon-interactions": "^6.4
|
|
39
|
-
"@storybook/addon-links": "^6.4
|
|
40
|
-
"@storybook/addons": "^6.4
|
|
41
|
-
"@storybook/api": "^6.4
|
|
42
|
-
"@storybook/builder-webpack5": "^6.4
|
|
43
|
-
"@storybook/components": "^6.4
|
|
44
|
-
"@storybook/core-events": "^6.4
|
|
45
|
-
"@storybook/manager-webpack5": "^6.4
|
|
46
|
-
"@storybook/react": "^6.4
|
|
32
|
+
"@babel/core": "^7.18.0",
|
|
33
|
+
"@babel/preset-env": "^7.18.0",
|
|
34
|
+
"@storybook/addon-actions": "^6.5.4",
|
|
35
|
+
"@storybook/addon-docs": "^6.5.4",
|
|
36
|
+
"@storybook/addon-essentials": "^6.5.4",
|
|
37
|
+
"@storybook/addon-interactions": "^6.5.4",
|
|
38
|
+
"@storybook/addon-links": "^6.5.4",
|
|
39
|
+
"@storybook/addons": "^6.5.4",
|
|
40
|
+
"@storybook/api": "^6.5.4",
|
|
41
|
+
"@storybook/builder-webpack5": "^6.5.4",
|
|
42
|
+
"@storybook/components": "^6.5.4",
|
|
43
|
+
"@storybook/core-events": "^6.5.4",
|
|
44
|
+
"@storybook/manager-webpack5": "^6.5.4",
|
|
45
|
+
"@storybook/react": "^6.5.4",
|
|
47
46
|
"@storybook/testing-library": "^0.0.11",
|
|
48
|
-
"@storybook/theming": "^6.4
|
|
47
|
+
"@storybook/theming": "^6.5.4",
|
|
49
48
|
"@types/lodash": "^4.14.182",
|
|
50
49
|
"@types/md5": "^2.3.2",
|
|
51
50
|
"@types/numeral": "^2.0.2",
|
|
52
51
|
"@types/react": "^18.0.9",
|
|
53
|
-
"@types/react-dom": "^18.0.
|
|
52
|
+
"@types/react-dom": "^18.0.5",
|
|
54
53
|
"@types/react-helmet": "^6.1.5",
|
|
55
54
|
"@xylabs/eslint-config-react": "^2.1.5",
|
|
56
55
|
"@xylabs/rollup-config": "^1.1.17",
|
|
@@ -58,13 +57,13 @@
|
|
|
58
57
|
"@xylabs/tsconfig": "^1.0.13",
|
|
59
58
|
"copyfiles": "^2.4.1",
|
|
60
59
|
"depcheck": "^1.4.3",
|
|
61
|
-
"eslint": "^8.
|
|
60
|
+
"eslint": "^8.16.0",
|
|
62
61
|
"react": "^18.1.0",
|
|
63
62
|
"react-dom": "^18.1.0",
|
|
64
63
|
"rimraf": "^3.0.2",
|
|
65
|
-
"rollup": "^2.
|
|
64
|
+
"rollup": "^2.74.1",
|
|
66
65
|
"storybook-dark-mode": "^1.1.0",
|
|
67
|
-
"ts-node": "^10.
|
|
66
|
+
"ts-node": "^10.8.0",
|
|
68
67
|
"typedoc": "^0.22.15",
|
|
69
68
|
"typescript": "^4.6.4",
|
|
70
69
|
"webpack": "^5.72.1"
|
|
@@ -127,6 +126,6 @@
|
|
|
127
126
|
},
|
|
128
127
|
"sideEffects": false,
|
|
129
128
|
"types": "dist/esm/index.d.ts",
|
|
130
|
-
"version": "2.12.
|
|
129
|
+
"version": "2.12.9",
|
|
131
130
|
"packageManager": "yarn@3.1.1"
|
|
132
131
|
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { Log } from '@xylabs/sdk-js'
|
|
2
|
+
import { ReactElement } from 'react'
|
|
3
|
+
|
|
4
|
+
import { ExperimentProps, ExperimentsData, ExperimentsLocalStorageKey, OutcomesData, OutcomesLocalStorageKey, VariantData } from '../components'
|
|
5
|
+
import { getLocalStorageObject, setLocalStorageObject } from '../lib'
|
|
6
|
+
|
|
7
|
+
const defaultLocalStorageKey = 'testData'
|
|
8
|
+
const experimentsTestData: { [index: string]: string } = {}
|
|
9
|
+
let outcomes: OutcomesData = {} //prevent multi-outcome
|
|
10
|
+
|
|
11
|
+
// TODO - some expire logic around experiments
|
|
12
|
+
const ExperimentsHelper = {
|
|
13
|
+
buildLocalStorageKey: (localStorageProp: boolean | string) => {
|
|
14
|
+
return localStorageProp === true ? defaultLocalStorageKey : typeof localStorageProp === 'string' ? localStorageProp ?? defaultLocalStorageKey : ''
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
calcTotalWeight: (variants: VariantData[]) => {
|
|
18
|
+
return variants.reduce((sum, variant) => {
|
|
19
|
+
return sum + variant.weight
|
|
20
|
+
}, 0)
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
calculateExperiment: (name: string, localStorageProp: string | boolean, variants: VariantData[]) => {
|
|
24
|
+
//TODO - user events, it needs to be in the hook, all other compatibility should
|
|
25
|
+
ExperimentsHelper.loadOutcomes()
|
|
26
|
+
const localStorageKey = ExperimentsHelper.buildLocalStorageKey(localStorageProp)
|
|
27
|
+
const totalWeight = ExperimentsHelper.calcTotalWeight(variants)
|
|
28
|
+
ExperimentsHelper.saveExperimentRanges(name, totalWeight, variants)
|
|
29
|
+
const firstTime = name in outcomes
|
|
30
|
+
let targetWeight = outcomes[name] ?? Math.random() * totalWeight
|
|
31
|
+
outcomes[name] = targetWeight
|
|
32
|
+
ExperimentsHelper.saveOutcomes()
|
|
33
|
+
for (const variant of variants) {
|
|
34
|
+
targetWeight -= variant.weight
|
|
35
|
+
if (targetWeight > 0) continue
|
|
36
|
+
if (!variant.name) {
|
|
37
|
+
throw new Error('Experiment Elements must have Keys')
|
|
38
|
+
}
|
|
39
|
+
experimentsTestData[name] = variant.name
|
|
40
|
+
if (firstTime) {
|
|
41
|
+
localStorage.setItem(localStorageKey, ExperimentsHelper.mergeData(experimentsTestData))
|
|
42
|
+
}
|
|
43
|
+
// if (userEvents) {
|
|
44
|
+
// forget(userEvents.testStarted({ name, variation: variant.name }))
|
|
45
|
+
// }
|
|
46
|
+
return variant
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
getExperiment: (name: string) => {
|
|
51
|
+
ExperimentsHelper.loadOutcomes()
|
|
52
|
+
const experiments = getLocalStorageObject<ExperimentsData>(ExperimentsLocalStorageKey) || {}
|
|
53
|
+
return experiments[name]
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
getSelectedVariant: (name: string) => {
|
|
57
|
+
const outcomes = ExperimentsHelper.loadOutcomes()
|
|
58
|
+
const experiment = ExperimentsHelper.getExperiment(name)
|
|
59
|
+
let total = 0
|
|
60
|
+
if (experiment && outcomes) {
|
|
61
|
+
const targetWeight = outcomes[name]
|
|
62
|
+
for (let i = 0; i < experiment.variants.length; i++) {
|
|
63
|
+
const variant = experiment.variants[i]
|
|
64
|
+
total += variant.weight
|
|
65
|
+
if (total >= targetWeight) {
|
|
66
|
+
return variant
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
loadOutcomes: () => {
|
|
73
|
+
outcomes = getLocalStorageObject(OutcomesLocalStorageKey)
|
|
74
|
+
return outcomes
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
makeChildrenArray: (children: ReactElement<ExperimentProps>[] | ReactElement<ExperimentProps>) => {
|
|
78
|
+
if (Array.isArray(children)) {
|
|
79
|
+
return children as ReactElement<ExperimentProps>[]
|
|
80
|
+
} else {
|
|
81
|
+
return [children] as ReactElement<ExperimentProps>[]
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
mergeData: (data: { [index: string]: string }, log?: Log) => {
|
|
86
|
+
const dataArray: string[] = []
|
|
87
|
+
for (const key in data) {
|
|
88
|
+
dataArray.push(`${key}-${data[key]}`)
|
|
89
|
+
}
|
|
90
|
+
log?.info('MergeData', dataArray.join('|'))
|
|
91
|
+
return dataArray.join('|')
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
saveExperimentRanges: (name: string, totalWeight: number, variants: VariantData[]) => {
|
|
95
|
+
const experiments = getLocalStorageObject<ExperimentsData>(ExperimentsLocalStorageKey) || {}
|
|
96
|
+
experiments[name] = {
|
|
97
|
+
totalWeight,
|
|
98
|
+
variants,
|
|
99
|
+
}
|
|
100
|
+
setLocalStorageObject(ExperimentsLocalStorageKey, experiments)
|
|
101
|
+
return experiments
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
saveOutcomes: () => {
|
|
105
|
+
setLocalStorageObject(OutcomesLocalStorageKey, outcomes)
|
|
106
|
+
},
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export { ExperimentsHelper }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ExperimentsHelper'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import ReplayIcon from '@mui/icons-material/Replay'
|
|
1
2
|
import { IconButton } from '@mui/material'
|
|
2
3
|
import React from 'react'
|
|
3
|
-
import { AiOutlineReload } from 'react-icons/ai'
|
|
4
4
|
|
|
5
5
|
import { FlexGrowCol } from '../FlexBox'
|
|
6
6
|
import { ErrorsViewerProps } from './ErrorsViewerProps'
|
|
@@ -15,7 +15,7 @@ const ErrorsViewer: React.FC<ErrorsViewerProps> = (props) => {
|
|
|
15
15
|
})}
|
|
16
16
|
{onRetry ? (
|
|
17
17
|
<IconButton onClick={onRetry}>
|
|
18
|
-
<
|
|
18
|
+
<ReplayIcon />
|
|
19
19
|
</IconButton>
|
|
20
20
|
) : null}
|
|
21
21
|
</FlexGrowCol>
|
|
@@ -14,6 +14,7 @@ export const EthAccountBox: React.FC<EthAccountProps & FlexBoxProps> = ({
|
|
|
14
14
|
iconSize = 16,
|
|
15
15
|
iconOnly = false,
|
|
16
16
|
shortenedLength,
|
|
17
|
+
height,
|
|
17
18
|
addressLength = 'auto',
|
|
18
19
|
fontFamily = '"Source Code Pro",monospace',
|
|
19
20
|
...props
|
|
@@ -40,10 +41,12 @@ export const EthAccountBox: React.FC<EthAccountProps & FlexBoxProps> = ({
|
|
|
40
41
|
// Note: We use the all zero address for spacing in case it is
|
|
41
42
|
|
|
42
43
|
return (
|
|
43
|
-
<FlexRow justifyContent="space-between" alignItems="
|
|
44
|
-
{icon ?
|
|
44
|
+
<FlexRow height={height} justifyContent="space-between" alignItems="stretch" minHeight={theme.spacing(3)} {...props}>
|
|
45
|
+
{icon ? (
|
|
46
|
+
<Identicon minHeight={height ?? theme.spacing(3)} minWidth={height ?? theme.spacing(3)} bgcolor={theme.palette.secondary.main} size={iconSize} value={address?.toHex()} />
|
|
47
|
+
) : null}
|
|
45
48
|
{iconOnly ? null : (
|
|
46
|
-
<Typography marginLeft={icon ? 1 : 0} variant="body1" fontFamily={fontFamily}>
|
|
49
|
+
<Typography alignSelf="center" marginLeft={icon ? 1 : 0} variant="body1" fontFamily={fontFamily}>
|
|
47
50
|
{textToDisplay}
|
|
48
51
|
</Typography>
|
|
49
52
|
)}
|