@fire-spark/analytics-server 0.0.0-stage → 0.25.0
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/google.d.ts +112 -0
- package/dist/google.js +651 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.js +750 -0
- package/dist/json-D5hsBi3M.js +183 -0
- package/dist/meta.d.ts +71 -0
- package/dist/meta.js +252 -0
- package/dist/provider-DIOneNqa.js +22 -0
- package/dist/retry-CKgkb0DS.d.ts +237 -0
- package/dist/tiktok.d.ts +77 -0
- package/dist/tiktok.js +374 -0
- package/package.json +77 -3
- package/README.md +0 -3
package/dist/google.d.ts
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { C as ResolvedEvent, F as JsonNumber, O as ServerProvider, i as HttpReply, t as AttemptOutcome } from "./retry-CKgkb0DS.js";
|
|
2
|
+
//#region src/google.types.d.ts
|
|
3
|
+
interface GoogleDataManagerOptions {
|
|
4
|
+
/** Service account e-mail (`client_email` of the JSON key). */
|
|
5
|
+
clientEmail: string;
|
|
6
|
+
/**
|
|
7
|
+
* PEM PKCS#8 private key (`private_key` of the JSON key). Escaped `\n`
|
|
8
|
+
* from an environment variable is accepted. Server only, never logged.
|
|
9
|
+
*/
|
|
10
|
+
privateKey: string;
|
|
11
|
+
/** Google Ads customer id that owns the conversion actions. */
|
|
12
|
+
customerId: string;
|
|
13
|
+
/** Manager (MCC) account the service account reaches `customerId` by. */
|
|
14
|
+
loginCustomerId?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Fire Spark event name → Google Ads conversion action id, for example
|
|
17
|
+
* `{ purchase: "987654321" }`. Other events are skipped (`not_mapped`).
|
|
18
|
+
*/
|
|
19
|
+
conversionActions: Record<string, string>;
|
|
20
|
+
/** Sends `validate_only: true`: Google checks, records nothing. */
|
|
21
|
+
validateOnly?: boolean;
|
|
22
|
+
/** Keeps `validateOnly` in production. */
|
|
23
|
+
allowTestInProduction?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/** Server-only environment variables read by `googleDataManagerFromEnv`. */
|
|
26
|
+
type GoogleDataManagerEnv = Record<string, string | undefined>;
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/google-auth.d.ts
|
|
29
|
+
declare const GOOGLE_TOKEN_URL = "https://oauth2.googleapis.com/token";
|
|
30
|
+
/** The only scope requested: Data Manager, nothing else in the account. */
|
|
31
|
+
declare const DATA_MANAGER_SCOPE = "https://www.googleapis.com/auth/datamanager";
|
|
32
|
+
/** A cached token is refreshed this long before Google says it expires. */
|
|
33
|
+
declare const TOKEN_REFRESH_MARGIN_MS = 300000;
|
|
34
|
+
/** Token endpoint reply → token and lifetime, or an attempt outcome. */
|
|
35
|
+
declare const classifyTokenReply: (reply: HttpReply) => {
|
|
36
|
+
token: string;
|
|
37
|
+
expiresInMs: number;
|
|
38
|
+
} | {
|
|
39
|
+
outcome: AttemptOutcome;
|
|
40
|
+
};
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/google.d.ts
|
|
43
|
+
/** Server-only variables `googleDataManagerFromEnv` reads. */
|
|
44
|
+
declare const GOOGLE_DATA_MANAGER_ENV_VARS: {
|
|
45
|
+
readonly serviceAccountJson: "FIRESPARK_GOOGLE_DATA_MANAGER_SERVICE_ACCOUNT_JSON";
|
|
46
|
+
readonly clientEmail: "FIRESPARK_GOOGLE_DATA_MANAGER_CLIENT_EMAIL";
|
|
47
|
+
readonly privateKey: "FIRESPARK_GOOGLE_DATA_MANAGER_PRIVATE_KEY";
|
|
48
|
+
readonly customerId: "FIRESPARK_GOOGLE_ADS_CUSTOMER_ID";
|
|
49
|
+
readonly loginCustomerId: "FIRESPARK_GOOGLE_ADS_LOGIN_CUSTOMER_ID";
|
|
50
|
+
readonly conversionActions: "FIRESPARK_GOOGLE_ADS_CONVERSION_ACTIONS";
|
|
51
|
+
readonly validateOnly: "FIRESPARK_GOOGLE_DATA_MANAGER_VALIDATE_ONLY";
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* One Data Manager event for a conversion action. `transaction_id` is the
|
|
55
|
+
* order id (what the Google tag sends, so Google deduplicates), else the
|
|
56
|
+
* Fire Spark event id.
|
|
57
|
+
*/
|
|
58
|
+
declare const googleEventOf: (event: ResolvedEvent, actionId: string) => Partial<{
|
|
59
|
+
destination_references: string[];
|
|
60
|
+
transaction_id: string;
|
|
61
|
+
event_timestamp: string;
|
|
62
|
+
event_source: string;
|
|
63
|
+
currency: string | undefined;
|
|
64
|
+
conversion_value: JsonNumber | undefined;
|
|
65
|
+
user_data: Partial<{
|
|
66
|
+
user_identifiers: ({
|
|
67
|
+
email_address: string;
|
|
68
|
+
} | {
|
|
69
|
+
phone_number: string;
|
|
70
|
+
})[];
|
|
71
|
+
}>;
|
|
72
|
+
ad_identifiers: Partial<{
|
|
73
|
+
gclid: string | undefined;
|
|
74
|
+
gbraid: string | undefined;
|
|
75
|
+
wbraid: string | undefined;
|
|
76
|
+
session_attributes: string | undefined;
|
|
77
|
+
}>;
|
|
78
|
+
event_device_info: Partial<{
|
|
79
|
+
user_agent: string | undefined;
|
|
80
|
+
ip_address: string | undefined;
|
|
81
|
+
}>;
|
|
82
|
+
consent: {
|
|
83
|
+
ad_user_data: string;
|
|
84
|
+
ad_personalization: string;
|
|
85
|
+
};
|
|
86
|
+
cart_data: {
|
|
87
|
+
items: Partial<{
|
|
88
|
+
merchant_product_id: string;
|
|
89
|
+
quantity: JsonNumber | undefined;
|
|
90
|
+
unit_price: JsonNumber | undefined;
|
|
91
|
+
}>[];
|
|
92
|
+
} | undefined;
|
|
93
|
+
}>;
|
|
94
|
+
/** Data Manager response → outcome. Google's error text is never kept. */
|
|
95
|
+
declare const classifyGoogleReply: (reply: HttpReply) => AttemptOutcome;
|
|
96
|
+
/**
|
|
97
|
+
* Google Data Manager destination (`events:ingest`) for Google Ads
|
|
98
|
+
* conversions. Authenticates as a service account with the Data Manager
|
|
99
|
+
* scope only. Invalid options never throw: the provider fails closed (see
|
|
100
|
+
* `disabledProvider`). The key and tokens are never logged.
|
|
101
|
+
*/
|
|
102
|
+
declare const googleDataManager: (options: GoogleDataManagerOptions) => ServerProvider;
|
|
103
|
+
/** Options from the server-only variables in `GOOGLE_DATA_MANAGER_ENV_VARS`. */
|
|
104
|
+
declare const googleDataManagerOptionsFromEnv: (env: GoogleDataManagerEnv) => GoogleDataManagerOptions;
|
|
105
|
+
/**
|
|
106
|
+
* `googleDataManager` configured from server-only environment variables
|
|
107
|
+
* (pass `process.env`, or the Worker `env`). Never throws: a missing or
|
|
108
|
+
* invalid variable makes the provider fail closed.
|
|
109
|
+
*/
|
|
110
|
+
declare const googleDataManagerFromEnv: (env: GoogleDataManagerEnv) => ServerProvider;
|
|
111
|
+
//#endregion
|
|
112
|
+
export { DATA_MANAGER_SCOPE, GOOGLE_DATA_MANAGER_ENV_VARS, GOOGLE_TOKEN_URL, type GoogleDataManagerEnv, type GoogleDataManagerOptions, TOKEN_REFRESH_MARGIN_MS, classifyGoogleReply, classifyTokenReply, googleDataManager, googleDataManagerFromEnv, googleDataManagerOptionsFromEnv, googleEventOf };
|