@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
|
@@ -1,100 +1,21 @@
|
|
|
1
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
|
-
var __esm = (fn, res, err) => function __init() {
|
|
3
|
-
if (err) throw err[0];
|
|
4
|
-
try {
|
|
5
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
6
|
-
} catch (e) {
|
|
7
|
-
throw err = [e], e;
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
// ../connectors/src/parameter-definition.ts
|
|
12
|
-
var ParameterDefinition;
|
|
13
|
-
var init_parameter_definition = __esm({
|
|
14
|
-
"../connectors/src/parameter-definition.ts"() {
|
|
15
|
-
"use strict";
|
|
16
|
-
ParameterDefinition = class {
|
|
17
|
-
slug;
|
|
18
|
-
name;
|
|
19
|
-
description;
|
|
20
|
-
envVarBaseKey;
|
|
21
|
-
type;
|
|
22
|
-
secret;
|
|
23
|
-
required;
|
|
24
|
-
isDeprecated;
|
|
25
|
-
constructor(config) {
|
|
26
|
-
this.slug = config.slug;
|
|
27
|
-
this.name = config.name;
|
|
28
|
-
this.description = config.description;
|
|
29
|
-
this.envVarBaseKey = config.envVarBaseKey;
|
|
30
|
-
this.type = config.type;
|
|
31
|
-
this.secret = config.secret;
|
|
32
|
-
this.required = config.required;
|
|
33
|
-
this.isDeprecated = config.isDeprecated ?? false;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Get the parameter value from a ConnectorConnectionObject.
|
|
37
|
-
*/
|
|
38
|
-
getValue(connection2) {
|
|
39
|
-
const param = connection2.parameters.find(
|
|
40
|
-
(p) => p.parameterSlug === this.slug
|
|
41
|
-
);
|
|
42
|
-
if (!param || param.value == null) {
|
|
43
|
-
throw new Error(
|
|
44
|
-
`Parameter "${this.slug}" not found or has no value in connection "${connection2.id}"`
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
return param.value;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Try to get the parameter value. Returns undefined if not found (for optional params).
|
|
51
|
-
*/
|
|
52
|
-
tryGetValue(connection2) {
|
|
53
|
-
const param = connection2.parameters.find(
|
|
54
|
-
(p) => p.parameterSlug === this.slug
|
|
55
|
-
);
|
|
56
|
-
if (!param || param.value == null) return void 0;
|
|
57
|
-
return param.value;
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
// ../connectors/src/connectors/google-analytics-oauth/parameters.ts
|
|
64
|
-
init_parameter_definition();
|
|
65
|
-
var parameters = {
|
|
66
|
-
propertyId: new ParameterDefinition({
|
|
67
|
-
slug: "property-id",
|
|
68
|
-
name: "Google Analytics Property ID",
|
|
69
|
-
description: "The Google Analytics 4 property ID (e.g., 123456789). Can be found in GA4 Admin > Property Settings.",
|
|
70
|
-
envVarBaseKey: "GA_OAUTH_PROPERTY_ID",
|
|
71
|
-
type: "text",
|
|
72
|
-
secret: false,
|
|
73
|
-
required: false
|
|
74
|
-
})
|
|
75
|
-
};
|
|
76
|
-
|
|
77
1
|
// ../connectors/src/connectors/google-analytics-oauth/sdk/index.ts
|
|
78
2
|
var BASE_URL = "https://analyticsdata.googleapis.com/v1beta/";
|
|
79
|
-
function createClient(
|
|
80
|
-
|
|
81
|
-
function resolvePropertyId() {
|
|
3
|
+
function createClient(_params, fetchFn) {
|
|
4
|
+
function resolvePropertyId(propertyId) {
|
|
82
5
|
if (!propertyId) {
|
|
83
6
|
throw new Error(
|
|
84
|
-
"google-analytics-oauth: propertyId is required.
|
|
7
|
+
"google-analytics-oauth: propertyId is required. Pass the numeric GA4 property id explicitly."
|
|
85
8
|
);
|
|
86
9
|
}
|
|
87
10
|
return propertyId;
|
|
88
11
|
}
|
|
89
12
|
return {
|
|
90
13
|
async request(path2, init) {
|
|
91
|
-
const
|
|
92
|
-
const resolvedPath = pid ? path2.replace(/\{propertyId\}/g, pid) : path2;
|
|
93
|
-
const url = `${BASE_URL.replace(/\/+$/, "")}/${resolvedPath.replace(/^\/+/, "")}`;
|
|
14
|
+
const url = `${BASE_URL.replace(/\/+$/, "")}/${path2.replace(/^\/+/, "")}`;
|
|
94
15
|
return fetchFn(url, init);
|
|
95
16
|
},
|
|
96
|
-
async runReport(request) {
|
|
97
|
-
const pid = resolvePropertyId();
|
|
17
|
+
async runReport({ propertyId, ...request }) {
|
|
18
|
+
const pid = resolvePropertyId(propertyId);
|
|
98
19
|
const response = await this.request(
|
|
99
20
|
`properties/${pid}:runReport`,
|
|
100
21
|
{
|
|
@@ -115,8 +36,8 @@ function createClient(params, fetchFn) {
|
|
|
115
36
|
rowCount: data.rowCount ?? 0
|
|
116
37
|
};
|
|
117
38
|
},
|
|
118
|
-
async getMetadata() {
|
|
119
|
-
const pid = resolvePropertyId();
|
|
39
|
+
async getMetadata(propertyId) {
|
|
40
|
+
const pid = resolvePropertyId(propertyId);
|
|
120
41
|
const response = await this.request(
|
|
121
42
|
`properties/${pid}/metadata`,
|
|
122
43
|
{ method: "GET" }
|
|
@@ -129,8 +50,8 @@ function createClient(params, fetchFn) {
|
|
|
129
50
|
}
|
|
130
51
|
return await response.json();
|
|
131
52
|
},
|
|
132
|
-
async runRealtimeReport(request) {
|
|
133
|
-
const pid = resolvePropertyId();
|
|
53
|
+
async runRealtimeReport({ propertyId, ...request }) {
|
|
54
|
+
const pid = resolvePropertyId(propertyId);
|
|
134
55
|
const response = await this.request(
|
|
135
56
|
`properties/${pid}:runRealtimeReport`,
|
|
136
57
|
{
|
|
@@ -659,11 +580,11 @@ var googleAnalyticsOauthOnboarding = new ConnectorOnboarding({
|
|
|
659
580
|
- \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
|
|
660
581
|
- \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
|
|
661
582
|
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
|
|
662
|
-
4.
|
|
663
|
-
- \`
|
|
664
|
-
-
|
|
665
|
-
- \u30D7\u30ED\u30D1\u30C6\u30A3\u304C **0\u4EF6
|
|
666
|
-
5. \
|
|
583
|
+
4. \u30D7\u30ED\u30D1\u30C6\u30A3\u306E\u9078\u629E:
|
|
584
|
+
- \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
|
|
585
|
+
- \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
|
|
586
|
+
- \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
|
|
587
|
+
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
|
|
667
588
|
|
|
668
589
|
#### \u5236\u7D04
|
|
669
590
|
- **\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
|
|
@@ -677,11 +598,11 @@ var googleAnalyticsOauthOnboarding = new ConnectorOnboarding({
|
|
|
677
598
|
- **Only 1 account**: Skip \`askUserQuestion\` and proceed using that account as the selection
|
|
678
599
|
- **0 accounts**: Abort setup and inform the user that no accessible accounts are available
|
|
679
600
|
3. Call \`${listPropertiesToolName}\` to get the list of properties for the selected account
|
|
680
|
-
4.
|
|
681
|
-
- \`
|
|
682
|
-
-
|
|
683
|
-
-
|
|
684
|
-
5.
|
|
601
|
+
4. Select a property:
|
|
602
|
+
- **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)
|
|
603
|
+
- **Only 1 property**: Skip \`askUserQuestion\` and proceed using that property as the selection
|
|
604
|
+
- **0 properties**: Abort setup and inform the user that no accessible properties are available
|
|
605
|
+
5. Write the selected numeric property id directly into the request path (it is not stored on the connection). Proceed to the next step
|
|
685
606
|
|
|
686
607
|
#### Constraints
|
|
687
608
|
- **Do NOT fetch report data during setup**. Only the metadata requests specified in the steps above are allowed
|
|
@@ -689,13 +610,18 @@ var googleAnalyticsOauthOnboarding = new ConnectorOnboarding({
|
|
|
689
610
|
- Write only 1 sentence between tool calls, then immediately call the next tool. Skip unnecessary explanations and proceed efficiently`
|
|
690
611
|
},
|
|
691
612
|
dataOverviewInstructions: {
|
|
692
|
-
en: `
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
613
|
+
en: `Use the selected numeric property id in the path (write it directly, e.g. properties/123456789).
|
|
614
|
+
1. Call connector_google-analytics-oauth_request with GET properties/<propertyId>/metadata to list available dimensions and metrics
|
|
615
|
+
2. Call connector_google-analytics-oauth_request with POST properties/<propertyId>:runReport using a small date range and basic metrics to verify data availability`,
|
|
616
|
+
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
|
|
617
|
+
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
|
|
618
|
+
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`
|
|
696
619
|
}
|
|
697
620
|
});
|
|
698
621
|
|
|
622
|
+
// ../connectors/src/connectors/google-analytics-oauth/parameters.ts
|
|
623
|
+
var parameters = {};
|
|
624
|
+
|
|
699
625
|
// ../connectors/src/connectors/google-analytics-oauth/setup-flow.ts
|
|
700
626
|
var ADMIN_BASE_URL3 = "https://analyticsadmin.googleapis.com/v1beta";
|
|
701
627
|
var DATA_BASE_URL = "https://analyticsdata.googleapis.com/v1beta";
|
|
@@ -1001,7 +927,7 @@ var inputSchema3 = z3.object({
|
|
|
1001
927
|
connectionId: z3.string().describe("ID of the Google Analytics OAuth connection to use"),
|
|
1002
928
|
method: z3.enum(["GET", "POST"]).describe("HTTP method"),
|
|
1003
929
|
path: z3.string().describe(
|
|
1004
|
-
"API path appended to https://analyticsdata.googleapis.com/v1beta/ (e.g., 'properties/
|
|
930
|
+
"API path appended to https://analyticsdata.googleapis.com/v1beta/ (e.g., 'properties/123456789:runReport'). Write the numeric property id directly into the path."
|
|
1005
931
|
),
|
|
1006
932
|
body: z3.record(z3.string(), z3.unknown()).optional().describe("POST request body (JSON)")
|
|
1007
933
|
});
|
|
@@ -1020,7 +946,7 @@ var requestTool = new ConnectorTool({
|
|
|
1020
946
|
name: "request",
|
|
1021
947
|
description: `Send authenticated requests to the Google Analytics Data API v1beta.
|
|
1022
948
|
Authentication is handled automatically via OAuth proxy.
|
|
1023
|
-
|
|
949
|
+
Write the numeric property id directly into the path (e.g. properties/123456789:runReport).`,
|
|
1024
950
|
inputSchema: inputSchema3,
|
|
1025
951
|
outputSchema: outputSchema3,
|
|
1026
952
|
async execute({ connectionId, method, path: path2, body }, connections, config) {
|
|
@@ -1035,9 +961,7 @@ Authentication is handled automatically via OAuth proxy.
|
|
|
1035
961
|
`[connector-request] google-analytics-oauth/${connection2.name}: ${method} ${path2}`
|
|
1036
962
|
);
|
|
1037
963
|
try {
|
|
1038
|
-
const
|
|
1039
|
-
const resolvedPath = propertyId ? path2.replace(/\{propertyId\}/g, propertyId) : path2;
|
|
1040
|
-
const url = `${BASE_URL2}${resolvedPath}`;
|
|
964
|
+
const url = `${BASE_URL2}${path2}`;
|
|
1041
965
|
const token = await getProxyToken3(config.oauthProxy);
|
|
1042
966
|
const proxyUrl = `https://${config.oauthProxy.sandboxId}.${config.oauthProxy.previewBaseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
1043
967
|
const controller = new AbortController();
|
|
@@ -1107,7 +1031,7 @@ var googleAnalyticsOauthConnector = new ConnectorPlugin({
|
|
|
1107
1031
|
systemPrompt: {
|
|
1108
1032
|
en: `### Tools
|
|
1109
1033
|
|
|
1110
|
-
- \`connector_google-analytics-oauth_request\`: Send authenticated requests to the GA4 Data API. Use it for running reports, getting metadata, and realtime reports.
|
|
1034
|
+
- \`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.
|
|
1111
1035
|
- \`connector_google-analytics-oauth_listAccounts\`: List accessible Google Analytics accounts. Use during setup to discover available accounts.
|
|
1112
1036
|
- \`connector_google-analytics-oauth_listProperties\`: List GA4 properties for a given account. Use during setup to select the target property.
|
|
1113
1037
|
|
|
@@ -1143,10 +1067,12 @@ averageSessionDuration, conversions, totalRevenue
|
|
|
1143
1067
|
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.
|
|
1144
1068
|
|
|
1145
1069
|
SDK surface (client created via \`connection(connectionId)\`):
|
|
1146
|
-
- \`client.request(
|
|
1147
|
-
- \`client.
|
|
1148
|
-
- \`client.
|
|
1149
|
-
- \`client.
|
|
1070
|
+
- \`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.
|
|
1071
|
+
- \`client.runRealtimeReport(request)\` \u2014 run a realtime report. \`propertyId\` works the same as \`runReport\`.
|
|
1072
|
+
- \`client.getMetadata(propertyId)\` \u2014 fetch available dimensions and metrics for a property.
|
|
1073
|
+
- \`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.
|
|
1074
|
+
|
|
1075
|
+
**\`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.
|
|
1150
1076
|
|
|
1151
1077
|
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.
|
|
1152
1078
|
|
|
@@ -1156,30 +1082,33 @@ If a handler test fails with \`Connection proxy is not configured\`, retry \u201
|
|
|
1156
1082
|
import { connection } from "@squadbase/vite-server/connectors/google-analytics-oauth";
|
|
1157
1083
|
|
|
1158
1084
|
const ga = connection("<connectionId>");
|
|
1085
|
+
const propertyId = "123456789"; // numeric GA4 property id from the data overview
|
|
1159
1086
|
|
|
1160
|
-
//
|
|
1161
|
-
const res = await ga.request("properties/{propertyId}:runReport", {
|
|
1162
|
-
method: "POST",
|
|
1163
|
-
body: JSON.stringify({ dateRanges: [{ startDate: "7daysAgo", endDate: "today" }], metrics: [{ name: "activeUsers" }] }),
|
|
1164
|
-
});
|
|
1165
|
-
const data = await res.json();
|
|
1166
|
-
|
|
1167
|
-
// Convenience methods
|
|
1087
|
+
// Convenience methods (pass propertyId explicitly)
|
|
1168
1088
|
const { rows, rowCount } = await ga.runReport({
|
|
1089
|
+
propertyId,
|
|
1169
1090
|
dateRanges: [{ startDate: "7daysAgo", endDate: "today" }],
|
|
1170
1091
|
dimensions: [{ name: "date" }],
|
|
1171
1092
|
metrics: [{ name: "activeUsers" }, { name: "sessions" }],
|
|
1172
1093
|
limit: 100,
|
|
1173
1094
|
});
|
|
1174
|
-
const metadata = await ga.getMetadata();
|
|
1095
|
+
const metadata = await ga.getMetadata(propertyId);
|
|
1175
1096
|
const realtime = await ga.runRealtimeReport({
|
|
1097
|
+
propertyId,
|
|
1176
1098
|
metrics: [{ name: "activeUsers" }],
|
|
1177
1099
|
dimensions: [{ name: "country" }],
|
|
1178
1100
|
});
|
|
1101
|
+
|
|
1102
|
+
// Low-level authenticated fetch (write the numeric property id into the path)
|
|
1103
|
+
const res = await ga.request(\`properties/\${propertyId}:runReport\`, {
|
|
1104
|
+
method: "POST",
|
|
1105
|
+
body: JSON.stringify({ dateRanges: [{ startDate: "7daysAgo", endDate: "today" }], metrics: [{ name: "activeUsers" }] }),
|
|
1106
|
+
});
|
|
1107
|
+
const data = await res.json();
|
|
1179
1108
|
\`\`\``,
|
|
1180
1109
|
ja: `### \u30C4\u30FC\u30EB
|
|
1181
1110
|
|
|
1182
|
-
- \`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\
|
|
1111
|
+
- \`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
|
|
1183
1112
|
- \`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
|
|
1184
1113
|
- \`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
|
|
1185
1114
|
|
|
@@ -1215,10 +1144,12 @@ averageSessionDuration, conversions, totalRevenue
|
|
|
1215
1144
|
\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
|
|
1216
1145
|
|
|
1217
1146
|
SDK\uFF08\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8\uFF09:
|
|
1218
|
-
- \`client.request
|
|
1219
|
-
- \`client.
|
|
1220
|
-
- \`client.
|
|
1221
|
-
- \`client.
|
|
1147
|
+
- \`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
|
|
1148
|
+
- \`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
|
|
1149
|
+
- \`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
|
|
1150
|
+
- \`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
|
|
1151
|
+
|
|
1152
|
+
**\`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
|
|
1222
1153
|
|
|
1223
1154
|
\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
|
|
1224
1155
|
|
|
@@ -1228,37 +1159,36 @@ SDK\uFF08\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9
|
|
|
1228
1159
|
import { connection } from "@squadbase/vite-server/connectors/google-analytics-oauth";
|
|
1229
1160
|
|
|
1230
1161
|
const ga = connection("<connectionId>");
|
|
1162
|
+
const propertyId = "123456789"; // \u30C7\u30FC\u30BF\u6982\u8981\u306B\u8F09\u3063\u3066\u3044\u308B\u6570\u5024\u306E GA4 \u30D7\u30ED\u30D1\u30C6\u30A3ID
|
|
1231
1163
|
|
|
1232
|
-
//
|
|
1233
|
-
const res = await ga.request("properties/{propertyId}:runReport", {
|
|
1234
|
-
method: "POST",
|
|
1235
|
-
body: JSON.stringify({ dateRanges: [{ startDate: "7daysAgo", endDate: "today" }], metrics: [{ name: "activeUsers" }] }),
|
|
1236
|
-
});
|
|
1237
|
-
const data = await res.json();
|
|
1238
|
-
|
|
1239
|
-
// Convenience methods
|
|
1164
|
+
// \u4FBF\u5229\u30E1\u30BD\u30C3\u30C9\uFF08propertyId \u3092\u660E\u793A\u7684\u306B\u6E21\u3059\uFF09
|
|
1240
1165
|
const { rows, rowCount } = await ga.runReport({
|
|
1166
|
+
propertyId,
|
|
1241
1167
|
dateRanges: [{ startDate: "7daysAgo", endDate: "today" }],
|
|
1242
1168
|
dimensions: [{ name: "date" }],
|
|
1243
1169
|
metrics: [{ name: "activeUsers" }, { name: "sessions" }],
|
|
1244
1170
|
limit: 100,
|
|
1245
1171
|
});
|
|
1246
|
-
const metadata = await ga.getMetadata();
|
|
1172
|
+
const metadata = await ga.getMetadata(propertyId);
|
|
1247
1173
|
const realtime = await ga.runRealtimeReport({
|
|
1174
|
+
propertyId,
|
|
1248
1175
|
metrics: [{ name: "activeUsers" }],
|
|
1249
1176
|
dimensions: [{ name: "country" }],
|
|
1250
1177
|
});
|
|
1178
|
+
|
|
1179
|
+
// \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
|
|
1180
|
+
const res = await ga.request(\`properties/\${propertyId}:runReport\`, {
|
|
1181
|
+
method: "POST",
|
|
1182
|
+
body: JSON.stringify({ dateRanges: [{ startDate: "7daysAgo", endDate: "today" }], metrics: [{ name: "activeUsers" }] }),
|
|
1183
|
+
});
|
|
1184
|
+
const data = await res.json();
|
|
1251
1185
|
\`\`\``
|
|
1252
1186
|
},
|
|
1253
1187
|
tools,
|
|
1254
1188
|
setup: (params, ctx, config) => runSetupFlow(googleAnalyticsOauthSetupFlow, params, ctx, config),
|
|
1255
|
-
async checkConnection(
|
|
1189
|
+
async checkConnection(_params, config) {
|
|
1256
1190
|
const { proxyFetch } = config;
|
|
1257
|
-
const
|
|
1258
|
-
if (!propertyId) {
|
|
1259
|
-
return { success: true };
|
|
1260
|
-
}
|
|
1261
|
-
const url = `https://analyticsdata.googleapis.com/v1beta/properties/${propertyId}/metadata`;
|
|
1191
|
+
const url = "https://analyticsadmin.googleapis.com/v1beta/accountSummaries";
|
|
1262
1192
|
try {
|
|
1263
1193
|
const res = await proxyFetch(url, { method: "GET" });
|
|
1264
1194
|
if (!res.ok) {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import * as hono_types from 'hono/types';
|
|
2
|
+
import * as hono from 'hono';
|
|
2
3
|
import { Hono } from 'hono';
|
|
3
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Called once at startup by the build-generated server entry with the map of
|
|
7
|
+
* bundled TypeScript handlers. See `vite-plugin.ts`.
|
|
8
|
+
*/
|
|
9
|
+
declare function registerBundledHandlers(handlers: Record<string, (c: hono.Context) => Promise<unknown>>): void;
|
|
10
|
+
|
|
4
11
|
interface ConnectionEntry {
|
|
5
12
|
connector: {
|
|
6
13
|
slug: string;
|
|
@@ -283,4 +290,4 @@ declare const storage: {
|
|
|
283
290
|
|
|
284
291
|
declare const app: Hono<hono_types.BlankEnv, hono_types.BlankSchema, "/">;
|
|
285
292
|
|
|
286
|
-
export { type AirtableClient, type AirtableRecord, type ConnectionEntry, type ConnectionFetchOptions, type ConnectionsMap, type DbtClient, type GoogleAnalyticsClient, type KintoneClient, type PresignedGetResult, PresignedHttpsTransport, type PresignedPutResult, type QueryFn, type GetResult as StorageGetResult, type StorageListItem, type ListOptions as StorageListOptions, type StorageListResult, type StorageMetadata, type PutOptions as StoragePutOptions, type StorageTransport, StorageUploadsClient, type StorageUsageDelta, type WixStoreClient, connection, createAirtableClient, createDbtClient, createGoogleAnalyticsClient, createKintoneClient, createWixStoreClient, app as default, getQuery, loadConnections, storage };
|
|
293
|
+
export { type AirtableClient, type AirtableRecord, type ConnectionEntry, type ConnectionFetchOptions, type ConnectionsMap, type DbtClient, type GoogleAnalyticsClient, type KintoneClient, type PresignedGetResult, PresignedHttpsTransport, type PresignedPutResult, type QueryFn, type GetResult as StorageGetResult, type StorageListItem, type ListOptions as StorageListOptions, type StorageListResult, type StorageMetadata, type PutOptions as StoragePutOptions, type StorageTransport, StorageUploadsClient, type StorageUsageDelta, type WixStoreClient, connection, createAirtableClient, createDbtClient, createGoogleAnalyticsClient, createKintoneClient, createWixStoreClient, app as default, getQuery, loadConnections, registerBundledHandlers, storage };
|