Skip to content

Commit 498294a

Browse files
committed
feature: add subtrace to shopify Dockerfile, add console.errors to debug
1 parent 3511243 commit 498294a

2 files changed

Lines changed: 23 additions & 3 deletions

File tree

clients/trieve-shopify-extension/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
FROM node:22-alpine
2-
RUN apk add --no-cache openssl
2+
RUN apk add --no-cache openssl curl
33

44
EXPOSE 3000
55

@@ -15,4 +15,7 @@ COPY . .
1515

1616
RUN yarn build
1717

18+
RUN curl -fsSLO https://github.com/subtrace/subtrace/releases/download/b270/subtrace-linux-amd64 \
19+
&& chmod +x ./subtrace-linux-amd64
20+
1821
CMD ["yarn", "run", "docker-start"]

clients/trieve-shopify-extension/app/auth.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export const validateTrieveAuth = async <S extends boolean = true>(
2525
`);
2626

2727
if (response.error) {
28+
console.error(response.error);
2829
throw response.error;
2930
}
3031

@@ -78,6 +79,7 @@ export const validateTrieveAuth = async <S extends boolean = true>(
7879
});
7980

8081
if (!key) {
82+
console.log("No key found for current shop, creating one");
8183
const query = await admin.graphql(
8284
`
8385
query {
@@ -86,13 +88,21 @@ export const validateTrieveAuth = async <S extends boolean = true>(
8688
email
8789
}
8890
}
89-
`);
91+
`).catch((e) => {
92+
console.error(e);
93+
throw e;
94+
});
9095

91-
const queryResponse = await query?.json();
96+
const queryResponse = await query?.json().catch((e) => {
97+
console.error(e);
98+
throw e;
99+
});
92100

93101
const shop_name = queryResponse?.data?.shop?.name ?? "";
94102
const shop_email = queryResponse?.data?.shop?.email ?? "";
95103

104+
console.log("New User, creating credentials", { shop_name, shop_email });
105+
96106
const userCredentialsResponse = await fetch(`${getTrieveBaseUrlEnv()}/api/auth/create_api_only_user`, {
97107
method: "POST",
98108
credentials: "include",
@@ -104,6 +114,9 @@ export const validateTrieveAuth = async <S extends boolean = true>(
104114
user_name: shop_name,
105115
user_email: shop_email,
106116
}),
117+
}).catch((e) => {
118+
console.error(e);
119+
throw e;
107120
});
108121

109122
const userCredentials = await userCredentialsResponse.json() as CreateApiUserResponse;
@@ -121,6 +134,9 @@ export const validateTrieveAuth = async <S extends boolean = true>(
121134
key: userCredentials.api_key,
122135
createdAt: new Date(),
123136
}
137+
}).catch((e) => {
138+
console.error(e);
139+
throw e;
124140
});
125141

126142
const trieve = new TrieveSDK({
@@ -135,6 +151,7 @@ export const validateTrieveAuth = async <S extends boolean = true>(
135151
let shopDataset = await trieve
136152
.getDatasetByTrackingId(session.shop)
137153
.catch(() => {
154+
console.error("Could not get dataset by tracking id");
138155
return null;
139156
});
140157

0 commit comments

Comments
 (0)