Skip to content

Commit 0fd64a7

Browse files
authored
Fix LaunchDarkly integration API call to get flags and config screen missing project key input (#860)
* Fix LaunchDarkly config missing project key input * Fix LD API call Authorization header * Add changeset
1 parent ba802b5 commit 0fd64a7

File tree

3 files changed

+67
-36
lines changed

3 files changed

+67
-36
lines changed

.changeset/nine-friends-trade.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@gitbook/integration-launchdarkly': minor
3+
---
4+
5+
Fix LaunchDarkly integration API call to get flags and config screen missing project key input

integrations/launchdarkly/src/components.tsx

Lines changed: 58 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -86,39 +86,65 @@ export const configBlock = createComponent<
8686
return (
8787
<configuration>
8888
{isAdaptiveContentEnabled ? (
89-
<block>
90-
<input
91-
label="Secret key"
92-
hint={
93-
<text>
94-
The secret key from your LaunchDarkly{' '}
95-
<link
96-
target={{
97-
url: 'https://app.LaunchDarkly.co/envs/current/settings/app-environments',
89+
<box>
90+
<vstack>
91+
<input
92+
label="Project key"
93+
hint={
94+
<text>
95+
The project key of your LaunchDarkly{' '}
96+
<link
97+
target={{
98+
url: 'https://app.launchdarkly.com/settings/projects',
99+
}}
100+
>
101+
environment.
102+
</link>
103+
</text>
104+
}
105+
element={
106+
<textinput state="project_key" placeholder="Project key" />
107+
}
108+
/>
109+
<input
110+
label="Service access token"
111+
hint={
112+
<text>
113+
A service token with reader role created in your
114+
LaunchDarkly{' '}
115+
<link
116+
target={{
117+
url: 'https://app.launchdarkly.com/settings/authorization',
118+
}}
119+
>
120+
project.
121+
</link>
122+
</text>
123+
}
124+
element={
125+
<textinput
126+
state="service_token"
127+
placeholder="Service access token"
128+
/>
129+
}
130+
/>
131+
<input
132+
label=""
133+
hint=""
134+
element={
135+
<button
136+
style="primary"
137+
disabled={false}
138+
label="Save"
139+
tooltip="Save configuration"
140+
onPress={{
141+
action: 'save.config',
98142
}}
99-
>
100-
environment settings.
101-
</link>
102-
</text>
103-
}
104-
element={<textinput state="secret_key" placeholder="Secret key" />}
105-
/>
106-
<input
107-
label=""
108-
hint=""
109-
element={
110-
<button
111-
style="primary"
112-
disabled={false}
113-
label="Save"
114-
tooltip="Save configuration"
115-
onPress={{
116-
action: 'save.config',
117-
}}
118-
/>
119-
}
120-
/>
121-
</block>
143+
/>
144+
}
145+
/>
146+
</vstack>
147+
</box>
122148
) : (
123149
<input
124150
label="Enable Adaptive Content"

integrations/launchdarkly/src/tasks.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ async function handleSyncAdaptiveSchema(
9595
getExistingAdaptiveSchema(api, organizationId, siteId),
9696
getFeatureFlags({
9797
projectKey,
98-
token: serviceToken,
98+
serviceToken,
9999
}),
100100
]);
101101

@@ -197,11 +197,11 @@ async function getExistingAdaptiveSchema(
197197
}
198198
}
199199

200-
async function getFeatureFlags(args: { projectKey: string; token: string }) {
201-
const { projectKey, token } = args;
200+
async function getFeatureFlags(args: { projectKey: string; serviceToken: string }) {
201+
const { projectKey, serviceToken } = args;
202202
const res = await fetch(`https://app.launchdarkly.com/api/v2/flags/${projectKey}`, {
203203
headers: {
204-
Authorization: `Bearer ${token}`,
204+
Authorization: serviceToken,
205205
},
206206
});
207207

0 commit comments

Comments
 (0)