@squadbase/vite-server 0.1.17-dev.3b633bb → 0.1.17-dev.9d1f952
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +14 -8
- package/dist/connectors/google-analytics.js +34 -13
- package/dist/index.d.ts +1 -0
- package/dist/index.js +25 -14
- package/dist/main.js +14 -8
- package/dist/vite-plugin.js +14 -8
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -8104,11 +8104,13 @@ var googleAnalyticsConnector = new ConnectorPlugin({
|
|
|
8104
8104
|
The business logic type for this connector is "typescript". Use the connector SDK in your handler. Do NOT read credentials from environment variables.
|
|
8105
8105
|
|
|
8106
8106
|
SDK methods (client created via \`connection(connectionId)\`):
|
|
8107
|
-
- \`client.runReport(
|
|
8108
|
-
- \`client.runRealtimeReport(
|
|
8109
|
-
- \`client.getMetadata(
|
|
8107
|
+
- \`client.runReport(request)\` \u2014 run a GA4 report
|
|
8108
|
+
- \`client.runRealtimeReport(request)\` \u2014 run a realtime report
|
|
8109
|
+
- \`client.getMetadata(request)\` \u2014 fetch available dimensions/metrics
|
|
8110
8110
|
- \`client.request(path, init?)\` \u2014 low-level authenticated fetch
|
|
8111
8111
|
|
|
8112
|
+
**IMPORTANT**: You MUST always include \`propertyId\` in every SDK method call. The property ID is obtained during the setup flow. Without it, the request will fail.
|
|
8113
|
+
|
|
8112
8114
|
\`\`\`ts
|
|
8113
8115
|
import type { Context } from "hono";
|
|
8114
8116
|
import { connection } from "@squadbase/vite-server/connectors/google-analytics";
|
|
@@ -8122,7 +8124,8 @@ export default async function handler(c: Context) {
|
|
|
8122
8124
|
endDate?: string;
|
|
8123
8125
|
}>();
|
|
8124
8126
|
|
|
8125
|
-
const { rows } = await ga.runReport(
|
|
8127
|
+
const { rows } = await ga.runReport({
|
|
8128
|
+
propertyId,
|
|
8126
8129
|
dateRanges: [{ startDate, endDate }],
|
|
8127
8130
|
dimensions: [{ name: "date" }],
|
|
8128
8131
|
metrics: [{ name: "activeUsers" }, { name: "sessions" }],
|
|
@@ -8173,11 +8176,13 @@ activeUsers, sessions, screenPageViews, bounceRate, averageSessionDuration, conv
|
|
|
8173
8176
|
\u3053\u306E\u30B3\u30CD\u30AF\u30BF\u306E\u30D3\u30B8\u30CD\u30B9\u30ED\u30B8\u30C3\u30AF\u30BF\u30A4\u30D7\u306F "typescript" \u3067\u3059\u3002\u30CF\u30F3\u30C9\u30E9\u5185\u3067\u306F\u30B3\u30CD\u30AF\u30BFSDK\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u74B0\u5883\u5909\u6570\u304B\u3089\u8A8D\u8A3C\u60C5\u5831\u3092\u8AAD\u307F\u53D6\u3089\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002
|
|
8174
8177
|
|
|
8175
8178
|
SDK\u30E1\u30BD\u30C3\u30C9 (\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8):
|
|
8176
|
-
- \`client.runReport(
|
|
8177
|
-
- \`client.runRealtimeReport(
|
|
8178
|
-
- \`client.getMetadata(
|
|
8179
|
+
- \`client.runReport(request)\` \u2014 GA4\u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C
|
|
8180
|
+
- \`client.runRealtimeReport(request)\` \u2014 \u30EA\u30A2\u30EB\u30BF\u30A4\u30E0\u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C
|
|
8181
|
+
- \`client.getMetadata(request)\` \u2014 \u5229\u7528\u53EF\u80FD\u306A\u30C7\u30A3\u30E1\u30F3\u30B7\u30E7\u30F3/\u30E1\u30C8\u30EA\u30AF\u30B9\u3092\u53D6\u5F97
|
|
8179
8182
|
- \`client.request(path, init?)\` \u2014 \u4F4E\u30EC\u30D9\u30EB\u306E\u8A8D\u8A3C\u4ED8\u304Dfetch
|
|
8180
8183
|
|
|
8184
|
+
**\u91CD\u8981**: \u3059\u3079\u3066\u306ESDK\u30E1\u30BD\u30C3\u30C9\u547C\u3073\u51FA\u3057\u306B\u306F\u5FC5\u305A \`propertyId\` \u3092\u542B\u3081\u3066\u304F\u3060\u3055\u3044\u3002\u30D7\u30ED\u30D1\u30C6\u30A3ID\u306F\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u30D5\u30ED\u30FC\u3067\u53D6\u5F97\u3055\u308C\u307E\u3059\u3002\u6307\u5B9A\u3057\u306A\u3044\u3068\u30EA\u30AF\u30A8\u30B9\u30C8\u304C\u5931\u6557\u3057\u307E\u3059\u3002
|
|
8185
|
+
|
|
8181
8186
|
\`\`\`ts
|
|
8182
8187
|
import type { Context } from "hono";
|
|
8183
8188
|
import { connection } from "@squadbase/vite-server/connectors/google-analytics";
|
|
@@ -8191,7 +8196,8 @@ export default async function handler(c: Context) {
|
|
|
8191
8196
|
endDate?: string;
|
|
8192
8197
|
}>();
|
|
8193
8198
|
|
|
8194
|
-
const { rows } = await ga.runReport(
|
|
8199
|
+
const { rows } = await ga.runReport({
|
|
8200
|
+
propertyId,
|
|
8195
8201
|
dateRanges: [{ startDate, endDate }],
|
|
8196
8202
|
dimensions: [{ name: "date" }],
|
|
8197
8203
|
metrics: [{ name: "activeUsers" }, { name: "sessions" }],
|
|
@@ -98,6 +98,7 @@ function buildJwt(clientEmail, privateKey, nowSec) {
|
|
|
98
98
|
}
|
|
99
99
|
function createClient(params) {
|
|
100
100
|
const serviceAccountKeyJsonBase64 = params[parameters.serviceAccountKeyJsonBase64.slug];
|
|
101
|
+
const defaultPropertyId = params["property-id"] ?? "";
|
|
101
102
|
if (!serviceAccountKeyJsonBase64) {
|
|
102
103
|
throw new Error(
|
|
103
104
|
`google-analytics: missing required parameters: ${parameters.serviceAccountKeyJsonBase64.slug}`
|
|
@@ -159,13 +160,18 @@ function createClient(params) {
|
|
|
159
160
|
headers.set("Authorization", `Bearer ${accessToken}`);
|
|
160
161
|
return fetch(url, { ...init, headers });
|
|
161
162
|
},
|
|
162
|
-
async runReport(
|
|
163
|
+
async runReport(request) {
|
|
164
|
+
const { propertyId: pid, ...body } = request;
|
|
165
|
+
const propertyId = pid || defaultPropertyId;
|
|
166
|
+
if (!propertyId) {
|
|
167
|
+
throw new Error("google-analytics: propertyId is required in runReport request");
|
|
168
|
+
}
|
|
163
169
|
const response = await this.request(
|
|
164
170
|
`properties/${propertyId}:runReport`,
|
|
165
171
|
{
|
|
166
172
|
method: "POST",
|
|
167
173
|
headers: { "Content-Type": "application/json" },
|
|
168
|
-
body: JSON.stringify(
|
|
174
|
+
body: JSON.stringify(body)
|
|
169
175
|
}
|
|
170
176
|
);
|
|
171
177
|
if (!response.ok) {
|
|
@@ -180,7 +186,11 @@ function createClient(params) {
|
|
|
180
186
|
rowCount: data.rowCount ?? 0
|
|
181
187
|
};
|
|
182
188
|
},
|
|
183
|
-
async getMetadata(
|
|
189
|
+
async getMetadata(request) {
|
|
190
|
+
const propertyId = request.propertyId || defaultPropertyId;
|
|
191
|
+
if (!propertyId) {
|
|
192
|
+
throw new Error("google-analytics: propertyId is required in getMetadata request");
|
|
193
|
+
}
|
|
184
194
|
const response = await this.request(
|
|
185
195
|
`properties/${propertyId}/metadata`,
|
|
186
196
|
{ method: "GET" }
|
|
@@ -193,13 +203,18 @@ function createClient(params) {
|
|
|
193
203
|
}
|
|
194
204
|
return await response.json();
|
|
195
205
|
},
|
|
196
|
-
async runRealtimeReport(
|
|
206
|
+
async runRealtimeReport(request) {
|
|
207
|
+
const { propertyId: pid, ...body } = request;
|
|
208
|
+
const propertyId = pid || defaultPropertyId;
|
|
209
|
+
if (!propertyId) {
|
|
210
|
+
throw new Error("google-analytics: propertyId is required in runRealtimeReport request");
|
|
211
|
+
}
|
|
197
212
|
const response = await this.request(
|
|
198
213
|
`properties/${propertyId}:runRealtimeReport`,
|
|
199
214
|
{
|
|
200
215
|
method: "POST",
|
|
201
216
|
headers: { "Content-Type": "application/json" },
|
|
202
|
-
body: JSON.stringify(
|
|
217
|
+
body: JSON.stringify(body)
|
|
203
218
|
}
|
|
204
219
|
);
|
|
205
220
|
if (!response.ok) {
|
|
@@ -899,11 +914,13 @@ var googleAnalyticsConnector = new ConnectorPlugin({
|
|
|
899
914
|
The business logic type for this connector is "typescript". Use the connector SDK in your handler. Do NOT read credentials from environment variables.
|
|
900
915
|
|
|
901
916
|
SDK methods (client created via \`connection(connectionId)\`):
|
|
902
|
-
- \`client.runReport(
|
|
903
|
-
- \`client.runRealtimeReport(
|
|
904
|
-
- \`client.getMetadata(
|
|
917
|
+
- \`client.runReport(request)\` \u2014 run a GA4 report
|
|
918
|
+
- \`client.runRealtimeReport(request)\` \u2014 run a realtime report
|
|
919
|
+
- \`client.getMetadata(request)\` \u2014 fetch available dimensions/metrics
|
|
905
920
|
- \`client.request(path, init?)\` \u2014 low-level authenticated fetch
|
|
906
921
|
|
|
922
|
+
**IMPORTANT**: You MUST always include \`propertyId\` in every SDK method call. The property ID is obtained during the setup flow. Without it, the request will fail.
|
|
923
|
+
|
|
907
924
|
\`\`\`ts
|
|
908
925
|
import type { Context } from "hono";
|
|
909
926
|
import { connection } from "@squadbase/vite-server/connectors/google-analytics";
|
|
@@ -917,7 +934,8 @@ export default async function handler(c: Context) {
|
|
|
917
934
|
endDate?: string;
|
|
918
935
|
}>();
|
|
919
936
|
|
|
920
|
-
const { rows } = await ga.runReport(
|
|
937
|
+
const { rows } = await ga.runReport({
|
|
938
|
+
propertyId,
|
|
921
939
|
dateRanges: [{ startDate, endDate }],
|
|
922
940
|
dimensions: [{ name: "date" }],
|
|
923
941
|
metrics: [{ name: "activeUsers" }, { name: "sessions" }],
|
|
@@ -968,11 +986,13 @@ activeUsers, sessions, screenPageViews, bounceRate, averageSessionDuration, conv
|
|
|
968
986
|
\u3053\u306E\u30B3\u30CD\u30AF\u30BF\u306E\u30D3\u30B8\u30CD\u30B9\u30ED\u30B8\u30C3\u30AF\u30BF\u30A4\u30D7\u306F "typescript" \u3067\u3059\u3002\u30CF\u30F3\u30C9\u30E9\u5185\u3067\u306F\u30B3\u30CD\u30AF\u30BFSDK\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u74B0\u5883\u5909\u6570\u304B\u3089\u8A8D\u8A3C\u60C5\u5831\u3092\u8AAD\u307F\u53D6\u3089\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002
|
|
969
987
|
|
|
970
988
|
SDK\u30E1\u30BD\u30C3\u30C9 (\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8):
|
|
971
|
-
- \`client.runReport(
|
|
972
|
-
- \`client.runRealtimeReport(
|
|
973
|
-
- \`client.getMetadata(
|
|
989
|
+
- \`client.runReport(request)\` \u2014 GA4\u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C
|
|
990
|
+
- \`client.runRealtimeReport(request)\` \u2014 \u30EA\u30A2\u30EB\u30BF\u30A4\u30E0\u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C
|
|
991
|
+
- \`client.getMetadata(request)\` \u2014 \u5229\u7528\u53EF\u80FD\u306A\u30C7\u30A3\u30E1\u30F3\u30B7\u30E7\u30F3/\u30E1\u30C8\u30EA\u30AF\u30B9\u3092\u53D6\u5F97
|
|
974
992
|
- \`client.request(path, init?)\` \u2014 \u4F4E\u30EC\u30D9\u30EB\u306E\u8A8D\u8A3C\u4ED8\u304Dfetch
|
|
975
993
|
|
|
994
|
+
**\u91CD\u8981**: \u3059\u3079\u3066\u306ESDK\u30E1\u30BD\u30C3\u30C9\u547C\u3073\u51FA\u3057\u306B\u306F\u5FC5\u305A \`propertyId\` \u3092\u542B\u3081\u3066\u304F\u3060\u3055\u3044\u3002\u30D7\u30ED\u30D1\u30C6\u30A3ID\u306F\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u30D5\u30ED\u30FC\u3067\u53D6\u5F97\u3055\u308C\u307E\u3059\u3002\u6307\u5B9A\u3057\u306A\u3044\u3068\u30EA\u30AF\u30A8\u30B9\u30C8\u304C\u5931\u6557\u3057\u307E\u3059\u3002
|
|
995
|
+
|
|
976
996
|
\`\`\`ts
|
|
977
997
|
import type { Context } from "hono";
|
|
978
998
|
import { connection } from "@squadbase/vite-server/connectors/google-analytics";
|
|
@@ -986,7 +1006,8 @@ export default async function handler(c: Context) {
|
|
|
986
1006
|
endDate?: string;
|
|
987
1007
|
}>();
|
|
988
1008
|
|
|
989
|
-
const { rows } = await ga.runReport(
|
|
1009
|
+
const { rows } = await ga.runReport({
|
|
1010
|
+
propertyId,
|
|
990
1011
|
dateRanges: [{ startDate, endDate }],
|
|
991
1012
|
dimensions: [{ name: "date" }],
|
|
992
1013
|
metrics: [{ name: "activeUsers" }, { name: "sessions" }],
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -8039,11 +8039,13 @@ var googleAnalyticsConnector = new ConnectorPlugin({
|
|
|
8039
8039
|
The business logic type for this connector is "typescript". Use the connector SDK in your handler. Do NOT read credentials from environment variables.
|
|
8040
8040
|
|
|
8041
8041
|
SDK methods (client created via \`connection(connectionId)\`):
|
|
8042
|
-
- \`client.runReport(
|
|
8043
|
-
- \`client.runRealtimeReport(
|
|
8044
|
-
- \`client.getMetadata(
|
|
8042
|
+
- \`client.runReport(request)\` \u2014 run a GA4 report
|
|
8043
|
+
- \`client.runRealtimeReport(request)\` \u2014 run a realtime report
|
|
8044
|
+
- \`client.getMetadata(request)\` \u2014 fetch available dimensions/metrics
|
|
8045
8045
|
- \`client.request(path, init?)\` \u2014 low-level authenticated fetch
|
|
8046
8046
|
|
|
8047
|
+
**IMPORTANT**: You MUST always include \`propertyId\` in every SDK method call. The property ID is obtained during the setup flow. Without it, the request will fail.
|
|
8048
|
+
|
|
8047
8049
|
\`\`\`ts
|
|
8048
8050
|
import type { Context } from "hono";
|
|
8049
8051
|
import { connection } from "@squadbase/vite-server/connectors/google-analytics";
|
|
@@ -8057,7 +8059,8 @@ export default async function handler(c: Context) {
|
|
|
8057
8059
|
endDate?: string;
|
|
8058
8060
|
}>();
|
|
8059
8061
|
|
|
8060
|
-
const { rows } = await ga.runReport(
|
|
8062
|
+
const { rows } = await ga.runReport({
|
|
8063
|
+
propertyId,
|
|
8061
8064
|
dateRanges: [{ startDate, endDate }],
|
|
8062
8065
|
dimensions: [{ name: "date" }],
|
|
8063
8066
|
metrics: [{ name: "activeUsers" }, { name: "sessions" }],
|
|
@@ -8108,11 +8111,13 @@ activeUsers, sessions, screenPageViews, bounceRate, averageSessionDuration, conv
|
|
|
8108
8111
|
\u3053\u306E\u30B3\u30CD\u30AF\u30BF\u306E\u30D3\u30B8\u30CD\u30B9\u30ED\u30B8\u30C3\u30AF\u30BF\u30A4\u30D7\u306F "typescript" \u3067\u3059\u3002\u30CF\u30F3\u30C9\u30E9\u5185\u3067\u306F\u30B3\u30CD\u30AF\u30BFSDK\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u74B0\u5883\u5909\u6570\u304B\u3089\u8A8D\u8A3C\u60C5\u5831\u3092\u8AAD\u307F\u53D6\u3089\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002
|
|
8109
8112
|
|
|
8110
8113
|
SDK\u30E1\u30BD\u30C3\u30C9 (\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8):
|
|
8111
|
-
- \`client.runReport(
|
|
8112
|
-
- \`client.runRealtimeReport(
|
|
8113
|
-
- \`client.getMetadata(
|
|
8114
|
+
- \`client.runReport(request)\` \u2014 GA4\u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C
|
|
8115
|
+
- \`client.runRealtimeReport(request)\` \u2014 \u30EA\u30A2\u30EB\u30BF\u30A4\u30E0\u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C
|
|
8116
|
+
- \`client.getMetadata(request)\` \u2014 \u5229\u7528\u53EF\u80FD\u306A\u30C7\u30A3\u30E1\u30F3\u30B7\u30E7\u30F3/\u30E1\u30C8\u30EA\u30AF\u30B9\u3092\u53D6\u5F97
|
|
8114
8117
|
- \`client.request(path, init?)\` \u2014 \u4F4E\u30EC\u30D9\u30EB\u306E\u8A8D\u8A3C\u4ED8\u304Dfetch
|
|
8115
8118
|
|
|
8119
|
+
**\u91CD\u8981**: \u3059\u3079\u3066\u306ESDK\u30E1\u30BD\u30C3\u30C9\u547C\u3073\u51FA\u3057\u306B\u306F\u5FC5\u305A \`propertyId\` \u3092\u542B\u3081\u3066\u304F\u3060\u3055\u3044\u3002\u30D7\u30ED\u30D1\u30C6\u30A3ID\u306F\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u30D5\u30ED\u30FC\u3067\u53D6\u5F97\u3055\u308C\u307E\u3059\u3002\u6307\u5B9A\u3057\u306A\u3044\u3068\u30EA\u30AF\u30A8\u30B9\u30C8\u304C\u5931\u6557\u3057\u307E\u3059\u3002
|
|
8120
|
+
|
|
8116
8121
|
\`\`\`ts
|
|
8117
8122
|
import type { Context } from "hono";
|
|
8118
8123
|
import { connection } from "@squadbase/vite-server/connectors/google-analytics";
|
|
@@ -8126,7 +8131,8 @@ export default async function handler(c: Context) {
|
|
|
8126
8131
|
endDate?: string;
|
|
8127
8132
|
}>();
|
|
8128
8133
|
|
|
8129
|
-
const { rows } = await ga.runReport(
|
|
8134
|
+
const { rows } = await ga.runReport({
|
|
8135
|
+
propertyId,
|
|
8130
8136
|
dateRanges: [{ startDate, endDate }],
|
|
8131
8137
|
dimensions: [{ name: "date" }],
|
|
8132
8138
|
metrics: [{ name: "activeUsers" }, { name: "sessions" }],
|
|
@@ -41847,7 +41853,7 @@ function createAirtableClient(entry, slug) {
|
|
|
41847
41853
|
// src/connector-client/google-analytics.ts
|
|
41848
41854
|
function createGoogleAnalyticsClient(entry, slug) {
|
|
41849
41855
|
const serviceAccountJsonBase64 = resolveEnvVar(entry, "service-account-key-json-base64", slug);
|
|
41850
|
-
const
|
|
41856
|
+
const defaultPropertyId = resolveEnvVarOptional(entry, "property-id");
|
|
41851
41857
|
const serviceAccountJson = Buffer.from(serviceAccountJsonBase64, "base64").toString("utf-8");
|
|
41852
41858
|
let credentials;
|
|
41853
41859
|
try {
|
|
@@ -41859,6 +41865,11 @@ function createGoogleAnalyticsClient(entry, slug) {
|
|
|
41859
41865
|
}
|
|
41860
41866
|
return {
|
|
41861
41867
|
async runReport(request) {
|
|
41868
|
+
const { propertyId: pid, ...reportRequest } = request;
|
|
41869
|
+
const propertyId = pid || defaultPropertyId;
|
|
41870
|
+
if (!propertyId) {
|
|
41871
|
+
throw new Error("Google Analytics: propertyId is required in runReport request");
|
|
41872
|
+
}
|
|
41862
41873
|
const { BetaAnalyticsDataClient } = await import("@google-analytics/data");
|
|
41863
41874
|
const client = new BetaAnalyticsDataClient({
|
|
41864
41875
|
credentials: {
|
|
@@ -41868,11 +41879,11 @@ function createGoogleAnalyticsClient(entry, slug) {
|
|
|
41868
41879
|
});
|
|
41869
41880
|
const response = await client.runReport({
|
|
41870
41881
|
property: `properties/${propertyId}`,
|
|
41871
|
-
dateRanges:
|
|
41872
|
-
dimensions:
|
|
41873
|
-
metrics:
|
|
41874
|
-
limit:
|
|
41875
|
-
offset:
|
|
41882
|
+
dateRanges: reportRequest.dateRanges,
|
|
41883
|
+
dimensions: reportRequest.dimensions,
|
|
41884
|
+
metrics: reportRequest.metrics,
|
|
41885
|
+
limit: reportRequest.limit != null ? String(reportRequest.limit) : void 0,
|
|
41886
|
+
offset: reportRequest.offset != null ? String(reportRequest.offset) : void 0
|
|
41876
41887
|
});
|
|
41877
41888
|
const reportResponse = Array.isArray(response) ? response[0] : response;
|
|
41878
41889
|
const rawRows = reportResponse.rows;
|
package/dist/main.js
CHANGED
|
@@ -8039,11 +8039,13 @@ var googleAnalyticsConnector = new ConnectorPlugin({
|
|
|
8039
8039
|
The business logic type for this connector is "typescript". Use the connector SDK in your handler. Do NOT read credentials from environment variables.
|
|
8040
8040
|
|
|
8041
8041
|
SDK methods (client created via \`connection(connectionId)\`):
|
|
8042
|
-
- \`client.runReport(
|
|
8043
|
-
- \`client.runRealtimeReport(
|
|
8044
|
-
- \`client.getMetadata(
|
|
8042
|
+
- \`client.runReport(request)\` \u2014 run a GA4 report
|
|
8043
|
+
- \`client.runRealtimeReport(request)\` \u2014 run a realtime report
|
|
8044
|
+
- \`client.getMetadata(request)\` \u2014 fetch available dimensions/metrics
|
|
8045
8045
|
- \`client.request(path, init?)\` \u2014 low-level authenticated fetch
|
|
8046
8046
|
|
|
8047
|
+
**IMPORTANT**: You MUST always include \`propertyId\` in every SDK method call. The property ID is obtained during the setup flow. Without it, the request will fail.
|
|
8048
|
+
|
|
8047
8049
|
\`\`\`ts
|
|
8048
8050
|
import type { Context } from "hono";
|
|
8049
8051
|
import { connection } from "@squadbase/vite-server/connectors/google-analytics";
|
|
@@ -8057,7 +8059,8 @@ export default async function handler(c: Context) {
|
|
|
8057
8059
|
endDate?: string;
|
|
8058
8060
|
}>();
|
|
8059
8061
|
|
|
8060
|
-
const { rows } = await ga.runReport(
|
|
8062
|
+
const { rows } = await ga.runReport({
|
|
8063
|
+
propertyId,
|
|
8061
8064
|
dateRanges: [{ startDate, endDate }],
|
|
8062
8065
|
dimensions: [{ name: "date" }],
|
|
8063
8066
|
metrics: [{ name: "activeUsers" }, { name: "sessions" }],
|
|
@@ -8108,11 +8111,13 @@ activeUsers, sessions, screenPageViews, bounceRate, averageSessionDuration, conv
|
|
|
8108
8111
|
\u3053\u306E\u30B3\u30CD\u30AF\u30BF\u306E\u30D3\u30B8\u30CD\u30B9\u30ED\u30B8\u30C3\u30AF\u30BF\u30A4\u30D7\u306F "typescript" \u3067\u3059\u3002\u30CF\u30F3\u30C9\u30E9\u5185\u3067\u306F\u30B3\u30CD\u30AF\u30BFSDK\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u74B0\u5883\u5909\u6570\u304B\u3089\u8A8D\u8A3C\u60C5\u5831\u3092\u8AAD\u307F\u53D6\u3089\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002
|
|
8109
8112
|
|
|
8110
8113
|
SDK\u30E1\u30BD\u30C3\u30C9 (\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8):
|
|
8111
|
-
- \`client.runReport(
|
|
8112
|
-
- \`client.runRealtimeReport(
|
|
8113
|
-
- \`client.getMetadata(
|
|
8114
|
+
- \`client.runReport(request)\` \u2014 GA4\u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C
|
|
8115
|
+
- \`client.runRealtimeReport(request)\` \u2014 \u30EA\u30A2\u30EB\u30BF\u30A4\u30E0\u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C
|
|
8116
|
+
- \`client.getMetadata(request)\` \u2014 \u5229\u7528\u53EF\u80FD\u306A\u30C7\u30A3\u30E1\u30F3\u30B7\u30E7\u30F3/\u30E1\u30C8\u30EA\u30AF\u30B9\u3092\u53D6\u5F97
|
|
8114
8117
|
- \`client.request(path, init?)\` \u2014 \u4F4E\u30EC\u30D9\u30EB\u306E\u8A8D\u8A3C\u4ED8\u304Dfetch
|
|
8115
8118
|
|
|
8119
|
+
**\u91CD\u8981**: \u3059\u3079\u3066\u306ESDK\u30E1\u30BD\u30C3\u30C9\u547C\u3073\u51FA\u3057\u306B\u306F\u5FC5\u305A \`propertyId\` \u3092\u542B\u3081\u3066\u304F\u3060\u3055\u3044\u3002\u30D7\u30ED\u30D1\u30C6\u30A3ID\u306F\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u30D5\u30ED\u30FC\u3067\u53D6\u5F97\u3055\u308C\u307E\u3059\u3002\u6307\u5B9A\u3057\u306A\u3044\u3068\u30EA\u30AF\u30A8\u30B9\u30C8\u304C\u5931\u6557\u3057\u307E\u3059\u3002
|
|
8120
|
+
|
|
8116
8121
|
\`\`\`ts
|
|
8117
8122
|
import type { Context } from "hono";
|
|
8118
8123
|
import { connection } from "@squadbase/vite-server/connectors/google-analytics";
|
|
@@ -8126,7 +8131,8 @@ export default async function handler(c: Context) {
|
|
|
8126
8131
|
endDate?: string;
|
|
8127
8132
|
}>();
|
|
8128
8133
|
|
|
8129
|
-
const { rows } = await ga.runReport(
|
|
8134
|
+
const { rows } = await ga.runReport({
|
|
8135
|
+
propertyId,
|
|
8130
8136
|
dateRanges: [{ startDate, endDate }],
|
|
8131
8137
|
dimensions: [{ name: "date" }],
|
|
8132
8138
|
metrics: [{ name: "activeUsers" }, { name: "sessions" }],
|
package/dist/vite-plugin.js
CHANGED
|
@@ -8040,11 +8040,13 @@ var googleAnalyticsConnector = new ConnectorPlugin({
|
|
|
8040
8040
|
The business logic type for this connector is "typescript". Use the connector SDK in your handler. Do NOT read credentials from environment variables.
|
|
8041
8041
|
|
|
8042
8042
|
SDK methods (client created via \`connection(connectionId)\`):
|
|
8043
|
-
- \`client.runReport(
|
|
8044
|
-
- \`client.runRealtimeReport(
|
|
8045
|
-
- \`client.getMetadata(
|
|
8043
|
+
- \`client.runReport(request)\` \u2014 run a GA4 report
|
|
8044
|
+
- \`client.runRealtimeReport(request)\` \u2014 run a realtime report
|
|
8045
|
+
- \`client.getMetadata(request)\` \u2014 fetch available dimensions/metrics
|
|
8046
8046
|
- \`client.request(path, init?)\` \u2014 low-level authenticated fetch
|
|
8047
8047
|
|
|
8048
|
+
**IMPORTANT**: You MUST always include \`propertyId\` in every SDK method call. The property ID is obtained during the setup flow. Without it, the request will fail.
|
|
8049
|
+
|
|
8048
8050
|
\`\`\`ts
|
|
8049
8051
|
import type { Context } from "hono";
|
|
8050
8052
|
import { connection } from "@squadbase/vite-server/connectors/google-analytics";
|
|
@@ -8058,7 +8060,8 @@ export default async function handler(c: Context) {
|
|
|
8058
8060
|
endDate?: string;
|
|
8059
8061
|
}>();
|
|
8060
8062
|
|
|
8061
|
-
const { rows } = await ga.runReport(
|
|
8063
|
+
const { rows } = await ga.runReport({
|
|
8064
|
+
propertyId,
|
|
8062
8065
|
dateRanges: [{ startDate, endDate }],
|
|
8063
8066
|
dimensions: [{ name: "date" }],
|
|
8064
8067
|
metrics: [{ name: "activeUsers" }, { name: "sessions" }],
|
|
@@ -8109,11 +8112,13 @@ activeUsers, sessions, screenPageViews, bounceRate, averageSessionDuration, conv
|
|
|
8109
8112
|
\u3053\u306E\u30B3\u30CD\u30AF\u30BF\u306E\u30D3\u30B8\u30CD\u30B9\u30ED\u30B8\u30C3\u30AF\u30BF\u30A4\u30D7\u306F "typescript" \u3067\u3059\u3002\u30CF\u30F3\u30C9\u30E9\u5185\u3067\u306F\u30B3\u30CD\u30AF\u30BFSDK\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u74B0\u5883\u5909\u6570\u304B\u3089\u8A8D\u8A3C\u60C5\u5831\u3092\u8AAD\u307F\u53D6\u3089\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002
|
|
8110
8113
|
|
|
8111
8114
|
SDK\u30E1\u30BD\u30C3\u30C9 (\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8):
|
|
8112
|
-
- \`client.runReport(
|
|
8113
|
-
- \`client.runRealtimeReport(
|
|
8114
|
-
- \`client.getMetadata(
|
|
8115
|
+
- \`client.runReport(request)\` \u2014 GA4\u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C
|
|
8116
|
+
- \`client.runRealtimeReport(request)\` \u2014 \u30EA\u30A2\u30EB\u30BF\u30A4\u30E0\u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C
|
|
8117
|
+
- \`client.getMetadata(request)\` \u2014 \u5229\u7528\u53EF\u80FD\u306A\u30C7\u30A3\u30E1\u30F3\u30B7\u30E7\u30F3/\u30E1\u30C8\u30EA\u30AF\u30B9\u3092\u53D6\u5F97
|
|
8115
8118
|
- \`client.request(path, init?)\` \u2014 \u4F4E\u30EC\u30D9\u30EB\u306E\u8A8D\u8A3C\u4ED8\u304Dfetch
|
|
8116
8119
|
|
|
8120
|
+
**\u91CD\u8981**: \u3059\u3079\u3066\u306ESDK\u30E1\u30BD\u30C3\u30C9\u547C\u3073\u51FA\u3057\u306B\u306F\u5FC5\u305A \`propertyId\` \u3092\u542B\u3081\u3066\u304F\u3060\u3055\u3044\u3002\u30D7\u30ED\u30D1\u30C6\u30A3ID\u306F\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u30D5\u30ED\u30FC\u3067\u53D6\u5F97\u3055\u308C\u307E\u3059\u3002\u6307\u5B9A\u3057\u306A\u3044\u3068\u30EA\u30AF\u30A8\u30B9\u30C8\u304C\u5931\u6557\u3057\u307E\u3059\u3002
|
|
8121
|
+
|
|
8117
8122
|
\`\`\`ts
|
|
8118
8123
|
import type { Context } from "hono";
|
|
8119
8124
|
import { connection } from "@squadbase/vite-server/connectors/google-analytics";
|
|
@@ -8127,7 +8132,8 @@ export default async function handler(c: Context) {
|
|
|
8127
8132
|
endDate?: string;
|
|
8128
8133
|
}>();
|
|
8129
8134
|
|
|
8130
|
-
const { rows } = await ga.runReport(
|
|
8135
|
+
const { rows } = await ga.runReport({
|
|
8136
|
+
propertyId,
|
|
8131
8137
|
dateRanges: [{ startDate, endDate }],
|
|
8132
8138
|
dimensions: [{ name: "date" }],
|
|
8133
8139
|
metrics: [{ name: "activeUsers" }, { name: "sessions" }],
|