@jitsu/protocols 1.9.7-canary.903.20240731112148 → 1.9.7

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.
Files changed (2) hide show
  1. package/analytics.d.ts +107 -1
  2. 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,103 @@ 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
+ * If not set at all, it will be detected automatically by presence of `window` object
361
+ */
362
+ s2s?: boolean;
363
+
364
+ /**
365
+ * Timeout for fetch requests. Default value: 5000
366
+ */
367
+ fetchTimeoutMs?: number;
368
+
369
+ /**
370
+ * Endpoint that makes sure that Jitsu anonymousId cookie is set as server (httpOnly) cookie.
371
+ * Endpoint must be hosted on the same domain as the site where Jitsu code is installed.
372
+ * Required to overcome Safari ITP restrictions.
373
+ */
374
+ idEndpoint?: string;
375
+
376
+ privacy?: {
377
+ dontSend?: boolean;
378
+ disableUserIds?: boolean;
379
+ ipPolicy?: "keep" | "remove" | "stripLastOctet";
380
+ consentCategories?: Record<string, boolean>;
381
+ };
382
+ };
383
+
384
+ export type DynamicJitsuOptions = Pick<JitsuOptions, "privacy" | "debug" | "echoEvents">;
385
+
284
386
  export interface AnalyticsInterface {
285
387
  track(
286
388
  eventName: string | JSONObject,
@@ -310,7 +412,9 @@ export interface AnalyticsInterface {
310
412
 
311
413
  user(): any;
312
414
 
313
- setAnonymousId(id: string): void;
415
+ setAnonymousId(id: string | undefined): void;
416
+
417
+ configure(options: DynamicJitsuOptions): void;
314
418
 
315
419
  // alias(
316
420
  // to: string | number,
@@ -327,3 +431,5 @@ export interface AnalyticsInterface {
327
431
  // callback?: Callback
328
432
  // ): Promise<DispatchedEvent>;
329
433
  }
434
+
435
+ export declare function jitsuAnalytics(opts: JitsuOptions): AnalyticsInterface;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jitsu/protocols",
3
- "version": "1.9.7-canary.903.20240731112148",
3
+ "version": "1.9.7",
4
4
  "description": "",
5
5
  "author": "Jitsu Dev Team <dev@jitsu.com>",
6
6
  "publishConfig": {