Skip to content
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

fix: correct JS code snippets syntax #3770

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 });
`