Skip to content

Commit

Permalink
fix: correct JS code snippets syntax (#3770)
Browse files Browse the repository at this point in the history
  • Loading branch information
rolodato authored Apr 16, 2024
1 parent 1f96b59 commit e2155d2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
9 changes: 5 additions & 4 deletions frontend/common/code-help/create-user/create-user-js.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ module.exports = (
// Option 1: initialise with an identity and traits
${LIB_NAME}.init({
environmentID: "${envId}",
identity:${userId || USER_ID},
traits:{${TRAIT_NAME}: 21}},
onChange: (oldFlags, params) => {...}
identity: "${userId || USER_ID}",
traits: { "${TRAIT_NAME}": 21 },
onChange: (oldFlags, params) => { /* ... */ },
});
// Option 2: identify after initialising
${LIB_NAME}.identify("${userId || USER_ID}", {${TRAIT_NAME}: 21);
${LIB_NAME}.identify("${userId || USER_ID}", { "${TRAIT_NAME}": 21 });
`
4 changes: 2 additions & 2 deletions frontend/common/code-help/init/init-js.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ module.exports = (
envId,
{ FEATURE_FUNCTION, FEATURE_NAME, FEATURE_NAME_ALT, LIB_NAME, NPM_CLIENT },
customFeature,
) => `import ${LIB_NAME} from "${NPM_CLIENT}"; //Add this line if you're using ${LIB_NAME} via npm
) => `import ${LIB_NAME} from "${NPM_CLIENT}"; // Add this line if you're using ${LIB_NAME} via npm
${LIB_NAME}.init({
environmentID:"${envId}",
environmentID: "${envId}",
onChange: (oldFlags, params) => { // Occurs whenever flags are changed
// Determines if the update came from the server or local cached storage
const { isFromServer } = params;
Expand Down
11 changes: 6 additions & 5 deletions frontend/common/code-help/traits/traits-js.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ module.exports = (
) => `// Option 1: initialise with an identity and traits
${LIB_NAME}.init({
environmentID: "${envId}",
identity:${userId || USER_ID},
traits:{${TRAIT_NAME}: 21}},
onChange: (oldFlags, params) => {...}
identity: "${userId || USER_ID}",
traits: { "${TRAIT_NAME}": 21 },
onChange: (oldFlags, params) => { /* ... */ },
});
// Option 2: identify/set traits after initialising
${LIB_NAME}.identify("${userId || USER_ID}", {${TRAIT_NAME}: 21);
${LIB_NAME}.setTraits({${TRAIT_NAME}: 21);
${LIB_NAME}.identify("${userId || USER_ID}", { "${TRAIT_NAME}": 21 });
${LIB_NAME}.setTraits({ "${TRAIT_NAME}": 21 });
`

0 comments on commit e2155d2

Please sign in to comment.