-
Notifications
You must be signed in to change notification settings - Fork 602
feat(EventBuilder): support overriding timestamp at user property and event level #2246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
7cae7ef
add timestamp_micros to user properties
lindsey-volta 5cee808
update style and include event update
lindsey-volta 1a013b0
fix request level timestamp_micros not being sent as number
lindsey-volta 6a2870e
fix tests
lindsey-volta 1ec650a
add timestamp picker component
lindsey-volta bcdbaf6
add package.json changes
lindsey-volta 18929ab
rename isUserProperty prop to be more clear
lindsey-volta c140012
Merge remote-tracking branch 'origin/main' into overwrite-timestamp
lindsey-volta 2981d57
fix type in ValidateEvent/index.spec.tsx
lindsey-volta 3ca2962
Merge branch 'main' into overwrite-timestamp
lindsey-volta 911ff67
Merge remote-tracking branch 'origin/main' into overwrite-timestamp
lindsey-volta cb90be0
Merge remote-tracking branch 'origin/main' into overwrite-timestamp
lindsey-volta 7a32a56
resolve conflicts
lindsey-volta 949b571
use iso-8601 format, add helper text, simplify value updates
lindsey-volta 8861633
remove unused import
lindsey-volta 7d5f103
Merge remote-tracking branch 'origin/main' into overwrite-timestamp
lindsey-volta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,91 +1,106 @@ | ||
| import * as React from "react" | ||
|
|
||
| import { styled } from '@mui/material/styles'; | ||
| import TextField from "@mui/material/TextField" | ||
| import { Parameter as ParameterT } from "./types" | ||
| import { ShowAdvancedCtx } from "." | ||
| import { IconButton, Tooltip } from "@mui/material" | ||
| import { | ||
| IconButton, | ||
| Tooltip, | ||
| Grid | ||
| } from "@mui/material" | ||
| import { Delete } from "@mui/icons-material" | ||
|
|
||
| const PREFIX = 'Parameter'; | ||
|
|
||
| const classes = { | ||
| parameter: `${PREFIX}-parameter` | ||
| }; | ||
|
|
||
| const Root = styled('section')(( | ||
| { | ||
| theme | ||
| } | ||
| ) => ({ | ||
| [`&.${classes.parameter}`]: { | ||
| display: "flex", | ||
| "&> *": { | ||
| flexGrow: 1, | ||
| }, | ||
| "&> :not(:first-child)": { | ||
| marginLeft: theme.spacing(1), | ||
| }, | ||
| } | ||
| })); | ||
| import TimestampPicker from "./TimestampPicker" | ||
| import { TimestampScope } from "@/constants" | ||
|
|
||
| interface Props { | ||
| parameter: ParameterT | ||
| idx: number | ||
| setParamName: (name: string) => void | ||
| setParamValue: (value: string) => void | ||
| setParamTimestamp: (idx: number, value: number | undefined) => void | ||
| removeParam: () => void | ||
| allowTimestampOverride: boolean | ||
| } | ||
|
|
||
| const Parameter: React.FC<Props> = ({ | ||
| parameter, | ||
| idx, | ||
| setParamName, | ||
| setParamValue, | ||
| setParamTimestamp, | ||
| removeParam, | ||
| allowTimestampOverride, | ||
| }) => { | ||
|
|
||
| const showAdvanced = React.useContext(ShowAdvancedCtx) | ||
|
|
||
| const [name, setName] = React.useState(parameter.name) | ||
| const [value, setValue] = React.useState(parameter.value || "") | ||
| const [timestamp, setTimestamp] = React.useState( | ||
| parameter.timestamp_micros?.toString() || "" | ||
| ) | ||
|
|
||
| React.useEffect(() => { | ||
| const num = parseInt(timestamp, 10) | ||
| setParamTimestamp(idx, isNaN(num) ? undefined : num) | ||
| }, [timestamp, setParamTimestamp, idx]) | ||
|
|
||
| const inputs = ( | ||
| <Root className={classes.parameter}> | ||
| <TextField | ||
| id={`#/events/0/params/${name}`} | ||
| variant="outlined" | ||
| size="small" | ||
| value={name} | ||
| onChange={e => setName(e.target.value)} | ||
| onBlur={() => setParamName(name)} | ||
| label="name" | ||
| /> | ||
| <TextField | ||
| variant="outlined" | ||
| size="small" | ||
| value={value || ""} | ||
| InputLabelProps={{ | ||
| ...(parameter.exampleValue === undefined ? {} : { shrink: true }), | ||
| }} | ||
| onChange={e => setValue(e.target.value)} | ||
| onBlur={() => setParamValue(value)} | ||
| label={`${parameter.type} value`} | ||
| placeholder={parameter.exampleValue?.toString()} | ||
| /> | ||
| </Root> | ||
| <Grid container spacing={1}> | ||
| <Grid item xs> | ||
| <TextField | ||
| id={`#/events/0/params/${name}`} | ||
| variant="outlined" | ||
| size="small" | ||
| value={name} | ||
| onChange={e => setName(e.target.value)} | ||
| onBlur={() => setParamName(name)} | ||
| label="name" | ||
| fullWidth | ||
| /> | ||
| </Grid> | ||
| <Grid item xs> | ||
| <TextField | ||
| variant="outlined" | ||
| size="small" | ||
| value={value || ""} | ||
| InputLabelProps={{ | ||
| ...(parameter.exampleValue === undefined ? {} : { shrink: true }), | ||
| }} | ||
| onChange={e => setValue(e.target.value)} | ||
| onBlur={() => setParamValue(value)} | ||
| label={`${parameter.type} value`} | ||
| placeholder={parameter.exampleValue?.toString()} | ||
| fullWidth | ||
| /> | ||
| </Grid> | ||
| {allowTimestampOverride && ( | ||
| <Grid item xs={12}> | ||
| <TimestampPicker | ||
| timestamp={timestamp} | ||
| scope={TimestampScope.USER_PROPERTY} | ||
| setTimestamp={setTimestamp} | ||
| /> | ||
| </Grid> | ||
| )} | ||
| </Grid> | ||
| ) | ||
| if (showAdvanced) { | ||
| return ( | ||
| <section /* className={formClasses.trashRow} */> | ||
| <Tooltip title="remove parameter"> | ||
| <IconButton onClick={removeParam}> | ||
| <Delete /> | ||
| </IconButton> | ||
| </Tooltip> | ||
| {inputs} | ||
| </section> | ||
| <Grid container spacing={1} alignItems="flex-start"> | ||
| <Grid item> | ||
| <Tooltip title="remove parameter"> | ||
| <IconButton onClick={removeParam}> | ||
| <Delete /> | ||
| </IconButton> | ||
| </Tooltip> | ||
| </Grid> | ||
| <Grid item xs> | ||
| {inputs} | ||
| </Grid> | ||
| </Grid> | ||
| ) | ||
| } | ||
| return inputs | ||
| } | ||
|
|
||
| export default Parameter | ||
| export default Parameter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we please double check if it really necessary to introduce another 3rd party library just for the purpose of date manipulation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, it seems to be the recommended approach for handling timezones when working with the Material UI date time picker based on the documentation: