@clikgate/node 2.0.1 → 2.1.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/CHANGELOG.md +25 -0
- package/README.md +116 -7
- package/SECURITY.md +2 -1
- package/dist/cjs/client.d.ts +38 -10
- package/dist/cjs/client.js +50 -16
- package/dist/cjs/currency.d.ts +7 -0
- package/dist/cjs/currency.js +75 -0
- package/dist/cjs/enums.js +1 -1
- package/dist/cjs/event-types.d.ts +108 -0
- package/dist/cjs/event-types.js +109 -0
- package/dist/cjs/express.d.ts +11 -2
- package/dist/cjs/express.js +3 -2
- package/dist/cjs/fastify.d.ts +4 -1
- package/dist/cjs/fastify.js +3 -2
- package/dist/cjs/generated/index.d.ts +1759 -86
- package/dist/cjs/generated/index.js +1 -1
- package/dist/cjs/identity.js +1 -1
- package/dist/cjs/index.d.ts +9 -1
- package/dist/cjs/index.js +15 -1
- package/dist/cjs/installation.d.ts +47 -0
- package/dist/cjs/installation.js +83 -0
- package/dist/cjs/lookups.d.ts +128 -0
- package/dist/cjs/lookups.js +149 -0
- package/dist/cjs/models.d.ts +342 -0
- package/dist/cjs/models.js +2 -0
- package/dist/cjs/next.d.ts +22 -0
- package/dist/cjs/next.js +20 -0
- package/dist/cjs/pager.d.ts +5 -0
- package/dist/cjs/pager.js +40 -0
- package/dist/cjs/referrals.d.ts +169 -0
- package/dist/cjs/referrals.js +208 -0
- package/dist/cjs/resources.d.ts +34 -5
- package/dist/cjs/resources.js +43 -42
- package/dist/cjs/types.d.ts +57 -10
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/webhooks.d.ts +3 -2
- package/dist/cjs/webhooks.js +43 -2
- package/dist/esm/client.d.ts +38 -10
- package/dist/esm/client.js +50 -16
- package/dist/esm/currency.d.ts +7 -0
- package/dist/esm/currency.js +67 -0
- package/dist/esm/enums.js +1 -1
- package/dist/esm/event-types.d.ts +108 -0
- package/dist/esm/event-types.js +106 -0
- package/dist/esm/express.d.ts +11 -2
- package/dist/esm/express.js +3 -2
- package/dist/esm/fastify.d.ts +4 -1
- package/dist/esm/fastify.js +3 -2
- package/dist/esm/generated/index.d.ts +1759 -86
- package/dist/esm/generated/index.js +1 -1
- package/dist/esm/identity.js +1 -1
- package/dist/esm/index.d.ts +9 -1
- package/dist/esm/index.js +4 -0
- package/dist/esm/installation.d.ts +47 -0
- package/dist/esm/installation.js +77 -0
- package/dist/esm/lookups.d.ts +128 -0
- package/dist/esm/lookups.js +142 -0
- package/dist/esm/models.d.ts +342 -0
- package/dist/esm/models.js +1 -0
- package/dist/esm/next.d.ts +22 -0
- package/dist/esm/next.js +19 -0
- package/dist/esm/pager.d.ts +5 -0
- package/dist/esm/pager.js +36 -0
- package/dist/esm/referrals.d.ts +169 -0
- package/dist/esm/referrals.js +204 -0
- package/dist/esm/resources.d.ts +34 -5
- package/dist/esm/resources.js +43 -42
- package/dist/esm/types.d.ts +57 -10
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/webhooks.d.ts +3 -2
- package/dist/esm/webhooks.js +42 -2
- package/package.json +2 -2
package/dist/esm/client.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ClickIds } from './click-ids.js';
|
|
2
2
|
import { type OnError } from './core.js';
|
|
3
3
|
import { type IdentityTokenOptions } from './identity.js';
|
|
4
|
+
import { type Installation } from './installation.js';
|
|
4
5
|
import type { RequestOptions } from './http.js';
|
|
5
6
|
import { ApiClient } from './generated/index.js';
|
|
6
7
|
import { Goals, type GoalOptions } from './goals.js';
|
|
@@ -9,18 +10,28 @@ import { type Logger } from './logger.js';
|
|
|
9
10
|
import { Payments } from './payments.js';
|
|
10
11
|
import { KnownCustomers } from './known-customers.js';
|
|
11
12
|
import { Clicks, Conversions, Links } from './resources.js';
|
|
13
|
+
import { Referrals } from './referrals.js';
|
|
14
|
+
import { Codes, Installs, People, Privacy } from './lookups.js';
|
|
12
15
|
import { type FetchLike } from './transport.js';
|
|
13
16
|
import type { ServerSdkConfig } from './types.js';
|
|
14
17
|
import { webhooks } from './webhooks.js';
|
|
15
18
|
/** Client options (SPEC section 3). Every option is optional. */
|
|
16
|
-
/** `identifyUser()`: at least one of `clickId`, `
|
|
19
|
+
/** `identifyUser()`: at least one of `clickId`, an installation (`installation` or `installationId`), `customerId`. */
|
|
17
20
|
export interface IdentifyUserParams {
|
|
18
21
|
/** The Clikgate click ID you kept (`clk_…`). */
|
|
19
22
|
clickId?: string | null;
|
|
20
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* The app's installation: the raw `Clikgate-Installation` header your app sent (`<app_id>:<installation_id>`), or
|
|
25
|
+
* the parsed `Installation` the framework helpers give (`req.clikgate.installation`, `getInstallation(...)`). It
|
|
26
|
+
* fills `appId` and `installationId`. Missing or invalid values (either form) are ignored, never sent. Not used when
|
|
27
|
+
* `installationId` is given.
|
|
28
|
+
*/
|
|
29
|
+
installation?: string | Installation | null;
|
|
30
|
+
/** The app the installation belongs to. Optional: without it Clikgate finds the app. Only with `installationId`. */
|
|
21
31
|
appId?: string | null;
|
|
32
|
+
/** The SDK's installation ID, sent by your app. */
|
|
22
33
|
installationId?: string | null;
|
|
23
|
-
/** Your
|
|
34
|
+
/** Your signed-in user's ID. Never read it from the request. With a click or installation, links it to this customer. */
|
|
24
35
|
customerId?: string | null;
|
|
25
36
|
/** A label your team sees instead of the click ID (1–80 characters, `''` clears it). */
|
|
26
37
|
label?: string | null;
|
|
@@ -106,6 +117,16 @@ export declare class Clikgate {
|
|
|
106
117
|
readonly clicks: Clicks;
|
|
107
118
|
/** Existing customers from before you added Clikgate: `import()` and `remove()`. */
|
|
108
119
|
readonly knownCustomers: KnownCustomers;
|
|
120
|
+
/** Referrals: referrers (`getOrCreateReferrer`, `findReferrer`), referrals, overrides, steps and imports. */
|
|
121
|
+
readonly referrals: Referrals;
|
|
122
|
+
/** Privacy requests: `createRequest`, `getRequest`. */
|
|
123
|
+
readonly privacy: Privacy;
|
|
124
|
+
/** People: `get`, `search`, `setLabel`. */
|
|
125
|
+
readonly people: People;
|
|
126
|
+
/** Installs: `getByCustomer`, `getByInstallation`. */
|
|
127
|
+
readonly installs: Installs;
|
|
128
|
+
/** Offline and referral codes: `redeem`. */
|
|
129
|
+
readonly codes: Codes;
|
|
109
130
|
/** Click-ID helpers using this client's `clickIdParam` (or the organisation's from config). */
|
|
110
131
|
readonly clickIds: ClickIds;
|
|
111
132
|
/** Every API-key operation, generated from openapi.json ("advanced"). */
|
|
@@ -143,22 +164,29 @@ export declare class Clikgate {
|
|
|
143
164
|
*/
|
|
144
165
|
createIdentityToken(customerId: string, options?: IdentityTokenOptions): string;
|
|
145
166
|
/**
|
|
146
|
-
* Tell Clikgate who a person is (`POST /v1/people/identify`): a click (`clickId`), an app installation
|
|
147
|
-
* `installationId`) or your `customerId`, at least one. With a click or installation, `customerId` links it to that
|
|
167
|
+
* Tell Clikgate who a person is (`POST /v1/people/identify`): a click (`clickId`), an app installation
|
|
168
|
+
* (`installation`, or `installationId` with an optional `appId`) or your `customerId`, at least one. With a click or installation, `customerId` links it to that
|
|
148
169
|
* customer. `label` is what your team sees instead of the click ID (1–80 characters, `''` clears it; Growth and
|
|
149
170
|
* up). Always verified (your server), so it also satisfies a referral program's `require_identity_token`.
|
|
150
171
|
* In private mode `customerId` is refused locally (the guard) and `label` needs "Allow labels in private mode".
|
|
151
172
|
* `customerSince` is when they became your customer, so existing customers are never counted as
|
|
152
173
|
* referrals or new customers; it is refused in private mode too.
|
|
153
174
|
*
|
|
154
|
-
* Path B of https://clikgate.com/docs/identify-users (no identity secret or token): the app
|
|
155
|
-
* `
|
|
156
|
-
*
|
|
157
|
-
*
|
|
175
|
+
* Path B of https://clikgate.com/docs/identify-users (no identity secret or token): the app sends the
|
|
176
|
+
* `Clikgate-Installation` header (from the mobile SDK) to your server. After your own sign-in check succeeds, and at
|
|
177
|
+
* every signed-in app open, pass the header as `installation` with your signed-in user's ID as `customerId` (never a
|
|
178
|
+
* customer ID read from the request). When the header is missing or invalid (tracking is off), skip the call.
|
|
179
|
+
* `appId` is optional: Clikgate finds the app. If the installation ID is in several of your apps, the API answers
|
|
180
|
+
* `409 installation_in_several_apps` (a `ConflictError`, param `app_id`): send `appId` too. Clikgate accepts
|
|
181
|
+
* installations active in the last 7 days.
|
|
158
182
|
*
|
|
159
183
|
* @example
|
|
160
184
|
* await clikgate.identifyUser({ clickId: order.clickId, customerId: 'user_42', label: 'Ada (VIP)' });
|
|
161
|
-
*
|
|
185
|
+
* // after your sign-in check: the header from the app, your user's ID
|
|
186
|
+
* const installation = req.get('Clikgate-Installation');
|
|
187
|
+
* if (parseInstallationHeader(installation)) await clikgate.identifyUser({ installation, customerId: req.user.id });
|
|
188
|
+
* // or the parsed installation from the Express middleware
|
|
189
|
+
* if (req.clikgate.installation) await clikgate.identifyUser({ installation: req.clikgate.installation, customerId: req.user.id });
|
|
162
190
|
*/
|
|
163
191
|
identifyUser(params: IdentifyUserParams, requestOptions?: RequestOptions): Promise<PersonIdentified>;
|
|
164
192
|
/**
|
package/dist/esm/client.js
CHANGED
|
@@ -4,6 +4,7 @@ import { Core } from './core.js';
|
|
|
4
4
|
import { ConfigurationError, localError } from './errors.js';
|
|
5
5
|
import { createIdentityTokenWith } from './identity.js';
|
|
6
6
|
import { guardPayload } from './guard.js';
|
|
7
|
+
import { toInstallation } from './installation.js';
|
|
7
8
|
import { ApiClient } from './generated/index.js';
|
|
8
9
|
import { GoalQueue, Goals, asClikgateError, buildGoalWire, checkBeforeSend } from './goals.js';
|
|
9
10
|
import { Requester, systemClock } from './http.js';
|
|
@@ -11,6 +12,8 @@ import { consoleLogger } from './logger.js';
|
|
|
11
12
|
import { Payments } from './payments.js';
|
|
12
13
|
import { KnownCustomers } from './known-customers.js';
|
|
13
14
|
import { Clicks, Conversions, Links } from './resources.js';
|
|
15
|
+
import { Referrals } from './referrals.js';
|
|
16
|
+
import { Codes, Installs, People, Privacy } from './lookups.js';
|
|
14
17
|
import { registerShutdown, unregisterShutdown } from './shutdown.js';
|
|
15
18
|
import { fetchTransport, nodeTransport } from './transport.js';
|
|
16
19
|
import { userAgent } from './user-agent.js';
|
|
@@ -69,6 +72,16 @@ export class Clikgate {
|
|
|
69
72
|
clicks;
|
|
70
73
|
/** Existing customers from before you added Clikgate: `import()` and `remove()`. */
|
|
71
74
|
knownCustomers;
|
|
75
|
+
/** Referrals: referrers (`getOrCreateReferrer`, `findReferrer`), referrals, overrides, steps and imports. */
|
|
76
|
+
referrals;
|
|
77
|
+
/** Privacy requests: `createRequest`, `getRequest`. */
|
|
78
|
+
privacy;
|
|
79
|
+
/** People: `get`, `search`, `setLabel`. */
|
|
80
|
+
people;
|
|
81
|
+
/** Installs: `getByCustomer`, `getByInstallation`. */
|
|
82
|
+
installs;
|
|
83
|
+
/** Offline and referral codes: `redeem`. */
|
|
84
|
+
codes;
|
|
72
85
|
/** Click-ID helpers using this client's `clickIdParam` (or the organisation's from config). */
|
|
73
86
|
clickIds;
|
|
74
87
|
/** Every API-key operation, generated from openapi.json ("advanced"). */
|
|
@@ -87,7 +100,7 @@ export class Clikgate {
|
|
|
87
100
|
throw new ConfigurationError({ message: 'No API key: pass { apiKey } or set CLIKGATE_API_KEY (cg_live_… or cg_test_…).', code: 'missing_api_key', param: 'apiKey' });
|
|
88
101
|
const m = KEY.exec(apiKey);
|
|
89
102
|
if (!m)
|
|
90
|
-
throw new ConfigurationError({ message: `The API key is ${keyType(apiKey)}. Server SDKs need a cg_live_… or cg_test_… API key from Developers
|
|
103
|
+
throw new ConfigurationError({ message: `The API key is ${keyType(apiKey)}. Server SDKs need a cg_live_… or cg_test_… API key from Developers › API keys & clients.`, code: 'invalid_api_key', param: 'apiKey' });
|
|
91
104
|
this.mode = m[1];
|
|
92
105
|
const baseUrl = (options.baseUrl ?? process.env.CLIKGATE_BASE_URL ?? 'https://api.clikgate.com').replace(/\/+$/, '');
|
|
93
106
|
let parsed;
|
|
@@ -129,6 +142,11 @@ export class Clikgate {
|
|
|
129
142
|
this.links = new Links(this.core);
|
|
130
143
|
this.clicks = new Clicks(this.core);
|
|
131
144
|
this.knownCustomers = new KnownCustomers(this.core);
|
|
145
|
+
this.referrals = new Referrals(this.core);
|
|
146
|
+
this.privacy = new Privacy(this.core);
|
|
147
|
+
this.people = new People(this.core);
|
|
148
|
+
this.installs = new Installs(this.core);
|
|
149
|
+
this.codes = new Codes(this.core);
|
|
132
150
|
const explicitParam = options.clickIdParam;
|
|
133
151
|
this.clickIds = new ClickIds(() => explicitParam ?? configCache.peek()?.click_id_param ?? 'cgid');
|
|
134
152
|
this.api = new ApiClient(requester);
|
|
@@ -196,38 +214,54 @@ export class Clikgate {
|
|
|
196
214
|
return createIdentityTokenWith(this.identitySource, customerId, options);
|
|
197
215
|
}
|
|
198
216
|
/**
|
|
199
|
-
* Tell Clikgate who a person is (`POST /v1/people/identify`): a click (`clickId`), an app installation
|
|
200
|
-
* `installationId`) or your `customerId`, at least one. With a click or installation, `customerId` links it to that
|
|
217
|
+
* Tell Clikgate who a person is (`POST /v1/people/identify`): a click (`clickId`), an app installation
|
|
218
|
+
* (`installation`, or `installationId` with an optional `appId`) or your `customerId`, at least one. With a click or installation, `customerId` links it to that
|
|
201
219
|
* customer. `label` is what your team sees instead of the click ID (1–80 characters, `''` clears it; Growth and
|
|
202
220
|
* up). Always verified (your server), so it also satisfies a referral program's `require_identity_token`.
|
|
203
221
|
* In private mode `customerId` is refused locally (the guard) and `label` needs "Allow labels in private mode".
|
|
204
222
|
* `customerSince` is when they became your customer, so existing customers are never counted as
|
|
205
223
|
* referrals or new customers; it is refused in private mode too.
|
|
206
224
|
*
|
|
207
|
-
* Path B of https://clikgate.com/docs/identify-users (no identity secret or token): the app
|
|
208
|
-
* `
|
|
209
|
-
*
|
|
210
|
-
*
|
|
225
|
+
* Path B of https://clikgate.com/docs/identify-users (no identity secret or token): the app sends the
|
|
226
|
+
* `Clikgate-Installation` header (from the mobile SDK) to your server. After your own sign-in check succeeds, and at
|
|
227
|
+
* every signed-in app open, pass the header as `installation` with your signed-in user's ID as `customerId` (never a
|
|
228
|
+
* customer ID read from the request). When the header is missing or invalid (tracking is off), skip the call.
|
|
229
|
+
* `appId` is optional: Clikgate finds the app. If the installation ID is in several of your apps, the API answers
|
|
230
|
+
* `409 installation_in_several_apps` (a `ConflictError`, param `app_id`): send `appId` too. Clikgate accepts
|
|
231
|
+
* installations active in the last 7 days.
|
|
211
232
|
*
|
|
212
233
|
* @example
|
|
213
234
|
* await clikgate.identifyUser({ clickId: order.clickId, customerId: 'user_42', label: 'Ada (VIP)' });
|
|
214
|
-
*
|
|
235
|
+
* // after your sign-in check: the header from the app, your user's ID
|
|
236
|
+
* const installation = req.get('Clikgate-Installation');
|
|
237
|
+
* if (parseInstallationHeader(installation)) await clikgate.identifyUser({ installation, customerId: req.user.id });
|
|
238
|
+
* // or the parsed installation from the Express middleware
|
|
239
|
+
* if (req.clikgate.installation) await clikgate.identifyUser({ installation: req.clikgate.installation, customerId: req.user.id });
|
|
215
240
|
*/
|
|
216
241
|
async identifyUser(params, requestOptions = {}) {
|
|
217
242
|
const p = (params ?? {});
|
|
218
|
-
|
|
219
|
-
|
|
243
|
+
let appId = p.appId;
|
|
244
|
+
let installationId = p.installationId;
|
|
245
|
+
if (installationId == null && p.installation != null) {
|
|
246
|
+
const fromHeader = toInstallation(p.installation);
|
|
247
|
+
if (fromHeader) {
|
|
248
|
+
appId = appId ?? fromHeader.appId;
|
|
249
|
+
installationId = fromHeader.installationId;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
if (appId != null && installationId == null) {
|
|
253
|
+
throw localError('invalid_request', 'Send installationId with appId.', 'installation_id');
|
|
220
254
|
}
|
|
221
|
-
if (p.clickId == null &&
|
|
222
|
-
throw localError('invalid_request', 'Send clickId,
|
|
255
|
+
if (p.clickId == null && installationId == null && p.customerId == null) {
|
|
256
|
+
throw localError('invalid_request', 'Send clickId, an installation (installation or installationId), or customerId.', 'click_id');
|
|
223
257
|
}
|
|
224
258
|
const body = {};
|
|
225
259
|
if (p.clickId != null)
|
|
226
260
|
body.click_id = p.clickId;
|
|
227
|
-
if (
|
|
228
|
-
body.app_id =
|
|
229
|
-
if (
|
|
230
|
-
body.installation_id =
|
|
261
|
+
if (appId != null)
|
|
262
|
+
body.app_id = appId;
|
|
263
|
+
if (installationId != null)
|
|
264
|
+
body.installation_id = installationId;
|
|
231
265
|
if (p.customerId != null)
|
|
232
266
|
body.customer_id = p.customerId;
|
|
233
267
|
if (p.label != null)
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** The ISO 4217 minor-unit exponent of a currency (2 when unknown). */
|
|
2
|
+
export declare function currencyExponent(currency: string): number;
|
|
3
|
+
/**
|
|
4
|
+
* Minor units to a decimal string in normal units, with exactly the currency's exponent of fraction digits
|
|
5
|
+
* (`50000` NGN → `"500.00"`, `1500` JPY → `"1500"`). No float is involved.
|
|
6
|
+
*/
|
|
7
|
+
export declare function minorToAmount(amountMinor: number | bigint, currency: string): string;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/** ISO 4217 exponents other than 2 (the backend's list); every other code has 2. */
|
|
2
|
+
const EXPONENTS = {
|
|
3
|
+
BHD: 3, BIF: 0, CLF: 4, CLP: 0, DJF: 0, GNF: 0, IQD: 3, ISK: 0, JOD: 3, JPY: 0, KMF: 0, KRW: 0, KWD: 3,
|
|
4
|
+
LYD: 3, OMR: 3, PYG: 0, RWF: 0, TND: 3, UGX: 0, UYI: 0, UYW: 4, VND: 0, VUV: 0, XAF: 0, XOF: 0, XPF: 0,
|
|
5
|
+
};
|
|
6
|
+
/** The ISO 4217 minor-unit exponent of a currency (2 when unknown). */
|
|
7
|
+
export function currencyExponent(currency) {
|
|
8
|
+
return EXPONENTS[currency.toUpperCase()] ?? 2;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Minor units to a decimal string in normal units, with exactly the currency's exponent of fraction digits
|
|
12
|
+
* (`50000` NGN → `"500.00"`, `1500` JPY → `"1500"`). No float is involved.
|
|
13
|
+
*/
|
|
14
|
+
export function minorToAmount(amountMinor, currency) {
|
|
15
|
+
const exp = currencyExponent(currency);
|
|
16
|
+
const n = typeof amountMinor === 'bigint' ? amountMinor : BigInt(Math.trunc(amountMinor));
|
|
17
|
+
const negative = n < 0n;
|
|
18
|
+
const digits = (negative ? -n : n).toString().padStart(exp + 1, '0');
|
|
19
|
+
const whole = exp === 0 ? digits : `${digits.slice(0, -exp)}.${digits.slice(-exp)}`;
|
|
20
|
+
return negative ? `-${whole}` : whole;
|
|
21
|
+
}
|
|
22
|
+
function isObject(v) {
|
|
23
|
+
return typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
24
|
+
}
|
|
25
|
+
function side(v) {
|
|
26
|
+
if (!isObject(v))
|
|
27
|
+
return v;
|
|
28
|
+
const out = { ...v };
|
|
29
|
+
if ((typeof v.amount_minor === 'number' || typeof v.amount_minor === 'bigint') && typeof v.currency === 'string' && v.currency !== '') {
|
|
30
|
+
out.amount = minorToAmount(v.amount_minor, v.currency);
|
|
31
|
+
}
|
|
32
|
+
return out;
|
|
33
|
+
}
|
|
34
|
+
/** @internal Add `amount` next to each reward side's `amount_minor`. */
|
|
35
|
+
export function rewardInfo(v) {
|
|
36
|
+
if (!isObject(v))
|
|
37
|
+
return v;
|
|
38
|
+
const out = { ...v };
|
|
39
|
+
if ('referrer' in v)
|
|
40
|
+
out.referrer = side(v.referrer);
|
|
41
|
+
if ('referee' in v)
|
|
42
|
+
out.referee = side(v.referee);
|
|
43
|
+
return out;
|
|
44
|
+
}
|
|
45
|
+
/** @internal A referral with reward amounts. */
|
|
46
|
+
export function toReferral(data) {
|
|
47
|
+
if (!isObject(data))
|
|
48
|
+
return data;
|
|
49
|
+
const out = { ...data };
|
|
50
|
+
if (isObject(data.reward_snapshot))
|
|
51
|
+
out.reward_snapshot = rewardInfo(data.reward_snapshot);
|
|
52
|
+
if (isObject(data.referrer))
|
|
53
|
+
out.referrer = { ...data.referrer, customerId: data.referrer.customer_user_id };
|
|
54
|
+
if (isObject(data.referee))
|
|
55
|
+
out.referee = { ...data.referee, customerId: data.referee.customer_user_id ?? null };
|
|
56
|
+
return out;
|
|
57
|
+
}
|
|
58
|
+
/** @internal A referrer with `customerId` next to `customer_user_id`. */
|
|
59
|
+
export function toReferrer(data) {
|
|
60
|
+
if (!isObject(data))
|
|
61
|
+
return data;
|
|
62
|
+
return { ...data, customerId: data.customer_user_id };
|
|
63
|
+
}
|
|
64
|
+
/** @internal A referrer with `created`. */
|
|
65
|
+
export function toReferrerResult(data, status) {
|
|
66
|
+
return { ...toReferrer(data), created: status === 201 };
|
|
67
|
+
}
|
package/dist/esm/enums.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Generated by server/codegen/generate.mjs from openapi.json (GoalKind, GoalStatus, Provider). Do not edit by hand.
|
|
2
|
-
// Source sha256
|
|
2
|
+
// Source sha256 3efd1f4fb7547b9b836402740027ff175d44649333c4b3a0003260c6ec5bd358.
|
|
3
3
|
/** A goal's kind, set in the goal's settings (never in a goal call): `standard` or `payment`. */
|
|
4
4
|
export const GoalKind = {
|
|
5
5
|
Standard: 'standard',
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every webhook event type the API sends (SPEC 29.1), as constants holding the wire string.
|
|
3
|
+
* `event.type` stays a plain string, so a type added later is never an error.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* if (event.type === EventType.ReferralQualified) { … }
|
|
7
|
+
*/
|
|
8
|
+
export declare const EventType: {
|
|
9
|
+
readonly AbTestLikelyWinner: "ab_test.likely_winner";
|
|
10
|
+
readonly AlertResolved: "alert.resolved";
|
|
11
|
+
readonly AlertTriggered: "alert.triggered";
|
|
12
|
+
readonly AppPushCredentialsInvalid: "app.push_credentials_invalid";
|
|
13
|
+
readonly AppReengaged: "app.reengaged";
|
|
14
|
+
readonly AppBannerPaused: "app_banner.paused";
|
|
15
|
+
readonly AppBannerPublished: "app_banner.published";
|
|
16
|
+
readonly CampaignPaused: "campaign.paused";
|
|
17
|
+
readonly CampaignResumed: "campaign.resumed";
|
|
18
|
+
readonly ChallengeCancelled: "challenge.cancelled";
|
|
19
|
+
readonly ChallengeEnded: "challenge.ended";
|
|
20
|
+
readonly ChallengeFinalized: "challenge.finalized";
|
|
21
|
+
readonly ChallengeScheduled: "challenge.scheduled";
|
|
22
|
+
readonly ChallengeStarted: "challenge.started";
|
|
23
|
+
readonly ClickCreated: "click.created";
|
|
24
|
+
readonly CodeRedeemed: "code.redeemed";
|
|
25
|
+
readonly ConversionAttributed: "conversion.attributed";
|
|
26
|
+
readonly ConversionReversed: "conversion.reversed";
|
|
27
|
+
readonly ConversionUnattributed: "conversion.unattributed";
|
|
28
|
+
readonly CreditNoteIssued: "credit_note.issued";
|
|
29
|
+
readonly DomainGroupChanged: "domain.group_changed";
|
|
30
|
+
readonly DomainSettingsUpdated: "domain.settings_updated";
|
|
31
|
+
readonly DomainStatusChanged: "domain.status_changed";
|
|
32
|
+
readonly FraudInstallFlagged: "fraud.install_flagged";
|
|
33
|
+
readonly FunnelStuck: "funnel.stuck";
|
|
34
|
+
readonly GoalCompleted: "goal.completed";
|
|
35
|
+
readonly GoalReversed: "goal.reversed";
|
|
36
|
+
readonly IdentityDuplicateDetected: "identity.duplicate_detected";
|
|
37
|
+
readonly InstallAttributed: "install.attributed";
|
|
38
|
+
readonly InstallAttributionUpdated: "install.attribution_updated";
|
|
39
|
+
readonly InstallOrganic: "install.organic";
|
|
40
|
+
readonly InstallUninstallReverted: "install.uninstall_reverted";
|
|
41
|
+
readonly InstallUninstalled: "install.uninstalled";
|
|
42
|
+
readonly InvoiceIssued: "invoice.issued";
|
|
43
|
+
readonly InvoicePaid: "invoice.paid";
|
|
44
|
+
readonly InvoiceVoided: "invoice.voided";
|
|
45
|
+
readonly JobCompleted: "job.completed";
|
|
46
|
+
readonly LeaderboardPeriodClosed: "leaderboard.period_closed";
|
|
47
|
+
readonly LeaderboardPeriodFinalized: "leaderboard.period_finalized";
|
|
48
|
+
readonly LeaderboardRankChanged: "leaderboard.rank_changed";
|
|
49
|
+
readonly LeaderboardTargetReached: "leaderboard.target_reached";
|
|
50
|
+
readonly LeaderboardTargetRevoked: "leaderboard.target_revoked";
|
|
51
|
+
readonly LinkArchived: "link.archived";
|
|
52
|
+
readonly LinkCreated: "link.created";
|
|
53
|
+
readonly LinkDestinationChanged: "link.destination_changed";
|
|
54
|
+
readonly LinkExpired: "link.expired";
|
|
55
|
+
readonly LinkFlagged: "link.flagged";
|
|
56
|
+
readonly LinkPaused: "link.paused";
|
|
57
|
+
readonly LinkResumed: "link.resumed";
|
|
58
|
+
readonly LinkStatsHourly: "link.stats.hourly";
|
|
59
|
+
readonly LinkUpdated: "link.updated";
|
|
60
|
+
readonly OrganizationDeleted: "organization.deleted";
|
|
61
|
+
readonly OrganizationFeatureChanged: "organization.feature_changed";
|
|
62
|
+
readonly OrganizationFeatureDataPurged: "organization.feature_data_purged";
|
|
63
|
+
readonly PartnerApproved: "partner.approved";
|
|
64
|
+
readonly PartnerEarningApproved: "partner_earning.approved";
|
|
65
|
+
readonly PartnerPayoutPaid: "partner_payout.paid";
|
|
66
|
+
readonly PartnerRewardApplied: "partner_reward.applied";
|
|
67
|
+
readonly PartnerRewardApproved: "partner_reward.approved";
|
|
68
|
+
readonly PartnerRewardRemoved: "partner_reward.removed";
|
|
69
|
+
readonly PartnerRewardReversed: "partner_reward.reversed";
|
|
70
|
+
readonly PaymentNotConfirmed: "payment.not_confirmed";
|
|
71
|
+
readonly PaymentRefunded: "payment.refunded";
|
|
72
|
+
readonly PaymentRejected: "payment.rejected";
|
|
73
|
+
readonly PaymentVerified: "payment.verified";
|
|
74
|
+
readonly PersonDeviceChanged: "person.device_changed";
|
|
75
|
+
readonly PrivacyRequestCompleted: "privacy.request_completed";
|
|
76
|
+
readonly ReceiptIssued: "receipt.issued";
|
|
77
|
+
readonly ReferralCreated: "referral.created";
|
|
78
|
+
readonly ReferralDisqualified: "referral.disqualified";
|
|
79
|
+
readonly ReferralHolding: "referral.holding";
|
|
80
|
+
readonly ReferralQualified: "referral.qualified";
|
|
81
|
+
readonly ReferralRefereeUninstalled: "referral.referee_uninstalled";
|
|
82
|
+
readonly ReferralRejected: "referral.rejected";
|
|
83
|
+
readonly ReferralStepCompleted: "referral.step_completed";
|
|
84
|
+
readonly ReferrerBlocked: "referrer.blocked";
|
|
85
|
+
readonly ReferrerCreated: "referrer.created";
|
|
86
|
+
readonly ReferrerQualityChanged: "referrer.quality_changed";
|
|
87
|
+
readonly ReferrerUnblocked: "referrer.unblocked";
|
|
88
|
+
readonly SaleMatched: "sale.matched";
|
|
89
|
+
readonly SaleRefunded: "sale.refunded";
|
|
90
|
+
readonly SkanPostbackReceived: "skan.postback_received";
|
|
91
|
+
readonly SubscriptionActivated: "subscription.activated";
|
|
92
|
+
readonly SubscriptionCancelled: "subscription.cancelled";
|
|
93
|
+
readonly SubscriptionChanged: "subscription.changed";
|
|
94
|
+
readonly SubscriptionExpired: "subscription.expired";
|
|
95
|
+
readonly SubscriptionGraceStarted: "subscription.grace_started";
|
|
96
|
+
readonly SubscriptionRenewed: "subscription.renewed";
|
|
97
|
+
readonly SubscriptionTrialConverted: "subscription.trial_converted";
|
|
98
|
+
readonly SubscriptionTrialEnded: "subscription.trial_ended";
|
|
99
|
+
readonly SubscriptionTrialExtended: "subscription.trial_extended";
|
|
100
|
+
readonly SubscriptionTrialStarted: "subscription.trial_started";
|
|
101
|
+
readonly SubscriptionUpdated: "subscription.updated";
|
|
102
|
+
readonly UsageThresholdReached: "usage.threshold_reached";
|
|
103
|
+
readonly WebhookTest: "webhook.test";
|
|
104
|
+
readonly WebhookEndpointDisabled: "webhook_endpoint.disabled";
|
|
105
|
+
readonly WhatsappConversationAttributed: "whatsapp.conversation_attributed";
|
|
106
|
+
};
|
|
107
|
+
/** A webhook event type this SDK release knows (`event.type` may also be a newer one). */
|
|
108
|
+
export type EventTypeValue = (typeof EventType)[keyof typeof EventType];
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every webhook event type the API sends (SPEC 29.1), as constants holding the wire string.
|
|
3
|
+
* `event.type` stays a plain string, so a type added later is never an error.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* if (event.type === EventType.ReferralQualified) { … }
|
|
7
|
+
*/
|
|
8
|
+
export const EventType = {
|
|
9
|
+
AbTestLikelyWinner: 'ab_test.likely_winner',
|
|
10
|
+
AlertResolved: 'alert.resolved',
|
|
11
|
+
AlertTriggered: 'alert.triggered',
|
|
12
|
+
AppPushCredentialsInvalid: 'app.push_credentials_invalid',
|
|
13
|
+
AppReengaged: 'app.reengaged',
|
|
14
|
+
AppBannerPaused: 'app_banner.paused',
|
|
15
|
+
AppBannerPublished: 'app_banner.published',
|
|
16
|
+
CampaignPaused: 'campaign.paused',
|
|
17
|
+
CampaignResumed: 'campaign.resumed',
|
|
18
|
+
ChallengeCancelled: 'challenge.cancelled',
|
|
19
|
+
ChallengeEnded: 'challenge.ended',
|
|
20
|
+
ChallengeFinalized: 'challenge.finalized',
|
|
21
|
+
ChallengeScheduled: 'challenge.scheduled',
|
|
22
|
+
ChallengeStarted: 'challenge.started',
|
|
23
|
+
ClickCreated: 'click.created',
|
|
24
|
+
CodeRedeemed: 'code.redeemed',
|
|
25
|
+
ConversionAttributed: 'conversion.attributed',
|
|
26
|
+
ConversionReversed: 'conversion.reversed',
|
|
27
|
+
ConversionUnattributed: 'conversion.unattributed',
|
|
28
|
+
CreditNoteIssued: 'credit_note.issued',
|
|
29
|
+
DomainGroupChanged: 'domain.group_changed',
|
|
30
|
+
DomainSettingsUpdated: 'domain.settings_updated',
|
|
31
|
+
DomainStatusChanged: 'domain.status_changed',
|
|
32
|
+
FraudInstallFlagged: 'fraud.install_flagged',
|
|
33
|
+
FunnelStuck: 'funnel.stuck',
|
|
34
|
+
GoalCompleted: 'goal.completed',
|
|
35
|
+
GoalReversed: 'goal.reversed',
|
|
36
|
+
IdentityDuplicateDetected: 'identity.duplicate_detected',
|
|
37
|
+
InstallAttributed: 'install.attributed',
|
|
38
|
+
InstallAttributionUpdated: 'install.attribution_updated',
|
|
39
|
+
InstallOrganic: 'install.organic',
|
|
40
|
+
InstallUninstallReverted: 'install.uninstall_reverted',
|
|
41
|
+
InstallUninstalled: 'install.uninstalled',
|
|
42
|
+
InvoiceIssued: 'invoice.issued',
|
|
43
|
+
InvoicePaid: 'invoice.paid',
|
|
44
|
+
InvoiceVoided: 'invoice.voided',
|
|
45
|
+
JobCompleted: 'job.completed',
|
|
46
|
+
LeaderboardPeriodClosed: 'leaderboard.period_closed',
|
|
47
|
+
LeaderboardPeriodFinalized: 'leaderboard.period_finalized',
|
|
48
|
+
LeaderboardRankChanged: 'leaderboard.rank_changed',
|
|
49
|
+
LeaderboardTargetReached: 'leaderboard.target_reached',
|
|
50
|
+
LeaderboardTargetRevoked: 'leaderboard.target_revoked',
|
|
51
|
+
LinkArchived: 'link.archived',
|
|
52
|
+
LinkCreated: 'link.created',
|
|
53
|
+
LinkDestinationChanged: 'link.destination_changed',
|
|
54
|
+
LinkExpired: 'link.expired',
|
|
55
|
+
LinkFlagged: 'link.flagged',
|
|
56
|
+
LinkPaused: 'link.paused',
|
|
57
|
+
LinkResumed: 'link.resumed',
|
|
58
|
+
LinkStatsHourly: 'link.stats.hourly',
|
|
59
|
+
LinkUpdated: 'link.updated',
|
|
60
|
+
OrganizationDeleted: 'organization.deleted',
|
|
61
|
+
OrganizationFeatureChanged: 'organization.feature_changed',
|
|
62
|
+
OrganizationFeatureDataPurged: 'organization.feature_data_purged',
|
|
63
|
+
PartnerApproved: 'partner.approved',
|
|
64
|
+
PartnerEarningApproved: 'partner_earning.approved',
|
|
65
|
+
PartnerPayoutPaid: 'partner_payout.paid',
|
|
66
|
+
PartnerRewardApplied: 'partner_reward.applied',
|
|
67
|
+
PartnerRewardApproved: 'partner_reward.approved',
|
|
68
|
+
PartnerRewardRemoved: 'partner_reward.removed',
|
|
69
|
+
PartnerRewardReversed: 'partner_reward.reversed',
|
|
70
|
+
PaymentNotConfirmed: 'payment.not_confirmed',
|
|
71
|
+
PaymentRefunded: 'payment.refunded',
|
|
72
|
+
PaymentRejected: 'payment.rejected',
|
|
73
|
+
PaymentVerified: 'payment.verified',
|
|
74
|
+
PersonDeviceChanged: 'person.device_changed',
|
|
75
|
+
PrivacyRequestCompleted: 'privacy.request_completed',
|
|
76
|
+
ReceiptIssued: 'receipt.issued',
|
|
77
|
+
ReferralCreated: 'referral.created',
|
|
78
|
+
ReferralDisqualified: 'referral.disqualified',
|
|
79
|
+
ReferralHolding: 'referral.holding',
|
|
80
|
+
ReferralQualified: 'referral.qualified',
|
|
81
|
+
ReferralRefereeUninstalled: 'referral.referee_uninstalled',
|
|
82
|
+
ReferralRejected: 'referral.rejected',
|
|
83
|
+
ReferralStepCompleted: 'referral.step_completed',
|
|
84
|
+
ReferrerBlocked: 'referrer.blocked',
|
|
85
|
+
ReferrerCreated: 'referrer.created',
|
|
86
|
+
ReferrerQualityChanged: 'referrer.quality_changed',
|
|
87
|
+
ReferrerUnblocked: 'referrer.unblocked',
|
|
88
|
+
SaleMatched: 'sale.matched',
|
|
89
|
+
SaleRefunded: 'sale.refunded',
|
|
90
|
+
SkanPostbackReceived: 'skan.postback_received',
|
|
91
|
+
SubscriptionActivated: 'subscription.activated',
|
|
92
|
+
SubscriptionCancelled: 'subscription.cancelled',
|
|
93
|
+
SubscriptionChanged: 'subscription.changed',
|
|
94
|
+
SubscriptionExpired: 'subscription.expired',
|
|
95
|
+
SubscriptionGraceStarted: 'subscription.grace_started',
|
|
96
|
+
SubscriptionRenewed: 'subscription.renewed',
|
|
97
|
+
SubscriptionTrialConverted: 'subscription.trial_converted',
|
|
98
|
+
SubscriptionTrialEnded: 'subscription.trial_ended',
|
|
99
|
+
SubscriptionTrialExtended: 'subscription.trial_extended',
|
|
100
|
+
SubscriptionTrialStarted: 'subscription.trial_started',
|
|
101
|
+
SubscriptionUpdated: 'subscription.updated',
|
|
102
|
+
UsageThresholdReached: 'usage.threshold_reached',
|
|
103
|
+
WebhookTest: 'webhook.test',
|
|
104
|
+
WebhookEndpointDisabled: 'webhook_endpoint.disabled',
|
|
105
|
+
WhatsappConversationAttributed: 'whatsapp.conversation_attributed',
|
|
106
|
+
};
|
package/dist/esm/express.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Express / Connect middleware: keeps the click ID (SPEC section 17).
|
|
2
|
+
* Express / Connect middleware: keeps the click ID and reads the app's `Clikgate-Installation` header (SPEC section 17).
|
|
3
3
|
*
|
|
4
4
|
* @example
|
|
5
5
|
* import express from 'express';
|
|
@@ -12,16 +12,25 @@
|
|
|
12
12
|
* app.post('/signup', (req, res) => {
|
|
13
13
|
* const clickId = req.clikgate.clickId; // save it with the application
|
|
14
14
|
* });
|
|
15
|
+
* app.post('/login', async (req, res) => {
|
|
16
|
+
* const user = await signIn(req.body); // your own sign-in check first
|
|
17
|
+
* if (req.clikgate.installation) {
|
|
18
|
+
* await clikgate.identifyUser({ installation: req.clikgate.installation, customerId: user.id });
|
|
19
|
+
* }
|
|
20
|
+
* });
|
|
15
21
|
*
|
|
16
22
|
* @packageDocumentation
|
|
17
23
|
*/
|
|
18
24
|
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
19
25
|
import { type PersistOptions } from './click-ids.js';
|
|
20
26
|
import type { Clikgate } from './client.js';
|
|
27
|
+
import { type Installation } from './installation.js';
|
|
21
28
|
/** What the middleware puts on the request. */
|
|
22
29
|
export interface ClikgateRequestContext {
|
|
23
30
|
/** The click ID from the query, the `_cg_<param>` cookie or the `Clikgate-Click-Id` header; `null` when there is none. */
|
|
24
31
|
clickId: string | null;
|
|
32
|
+
/** The app installation from the `Clikgate-Installation` header; `null` when it is missing or invalid. */
|
|
33
|
+
installation: Installation | null;
|
|
25
34
|
}
|
|
26
35
|
declare global {
|
|
27
36
|
namespace Express {
|
|
@@ -38,7 +47,7 @@ export interface ClikgateMiddlewareOptions extends PersistOptions {
|
|
|
38
47
|
}
|
|
39
48
|
type Next = (err?: unknown) => void;
|
|
40
49
|
/**
|
|
41
|
-
* Express/Connect middleware: sets `req.clikgate.clickId`, and stores a click ID that arrives in
|
|
50
|
+
* Express/Connect middleware: sets `req.clikgate.clickId` and `req.clikgate.installation`, and stores a click ID that arrives in
|
|
42
51
|
* the query string in the first-party `_cg_<param>` cookie. Pass the client so the organisation's
|
|
43
52
|
* click-ID parameter is used; without it, `cgid`.
|
|
44
53
|
*
|
package/dist/esm/express.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { clickIds as defaultClickIds } from './click-ids.js';
|
|
2
|
+
import { installationFromRequest } from './installation.js';
|
|
2
3
|
/** @internal Shared by the add-ons: read, expose and (optionally) persist the click ID. */
|
|
3
4
|
export function captureClickId(helpers, req, res, options) {
|
|
4
5
|
const clickId = helpers.fromRequest(req);
|
|
@@ -12,7 +13,7 @@ export function captureClickId(helpers, req, res, options) {
|
|
|
12
13
|
return clickId;
|
|
13
14
|
}
|
|
14
15
|
/**
|
|
15
|
-
* Express/Connect middleware: sets `req.clikgate.clickId`, and stores a click ID that arrives in
|
|
16
|
+
* Express/Connect middleware: sets `req.clikgate.clickId` and `req.clikgate.installation`, and stores a click ID that arrives in
|
|
16
17
|
* the query string in the first-party `_cg_<param>` cookie. Pass the client so the organisation's
|
|
17
18
|
* click-ID parameter is used; without it, `cgid`.
|
|
18
19
|
*
|
|
@@ -30,7 +31,7 @@ export function clikgateMiddleware(client, options = {}) {
|
|
|
30
31
|
void client.config().catch(() => undefined);
|
|
31
32
|
}
|
|
32
33
|
const clickId = captureClickId(helpers, req, res, options);
|
|
33
|
-
req.clikgate = { clickId };
|
|
34
|
+
req.clikgate = { clickId, installation: installationFromRequest(req) };
|
|
34
35
|
next();
|
|
35
36
|
}
|
|
36
37
|
catch (err) {
|
package/dist/esm/fastify.d.ts
CHANGED
|
@@ -18,10 +18,13 @@
|
|
|
18
18
|
import type { FastifyPluginAsync } from 'fastify';
|
|
19
19
|
import { type PersistOptions } from './click-ids.js';
|
|
20
20
|
import type { Clikgate } from './client.js';
|
|
21
|
+
import { type Installation } from './installation.js';
|
|
21
22
|
/** What the plugin puts on the request. */
|
|
22
23
|
export interface ClikgateRequestContext {
|
|
23
24
|
/** The click ID, or `null`. */
|
|
24
25
|
clickId: string | null;
|
|
26
|
+
/** The app installation from the `Clikgate-Installation` header; `null` when it is missing or invalid. */
|
|
27
|
+
installation: Installation | null;
|
|
25
28
|
}
|
|
26
29
|
declare module 'fastify' {
|
|
27
30
|
interface FastifyRequest {
|
|
@@ -37,7 +40,7 @@ export interface ClikgatePluginOptions extends PersistOptions {
|
|
|
37
40
|
persist?: boolean;
|
|
38
41
|
}
|
|
39
42
|
/**
|
|
40
|
-
* Fastify plugin: sets `request.clikgate.clickId` and keeps a click ID from the query string in the
|
|
43
|
+
* Fastify plugin: sets `request.clikgate.clickId` and `request.clikgate.installation`, and keeps a click ID from the query string in the
|
|
41
44
|
* `_cg_<param>` cookie.
|
|
42
45
|
*
|
|
43
46
|
* @example
|
package/dist/esm/fastify.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { clickIds as defaultClickIds } from './click-ids.js';
|
|
2
|
+
import { installationFromRequest } from './installation.js';
|
|
2
3
|
const plugin = async (fastify, options) => {
|
|
3
4
|
const { client, persist, ...cookie } = options;
|
|
4
5
|
const helpers = client ? client.clickIds : defaultClickIds;
|
|
@@ -8,7 +9,7 @@ const plugin = async (fastify, options) => {
|
|
|
8
9
|
fastify.decorateRequest('clikgate', null);
|
|
9
10
|
fastify.addHook('onRequest', async (request, reply) => {
|
|
10
11
|
const clickId = helpers.fromRequest({ url: request.url, headers: request.headers });
|
|
11
|
-
request.clikgate = { clickId };
|
|
12
|
+
request.clikgate = { clickId, installation: installationFromRequest(request) };
|
|
12
13
|
if (clickId && persist !== false) {
|
|
13
14
|
const url = new URL(request.url, 'http://localhost');
|
|
14
15
|
if (url.searchParams.getAll(helpers.paramName).includes(clickId))
|
|
@@ -22,7 +23,7 @@ meta[Symbol.for('skip-override')] = true;
|
|
|
22
23
|
meta[Symbol.for('fastify.display-name')] = '@clikgate/node/fastify';
|
|
23
24
|
meta[Symbol.for('plugin-meta')] = { name: '@clikgate/node/fastify', fastify: '>=5' };
|
|
24
25
|
/**
|
|
25
|
-
* Fastify plugin: sets `request.clikgate.clickId` and keeps a click ID from the query string in the
|
|
26
|
+
* Fastify plugin: sets `request.clikgate.clickId` and `request.clikgate.installation`, and keeps a click ID from the query string in the
|
|
26
27
|
* `_cg_<param>` cookie.
|
|
27
28
|
*
|
|
28
29
|
* @example
|