@walkeros/server-destination-datamanager 0.4.0 → 0.4.1
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/README.md +186 -41
- package/dist/dev.d.mts +105 -35
- package/dist/dev.d.ts +105 -35
- package/dist/dev.js +1 -1
- package/dist/dev.js.map +1 -1
- package/dist/dev.mjs +1 -1
- package/dist/dev.mjs.map +1 -1
- package/dist/examples/index.d.mts +104 -35
- package/dist/examples/index.d.ts +104 -35
- package/dist/examples/index.js +182 -88
- package/dist/examples/index.mjs +181 -88
- package/dist/index.d.mts +115 -29
- package/dist/index.d.ts +115 -29
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ npm install @walkeros/server-destination-datamanager
|
|
|
23
23
|
|
|
24
24
|
## Quick Start
|
|
25
25
|
|
|
26
|
-
### Minimal Configuration
|
|
26
|
+
### Minimal Configuration (AWS Lambda / Serverless)
|
|
27
27
|
|
|
28
28
|
```typescript
|
|
29
29
|
import { destinationDataManager } from '@walkeros/server-destination-datamanager';
|
|
@@ -35,8 +35,11 @@ const { collector, elb } = await startFlow({
|
|
|
35
35
|
...destinationDataManager,
|
|
36
36
|
config: {
|
|
37
37
|
settings: {
|
|
38
|
-
//
|
|
39
|
-
|
|
38
|
+
// Service account credentials from environment variables
|
|
39
|
+
credentials: {
|
|
40
|
+
client_email: process.env.GOOGLE_CLIENT_EMAIL!,
|
|
41
|
+
private_key: process.env.GOOGLE_PRIVATE_KEY!.replace(/\\n/g, '\n'),
|
|
42
|
+
},
|
|
40
43
|
|
|
41
44
|
// Destination accounts
|
|
42
45
|
destinations: [
|
|
@@ -62,7 +65,36 @@ await elb('order complete', {
|
|
|
62
65
|
});
|
|
63
66
|
```
|
|
64
67
|
|
|
65
|
-
###
|
|
68
|
+
### GCP Cloud Functions (Application Default Credentials)
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
import { destinationDataManager } from '@walkeros/server-destination-datamanager';
|
|
72
|
+
import { startFlow } from '@walkeros/collector';
|
|
73
|
+
|
|
74
|
+
// No auth config needed - ADC works automatically on GCP!
|
|
75
|
+
const { collector, elb } = await startFlow({
|
|
76
|
+
destinations: {
|
|
77
|
+
datamanager: {
|
|
78
|
+
...destinationDataManager,
|
|
79
|
+
config: {
|
|
80
|
+
settings: {
|
|
81
|
+
destinations: [
|
|
82
|
+
{
|
|
83
|
+
operatingAccount: {
|
|
84
|
+
accountId: '123-456-7890',
|
|
85
|
+
accountType: 'GOOGLE_ADS',
|
|
86
|
+
},
|
|
87
|
+
productDestinationId: 'AW-CONVERSION-123',
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Local Development
|
|
66
98
|
|
|
67
99
|
```typescript
|
|
68
100
|
import { destinationDataManager } from '@walkeros/server-destination-datamanager';
|
|
@@ -71,7 +103,8 @@ const config = {
|
|
|
71
103
|
...destinationDataManager,
|
|
72
104
|
config: {
|
|
73
105
|
settings: {
|
|
74
|
-
|
|
106
|
+
// Service account JSON file
|
|
107
|
+
keyFilename: './service-account.json',
|
|
75
108
|
|
|
76
109
|
// Multiple destinations (max 10)
|
|
77
110
|
destinations: [
|
|
@@ -136,34 +169,141 @@ const config = {
|
|
|
136
169
|
|
|
137
170
|
## Authentication
|
|
138
171
|
|
|
139
|
-
|
|
172
|
+
The Data Manager destination uses Google Cloud service accounts with automatic
|
|
173
|
+
token refresh. The library handles token management automatically - you just
|
|
174
|
+
provide credentials and tokens are cached and refreshed as needed.
|
|
175
|
+
|
|
176
|
+
### Authentication Methods
|
|
177
|
+
|
|
178
|
+
The destination supports three authentication methods (in priority order):
|
|
179
|
+
|
|
180
|
+
1. **Inline Credentials** - Best for serverless (AWS Lambda, Docker, K8s)
|
|
181
|
+
2. **Service Account File** - Best for local development
|
|
182
|
+
3. **Application Default Credentials (ADC)** - Automatic on GCP
|
|
183
|
+
|
|
184
|
+
### 1. Inline Credentials (Recommended for Serverless)
|
|
185
|
+
|
|
186
|
+
Best for AWS Lambda, Docker, Kubernetes, and other containerized environments
|
|
187
|
+
where you manage secrets via environment variables.
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
import { destinationDataManager } from '@walkeros/server-destination-datamanager';
|
|
191
|
+
|
|
192
|
+
const config = {
|
|
193
|
+
...destinationDataManager,
|
|
194
|
+
config: {
|
|
195
|
+
settings: {
|
|
196
|
+
credentials: {
|
|
197
|
+
client_email: process.env.GOOGLE_CLIENT_EMAIL!,
|
|
198
|
+
private_key: process.env.GOOGLE_PRIVATE_KEY!.replace(/\\n/g, '\n'),
|
|
199
|
+
},
|
|
200
|
+
destinations: [
|
|
201
|
+
/* ... */
|
|
202
|
+
],
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
};
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
**Environment Variables:**
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
GOOGLE_CLIENT_EMAIL=service-account@project.iam.gserviceaccount.com
|
|
212
|
+
GOOGLE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nMIIE...\n-----END PRIVATE KEY-----\n"
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
**Note:** Use `.replace(/\\n/g, '\n')` to convert escaped newlines from
|
|
216
|
+
environment variables.
|
|
217
|
+
|
|
218
|
+
### 2. Service Account File (Local Development)
|
|
219
|
+
|
|
220
|
+
Best for local development with filesystem access.
|
|
221
|
+
|
|
222
|
+
```typescript
|
|
223
|
+
const config = {
|
|
224
|
+
...destinationDataManager,
|
|
225
|
+
config: {
|
|
226
|
+
settings: {
|
|
227
|
+
keyFilename: './service-account.json',
|
|
228
|
+
destinations: [
|
|
229
|
+
/* ... */
|
|
230
|
+
],
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
};
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### 3. Application Default Credentials (GCP)
|
|
237
|
+
|
|
238
|
+
Automatic on Google Cloud Platform - no configuration needed!
|
|
140
239
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
240
|
+
```typescript
|
|
241
|
+
const config = {
|
|
242
|
+
...destinationDataManager,
|
|
243
|
+
config: {
|
|
244
|
+
settings: {
|
|
245
|
+
// No auth config needed - ADC used automatically!
|
|
246
|
+
destinations: [
|
|
247
|
+
/* ... */
|
|
248
|
+
],
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
};
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
**Works automatically on:**
|
|
144
255
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
256
|
+
- Google Cloud Functions
|
|
257
|
+
- Google Cloud Run
|
|
258
|
+
- Google Compute Engine
|
|
259
|
+
- Google Kubernetes Engine
|
|
260
|
+
- Any GCP environment with default service account
|
|
149
261
|
|
|
150
|
-
|
|
151
|
-
- Go to APIs & Services > Credentials
|
|
152
|
-
- Click "Create Credentials" > "Service Account"
|
|
153
|
-
- Grant necessary permissions
|
|
154
|
-
- Download JSON key file
|
|
262
|
+
**Also works with:**
|
|
155
263
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
gcloud auth application-default print-access-token --scopes=https://www.googleapis.com/auth/datamanager
|
|
159
|
-
```
|
|
264
|
+
- `GOOGLE_APPLICATION_CREDENTIALS` environment variable
|
|
265
|
+
- gcloud CLI: `gcloud auth application-default login`
|
|
160
266
|
|
|
161
|
-
###
|
|
267
|
+
### Creating a Service Account
|
|
268
|
+
|
|
269
|
+
1. Go to [Google Cloud Console](https://console.cloud.google.com/)
|
|
270
|
+
2. Navigate to **IAM & Admin > Service Accounts**
|
|
271
|
+
3. Click **Create Service Account**
|
|
272
|
+
4. Name: `walkeros-datamanager` (or your choice)
|
|
273
|
+
5. Grant role: **Data Manager Admin** or custom role with datamanager
|
|
274
|
+
permissions
|
|
275
|
+
6. Click **Keys > Add Key > Create New Key**
|
|
276
|
+
7. Select **JSON** format and download
|
|
277
|
+
|
|
278
|
+
**For inline credentials:**
|
|
279
|
+
|
|
280
|
+
- Extract `client_email` and `private_key` from the JSON
|
|
281
|
+
- Store in environment variables or secrets manager
|
|
282
|
+
|
|
283
|
+
**For keyFilename:**
|
|
284
|
+
|
|
285
|
+
- Set `keyFilename: '/path/to/downloaded-key.json'`
|
|
286
|
+
|
|
287
|
+
**For ADC:**
|
|
288
|
+
|
|
289
|
+
- Set `GOOGLE_APPLICATION_CREDENTIALS=/path/to/downloaded-key.json`
|
|
290
|
+
- Or deploy to GCP where ADC works automatically
|
|
291
|
+
|
|
292
|
+
### Required OAuth Scope
|
|
162
293
|
|
|
163
294
|
```
|
|
164
295
|
https://www.googleapis.com/auth/datamanager
|
|
165
296
|
```
|
|
166
297
|
|
|
298
|
+
This scope is automatically applied - no configuration needed.
|
|
299
|
+
|
|
300
|
+
### Token Management
|
|
301
|
+
|
|
302
|
+
- **Lifetime:** 1 hour (3600 seconds)
|
|
303
|
+
- **Refresh:** Automatic - library handles expiration
|
|
304
|
+
- **Caching:** Tokens are cached and reused until expiration
|
|
305
|
+
- **Performance:** ~10-50ms overhead per request for token validation
|
|
306
|
+
|
|
167
307
|
## Guided Mapping Helpers
|
|
168
308
|
|
|
169
309
|
Define common fields once in Settings instead of repeating them in every event
|
|
@@ -172,7 +312,7 @@ mapping:
|
|
|
172
312
|
```typescript
|
|
173
313
|
{
|
|
174
314
|
settings: {
|
|
175
|
-
|
|
315
|
+
credentials: { /* ... */ },
|
|
176
316
|
destinations: [...],
|
|
177
317
|
|
|
178
318
|
// Guided helpers (apply to all events)
|
|
@@ -616,23 +756,28 @@ be rejected.
|
|
|
616
756
|
|
|
617
757
|
### Settings
|
|
618
758
|
|
|
619
|
-
| Property | Type | Required | Description
|
|
620
|
-
| -------------------------- | -------------- | -------- |
|
|
621
|
-
| `
|
|
622
|
-
| `
|
|
623
|
-
| `
|
|
624
|
-
| `
|
|
625
|
-
| `
|
|
626
|
-
| `
|
|
627
|
-
| `
|
|
628
|
-
| `
|
|
629
|
-
| `
|
|
630
|
-
| `
|
|
631
|
-
| `
|
|
632
|
-
| `
|
|
633
|
-
| `
|
|
634
|
-
| `
|
|
635
|
-
| `
|
|
759
|
+
| Property | Type | Required | Description |
|
|
760
|
+
| -------------------------- | -------------- | -------- | -------------------------------------------- |
|
|
761
|
+
| `credentials` | object | \* | Service account (client_email + private_key) |
|
|
762
|
+
| `keyFilename` | string | \* | Path to service account JSON file |
|
|
763
|
+
| `scopes` | string[] | | OAuth scopes (default: datamanager scope) |
|
|
764
|
+
| `destinations` | Destination[] | ✓ | Array of destination accounts (max 10) |
|
|
765
|
+
| `eventSource` | EventSource | | Default event source (WEB, APP, etc.) |
|
|
766
|
+
| `batchSize` | number | | Max events per batch (max 2000) |
|
|
767
|
+
| `batchInterval` | number | | Batch flush interval in ms |
|
|
768
|
+
| `validateOnly` | boolean | | Validate without ingestion |
|
|
769
|
+
| `url` | string | | Override API endpoint |
|
|
770
|
+
| `consent` | Consent | | Request-level consent |
|
|
771
|
+
| `testEventCode` | string | | Test event code for debugging |
|
|
772
|
+
| `userData` | object | | Guided helper: User data mapping |
|
|
773
|
+
| `userId` | string | | Guided helper: First-party user ID |
|
|
774
|
+
| `clientId` | string | | Guided helper: GA4 client ID |
|
|
775
|
+
| `sessionAttributes` | string | | Guided helper: Privacy-safe attribution |
|
|
776
|
+
| `consentAdUserData` | string/boolean | | Consent mapping: Field name or static value |
|
|
777
|
+
| `consentAdPersonalization` | string/boolean | | Consent mapping: Field name or static value |
|
|
778
|
+
|
|
779
|
+
**\* One of `credentials`, `keyFilename`, or ADC (automatic) required for
|
|
780
|
+
authentication**
|
|
636
781
|
|
|
637
782
|
### Event Fields
|
|
638
783
|
|
package/dist/dev.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { JSONSchema } from '@walkeros/core/dev';
|
|
2
2
|
import { Mapping as Mapping$1, Destination as Destination$1 } from '@walkeros/core';
|
|
3
3
|
import { DestinationServer } from '@walkeros/server-core';
|
|
4
|
+
import { OAuth2Client } from 'google-auth-library';
|
|
4
5
|
|
|
5
6
|
declare const schemas$1: Record<string, JSONSchema>;
|
|
6
7
|
|
|
@@ -11,8 +12,24 @@ declare namespace schemas {
|
|
|
11
12
|
type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'none';
|
|
12
13
|
|
|
13
14
|
interface Settings {
|
|
14
|
-
/**
|
|
15
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Service account credentials (client_email + private_key)
|
|
17
|
+
* Recommended for serverless environments (AWS Lambda, Docker, etc.)
|
|
18
|
+
*/
|
|
19
|
+
credentials?: {
|
|
20
|
+
client_email: string;
|
|
21
|
+
private_key: string;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Path to service account JSON file
|
|
25
|
+
* For local development or environments with filesystem access
|
|
26
|
+
*/
|
|
27
|
+
keyFilename?: string;
|
|
28
|
+
/**
|
|
29
|
+
* OAuth scopes for Data Manager API
|
|
30
|
+
* @default ['https://www.googleapis.com/auth/datamanager']
|
|
31
|
+
*/
|
|
32
|
+
scopes?: string[];
|
|
16
33
|
/** Array of destination accounts and conversion actions/user lists */
|
|
17
34
|
destinations: Destination[];
|
|
18
35
|
/** Default event source if not specified per event */
|
|
@@ -52,8 +69,10 @@ interface Mapping {
|
|
|
52
69
|
}
|
|
53
70
|
interface Env extends DestinationServer.Env {
|
|
54
71
|
fetch?: typeof fetch;
|
|
72
|
+
authClient?: OAuth2Client | null;
|
|
55
73
|
}
|
|
56
|
-
type
|
|
74
|
+
type InitSettings = Partial<Settings>;
|
|
75
|
+
type Types = Destination$1.Types<Settings, Mapping, Env, InitSettings>;
|
|
57
76
|
type Config = {
|
|
58
77
|
settings: Settings;
|
|
59
78
|
} & DestinationServer.Config<Types>;
|
|
@@ -63,21 +82,27 @@ type Rule = Mapping$1.Rule<Mapping>;
|
|
|
63
82
|
* https://developers.google.com/data-manager/api/reference/rest/v1/Destination
|
|
64
83
|
*/
|
|
65
84
|
interface Destination {
|
|
66
|
-
/**
|
|
67
|
-
|
|
85
|
+
/** Reference identifier for this destination */
|
|
86
|
+
reference?: string;
|
|
87
|
+
/** Login account (account initiating the request) */
|
|
88
|
+
loginAccount?: ProductAccount;
|
|
89
|
+
/** Linked account (child account linked to login account) */
|
|
90
|
+
linkedAccount?: ProductAccount;
|
|
91
|
+
/** Operating account (account where data is sent) */
|
|
92
|
+
operatingAccount?: ProductAccount;
|
|
68
93
|
/** Product-specific destination ID (conversion action or user list) */
|
|
69
|
-
productDestinationId
|
|
94
|
+
productDestinationId?: string;
|
|
70
95
|
}
|
|
71
96
|
/**
|
|
72
|
-
*
|
|
97
|
+
* Product account information
|
|
73
98
|
*/
|
|
74
|
-
interface
|
|
99
|
+
interface ProductAccount {
|
|
75
100
|
/** Account ID (e.g., "123-456-7890" for Google Ads) */
|
|
76
101
|
accountId: string;
|
|
77
102
|
/** Type of account */
|
|
78
103
|
accountType: AccountType;
|
|
79
104
|
}
|
|
80
|
-
type AccountType = 'GOOGLE_ADS' | 'DISPLAY_VIDEO_ADVERTISER' | 'DISPLAY_VIDEO_PARTNER' | 'GOOGLE_ANALYTICS_PROPERTY';
|
|
105
|
+
type AccountType = 'ACCOUNT_TYPE_UNSPECIFIED' | 'GOOGLE_ADS' | 'DISPLAY_VIDEO_ADVERTISER' | 'DISPLAY_VIDEO_PARTNER' | 'GOOGLE_ANALYTICS_PROPERTY' | 'DATA_PARTNER';
|
|
81
106
|
type EventSource = 'WEB' | 'APP' | 'IN_STORE' | 'PHONE' | 'OTHER';
|
|
82
107
|
/**
|
|
83
108
|
* Consent for Digital Markets Act (DMA) compliance
|
|
@@ -91,6 +116,75 @@ interface Consent {
|
|
|
91
116
|
}
|
|
92
117
|
type ConsentStatus = 'CONSENT_GRANTED' | 'CONSENT_DENIED';
|
|
93
118
|
|
|
119
|
+
/**
|
|
120
|
+
* AWS Lambda / Serverless Configuration
|
|
121
|
+
* Uses inline credentials from environment variables
|
|
122
|
+
* Best for: AWS Lambda, Docker, Kubernetes, any serverless environment
|
|
123
|
+
*/
|
|
124
|
+
declare const awsLambda: Config;
|
|
125
|
+
/**
|
|
126
|
+
* GCP Cloud Functions / Cloud Run Configuration
|
|
127
|
+
* Uses Application Default Credentials (ADC) - no explicit auth config needed
|
|
128
|
+
* Best for: Google Cloud Functions, Cloud Run, GCE, GKE
|
|
129
|
+
*/
|
|
130
|
+
declare const gcpCloudFunctions: Config;
|
|
131
|
+
/**
|
|
132
|
+
* Local Development Configuration
|
|
133
|
+
* Uses service account JSON file
|
|
134
|
+
* Best for: Local development, testing
|
|
135
|
+
*/
|
|
136
|
+
declare const localDevelopment: Config;
|
|
137
|
+
/**
|
|
138
|
+
* Docker / Kubernetes Configuration
|
|
139
|
+
* Uses ADC via GOOGLE_APPLICATION_CREDENTIALS environment variable
|
|
140
|
+
* Best for: Docker containers, Kubernetes pods
|
|
141
|
+
*
|
|
142
|
+
* Setup:
|
|
143
|
+
* 1. Mount service account JSON as secret/configmap
|
|
144
|
+
* 2. Set GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json
|
|
145
|
+
* 3. ADC will automatically use it
|
|
146
|
+
*/
|
|
147
|
+
declare const dockerKubernetes: Config;
|
|
148
|
+
/**
|
|
149
|
+
* Custom Scopes Configuration
|
|
150
|
+
* For specific use cases requiring different OAuth scopes
|
|
151
|
+
*/
|
|
152
|
+
declare const customScopes: Config;
|
|
153
|
+
|
|
154
|
+
declare const auth_awsLambda: typeof awsLambda;
|
|
155
|
+
declare const auth_customScopes: typeof customScopes;
|
|
156
|
+
declare const auth_dockerKubernetes: typeof dockerKubernetes;
|
|
157
|
+
declare const auth_gcpCloudFunctions: typeof gcpCloudFunctions;
|
|
158
|
+
declare const auth_localDevelopment: typeof localDevelopment;
|
|
159
|
+
declare namespace auth {
|
|
160
|
+
export { auth_awsLambda as awsLambda, auth_customScopes as customScopes, auth_dockerKubernetes as dockerKubernetes, auth_gcpCloudFunctions as gcpCloudFunctions, auth_localDevelopment as localDevelopment };
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Minimal configuration for Google Data Manager with inline credentials
|
|
165
|
+
*/
|
|
166
|
+
declare const minimal: Config;
|
|
167
|
+
/**
|
|
168
|
+
* Complete configuration with all options
|
|
169
|
+
*/
|
|
170
|
+
declare const complete: Config;
|
|
171
|
+
/**
|
|
172
|
+
* GA4-specific configuration using Application Default Credentials
|
|
173
|
+
*/
|
|
174
|
+
declare const ga4: Config;
|
|
175
|
+
/**
|
|
176
|
+
* Debug configuration with logging enabled using keyFilename
|
|
177
|
+
*/
|
|
178
|
+
declare const debug: Config;
|
|
179
|
+
|
|
180
|
+
declare const basic_complete: typeof complete;
|
|
181
|
+
declare const basic_debug: typeof debug;
|
|
182
|
+
declare const basic_ga4: typeof ga4;
|
|
183
|
+
declare const basic_minimal: typeof minimal;
|
|
184
|
+
declare namespace basic {
|
|
185
|
+
export { basic_complete as complete, basic_debug as debug, basic_ga4 as ga4, basic_minimal as minimal };
|
|
186
|
+
}
|
|
187
|
+
|
|
94
188
|
/**
|
|
95
189
|
* Purchase event mapping for Google Ads conversion
|
|
96
190
|
*/
|
|
@@ -132,34 +226,10 @@ declare namespace mapping$1 {
|
|
|
132
226
|
export { mapping$1_Lead as Lead, mapping$1_PageView as PageView, mapping$1_Purchase as Purchase, mapping$1_mapping as mapping, mapping$1_userDataMapping as userDataMapping };
|
|
133
227
|
}
|
|
134
228
|
|
|
135
|
-
|
|
136
|
-
* Minimal configuration for Google Data Manager
|
|
137
|
-
*/
|
|
138
|
-
declare const minimal: Config;
|
|
139
|
-
/**
|
|
140
|
-
* Complete configuration with all options
|
|
141
|
-
*/
|
|
142
|
-
declare const complete: Config;
|
|
143
|
-
/**
|
|
144
|
-
* GA4-specific configuration
|
|
145
|
-
*/
|
|
146
|
-
declare const ga4: Config;
|
|
147
|
-
/**
|
|
148
|
-
* Debug configuration with logging enabled
|
|
149
|
-
*/
|
|
150
|
-
declare const debug: Config;
|
|
151
|
-
|
|
152
|
-
declare const basic_complete: typeof complete;
|
|
153
|
-
declare const basic_debug: typeof debug;
|
|
154
|
-
declare const basic_ga4: typeof ga4;
|
|
155
|
-
declare const basic_minimal: typeof minimal;
|
|
156
|
-
declare namespace basic {
|
|
157
|
-
export { basic_complete as complete, basic_debug as debug, basic_ga4 as ga4, basic_minimal as minimal };
|
|
158
|
-
}
|
|
159
|
-
|
|
229
|
+
declare const index_auth: typeof auth;
|
|
160
230
|
declare const index_basic: typeof basic;
|
|
161
231
|
declare namespace index {
|
|
162
|
-
export { index_basic as basic, mapping$1 as mapping };
|
|
232
|
+
export { index_auth as auth, index_basic as basic, mapping$1 as mapping };
|
|
163
233
|
}
|
|
164
234
|
|
|
165
235
|
export { index as examples, schemas };
|
package/dist/dev.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { JSONSchema } from '@walkeros/core/dev';
|
|
2
2
|
import { Mapping as Mapping$1, Destination as Destination$1 } from '@walkeros/core';
|
|
3
3
|
import { DestinationServer } from '@walkeros/server-core';
|
|
4
|
+
import { OAuth2Client } from 'google-auth-library';
|
|
4
5
|
|
|
5
6
|
declare const schemas$1: Record<string, JSONSchema>;
|
|
6
7
|
|
|
@@ -11,8 +12,24 @@ declare namespace schemas {
|
|
|
11
12
|
type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'none';
|
|
12
13
|
|
|
13
14
|
interface Settings {
|
|
14
|
-
/**
|
|
15
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Service account credentials (client_email + private_key)
|
|
17
|
+
* Recommended for serverless environments (AWS Lambda, Docker, etc.)
|
|
18
|
+
*/
|
|
19
|
+
credentials?: {
|
|
20
|
+
client_email: string;
|
|
21
|
+
private_key: string;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Path to service account JSON file
|
|
25
|
+
* For local development or environments with filesystem access
|
|
26
|
+
*/
|
|
27
|
+
keyFilename?: string;
|
|
28
|
+
/**
|
|
29
|
+
* OAuth scopes for Data Manager API
|
|
30
|
+
* @default ['https://www.googleapis.com/auth/datamanager']
|
|
31
|
+
*/
|
|
32
|
+
scopes?: string[];
|
|
16
33
|
/** Array of destination accounts and conversion actions/user lists */
|
|
17
34
|
destinations: Destination[];
|
|
18
35
|
/** Default event source if not specified per event */
|
|
@@ -52,8 +69,10 @@ interface Mapping {
|
|
|
52
69
|
}
|
|
53
70
|
interface Env extends DestinationServer.Env {
|
|
54
71
|
fetch?: typeof fetch;
|
|
72
|
+
authClient?: OAuth2Client | null;
|
|
55
73
|
}
|
|
56
|
-
type
|
|
74
|
+
type InitSettings = Partial<Settings>;
|
|
75
|
+
type Types = Destination$1.Types<Settings, Mapping, Env, InitSettings>;
|
|
57
76
|
type Config = {
|
|
58
77
|
settings: Settings;
|
|
59
78
|
} & DestinationServer.Config<Types>;
|
|
@@ -63,21 +82,27 @@ type Rule = Mapping$1.Rule<Mapping>;
|
|
|
63
82
|
* https://developers.google.com/data-manager/api/reference/rest/v1/Destination
|
|
64
83
|
*/
|
|
65
84
|
interface Destination {
|
|
66
|
-
/**
|
|
67
|
-
|
|
85
|
+
/** Reference identifier for this destination */
|
|
86
|
+
reference?: string;
|
|
87
|
+
/** Login account (account initiating the request) */
|
|
88
|
+
loginAccount?: ProductAccount;
|
|
89
|
+
/** Linked account (child account linked to login account) */
|
|
90
|
+
linkedAccount?: ProductAccount;
|
|
91
|
+
/** Operating account (account where data is sent) */
|
|
92
|
+
operatingAccount?: ProductAccount;
|
|
68
93
|
/** Product-specific destination ID (conversion action or user list) */
|
|
69
|
-
productDestinationId
|
|
94
|
+
productDestinationId?: string;
|
|
70
95
|
}
|
|
71
96
|
/**
|
|
72
|
-
*
|
|
97
|
+
* Product account information
|
|
73
98
|
*/
|
|
74
|
-
interface
|
|
99
|
+
interface ProductAccount {
|
|
75
100
|
/** Account ID (e.g., "123-456-7890" for Google Ads) */
|
|
76
101
|
accountId: string;
|
|
77
102
|
/** Type of account */
|
|
78
103
|
accountType: AccountType;
|
|
79
104
|
}
|
|
80
|
-
type AccountType = 'GOOGLE_ADS' | 'DISPLAY_VIDEO_ADVERTISER' | 'DISPLAY_VIDEO_PARTNER' | 'GOOGLE_ANALYTICS_PROPERTY';
|
|
105
|
+
type AccountType = 'ACCOUNT_TYPE_UNSPECIFIED' | 'GOOGLE_ADS' | 'DISPLAY_VIDEO_ADVERTISER' | 'DISPLAY_VIDEO_PARTNER' | 'GOOGLE_ANALYTICS_PROPERTY' | 'DATA_PARTNER';
|
|
81
106
|
type EventSource = 'WEB' | 'APP' | 'IN_STORE' | 'PHONE' | 'OTHER';
|
|
82
107
|
/**
|
|
83
108
|
* Consent for Digital Markets Act (DMA) compliance
|
|
@@ -91,6 +116,75 @@ interface Consent {
|
|
|
91
116
|
}
|
|
92
117
|
type ConsentStatus = 'CONSENT_GRANTED' | 'CONSENT_DENIED';
|
|
93
118
|
|
|
119
|
+
/**
|
|
120
|
+
* AWS Lambda / Serverless Configuration
|
|
121
|
+
* Uses inline credentials from environment variables
|
|
122
|
+
* Best for: AWS Lambda, Docker, Kubernetes, any serverless environment
|
|
123
|
+
*/
|
|
124
|
+
declare const awsLambda: Config;
|
|
125
|
+
/**
|
|
126
|
+
* GCP Cloud Functions / Cloud Run Configuration
|
|
127
|
+
* Uses Application Default Credentials (ADC) - no explicit auth config needed
|
|
128
|
+
* Best for: Google Cloud Functions, Cloud Run, GCE, GKE
|
|
129
|
+
*/
|
|
130
|
+
declare const gcpCloudFunctions: Config;
|
|
131
|
+
/**
|
|
132
|
+
* Local Development Configuration
|
|
133
|
+
* Uses service account JSON file
|
|
134
|
+
* Best for: Local development, testing
|
|
135
|
+
*/
|
|
136
|
+
declare const localDevelopment: Config;
|
|
137
|
+
/**
|
|
138
|
+
* Docker / Kubernetes Configuration
|
|
139
|
+
* Uses ADC via GOOGLE_APPLICATION_CREDENTIALS environment variable
|
|
140
|
+
* Best for: Docker containers, Kubernetes pods
|
|
141
|
+
*
|
|
142
|
+
* Setup:
|
|
143
|
+
* 1. Mount service account JSON as secret/configmap
|
|
144
|
+
* 2. Set GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json
|
|
145
|
+
* 3. ADC will automatically use it
|
|
146
|
+
*/
|
|
147
|
+
declare const dockerKubernetes: Config;
|
|
148
|
+
/**
|
|
149
|
+
* Custom Scopes Configuration
|
|
150
|
+
* For specific use cases requiring different OAuth scopes
|
|
151
|
+
*/
|
|
152
|
+
declare const customScopes: Config;
|
|
153
|
+
|
|
154
|
+
declare const auth_awsLambda: typeof awsLambda;
|
|
155
|
+
declare const auth_customScopes: typeof customScopes;
|
|
156
|
+
declare const auth_dockerKubernetes: typeof dockerKubernetes;
|
|
157
|
+
declare const auth_gcpCloudFunctions: typeof gcpCloudFunctions;
|
|
158
|
+
declare const auth_localDevelopment: typeof localDevelopment;
|
|
159
|
+
declare namespace auth {
|
|
160
|
+
export { auth_awsLambda as awsLambda, auth_customScopes as customScopes, auth_dockerKubernetes as dockerKubernetes, auth_gcpCloudFunctions as gcpCloudFunctions, auth_localDevelopment as localDevelopment };
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Minimal configuration for Google Data Manager with inline credentials
|
|
165
|
+
*/
|
|
166
|
+
declare const minimal: Config;
|
|
167
|
+
/**
|
|
168
|
+
* Complete configuration with all options
|
|
169
|
+
*/
|
|
170
|
+
declare const complete: Config;
|
|
171
|
+
/**
|
|
172
|
+
* GA4-specific configuration using Application Default Credentials
|
|
173
|
+
*/
|
|
174
|
+
declare const ga4: Config;
|
|
175
|
+
/**
|
|
176
|
+
* Debug configuration with logging enabled using keyFilename
|
|
177
|
+
*/
|
|
178
|
+
declare const debug: Config;
|
|
179
|
+
|
|
180
|
+
declare const basic_complete: typeof complete;
|
|
181
|
+
declare const basic_debug: typeof debug;
|
|
182
|
+
declare const basic_ga4: typeof ga4;
|
|
183
|
+
declare const basic_minimal: typeof minimal;
|
|
184
|
+
declare namespace basic {
|
|
185
|
+
export { basic_complete as complete, basic_debug as debug, basic_ga4 as ga4, basic_minimal as minimal };
|
|
186
|
+
}
|
|
187
|
+
|
|
94
188
|
/**
|
|
95
189
|
* Purchase event mapping for Google Ads conversion
|
|
96
190
|
*/
|
|
@@ -132,34 +226,10 @@ declare namespace mapping$1 {
|
|
|
132
226
|
export { mapping$1_Lead as Lead, mapping$1_PageView as PageView, mapping$1_Purchase as Purchase, mapping$1_mapping as mapping, mapping$1_userDataMapping as userDataMapping };
|
|
133
227
|
}
|
|
134
228
|
|
|
135
|
-
|
|
136
|
-
* Minimal configuration for Google Data Manager
|
|
137
|
-
*/
|
|
138
|
-
declare const minimal: Config;
|
|
139
|
-
/**
|
|
140
|
-
* Complete configuration with all options
|
|
141
|
-
*/
|
|
142
|
-
declare const complete: Config;
|
|
143
|
-
/**
|
|
144
|
-
* GA4-specific configuration
|
|
145
|
-
*/
|
|
146
|
-
declare const ga4: Config;
|
|
147
|
-
/**
|
|
148
|
-
* Debug configuration with logging enabled
|
|
149
|
-
*/
|
|
150
|
-
declare const debug: Config;
|
|
151
|
-
|
|
152
|
-
declare const basic_complete: typeof complete;
|
|
153
|
-
declare const basic_debug: typeof debug;
|
|
154
|
-
declare const basic_ga4: typeof ga4;
|
|
155
|
-
declare const basic_minimal: typeof minimal;
|
|
156
|
-
declare namespace basic {
|
|
157
|
-
export { basic_complete as complete, basic_debug as debug, basic_ga4 as ga4, basic_minimal as minimal };
|
|
158
|
-
}
|
|
159
|
-
|
|
229
|
+
declare const index_auth: typeof auth;
|
|
160
230
|
declare const index_basic: typeof basic;
|
|
161
231
|
declare namespace index {
|
|
162
|
-
export { index_basic as basic, mapping$1 as mapping };
|
|
232
|
+
export { index_auth as auth, index_basic as basic, mapping$1 as mapping };
|
|
163
233
|
}
|
|
164
234
|
|
|
165
235
|
export { index as examples, schemas };
|