@squadbase/vite-server 0.1.19-dev.6ec878e → 0.1.19-dev.907a033
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/build-entry/server-entry.mjs +18 -0
- package/dist/cli/index.js +60 -65
- package/dist/connectors/google-analytics-oauth.js +72 -142
- package/dist/index.d.ts +8 -1
- package/dist/index.js +82 -88
- package/dist/main.d.ts +1 -0
- package/dist/main.js +83 -89
- package/dist/vite-plugin.d.ts +0 -1
- package/dist/vite-plugin.js +144 -82
- package/package.json +3 -3
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Server build entry used by `squadbasePlugin` (see vite-plugin.ts).
|
|
2
|
+
//
|
|
3
|
+
// It re-exports the vite-server app as default (so @hono/vite-build's injected
|
|
4
|
+
// `serve({ fetch: app.fetch })` works), and statically imports the project's
|
|
5
|
+
// TypeScript server-logic handlers via the `virtual:squadbase-server-logics`
|
|
6
|
+
// module (generated by the plugin from `server-logic/*.json`). Because the
|
|
7
|
+
// handlers are compiled into THIS bundle, they share the server's module graph
|
|
8
|
+
// — in particular hono's `contextStorage` AsyncLocalStorage — so `getContext()`
|
|
9
|
+
// works. This replaces runtime jiti transpilation.
|
|
10
|
+
//
|
|
11
|
+
// Registration goes through `@squadbase/vite-server/main` (not `/`) because
|
|
12
|
+
// `./main` and `./` are separate bundle entry points with separate module state.
|
|
13
|
+
import app, { registerBundledHandlers } from "@squadbase/vite-server/main";
|
|
14
|
+
import { HANDLERS } from "virtual:squadbase-server-logics";
|
|
15
|
+
|
|
16
|
+
registerBundledHandlers(HANDLERS);
|
|
17
|
+
|
|
18
|
+
export default app;
|
package/dist/cli/index.js
CHANGED
|
@@ -10570,11 +10570,11 @@ var googleAnalyticsOauthOnboarding = new ConnectorOnboarding({
|
|
|
10570
10570
|
- \u30A2\u30AB\u30A6\u30F3\u30C8\u304C **1\u4EF6\u306E\u307F**: \`askUserQuestion\` \u306F\u30B9\u30AD\u30C3\u30D7\u3057\u3001\u305D\u306E\u30A2\u30AB\u30A6\u30F3\u30C8\u3092\u9078\u629E\u6E08\u307F\u3068\u3057\u3066\u6B21\u3078\u9032\u3080
|
|
10571
10571
|
- \u30A2\u30AB\u30A6\u30F3\u30C8\u304C **0\u4EF6**: \u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3092\u4E2D\u65AD\u3057\u3001\u30E6\u30FC\u30B6\u30FC\u306B\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u306A\u30A2\u30AB\u30A6\u30F3\u30C8\u304C\u306A\u3044\u65E8\u3092\u4F1D\u3048\u308B
|
|
10572
10572
|
3. \`${listPropertiesToolName}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u3001\u9078\u629E\u3055\u308C\u305F\u30A2\u30AB\u30A6\u30F3\u30C8\u306E\u30D7\u30ED\u30D1\u30C6\u30A3\u4E00\u89A7\u3092\u53D6\u5F97\u3059\u308B
|
|
10573
|
-
4.
|
|
10574
|
-
- \`
|
|
10575
|
-
-
|
|
10576
|
-
- \u30D7\u30ED\u30D1\u30C6\u30A3\u304C **0\u4EF6
|
|
10577
|
-
5. \
|
|
10573
|
+
4. \u30D7\u30ED\u30D1\u30C6\u30A3\u306E\u9078\u629E:
|
|
10574
|
+
- \u30D7\u30ED\u30D1\u30C6\u30A3\u304C **2\u4EF6\u4EE5\u4E0A**: \u300C\u4F7F\u7528\u3059\u308B\u30D7\u30ED\u30D1\u30C6\u30A3\u3092\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u300D\u3068\u30E6\u30FC\u30B6\u30FC\u306B\u4F1D\u3048\u305F\u4E0A\u3067\u3001\`askUserQuestion\` \u3092\u547C\u3073\u51FA\u3059\uFF08\`options\`: \u5404 option \u306E \`label\` \u306F \`\u8868\u793A\u540D (id: \u30D7\u30ED\u30D1\u30C6\u30A3ID)\` \u306E\u5F62\u5F0F\u3001\`value\` \u306F\u30D7\u30ED\u30D1\u30C6\u30A3ID\uFF09
|
|
10575
|
+
- \u30D7\u30ED\u30D1\u30C6\u30A3\u304C **1\u4EF6\u306E\u307F**: \`askUserQuestion\` \u306F\u30B9\u30AD\u30C3\u30D7\u3057\u3001\u305D\u306E\u30D7\u30ED\u30D1\u30C6\u30A3\u3092\u9078\u629E\u6E08\u307F\u3068\u3057\u3066\u6B21\u3078\u9032\u3080
|
|
10576
|
+
- \u30D7\u30ED\u30D1\u30C6\u30A3\u304C **0\u4EF6**: \u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3092\u4E2D\u65AD\u3057\u3001\u30E6\u30FC\u30B6\u30FC\u306B\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u306A\u30D7\u30ED\u30D1\u30C6\u30A3\u304C\u306A\u3044\u65E8\u3092\u4F1D\u3048\u308B
|
|
10577
|
+
5. \u9078\u629E\u3055\u308C\u305F\u30D7\u30ED\u30D1\u30C6\u30A3ID\uFF08\u6570\u5024\uFF09\u306F\u4EE5\u964D\u306E\u30EA\u30AF\u30A8\u30B9\u30C8\u3067\u30D1\u30B9\u306B\u76F4\u63A5\u6307\u5B9A\u3059\u308B\uFF08\u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u306B\u306F\u4FDD\u5B58\u3055\u308C\u306A\u3044\uFF09\u3002\u6B21\u306E\u30B9\u30C6\u30C3\u30D7\u306B\u9032\u3080
|
|
10578
10578
|
|
|
10579
10579
|
#### \u5236\u7D04
|
|
10580
10580
|
- **\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u4E2D\u306B\u30EC\u30DD\u30FC\u30C8\u30C7\u30FC\u30BF\u3092\u53D6\u5F97\u3057\u306A\u3044\u3053\u3068**\u3002\u5B9F\u884C\u3057\u3066\u3088\u3044\u306E\u306F\u4E0A\u8A18\u624B\u9806\u3067\u6307\u5B9A\u3055\u308C\u305F\u30E1\u30BF\u30C7\u30FC\u30BF\u53D6\u5F97\u306E\u307F
|
|
@@ -10588,11 +10588,11 @@ var googleAnalyticsOauthOnboarding = new ConnectorOnboarding({
|
|
|
10588
10588
|
- **Only 1 account**: Skip \`askUserQuestion\` and proceed using that account as the selection
|
|
10589
10589
|
- **0 accounts**: Abort setup and inform the user that no accessible accounts are available
|
|
10590
10590
|
3. Call \`${listPropertiesToolName}\` to get the list of properties for the selected account
|
|
10591
|
-
4.
|
|
10592
|
-
- \`
|
|
10593
|
-
-
|
|
10594
|
-
-
|
|
10595
|
-
5.
|
|
10591
|
+
4. Select a property:
|
|
10592
|
+
- **2 or more properties**: Tell the user "Please select a property.", then call \`askUserQuestion\` (\`options\`: each option's \`label\` should be \`Display Name (id: propertyId)\`, \`value\` should be the property ID)
|
|
10593
|
+
- **Only 1 property**: Skip \`askUserQuestion\` and proceed using that property as the selection
|
|
10594
|
+
- **0 properties**: Abort setup and inform the user that no accessible properties are available
|
|
10595
|
+
5. Write the selected numeric property id directly into the request path (it is not stored on the connection). Proceed to the next step
|
|
10596
10596
|
|
|
10597
10597
|
#### Constraints
|
|
10598
10598
|
- **Do NOT fetch report data during setup**. Only the metadata requests specified in the steps above are allowed
|
|
@@ -10600,26 +10600,17 @@ var googleAnalyticsOauthOnboarding = new ConnectorOnboarding({
|
|
|
10600
10600
|
- Write only 1 sentence between tool calls, then immediately call the next tool. Skip unnecessary explanations and proceed efficiently`
|
|
10601
10601
|
},
|
|
10602
10602
|
dataOverviewInstructions: {
|
|
10603
|
-
en: `
|
|
10604
|
-
|
|
10605
|
-
|
|
10606
|
-
|
|
10603
|
+
en: `Use the selected numeric property id in the path (write it directly, e.g. properties/123456789).
|
|
10604
|
+
1. Call connector_google-analytics-oauth_request with GET properties/<propertyId>/metadata to list available dimensions and metrics
|
|
10605
|
+
2. Call connector_google-analytics-oauth_request with POST properties/<propertyId>:runReport using a small date range and basic metrics to verify data availability`,
|
|
10606
|
+
ja: `\u9078\u629E\u3057\u305F\u6570\u5024\u306E\u30D7\u30ED\u30D1\u30C6\u30A3ID\u3092\u30D1\u30B9\u306B\u76F4\u63A5\u8A18\u8FF0\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u4F8B: properties/123456789\uFF09\u3002
|
|
10607
|
+
1. connector_google-analytics-oauth_request \u3067 GET properties/<propertyId>/metadata \u3092\u547C\u3073\u51FA\u3057\u3001\u5229\u7528\u53EF\u80FD\u306A\u30C7\u30A3\u30E1\u30F3\u30B7\u30E7\u30F3\u3068\u30E1\u30C8\u30EA\u30AF\u30B9\u306E\u4E00\u89A7\u3092\u53D6\u5F97
|
|
10608
|
+
2. connector_google-analytics-oauth_request \u3067 POST properties/<propertyId>:runReport \u3092\u77ED\u3044\u671F\u9593\u3068\u57FA\u672C\u30E1\u30C8\u30EA\u30AF\u30B9\u3067\u547C\u3073\u51FA\u3057\u3001\u30C7\u30FC\u30BF\u306E\u53EF\u7528\u6027\u3092\u78BA\u8A8D`
|
|
10607
10609
|
}
|
|
10608
10610
|
});
|
|
10609
10611
|
|
|
10610
10612
|
// ../connectors/src/connectors/google-analytics-oauth/parameters.ts
|
|
10611
|
-
|
|
10612
|
-
var parameters16 = {
|
|
10613
|
-
propertyId: new ParameterDefinition({
|
|
10614
|
-
slug: "property-id",
|
|
10615
|
-
name: "Google Analytics Property ID",
|
|
10616
|
-
description: "The Google Analytics 4 property ID (e.g., 123456789). Can be found in GA4 Admin > Property Settings.",
|
|
10617
|
-
envVarBaseKey: "GA_OAUTH_PROPERTY_ID",
|
|
10618
|
-
type: "text",
|
|
10619
|
-
secret: false,
|
|
10620
|
-
required: false
|
|
10621
|
-
})
|
|
10622
|
-
};
|
|
10613
|
+
var parameters16 = {};
|
|
10623
10614
|
|
|
10624
10615
|
// ../connectors/src/connectors/google-analytics-oauth/setup-flow.ts
|
|
10625
10616
|
var ADMIN_BASE_URL4 = "https://analyticsadmin.googleapis.com/v1beta";
|
|
@@ -10926,7 +10917,7 @@ var inputSchema25 = z25.object({
|
|
|
10926
10917
|
connectionId: z25.string().describe("ID of the Google Analytics OAuth connection to use"),
|
|
10927
10918
|
method: z25.enum(["GET", "POST"]).describe("HTTP method"),
|
|
10928
10919
|
path: z25.string().describe(
|
|
10929
|
-
"API path appended to https://analyticsdata.googleapis.com/v1beta/ (e.g., 'properties/
|
|
10920
|
+
"API path appended to https://analyticsdata.googleapis.com/v1beta/ (e.g., 'properties/123456789:runReport'). Write the numeric property id directly into the path."
|
|
10930
10921
|
),
|
|
10931
10922
|
body: z25.record(z25.string(), z25.unknown()).optional().describe("POST request body (JSON)")
|
|
10932
10923
|
});
|
|
@@ -10945,7 +10936,7 @@ var requestTool4 = new ConnectorTool({
|
|
|
10945
10936
|
name: "request",
|
|
10946
10937
|
description: `Send authenticated requests to the Google Analytics Data API v1beta.
|
|
10947
10938
|
Authentication is handled automatically via OAuth proxy.
|
|
10948
|
-
|
|
10939
|
+
Write the numeric property id directly into the path (e.g. properties/123456789:runReport).`,
|
|
10949
10940
|
inputSchema: inputSchema25,
|
|
10950
10941
|
outputSchema: outputSchema25,
|
|
10951
10942
|
async execute({ connectionId, method, path: path5, body }, connections, config) {
|
|
@@ -10960,9 +10951,7 @@ Authentication is handled automatically via OAuth proxy.
|
|
|
10960
10951
|
`[connector-request] google-analytics-oauth/${connection.name}: ${method} ${path5}`
|
|
10961
10952
|
);
|
|
10962
10953
|
try {
|
|
10963
|
-
const
|
|
10964
|
-
const resolvedPath = propertyId ? path5.replace(/\{propertyId\}/g, propertyId) : path5;
|
|
10965
|
-
const url = `${BASE_URL4}${resolvedPath}`;
|
|
10954
|
+
const url = `${BASE_URL4}${path5}`;
|
|
10966
10955
|
const token = await getProxyToken8(config.oauthProxy);
|
|
10967
10956
|
const proxyUrl = `https://${config.oauthProxy.sandboxId}.${config.oauthProxy.previewBaseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
10968
10957
|
const controller = new AbortController();
|
|
@@ -11032,7 +11021,7 @@ var googleAnalyticsOauthConnector = new ConnectorPlugin({
|
|
|
11032
11021
|
systemPrompt: {
|
|
11033
11022
|
en: `### Tools
|
|
11034
11023
|
|
|
11035
|
-
- \`connector_google-analytics-oauth_request\`: Send authenticated requests to the GA4 Data API. Use it for running reports, getting metadata, and realtime reports.
|
|
11024
|
+
- \`connector_google-analytics-oauth_request\`: Send authenticated requests to the GA4 Data API. Use it for running reports, getting metadata, and realtime reports. Write the target property into the path as \`properties/{numericPropertyId}\`. Authentication is configured automatically via OAuth.
|
|
11036
11025
|
- \`connector_google-analytics-oauth_listAccounts\`: List accessible Google Analytics accounts. Use during setup to discover available accounts.
|
|
11037
11026
|
- \`connector_google-analytics-oauth_listProperties\`: List GA4 properties for a given account. Use during setup to select the target property.
|
|
11038
11027
|
|
|
@@ -11068,10 +11057,12 @@ averageSessionDuration, conversions, totalRevenue
|
|
|
11068
11057
|
The business logic type for this connector is "typescript". Write handler code using the connector SDK shown below. Do NOT access credentials directly from environment variables and do NOT read \`INTERNAL_SQUADBASE_*\` env vars \u2014 the SDK takes care of OAuth.
|
|
11069
11058
|
|
|
11070
11059
|
SDK surface (client created via \`connection(connectionId)\`):
|
|
11071
|
-
- \`client.request(
|
|
11072
|
-
- \`client.
|
|
11073
|
-
- \`client.
|
|
11074
|
-
- \`client.
|
|
11060
|
+
- \`client.runReport(request)\` \u2014 run a GA4 report and get back \`{ rows, rowCount }\` (JSON, already parsed). **This is the primary method \u2014 prefer it over \`request\`.** Pass \`propertyId\` (bare numeric id) on the request object to target a property.
|
|
11061
|
+
- \`client.runRealtimeReport(request)\` \u2014 run a realtime report. \`propertyId\` works the same as \`runReport\`.
|
|
11062
|
+
- \`client.getMetadata(propertyId)\` \u2014 fetch available dimensions and metrics for a property.
|
|
11063
|
+
- \`client.request(path, init?)\` \u2014 low-level authenticated fetch that returns a raw \`Response\` (\`path\` is appended to \`https://analyticsdata.googleapis.com/v1beta/\`; write the numeric property id directly into the path). Only use this for endpoints the convenience methods above do not cover, and remember to \`await res.json()\` yourself.
|
|
11064
|
+
|
|
11065
|
+
**\`propertyId\` is required on every call** \u2014 pass the numeric id from the data overview. A GA connection can span multiple properties, so there is no stored default.
|
|
11075
11066
|
|
|
11076
11067
|
If a handler test fails with \`Connection proxy is not configured\`, retry \u2014 the sandbox is still initializing. Do NOT abandon the SDK and construct OAuth proxy URLs manually.
|
|
11077
11068
|
|
|
@@ -11081,30 +11072,33 @@ If a handler test fails with \`Connection proxy is not configured\`, retry \u201
|
|
|
11081
11072
|
import { connection } from "@squadbase/vite-server/connectors/google-analytics-oauth";
|
|
11082
11073
|
|
|
11083
11074
|
const ga = connection("<connectionId>");
|
|
11075
|
+
const propertyId = "123456789"; // numeric GA4 property id from the data overview
|
|
11084
11076
|
|
|
11085
|
-
//
|
|
11086
|
-
const res = await ga.request("properties/{propertyId}:runReport", {
|
|
11087
|
-
method: "POST",
|
|
11088
|
-
body: JSON.stringify({ dateRanges: [{ startDate: "7daysAgo", endDate: "today" }], metrics: [{ name: "activeUsers" }] }),
|
|
11089
|
-
});
|
|
11090
|
-
const data = await res.json();
|
|
11091
|
-
|
|
11092
|
-
// Convenience methods
|
|
11077
|
+
// Convenience methods (pass propertyId explicitly)
|
|
11093
11078
|
const { rows, rowCount } = await ga.runReport({
|
|
11079
|
+
propertyId,
|
|
11094
11080
|
dateRanges: [{ startDate: "7daysAgo", endDate: "today" }],
|
|
11095
11081
|
dimensions: [{ name: "date" }],
|
|
11096
11082
|
metrics: [{ name: "activeUsers" }, { name: "sessions" }],
|
|
11097
11083
|
limit: 100,
|
|
11098
11084
|
});
|
|
11099
|
-
const metadata = await ga.getMetadata();
|
|
11085
|
+
const metadata = await ga.getMetadata(propertyId);
|
|
11100
11086
|
const realtime = await ga.runRealtimeReport({
|
|
11087
|
+
propertyId,
|
|
11101
11088
|
metrics: [{ name: "activeUsers" }],
|
|
11102
11089
|
dimensions: [{ name: "country" }],
|
|
11103
11090
|
});
|
|
11091
|
+
|
|
11092
|
+
// Low-level authenticated fetch (write the numeric property id into the path)
|
|
11093
|
+
const res = await ga.request(\`properties/\${propertyId}:runReport\`, {
|
|
11094
|
+
method: "POST",
|
|
11095
|
+
body: JSON.stringify({ dateRanges: [{ startDate: "7daysAgo", endDate: "today" }], metrics: [{ name: "activeUsers" }] }),
|
|
11096
|
+
});
|
|
11097
|
+
const data = await res.json();
|
|
11104
11098
|
\`\`\``,
|
|
11105
11099
|
ja: `### \u30C4\u30FC\u30EB
|
|
11106
11100
|
|
|
11107
|
-
- \`connector_google-analytics-oauth_request\`: GA4 Data API\u3078\u8A8D\u8A3C\u6E08\u307F\u30EA\u30AF\u30A8\u30B9\u30C8\u3092\u9001\u4FE1\u3057\u307E\u3059\u3002\u30EC\u30DD\u30FC\u30C8\u306E\u5B9F\u884C\u3001\u30E1\u30BF\u30C7\u30FC\u30BF\u306E\u53D6\u5F97\u3001\u30EA\u30A2\u30EB\u30BF\u30A4\u30E0\u30EC\u30DD\u30FC\u30C8\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002\u30D1\u30B9\
|
|
11101
|
+
- \`connector_google-analytics-oauth_request\`: GA4 Data API\u3078\u8A8D\u8A3C\u6E08\u307F\u30EA\u30AF\u30A8\u30B9\u30C8\u3092\u9001\u4FE1\u3057\u307E\u3059\u3002\u30EC\u30DD\u30FC\u30C8\u306E\u5B9F\u884C\u3001\u30E1\u30BF\u30C7\u30FC\u30BF\u306E\u53D6\u5F97\u3001\u30EA\u30A2\u30EB\u30BF\u30A4\u30E0\u30EC\u30DD\u30FC\u30C8\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002\u5BFE\u8C61\u30D7\u30ED\u30D1\u30C6\u30A3\u306F\u30D1\u30B9\u306B \`properties/{\u6570\u5024\u306E\u30D7\u30ED\u30D1\u30C6\u30A3ID}\` \u306E\u5F62\u3067\u76F4\u63A5\u8A18\u8FF0\u3057\u3066\u304F\u3060\u3055\u3044\u3002OAuth\u7D4C\u7531\u3067\u8A8D\u8A3C\u306F\u81EA\u52D5\u8A2D\u5B9A\u3055\u308C\u307E\u3059\u3002
|
|
11108
11102
|
- \`connector_google-analytics-oauth_listAccounts\`: \u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u306AGoogle Analytics\u30A2\u30AB\u30A6\u30F3\u30C8\u306E\u4E00\u89A7\u3092\u53D6\u5F97\u3057\u307E\u3059\u3002\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u6642\u306B\u5229\u7528\u53EF\u80FD\u306A\u30A2\u30AB\u30A6\u30F3\u30C8\u3092\u78BA\u8A8D\u3059\u308B\u305F\u3081\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002
|
|
11109
11103
|
- \`connector_google-analytics-oauth_listProperties\`: \u6307\u5B9A\u30A2\u30AB\u30A6\u30F3\u30C8\u306EGA4\u30D7\u30ED\u30D1\u30C6\u30A3\u4E00\u89A7\u3092\u53D6\u5F97\u3057\u307E\u3059\u3002\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u6642\u306B\u30BF\u30FC\u30B2\u30C3\u30C8\u30D7\u30ED\u30D1\u30C6\u30A3\u3092\u9078\u629E\u3059\u308B\u305F\u3081\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002
|
|
11110
11104
|
|
|
@@ -11140,10 +11134,12 @@ averageSessionDuration, conversions, totalRevenue
|
|
|
11140
11134
|
\u3053\u306E\u30B3\u30CD\u30AF\u30BF\u306E\u30D3\u30B8\u30CD\u30B9\u30ED\u30B8\u30C3\u30AF\u30BF\u30A4\u30D7\u306F "typescript" \u3067\u3059\u3002\u4EE5\u4E0B\u306B\u793A\u3059\u30B3\u30CD\u30AF\u30BF SDK \u3092\u4F7F\u7528\u3057\u3066\u30CF\u30F3\u30C9\u30E9\u30B3\u30FC\u30C9\u3092\u8A18\u8FF0\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u74B0\u5883\u5909\u6570\u304B\u3089\u76F4\u63A5\u8A8D\u8A3C\u60C5\u5831\u306B\u30A2\u30AF\u30BB\u30B9\u3057\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002\`INTERNAL_SQUADBASE_*\` \u306E\u74B0\u5883\u5909\u6570\u3092\u4F7F\u3063\u3066\u624B\u52D5\u3067 OAuth \u30D7\u30ED\u30AD\u30B7\u3092\u53E9\u304F\u3053\u3068\u3082\u3057\u306A\u3044\u3067\u304F\u3060\u3055\u3044 \u2014 SDK \u304C OAuth \u3092\u51E6\u7406\u3057\u307E\u3059\u3002
|
|
11141
11135
|
|
|
11142
11136
|
SDK\uFF08\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8\uFF09:
|
|
11143
|
-
- \`client.request
|
|
11144
|
-
- \`client.
|
|
11145
|
-
- \`client.
|
|
11146
|
-
- \`client.
|
|
11137
|
+
- \`client.runReport(request)\` \u2014 GA4 \u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C\u3057\u3001\`{ rows, rowCount }\`\uFF08\u30D1\u30FC\u30B9\u6E08\u307F JSON\uFF09\u3092\u8FD4\u3057\u307E\u3059\u3002**\u3053\u308C\u304C\u4E3B\u8981\u30E1\u30BD\u30C3\u30C9\u3067\u3059 \u2014 \`request\` \u3088\u308A\u512A\u5148\u3057\u3066\u4F7F\u3063\u3066\u304F\u3060\u3055\u3044\u3002** \u30EA\u30AF\u30A8\u30B9\u30C8\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u306B \`propertyId\`\uFF08\u6570\u5024\u306E\u30D7\u30ED\u30D1\u30C6\u30A3ID\uFF09\u3092\u6307\u5B9A\u3057\u3066\u5BFE\u8C61\u30D7\u30ED\u30D1\u30C6\u30A3\u3092\u6C7A\u3081\u307E\u3059\u3002
|
|
11138
|
+
- \`client.runRealtimeReport(request)\` \u2014 \u30EA\u30A2\u30EB\u30BF\u30A4\u30E0\u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C\u3002\`propertyId\` \u306E\u6271\u3044\u306F \`runReport\` \u3068\u540C\u3058\u3067\u3059\u3002
|
|
11139
|
+
- \`client.getMetadata(propertyId)\` \u2014 \u6307\u5B9A\u30D7\u30ED\u30D1\u30C6\u30A3\u306E\u5229\u7528\u53EF\u80FD\u306A\u30C7\u30A3\u30E1\u30F3\u30B7\u30E7\u30F3\u3068\u30E1\u30C8\u30EA\u30AF\u30B9\u3092\u53D6\u5F97\u3002
|
|
11140
|
+
- \`client.request(path, init?)\` \u2014 \u4F4E\u30EC\u30D9\u30EB\u306E\u8A8D\u8A3C\u4ED8\u304D fetch\u3002\u751F\u306E \`Response\` \u3092\u8FD4\u3057\u307E\u3059\uFF08\`path\` \u306F \`https://analyticsdata.googleapis.com/v1beta/\` \u306B\u8FFD\u52A0\u3055\u308C\u307E\u3059\u3002\u6570\u5024\u306E\u30D7\u30ED\u30D1\u30C6\u30A3ID\u3092\u30D1\u30B9\u306B\u76F4\u63A5\u66F8\u3044\u3066\u304F\u3060\u3055\u3044\uFF09\u3002\u4E0A\u8A18\u306E\u4FBF\u5229\u30E1\u30BD\u30C3\u30C9\u3067\u8CC4\u3048\u306A\u3044\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8\u306E\u5834\u5408\u306E\u307F\u4F7F\u7528\u3057\u3001\`await res.json()\` \u306F\u81EA\u5206\u3067\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002
|
|
11141
|
+
|
|
11142
|
+
**\`propertyId\` \u306F\u3059\u3079\u3066\u306E\u547C\u3073\u51FA\u3057\u3067\u5FC5\u9808\u3067\u3059**\uFF08\u30C7\u30FC\u30BF\u6982\u8981\u306B\u8F09\u3063\u3066\u3044\u308B\u6570\u5024ID\uFF09\u3002GA \u306E\u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u306F\u8907\u6570\u30D7\u30ED\u30D1\u30C6\u30A3\u306B\u307E\u305F\u304C\u308B\u3053\u3068\u304C\u3042\u308B\u305F\u3081\u3001\u30C7\u30D5\u30A9\u30EB\u30C8\u306F\u4FDD\u5B58\u3055\u308C\u307E\u305B\u3093\u3002
|
|
11147
11143
|
|
|
11148
11144
|
\u30CF\u30F3\u30C9\u30E9\u306E\u30C6\u30B9\u30C8\u304C \`Connection proxy is not configured\` \u3067\u5931\u6557\u3059\u308B\u5834\u5408\u306F\u518D\u8A66\u884C\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u901A\u5E38\u306F\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306E\u521D\u671F\u5316\u4E2D\u306B\u8D77\u304D\u307E\u3059\u3002SDK \u3092\u8AE6\u3081\u3066 OAuth \u30D7\u30ED\u30AD\u30B7\u306E URL \u3092\u81EA\u5206\u3067\u7D44\u307F\u7ACB\u3066\u308B\u3053\u3068\u306F **\u3057\u306A\u3044\u3067\u304F\u3060\u3055\u3044**\u3002
|
|
11149
11145
|
|
|
@@ -11153,37 +11149,36 @@ SDK\uFF08\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9
|
|
|
11153
11149
|
import { connection } from "@squadbase/vite-server/connectors/google-analytics-oauth";
|
|
11154
11150
|
|
|
11155
11151
|
const ga = connection("<connectionId>");
|
|
11152
|
+
const propertyId = "123456789"; // \u30C7\u30FC\u30BF\u6982\u8981\u306B\u8F09\u3063\u3066\u3044\u308B\u6570\u5024\u306E GA4 \u30D7\u30ED\u30D1\u30C6\u30A3ID
|
|
11156
11153
|
|
|
11157
|
-
//
|
|
11158
|
-
const res = await ga.request("properties/{propertyId}:runReport", {
|
|
11159
|
-
method: "POST",
|
|
11160
|
-
body: JSON.stringify({ dateRanges: [{ startDate: "7daysAgo", endDate: "today" }], metrics: [{ name: "activeUsers" }] }),
|
|
11161
|
-
});
|
|
11162
|
-
const data = await res.json();
|
|
11163
|
-
|
|
11164
|
-
// Convenience methods
|
|
11154
|
+
// \u4FBF\u5229\u30E1\u30BD\u30C3\u30C9\uFF08propertyId \u3092\u660E\u793A\u7684\u306B\u6E21\u3059\uFF09
|
|
11165
11155
|
const { rows, rowCount } = await ga.runReport({
|
|
11156
|
+
propertyId,
|
|
11166
11157
|
dateRanges: [{ startDate: "7daysAgo", endDate: "today" }],
|
|
11167
11158
|
dimensions: [{ name: "date" }],
|
|
11168
11159
|
metrics: [{ name: "activeUsers" }, { name: "sessions" }],
|
|
11169
11160
|
limit: 100,
|
|
11170
11161
|
});
|
|
11171
|
-
const metadata = await ga.getMetadata();
|
|
11162
|
+
const metadata = await ga.getMetadata(propertyId);
|
|
11172
11163
|
const realtime = await ga.runRealtimeReport({
|
|
11164
|
+
propertyId,
|
|
11173
11165
|
metrics: [{ name: "activeUsers" }],
|
|
11174
11166
|
dimensions: [{ name: "country" }],
|
|
11175
11167
|
});
|
|
11168
|
+
|
|
11169
|
+
// \u4F4E\u30EC\u30D9\u30EB\u306E\u8A8D\u8A3C\u4ED8\u304D fetch\uFF08\u6570\u5024\u306E\u30D7\u30ED\u30D1\u30C6\u30A3ID\u3092\u30D1\u30B9\u306B\u76F4\u63A5\u66F8\u304F\uFF09
|
|
11170
|
+
const res = await ga.request(\`properties/\${propertyId}:runReport\`, {
|
|
11171
|
+
method: "POST",
|
|
11172
|
+
body: JSON.stringify({ dateRanges: [{ startDate: "7daysAgo", endDate: "today" }], metrics: [{ name: "activeUsers" }] }),
|
|
11173
|
+
});
|
|
11174
|
+
const data = await res.json();
|
|
11176
11175
|
\`\`\``
|
|
11177
11176
|
},
|
|
11178
11177
|
tools: tools16,
|
|
11179
11178
|
setup: (params, ctx, config) => runSetupFlow(googleAnalyticsOauthSetupFlow, params, ctx, config),
|
|
11180
|
-
async checkConnection(
|
|
11179
|
+
async checkConnection(_params, config) {
|
|
11181
11180
|
const { proxyFetch } = config;
|
|
11182
|
-
const
|
|
11183
|
-
if (!propertyId) {
|
|
11184
|
-
return { success: true };
|
|
11185
|
-
}
|
|
11186
|
-
const url = `https://analyticsdata.googleapis.com/v1beta/properties/${propertyId}/metadata`;
|
|
11181
|
+
const url = "https://analyticsadmin.googleapis.com/v1beta/accountSummaries";
|
|
11187
11182
|
try {
|
|
11188
11183
|
const res = await proxyFetch(url, { method: "GET" });
|
|
11189
11184
|
if (!res.ok) {
|