@walkeros/web-destination-api 4.7.0 → 4.7.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/CHANGELOG.md +13 -0
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/walkerOS.json +7 -7
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @walkeros/web-destination-api
|
|
2
2
|
|
|
3
|
+
## 4.7.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0635330: The ESM build no longer contains its own copy of `@walkeros/core` and
|
|
8
|
+
`@walkeros/web-core`, so bundles that use it are smaller.
|
|
9
|
+
- Updated dependencies [91e9aeb]
|
|
10
|
+
- Updated dependencies [0635330]
|
|
11
|
+
- Updated dependencies [91e9aeb]
|
|
12
|
+
- Updated dependencies [0635330]
|
|
13
|
+
- @walkeros/web-core@4.7.1
|
|
14
|
+
- @walkeros/core@4.7.1
|
|
15
|
+
|
|
3
16
|
## 4.7.0
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{isDefined as t}from"@walkeros/core";import{sendWeb as r}from"@walkeros/web-core";var e={};function n(t,r,e){const{url:n,headers:s,method:o,transport:i="fetch"}=r;e(n,t,{headers:s,method:o,transport:i})}var s={type:"api",config:{},init({config:t,logger:r}){const{url:e}=t.settings||{};e||r.throw("Config settings url missing")},push(e,{config:s,rule:o,data:i,env:a,logger:c}){const{settings:u}=s,{url:g,transform:f}=u||{};if(!g)return void c.throw("Config settings url missing");const l=t(i)?i:e,d=f?f(l,s,o):JSON.stringify(l),p=function(t,r){var e;const n=null==(e=t.source)?void 0:e.trace,{id:s}=t,o=r&&Object.keys(r).some(t=>"traceparent"===t.toLowerCase());return n&&s&&!o?{...r,traceparent:`00-${n}-${s}-01`}:r}(e,null==u?void 0:u.headers);n(d,{...u,url:g,headers:p},a.sendWeb||r)},pushBatch(e,{config:s,rule:o,env:i,logger:a}){const{settings:c}=s,{url:u,transform:g}=c||{};if(!u)return void a.throw("Config settings url missing");const f=e.entries.map(r=>t(r.data)?r.data:r.event),l=g?f.map(t=>function(t){if("string"!=typeof t)return t;try{const r=JSON.parse(t);return"object"==typeof r&&null!==r?r:t}catch(r){return t}}(g(t,s,o))):f;n(JSON.stringify(l),{...c,url:u},i.sendWeb||r)}},o=s;export{e as DestinationAPI,o as default,s as destinationAPI};//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/types/index.ts"],"sourcesContent":["import type { SendDataValue, SendHeaders, WalkerOS } from '@walkeros/core';\nimport type { Settings, Destination } from './types';\nimport { isDefined } from '@walkeros/core';\nimport { sendWeb } from '@walkeros/web-core';\n\n// Types\nexport * as DestinationAPI from './types';\n\n/**\n * Adds a W3C `traceparent` header built from the event's trace id and span id\n * so the receiving collector can stitch the span across the wire. Emission is\n * best-effort and unconditional on presence: values are passed through verbatim\n * (a malformed id yields a header the strict server-side parser rejects, which\n * is intended). A user-configured `traceparent` always wins; header names are\n * case-insensitive on the wire, so the check matches any casing.\n */\nfunction withTraceparent(\n event: WalkerOS.Event,\n headers?: SendHeaders,\n): SendHeaders | undefined {\n const trace = event.source?.trace;\n const { id } = event;\n const userSet =\n headers &&\n Object.keys(headers).some((key) => key.toLowerCase() === 'traceparent');\n if (!trace || !id || userSet) return headers;\n\n return { ...headers, traceparent: `00-${trace}-${id}-01` };\n}\n\nfunction send(\n body: SendDataValue,\n settings: Settings,\n sendWebFn: typeof sendWeb,\n): void {\n const { url, headers, method, transport = 'fetch' } = settings;\n sendWebFn(url, body, { headers, method, transport });\n}\n\n/** A transformed body as a batch item: JSON object or array text becomes its value. */\nfunction fromBody(body: SendDataValue): unknown {\n if (typeof body !== 'string') return body;\n try {\n const parsed: unknown = JSON.parse(body);\n return typeof parsed === 'object' && parsed !== null ? parsed : body;\n } catch {\n return body;\n }\n}\n\nexport const destinationAPI: Destination = {\n type: 'api',\n\n config: {},\n\n init({ config, logger }) {\n const { url } = config.settings || {};\n if (!url) logger.throw('Config settings url missing');\n },\n\n push(event, { config, rule, data, env, logger }) {\n const { settings } = config;\n const { url, transform } = settings || {};\n\n if (!url) {\n logger.throw('Config settings url missing');\n return;\n }\n\n const eventData = isDefined(data) ? data : event;\n // Transform returns body directly, otherwise stringify\n const body = transform\n ? transform(eventData, config, rule)\n : JSON.stringify(eventData);\n\n const headers = withTraceparent(event, settings?.headers);\n\n send(body, { ...settings, url, headers }, env.sendWeb || sendWeb);\n },\n\n pushBatch(batch, { config, rule, env, logger }) {\n const { settings } = config;\n const { url, transform } = settings || {};\n\n if (!url) {\n logger.throw('Config settings url missing');\n return;\n }\n\n const items = batch.entries.map((e) =>\n isDefined(e.data) ? e.data : e.event,\n );\n\n // Apply transform to each item if defined, then stringify the array. A\n // transform returns one serialized body, so a JSON string joins the array\n // as its value instead of as an escaped string.\n const payload = transform\n ? items.map((item) => fromBody(transform(item, config, rule)))\n : items;\n\n // No traceparent here: a batch may aggregate events from distinct\n // upstream traces, so there is no single identity to stamp. Per-event\n // correlation is emitted on the non-batched push path only.\n send(JSON.stringify(payload), { ...settings, url }, env.sendWeb || sendWeb);\n },\n};\n\nexport default destinationAPI;\n","import type {\n Mapping as WalkerOSMapping,\n SendDataValue,\n SendHeaders,\n Destination as CoreDestination,\n} from '@walkeros/core';\nimport type { DestinationWeb, sendWeb } from '@walkeros/web-core';\nimport type { SendWebTransport } from '@walkeros/web-core';\n\nexport interface Settings {\n url: string;\n headers?: SendHeaders;\n method?: string;\n transform?: Transform;\n transport?: SendWebTransport;\n}\n\n// InitSettings: user input (all optional)\nexport type InitSettings = Partial<Settings>;\n\nexport interface Mapping {}\n\nexport interface Env extends DestinationWeb.Env {\n sendWeb?: typeof sendWeb;\n}\n\nexport type Types = CoreDestination.Types<Settings, Mapping, Env, InitSettings>;\n\nexport type Destination = DestinationWeb.Destination<Types>;\nexport type Config = DestinationWeb.Config<Types>;\n\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n\nexport type Transform = (\n data?: unknown,\n config?: Config,\n mapping?: WalkerOSMapping.Rule<Mapping>,\n) => SendDataValue;\n"],"mappings":";AAEA,SAAS,iBAAiB;AAC1B,SAAS,eAAe;;;ACHxB;;;ADgBA,SAAS,gBACP,OACA,SACyB;AAnB3B;AAoBE,QAAM,SAAQ,WAAM,WAAN,mBAAc;AAC5B,QAAM,EAAE,GAAG,IAAI;AACf,QAAM,UACJ,WACA,OAAO,KAAK,OAAO,EAAE,KAAK,CAAC,QAAQ,IAAI,YAAY,MAAM,aAAa;AACxE,MAAI,CAAC,SAAS,CAAC,MAAM,QAAS,QAAO;AAErC,SAAO,EAAE,GAAG,SAAS,aAAa,MAAM,KAAK,IAAI,EAAE,MAAM;AAC3D;AAEA,SAAS,KACP,MACA,UACA,WACM;AACN,QAAM,EAAE,KAAK,SAAS,QAAQ,YAAY,QAAQ,IAAI;AACtD,YAAU,KAAK,MAAM,EAAE,SAAS,QAAQ,UAAU,CAAC;AACrD;AAGA,SAAS,SAAS,MAA8B;AAC9C,MAAI,OAAO,SAAS,SAAU,QAAO;AACrC,MAAI;AACF,UAAM,SAAkB,KAAK,MAAM,IAAI;AACvC,WAAO,OAAO,WAAW,YAAY,WAAW,OAAO,SAAS;AAAA,EAClE,SAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEO,IAAM,iBAA8B;AAAA,EACzC,MAAM;AAAA,EAEN,QAAQ,CAAC;AAAA,EAET,KAAK,EAAE,QAAQ,OAAO,GAAG;AACvB,UAAM,EAAE,IAAI,IAAI,OAAO,YAAY,CAAC;AACpC,QAAI,CAAC,IAAK,QAAO,MAAM,6BAA6B;AAAA,E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7
|
"web"
|
|
@@ -154,7 +154,7 @@
|
|
|
154
154
|
"consent": {
|
|
155
155
|
"functional": true
|
|
156
156
|
},
|
|
157
|
-
"id": "
|
|
157
|
+
"id": "7787a450835faed0",
|
|
158
158
|
"trigger": "load",
|
|
159
159
|
"entity": "order",
|
|
160
160
|
"action": "complete",
|
|
@@ -187,7 +187,7 @@
|
|
|
187
187
|
"{\"order_id\":\"0rd3r1d\",\"amount\":555,\"tax\":73.76,\"shipping_cost\":5.22,\"currency\":\"EUR\",\"event_name\":\"order complete\",\"user_id\":\"us3r\"}",
|
|
188
188
|
{
|
|
189
189
|
"headers": {
|
|
190
|
-
"traceparent": "00-0a1b2c3d4e5f60718293a4b5c6d7e8f9-
|
|
190
|
+
"traceparent": "00-0a1b2c3d4e5f60718293a4b5c6d7e8f9-7787a450835faed0-01"
|
|
191
191
|
},
|
|
192
192
|
"transport": "fetch"
|
|
193
193
|
}
|
|
@@ -237,7 +237,7 @@
|
|
|
237
237
|
"consent": {
|
|
238
238
|
"functional": true
|
|
239
239
|
},
|
|
240
|
-
"id": "
|
|
240
|
+
"id": "e446c605e76f7214",
|
|
241
241
|
"trigger": "test",
|
|
242
242
|
"entity": "entity",
|
|
243
243
|
"action": "action",
|
|
@@ -260,7 +260,7 @@
|
|
|
260
260
|
"{\"string\":\"foo\",\"number\":1,\"boolean\":true,\"array\":[0,\"text\",false]}",
|
|
261
261
|
{
|
|
262
262
|
"headers": {
|
|
263
|
-
"traceparent": "00-0a1b2c3d4e5f60718293a4b5c6d7e8f9-
|
|
263
|
+
"traceparent": "00-0a1b2c3d4e5f60718293a4b5c6d7e8f9-e446c605e76f7214-01"
|
|
264
264
|
},
|
|
265
265
|
"transport": "fetch"
|
|
266
266
|
}
|
|
@@ -308,7 +308,7 @@
|
|
|
308
308
|
"consent": {
|
|
309
309
|
"functional": true
|
|
310
310
|
},
|
|
311
|
-
"id": "
|
|
311
|
+
"id": "4e9592f7a654f0ce",
|
|
312
312
|
"trigger": "load",
|
|
313
313
|
"entity": "page",
|
|
314
314
|
"action": "view",
|
|
@@ -331,7 +331,7 @@
|
|
|
331
331
|
"{\"domain\":\"www.example.com\",\"title\":\"walkerOS documentation\",\"referrer\":\"https://www.walkeros.io/\",\"search\":\"?foo=bar\",\"hash\":\"#hash\",\"id\":\"/docs/\"}",
|
|
332
332
|
{
|
|
333
333
|
"headers": {
|
|
334
|
-
"traceparent": "00-0a1b2c3d4e5f60718293a4b5c6d7e8f9-
|
|
334
|
+
"traceparent": "00-0a1b2c3d4e5f60718293a4b5c6d7e8f9-4e9592f7a654f0ce-01"
|
|
335
335
|
},
|
|
336
336
|
"transport": "fetch"
|
|
337
337
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@walkeros/web-destination-api",
|
|
3
3
|
"description": "Web API destination for walkerOS",
|
|
4
|
-
"version": "4.7.
|
|
4
|
+
"version": "4.7.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.mjs",
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
"update": "npx npm-check-updates -u && npm update"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@walkeros/core": "4.7.
|
|
42
|
-
"@walkeros/web-core": "4.7.
|
|
41
|
+
"@walkeros/core": "4.7.1",
|
|
42
|
+
"@walkeros/web-core": "4.7.1"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@walkeros/collector": "4.7.
|
|
45
|
+
"@walkeros/collector": "4.7.1"
|
|
46
46
|
},
|
|
47
47
|
"repository": {
|
|
48
48
|
"url": "git+https://github.com/elbwalker/walkerOS.git",
|