@xylabs/sdk-react 2.7.24 → 2.8.2

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.
@@ -1,8 +1,8 @@
1
- import { Log } from '@xylabs/sdk-js'
1
+ import { forget, Log } from '@xylabs/sdk-js'
2
2
  import React, { ReactElement, useContext } from 'react'
3
3
 
4
4
  import { UserEventsContext } from '../../contexts'
5
- import { getLocalStorageObject, isLocalhost, setLocalStorageObject } from '../../lib'
5
+ import { getLocalStorageObject, setLocalStorageObject } from '../../lib'
6
6
  import { ExperimentProps } from './Experiment'
7
7
 
8
8
  const defaultLocalStorageKey = 'testData'
@@ -31,7 +31,6 @@ type Props = {
31
31
  children: ReactElement<ExperimentProps>[] | ReactElement<ExperimentProps>
32
32
  localStorageProp?: string | boolean
33
33
  name: string
34
- testStarted?: () => Promise<void>
35
34
  }
36
35
 
37
36
  const missingKeyError = new Error('Experiment Elements must have Keys')
@@ -61,9 +60,9 @@ const calcTotalWeight = (childList: ReactElement<ExperimentProps>[]) => {
61
60
  }
62
61
 
63
62
  const Experiments: React.FC<Props> = (props) => {
64
- const { name, children, testStarted, localStorageProp = true } = props
65
- const userEventsConntext = useContext(UserEventsContext)
66
- const { userEvents } = userEventsConntext
63
+ const { name, children, localStorageProp = true } = props
64
+ const userEventsContext = useContext(UserEventsContext)
65
+ const { userEvents } = userEventsContext
67
66
  loadOutcomes()
68
67
 
69
68
  const localStorageKey = buildLocalStorageKey(localStorageProp)
@@ -87,14 +86,8 @@ const Experiments: React.FC<Props> = (props) => {
87
86
  if (localStorageProp !== false) {
88
87
  localStorage.setItem(localStorageKey, mergeData(experimentsTestData))
89
88
  }
90
- if (!isLocalhost) {
91
- Promise.all([userEvents?.testStarted({}), testStarted?.()])
92
- .then(() => {
93
- return
94
- })
95
- .catch((reason) => {
96
- console.log(`Experiments Excepted: ${reason}`)
97
- })
89
+ if (userEvents) {
90
+ forget(userEvents.testStarted({ name, variation: child.key }))
98
91
  }
99
92
  }
100
93
 
Binary file