@jitsu/protocols 1.3.2 → 1.6.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/analytics.d.ts CHANGED
@@ -152,8 +152,14 @@ interface AnalyticsContext {
152
152
  */
153
153
  clientIds?: {
154
154
  //Client ID of GA4 property
155
- ga4?: string;
156
- [key: string]: string;
155
+ ga4?: {
156
+ clientId: string;
157
+ sessions?: Record<string, string>;
158
+ };
159
+ //from cookies: _fbc - Facebook click ID, _fbp - Facebook browser ID.
160
+ //see https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/customer-information-parameters
161
+ fbc?: string;
162
+ fbp?: string;
157
163
  };
158
164
 
159
165
  [key: string]: any;
package/errors.d.ts ADDED
File without changes
package/functions.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  import { AnalyticsServerEvent } from "./analytics";
2
2
 
3
- export type SetOpts = { ttlMs?: number } | { ttlSec?: number };
3
+ /**
4
+ * Store set options: ttl in seconds or string representation of duration (e.g. "1d")
5
+ */
6
+ export type SetOpts = number | string | { ttl: number };
4
7
 
5
8
  /**
6
9
  * A key value store that exposed to a function
@@ -9,6 +12,7 @@ export interface Store {
9
12
  get(key: string): Promise<any>;
10
13
  del(key: string): Promise<void>;
11
14
  set(key: string, value: any, opts?: SetOpts): Promise<void>;
15
+ ttl(key: string): Promise<number>;
12
16
  }
13
17
 
14
18
  /**
@@ -77,15 +81,6 @@ export type AnonymousEventsStore = {
77
81
  evictEvents(collectionName: string, anonymousId: string): Promise<AnalyticsServerEvent[]>;
78
82
  };
79
83
 
80
- /**
81
- * Function execution context available for builin functions only
82
- */
83
- export type SystemContext = {
84
- $system: {
85
- anonymousEventsStore: AnonymousEventsStore;
86
- };
87
- };
88
-
89
84
  export type WithConfidence<T> = T & {
90
85
  //A value from 0-100 indicating how confident we are in the result
91
86
  confidence?: number;
@@ -154,11 +149,40 @@ export type Geo = {
154
149
  };
155
150
  };
156
151
 
152
+ export type UserAgent = {
153
+ browser: {
154
+ name: string;
155
+ version: string;
156
+ major: string; //@deprecated
157
+ };
158
+ engine: {
159
+ name: string;
160
+ version: string;
161
+ };
162
+ os: {
163
+ name: string;
164
+ version: string;
165
+ };
166
+ device: {
167
+ model: string;
168
+ type: "console" | "mobile" | "tablet" | "smarttv" | "wearable" | "embedded" | "desktop";
169
+ vendor: string;
170
+ };
171
+ cpu: {
172
+ architecture: string;
173
+ };
174
+ bot?: boolean;
175
+ };
176
+
157
177
  export type EventContext = {
158
178
  /**
159
179
  * Geo data of incoming request
160
180
  */
161
181
  geo?: Geo;
182
+ /**
183
+ * Parsed User Agent of incoming request
184
+ */
185
+ ua?: UserAgent;
162
186
  /**
163
187
  * Headers of incoming request
164
188
  */
@@ -166,18 +190,18 @@ export type EventContext = {
166
190
  /**
167
191
  * Source of the incoming event
168
192
  */
169
- source?: {
193
+ source: {
170
194
  id: string;
171
195
  name?: string;
172
196
  domain?: string;
173
197
  };
174
- destination?: {
198
+ destination: {
175
199
  id: string;
176
200
  type: string;
177
201
  updatedAt: Date;
178
202
  hash: string;
179
203
  };
180
- connection?: {
204
+ connection: {
181
205
  id: string;
182
206
  mode?: string;
183
207
  options?: any;
@@ -193,10 +217,7 @@ export type FunctionConfigContext<P extends AnyProps = AnyProps> = {
193
217
  /**
194
218
  * Parameters for a function
195
219
  */
196
- export type FullContext<P extends AnyProps = AnyProps> = EventContext &
197
- FunctionContext &
198
- FunctionConfigContext<P> &
199
- (SystemContext | {});
220
+ export type FullContext<P extends AnyProps = AnyProps> = EventContext & FunctionContext & FunctionConfigContext<P>;
200
221
 
201
222
  //equivalent to returning [] from a function
202
223
  export type FunctionCommand = "drop";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jitsu/protocols",
3
- "version": "1.3.2",
3
+ "version": "1.6.1",
4
4
  "description": "",
5
5
  "author": "Jitsu Dev Team <dev@jitsu.com>",
6
6
  "publishConfig": {