Skip to content

Commit a891dec

Browse files
committed
fix schema and path
1 parent 4832765 commit a891dec

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

cmd/sourcemaps/upload.go

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ const (
3333
defaultBackendUrl = "https://pri.observability.app.launchdarkly.com"
3434

3535
getSourceMapUrlsQuery = `
36-
query GetSourceMapUploadUrls($api_key: String!, $paths: [String!]!) {
36+
query GetSourceMapUploadUrls($api_key: String!, $project_id: String!, $paths: [String!]!) {
3737
get_source_map_upload_urls_ld(
38-
api_key: String!
39-
project_id: String!
40-
paths: [String!]!
41-
): [String!]!
38+
api_key: $api_key
39+
project_id: $project_id
40+
paths: $paths
41+
)
4242
}
4343
`
4444
)
@@ -57,7 +57,7 @@ type ApiKeyResponse struct {
5757

5858
type SourceMapUrlsResponse struct {
5959
Data struct {
60-
GetSourceMapUploadUrls []string `json:"get_source_map_upload_urls"`
60+
GetSourceMapUploadUrls []string `json:"get_source_map_upload_urls_ld"`
6161
} `json:"data"`
6262
}
6363

@@ -134,10 +134,10 @@ func runE(client resources.Client) func(cmd *cobra.Command, args []string) error
134134

135135
s3Keys := make([]string, 0, len(files))
136136
for _, file := range files {
137-
s3Keys = append(s3Keys, getS3Key(projectResult.ID, appVersion, basePath, file.Name))
137+
s3Keys = append(s3Keys, getS3Key(appVersion, basePath, file.Name))
138138
}
139139

140-
uploadUrls, err := getSourceMapUploadUrls(viper.GetString(cliflags.AccessTokenFlag), s3Keys, backendUrl)
140+
uploadUrls, err := getSourceMapUploadUrls(viper.GetString(cliflags.AccessTokenFlag), projectResult.ID, s3Keys, backendUrl)
141141
if err != nil {
142142
return fmt.Errorf("failed to get upload URLs: %w", err)
143143
}
@@ -213,7 +213,7 @@ func getAllSourceMapFiles(path string) ([]SourceMapFile, error) {
213213
return files, nil
214214
}
215215

216-
func getS3Key(organizationID, version, basePath, fileName string) string {
216+
func getS3Key(version, basePath, fileName string) string {
217217
if version == "" {
218218
version = "unversioned"
219219
}
@@ -222,13 +222,14 @@ func getS3Key(organizationID, version, basePath, fileName string) string {
222222
basePath = basePath + "/"
223223
}
224224

225-
return fmt.Sprintf("%s/%s/%s%s", organizationID, version, basePath, fileName)
225+
return fmt.Sprintf("%s/%s%s", version, basePath, fileName)
226226
}
227227

228-
func getSourceMapUploadUrls(apiKey string, paths []string, backendUrl string) ([]string, error) {
228+
func getSourceMapUploadUrls(apiKey, projectID string, paths []string, backendUrl string) ([]string, error) {
229229
variables := map[string]interface{}{
230-
"api_key": apiKey,
231-
"paths": paths,
230+
"api_key": apiKey,
231+
"project_id": projectID,
232+
"paths": paths,
232233
}
233234

234235
reqBody, err := json.Marshal(map[string]interface{}{

0 commit comments

Comments
 (0)