@jitsu/protocols 1.9.7-canary.903.20240731114701 → 1.9.8
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/analytics.d.ts +106 -1
- package/package.json +1 -1
package/analytics.d.ts
CHANGED
|
@@ -215,6 +215,11 @@ interface AnalyticsContext {
|
|
|
215
215
|
amp?: {
|
|
216
216
|
id: string;
|
|
217
217
|
};
|
|
218
|
+
|
|
219
|
+
consent?: {
|
|
220
|
+
categoryPreferences?: Record<string, any>;
|
|
221
|
+
};
|
|
222
|
+
|
|
218
223
|
/**
|
|
219
224
|
* Other tracking tools client ids
|
|
220
225
|
*/
|
|
@@ -281,6 +286,102 @@ export type DispatchedEvent = Context;
|
|
|
281
286
|
|
|
282
287
|
export type Callback = (ctx: Context | undefined) => Promise<unknown> | unknown;
|
|
283
288
|
|
|
289
|
+
type PersistentStorage = {
|
|
290
|
+
getItem: (key: string, options?: any) => any;
|
|
291
|
+
setItem: (key: string, value: any, options?: any) => void;
|
|
292
|
+
removeItem: (key: string, options?: any) => void;
|
|
293
|
+
reset: () => void;
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
export type RuntimeFacade = {
|
|
297
|
+
store(): PersistentStorage;
|
|
298
|
+
userAgent(): string | undefined;
|
|
299
|
+
language(): string | undefined;
|
|
300
|
+
pageUrl(): string | undefined;
|
|
301
|
+
documentEncoding(): string | undefined;
|
|
302
|
+
getCookie(name: string): string | undefined;
|
|
303
|
+
getCookies(): Record<string, string>;
|
|
304
|
+
|
|
305
|
+
timezoneOffset(): number | undefined;
|
|
306
|
+
screen():
|
|
307
|
+
| {
|
|
308
|
+
width: number;
|
|
309
|
+
height: number;
|
|
310
|
+
innerWidth: number;
|
|
311
|
+
innerHeight: number;
|
|
312
|
+
density: number;
|
|
313
|
+
}
|
|
314
|
+
| undefined;
|
|
315
|
+
referrer(): string | undefined;
|
|
316
|
+
pageTitle(): string | undefined;
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
export type JitsuOptions = {
|
|
320
|
+
/**
|
|
321
|
+
* API Key. Optional. If not set, Jitsu will send event to the server without auth, and server
|
|
322
|
+
* will link the call to configured source by domain name
|
|
323
|
+
*/
|
|
324
|
+
writeKey?: string;
|
|
325
|
+
/**
|
|
326
|
+
* API Host. Default value: same host as script origin
|
|
327
|
+
*/
|
|
328
|
+
host?: string;
|
|
329
|
+
/**
|
|
330
|
+
* To enable debug logging
|
|
331
|
+
*/
|
|
332
|
+
debug?: boolean;
|
|
333
|
+
/**
|
|
334
|
+
* Explicitly specify cookie domain. If not set, cookie domain will be set to top level
|
|
335
|
+
* of the current domain. Example: if JS lives on "app.example.com", cookie domain will be
|
|
336
|
+
* set to ".example.com". If it lives on "example.com", cookie domain will be set to ".example.com" too
|
|
337
|
+
*/
|
|
338
|
+
cookieDomain?: string;
|
|
339
|
+
/**
|
|
340
|
+
* Provide fetch implementation. It is required if you want to use Jitsu in NodeJS
|
|
341
|
+
*/
|
|
342
|
+
fetch?: typeof fetch;
|
|
343
|
+
/**
|
|
344
|
+
* Which runtime to use. Runtime is used for obtaining context of the event: cookies,
|
|
345
|
+
* url, etc. At the moment, Jitsu supports browser runtime and NodeJS runtime, but you
|
|
346
|
+
* can provide your own implementation.
|
|
347
|
+
*
|
|
348
|
+
* If it's not set, the runtime will be detected automatically by presence of `window` object
|
|
349
|
+
*/
|
|
350
|
+
runtime?: RuntimeFacade;
|
|
351
|
+
/**
|
|
352
|
+
* If set to true, jitsu will output events in console. In this case you don't need to set
|
|
353
|
+
* writeKey / host. It's useful for debugging development environment
|
|
354
|
+
*/
|
|
355
|
+
echoEvents?: boolean;
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* If true, events will go to s2s endpoints like ${host}/api/s/s2s/{type}. Otherwise, they'll go to ${host}/api/s/{type}.
|
|
359
|
+
*
|
|
360
|
+
*/
|
|
361
|
+
s2s?: boolean;
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Timeout for fetch requests. Default value: 5000
|
|
365
|
+
*/
|
|
366
|
+
fetchTimeoutMs?: number;
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* Endpoint that makes sure that Jitsu anonymousId cookie is set as server (httpOnly) cookie.
|
|
370
|
+
* Endpoint must be hosted on the same domain as the site where Jitsu code is installed.
|
|
371
|
+
* Required to overcome Safari ITP restrictions.
|
|
372
|
+
*/
|
|
373
|
+
idEndpoint?: string;
|
|
374
|
+
|
|
375
|
+
privacy?: {
|
|
376
|
+
dontSend?: boolean;
|
|
377
|
+
disableUserIds?: boolean;
|
|
378
|
+
ipPolicy?: "keep" | "remove" | "stripLastOctet";
|
|
379
|
+
consentCategories?: Record<string, boolean>;
|
|
380
|
+
};
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
export type DynamicJitsuOptions = Pick<JitsuOptions, "privacy" | "debug" | "echoEvents">;
|
|
384
|
+
|
|
284
385
|
export interface AnalyticsInterface {
|
|
285
386
|
track(
|
|
286
387
|
eventName: string | JSONObject,
|
|
@@ -310,7 +411,9 @@ export interface AnalyticsInterface {
|
|
|
310
411
|
|
|
311
412
|
user(): any;
|
|
312
413
|
|
|
313
|
-
setAnonymousId(id: string): void;
|
|
414
|
+
setAnonymousId(id: string | undefined): void;
|
|
415
|
+
|
|
416
|
+
configure(options: DynamicJitsuOptions): void;
|
|
314
417
|
|
|
315
418
|
// alias(
|
|
316
419
|
// to: string | number,
|
|
@@ -327,3 +430,5 @@ export interface AnalyticsInterface {
|
|
|
327
430
|
// callback?: Callback
|
|
328
431
|
// ): Promise<DispatchedEvent>;
|
|
329
432
|
}
|
|
433
|
+
|
|
434
|
+
export declare function jitsuAnalytics(opts: JitsuOptions): AnalyticsInterface;
|