@seeka-labs/sdk-apps-server-telemetry-core 2.2.4 → 2.2.6
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.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{fetch as
|
|
1
|
+
import{fetch as q,Headers as H}from"undici";import{jwtDecode as B}from"jwt-decode";import{getNewOrCachedAppInstallToken as G}from"@seeka-labs/sdk-apps-server";var P=new TextEncoder;function f(t){let e=t>>>0,n=[];for(;e>=128;)n.push(e&127|128),e>>>=7;return n.push(e),Uint8Array.from(n)}function A(t,e){let n=t<<3|e;return f(n)}function c(t,e){if(e==null)return[];let n=P.encode(e);return[A(t,2),f(n.length),n]}function a(t,e){return[A(t,2),f(e.length),e]}function R(t,e){if(e==null)return[];let n=new ArrayBuffer(8);return new DataView(n).setFloat64(0,e,!0),[A(t,1),new Uint8Array(n)]}function o(t){let e=t.filter(s=>s instanceof Uint8Array),n=e.reduce((s,u)=>s+u.length,0),r=new Uint8Array(n),i=0;for(let s of e)r.set(s,i),i+=s.length;return r}function V(t){if(!t)return new Uint8Array(0);let e;if("stringValue"in t&&typeof t.stringValue=="string")e=t.stringValue;else{let r=t.doubleValue??t.intValue??t.boolValue??t.bytesValue??t.arrayValue??t.kvlistValue;try{e=typeof r=="string"?r:JSON.stringify(r)}catch{e=String(r)}}let n=o(c(1,e));return n}function C(t){let e=[];return e.push(...c(1,t.key)),e.push(...a(2,V(t.value))),o(e)}function N(t){if(!t)return new Uint8Array(0);let e=[];for(let n of t.attributes??[])e.push(...a(1,C(n)));return o(e)}function w(t){let e=[];return t&&(e.push(...c(1,t.name)),e.push(...c(2,t.version))),o(e)}function D(t){let e=[];return e.push(...R(4,t.asDouble)),o(e)}function _(t){let e=[];for(let n of t.dataPoints??[])e.push(...a(1,D(n)));return o(e)}function K(t){let e=[];return e.push(...c(1,t.name)),e.push(...c(2,t.description)),e.push(...c(3,t.unit)),t.gauge&&e.push(...a(5,_(t.gauge))),o(e)}function L(t){let e=[];e.push(...a(1,w(t.scope)));for(let n of t.metrics??[])e.push(...a(2,K(n)));return o(e)}function O(t){let e=[];e.push(...a(1,N(t.resource)));for(let n of t.scopeMetrics??[])e.push(...a(2,L(n)));return o(e)}function x(t){let e=[];for(let n of t.resourceMetrics??[]){let r=O(n);e.push(...a(1,r))}return o(e)}var b=t=>{let e=r=>String(r).padStart(2,"0"),n=r=>String(r).padStart(3,"0");return t.getUTCFullYear()+"-"+e(t.getUTCMonth()+1)+"-"+e(t.getUTCDate())+"T"+e(t.getUTCHours())+":"+e(t.getUTCMinutes())+":"+e(t.getUTCSeconds())+"."+n(t.getUTCMilliseconds())};import"winston";import{urls as T}from"@seeka-labs/sdk-apps-server";var E="seeka.tel",h=class{options;constructor(e){this.options=e}pushStr=(e,n,r)=>{n!=null&&r.push({key:`${E}.${e}`,value:{stringValue:String(n)}})};getStr(e,n){let r=`${E}.${e}`,i=n.find(s=>s.key===r);if(i?.value&&"stringValue"in i.value)return i.value.stringValue}sendEgressMetric=async(e,n)=>{let r=[],i=p=>{if(typeof p=="string")return p;try{return JSON.stringify(p??{})}catch{return'""'}},s=new Date;this.pushStr("type","record.activity.egress",r),this.pushStr("originActivityId",e.originActivityId,r),this.pushStr("occurredAt",b(e.occurredAt||s),r),this.pushStr("timestamp",b(s),r),this.pushStr("personId",e.personId,r),this.pushStr("originSessionIdentifier",e.originSessionIdentifier,r),this.pushStr("originDnsName",e.originDnsName,r),this.pushStr("destinationPlatformIdentifier",e.destinationPlatformIdentifier,r),this.pushStr("destinationPlatformEgressType",e.destinationPlatformEgressType,r),this.pushStr("destinationPlatformTypeKey",e.destinationPlatformTypeKey,r),this.pushStr("originActivityName",e.originActivityName,r),this.pushStr("originActivityNameCustom",e.originActivityNameCustom,r),this.pushStr("publishedPayload",i(e.publishedPayload),r),this.pushStr("egressQualityMetrics",i(e.egressQualityMetrics),r),this.pushStr("egressIdentityMetrics",i(e.egressIdentityMetrics),r);let u={resourceMetrics:[{resource:{attributes:r},scopeMetrics:[{scope:{name:"seeka.telemetry.apps-server-core",version:"0.0.0"},metrics:[{name:"record.activity.egress",description:"Activity egress record",unit:"1",gauge:{dataPoints:[{asDouble:1}]}}]}]}]};await this.sendMetric(u,n)};sendMetric=async(e,n)=>{let{telemetryEndpointUrl:r,logger:i,issuerUrl:s,appId:u,appSecret:p}=this.options;if(!e||!Array.isArray(e.resourceMetrics))throw new Error("SeekaTelemetry: metric must be an OTLP ExportMetricsServiceRequest with a resourceMetrics array");let U={appId:u,appSecret:p,issuerUrl:s,ingestUrl:r,applicationInstallId:n.appInstallId,logger:i,grantedPermissions:[],runtime:this.getRuntimeInfo()},m=await G(U);if(!m||!m.access_token)throw new Error("SeekaTelemetry: failed to get access token for install");let v=r.endsWith("/")?r:r+"/",I=new URL("v1/metrics",v).toString(),y=B(m.access_token),l=new H;l.set("Content-Type",this.options.protobuf?"application/x-protobuf":"application/json"),l.set("Accept",this.options.protobuf?"application/x-protobuf":"application/json"),l.set("Authorization",`Bearer ${m.access_token}`),l.set("X-OrgId",y.tenantid);let g=e.resourceMetrics[0]?.resource?.attributes||[];this.pushStr("tenantId",y.tenantid,g),this.pushStr("organisationBrandId",y.org_brand_id,g),this.getStr("type",g)==="record.activity.egress"&&this.pushStr("convergeInstanceId",y.converge_instance_id,g);let M=this.options.protobuf?x(e):JSON.stringify(e),d=await q(I,{method:"POST",headers:l,body:M});if(d.ok)i?.debug("SeekaTelemetry: metric send succeeded");else{let k=await d.text().catch(()=>""),S=`SeekaTelemetry: metric send failed with status ${d.status} ${d.statusText}`;throw i?.error(S,{body:k}),new Error(S)}};shutdown=async()=>{};getRuntimeInfo(){return{type:"sdk/js/apps-server-telemetry-core",ver:"0.0.0",client:{type:"server",ver:process.versions?.node||"unknown"}}}},ee=(t,e)=>new h({...t,appId:t?.appId||process.env.SEEKA_APP_ID,appSecret:t?.appSecret||process.env.SEEKA_APP_SECRET,telemetryEndpointUrl:t?.telemetryEndpointUrl||process.env.SEEKA_TELEMETRY_URL||T.defaultTelemetryUrl,issuerUrl:t?.issuerUrl||process.env.SEEKA_ISSUER_URL||T.defaultIssuerUrl,logger:e});var W=(r=>(r[r.AGGREGATION_TEMPORALITY_UNSPECIFIED=0]="AGGREGATION_TEMPORALITY_UNSPECIFIED",r[r.AGGREGATION_TEMPORALITY_DELTA=1]="AGGREGATION_TEMPORALITY_DELTA",r[r.AGGREGATION_TEMPORALITY_CUMULATIVE=2]="AGGREGATION_TEMPORALITY_CUMULATIVE",r))(W||{}),re=(t,e,n)=>({...e,...t,personId:n.personId,originActivityId:n.activity?.activityId,occurredAt:new Date,originActivityName:n.activity?.activityName,originActivityNameCustom:n.activity?.activityNameCustom,originSessionIdentifier:n.source?.sess,originDnsName:new URL(n.source?.loc||"").hostname.toLowerCase()});export{W as AggregationTemporality,re as createEgressTelemetryRecord,ee as createSeekaTelemetryClient,b as toIsoDateTime};
|
|
2
2
|
//# sourceMappingURL=sdk-apps-server-telemetry-core.module.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/client.ts", "../../src/otlpEncoder.ts", "../../src/helpers.ts", "../../src/models.ts"],
|
|
4
|
-
"sourcesContent": ["\uFEFF\n\n// We use undici's fetch for Node environments\nimport { fetch as undiciFetch, Headers as UndiciHeaders } from 'undici';\n// For safely requiring CJS modules from ESM (used under Jest)\n// import { createRequire } from 'node:module';\n\nimport {jwtDecode, type JwtPayload} from \"jwt-decode\";\n\n// OTLP metric types (type-safe input)\nimport {type AppRuntimeInfo, getNewOrCachedAppInstallToken} from \"@seeka-labs/sdk-apps-server\";\nimport type {\n ActivityEgressTelemetryRecord,\n ExportMetricsServiceRequest, KeyValue, SeekaTelemetryClientCore, SeekaTelemetryClientCoreOptions,\n SeekaTelemetryInstallContext\n} from \"./models.ts\";\nimport { encodeExportMetricsServiceRequestToProto } from './otlpEncoder.ts';\nimport {toIsoDateTime} from \"./helpers.ts\";\nimport * as winston from \"winston\";\nimport {urls} from \"@seeka-labs/sdk-apps-server\";\n\nconst attrPrefix = 'seeka.tel';\n\nclass SeekaTelemetryClientCoreImpl implements SeekaTelemetryClientCore {\n private readonly options: SeekaTelemetryClientCoreOptions;\n\n constructor(options: SeekaTelemetryClientCoreOptions) {\n this.options = options;\n }\n\n private pushStr = (key: string, value: string | undefined | null, attrs: KeyValue[]) => {\n if (value == null) return;\n attrs.push({ key: `${attrPrefix}.${key}`, value: { stringValue: String(value) } });\n };\n\n private getStr(key: string, attrs: KeyValue[]): string | undefined {\n const targetKey = `${attrPrefix}.${key}`;\n const attr = attrs.find((a) => a.key === targetKey);\n\n if (attr?.value && 'stringValue' in attr.value) {\n return attr.value.stringValue;\n }\n\n return undefined;\n }\n\n // Convenience: build and send a standardised record.activity.egress metric\n public sendEgressMetric = async (\n record: ActivityEgressTelemetryRecord,\n installContext: SeekaTelemetryInstallContext\n ): Promise<void> => {\n const attrs: KeyValue[] = [];\n\n const stringifyJson = (v: unknown): string => {\n if (typeof v === 'string') return v;\n try { return JSON.stringify(v ?? {}); } catch { return '\"\"'; }\n };\n\n const now = new Date();\n // Required core attributes (resource-level) \u2014 default certain values from installContext when sensible\n this.pushStr('type', 'record.activity.egress', attrs);\n // this.pushStr('tenantId', record.tenantId ?? installContext.organisationId, attrs);\n this.pushStr('originActivityId', record.originActivityId, attrs);\n // this.pushStr('convergeInstanceId', record.convergeInstanceId, attrs);\n // this.pushStr('organisationBrandId', record.organisationBrandId, attrs);\n this.pushStr('occurredAt', toIsoDateTime(record.occurredAt || now), attrs);\n this.pushStr('timestamp', toIsoDateTime(now), attrs);\n // pushStr('occurredAt', (record.occurredAt || now).toISOString());\n // pushStr('timestamp', now.toISOString());\n\n // Strings\n this.pushStr('personId', record.personId, attrs);\n this.pushStr('originSessionIdentifier', record.originSessionIdentifier, attrs);\n this.pushStr('originDnsName', record.originDnsName, attrs);\n this.pushStr('destinationPlatformIdentifier', record.destinationPlatformIdentifier, attrs);\n this.pushStr('destinationPlatformEgressType', record.destinationPlatformEgressType, attrs);\n this.pushStr('destinationPlatformTypeKey', record.destinationPlatformTypeKey, attrs);\n this.pushStr('originActivityName', record.originActivityName, attrs);\n this.pushStr('originActivityNameCustom', record.originActivityNameCustom, attrs);\n\n // JSON payloads as strings per validation expectations\n this.pushStr('publishedPayload', stringifyJson(record.publishedPayload), attrs);\n this.pushStr('egressQualityMetrics', stringifyJson(record.egressQualityMetrics), attrs);\n this.pushStr('egressIdentityMetrics', stringifyJson(record.egressIdentityMetrics), attrs);\n\n const metric: ExportMetricsServiceRequest = {\n resourceMetrics: [\n {\n resource: {\n attributes: attrs\n },\n scopeMetrics: [\n {\n scope: { name: 'seeka.telemetry.apps-server-core', version: '0.0.0' },\n metrics: [\n {\n name: 'record.activity.egress',\n description: 'Activity egress record',\n unit: '1',\n gauge: {\n dataPoints: [\n {\n asDouble: 1\n }\n ]\n }\n }\n ]\n }\n ]\n }\n ]\n };\n\n await this.sendMetric(metric, installContext);\n };\n\n // Minimal serverless-friendly metric sender using OTLP/HTTP 1.1 Protobuf\n public sendMetric = async (metric: ExportMetricsServiceRequest, installContext: SeekaTelemetryInstallContext): Promise<void> => {\n const { telemetryEndpointUrl, logger, issuerUrl } = this.options;\n\n // Minimal runtime guard to help diagnose common shape mistakes without heavy validation\n if (!metric || !Array.isArray((metric as any).resourceMetrics)) {\n throw new Error('SeekaTelemetry: metric must be an OTLP ExportMetricsServiceRequest with a resourceMetrics array');\n }\n\n // Lazily load the server SDK. Prefer require() so Jest can map to a CJS mock.\n // let getNewOrCachedAppInstallToken: any;\n // try {\n // const req = createRequire(import.meta.url);\n // const mod = req('@seeka-labs/sdk-apps-server');\n // getNewOrCachedAppInstallToken = mod.getNewOrCachedAppInstallToken || mod.default?.getNewOrCachedAppInstallToken;\n // } catch {\n // // Fallback to dynamic import (ESM)\n // try {\n // ({ getNewOrCachedAppInstallToken } = await import('@seeka-labs/sdk-apps-server'));\n // } catch {\n // // Last resort: explicit ESM file path (if package exports are strict)\n // ({ getNewOrCachedAppInstallToken } = await import('@seeka-labs/sdk-apps-server/dist/sdk-apps-server.module.mjs'));\n // }\n // }\n\n // Build a minimal config POJO with the fields used by the auth flow\n const config: any = {\n appId: installContext.appId,\n appSecret: installContext.appSecret,\n issuerUrl: issuerUrl,\n ingestUrl: telemetryEndpointUrl,\n // organisationId: installContext.organisationId,\n applicationInstallId: installContext.appInstallId,\n logger,\n grantedPermissions: [],\n runtime: this.getRuntimeInfo()\n };\n\n const token = await\n getNewOrCachedAppInstallToken(config as any);\n\n if (!token || !token.access_token) {\n throw new Error('SeekaTelemetry: failed to get access token for install');\n }\n\n const base = telemetryEndpointUrl.endsWith('/') ? telemetryEndpointUrl : telemetryEndpointUrl + '/';\n const url = new URL('v1/metrics', base).toString();\n const decoded = jwtDecode<JwtPayload & {converge_instance_id: string, org_brand_id: string, tenantid: string}>(token.access_token);\n\n const headers = new UndiciHeaders();\n headers.set('Content-Type', this.options.protobuf ? 'application/x-protobuf' : 'application/json');\n headers.set('Accept', this.options.protobuf ? 'application/x-protobuf' : 'application/json');\n headers.set('Authorization', `Bearer ${token.access_token}`);\n headers.set('X-OrgId', decoded.tenantid);\n\n // Encode to Protobuf (OTLP/HTTP 1.1 over HTTP/1.1)\n // const attrs = metric.resourceMetrics[0].resource.attributes['convergeInstanceId'] = ;\n const attrs = metric.resourceMetrics[0]?.resource?.attributes || [];\n\n this.pushStr('tenantId', decoded.tenantid, attrs);\n this.pushStr('organisationBrandId', decoded.org_brand_id, attrs);\n if(this.getStr('type', attrs) === 'record.activity.egress'){\n // set convergeInstanceId to the converge_instance_id claim of the token\n // get claims from jwt token.access_token\n // console.log(JSON.stringify(decoded));\n\n this.pushStr('convergeInstanceId', decoded.converge_instance_id, attrs);\n }\n\n const body = this.options.protobuf ? encodeExportMetricsServiceRequestToProto(metric) : JSON.stringify(metric);\n\n // Avoid batching entirely: send exactly what we were given, immediately await response\n const resp = await undiciFetch(url, {\n method: 'POST',\n headers: headers as any,\n body\n });\n\n if (!resp.ok) {\n const text = await resp.text().catch(() => '');\n const msg = `SeekaTelemetry: metric send failed with status ${resp.status} ${resp.statusText}`;\n logger?.error(msg, { body: text });\n throw new Error(msg);\n }\n }\n\n public shutdown = async (): Promise<void> => {\n // Core package has no SDK to shutdown; provided for API symmetry.\n }\n\n // NodeSDK support is intentionally omitted from the core package.\n\n private getRuntimeInfo(): AppRuntimeInfo {\n return {\n type: 'sdk/js/apps-server-telemetry-core',\n ver: '0.0.0',\n client: {\n type: 'server',\n ver: process.versions?.node || 'unknown'\n }\n };\n }\n}\n\nexport const createSeekaTelemetryClient = (options?: SeekaTelemetryClientCoreOptions | null | undefined, logger?: winston.Logger): SeekaTelemetryClientCore => {\n return new SeekaTelemetryClientCoreImpl({\n ...options,\n appId: options?.appId || process.env.SEEKA_APP_ID as string,\n appSecret: options?.appSecret || process.env.SEEKA_APP_SECRET as string,\n telemetryEndpointUrl: options?.telemetryEndpointUrl || process.env.SEEKA_TELEMETRY_URL || urls.defaultTelemetryUrl,\n issuerUrl: options?.issuerUrl || process.env.SEEKA_ISSUER_URL || urls.defaultIssuerUrl,\n logger\n });\n};\n", "\uFEFF// Minimal OTLP Metrics protobuf encoder for the subset we use (HTTP/1.1, no HTTP/2)\n// We hand-encode only the fields we need for our gauge metric with string attributes.\n// This avoids pulling in a full protobuf runtime and keeps the package light.\n\nimport type {\n AnyValue,\n ExportMetricsServiceRequest,\n Gauge,\n InstrumentationScope,\n KeyValue,\n Metric,\n NumberDataPoint,\n Resource,\n ResourceMetrics,\n ScopeMetrics,\n} from './models.ts';\n\n// Protobuf wire types\n// const WT_VARINT = 0;\nconst WT_64BIT = 1; // fixed64 / double\nconst WT_LEN = 2; // length-delimited (strings, bytes, submessages)\n\n// Utilities\nconst textEncoder = new TextEncoder();\n\nfunction encodeVarint(value: number): Uint8Array {\n // Support up to 32-bit values used in tags/lengths; sufficient for our use.\n let v = value >>> 0;\n const bytes: number[] = [];\n while (v >= 0x80) {\n bytes.push((v & 0x7f) | 0x80);\n v >>>= 7;\n }\n bytes.push(v);\n return Uint8Array.from(bytes);\n}\n\nfunction encodeTag(fieldNumber: number, wireType: number): Uint8Array {\n const key = (fieldNumber << 3) | wireType;\n return encodeVarint(key);\n}\n\nfunction encodeStringField(fieldNumber: number, value: string | undefined): Uint8Array[] {\n if (value == null) return [];\n const str = textEncoder.encode(value);\n return [encodeTag(fieldNumber, WT_LEN), encodeVarint(str.length), str];\n}\n\nfunction encodeBytesField(fieldNumber: number, value: Uint8Array): Uint8Array[] {\n return [encodeTag(fieldNumber, WT_LEN), encodeVarint(value.length), value];\n}\n\nfunction encodeDoubleField(fieldNumber: number, value: number | undefined): Uint8Array[] {\n if (value == null) return [];\n const buf = new ArrayBuffer(8);\n new DataView(buf).setFloat64(0, value, true); // little-endian\n return [encodeTag(fieldNumber, WT_64BIT), new Uint8Array(buf)];\n}\n\nfunction concatParts(parts: (Uint8Array | undefined)[]): Uint8Array {\n const filtered = parts.filter((p): p is Uint8Array => p instanceof Uint8Array);\n const total = filtered.reduce((sum, p) => sum + p.length, 0);\n const out = new Uint8Array(total);\n let off = 0;\n for (const p of filtered) { out.set(p, off); off += p.length; }\n return out;\n}\n\nfunction encodeAnyValue(value: AnyValue | undefined): Uint8Array {\n if (!value) return new Uint8Array(0);\n // We only support stringValue directly; other types are coerced to string via JSON.\n let str: string | undefined = undefined;\n if ('stringValue' in value && typeof value.stringValue === 'string') {\n str = value.stringValue;\n } else {\n // Coerce any present field to a string representation to keep encoder simple\n const v = (value as any).doubleValue ?? (value as any).intValue ?? (value as any).boolValue ?? (value as any).bytesValue ?? (value as any).arrayValue ?? (value as any).kvlistValue;\n try { str = typeof v === 'string' ? v : JSON.stringify(v); } catch { str = String(v); }\n }\n const inner = concatParts(encodeStringField(1, str)); // AnyValue.string_value = 1\n return wrapMessage(inner);\n}\n\nfunction encodeKeyValue(kv: KeyValue): Uint8Array {\n const parts: Uint8Array[] = [];\n parts.push(...encodeStringField(1, kv.key)); // key = 1\n parts.push(...encodeBytesField(2, encodeAnyValue(kv.value))); // value = 2 (submessage)\n return wrapMessage(concatParts(parts));\n}\n\nfunction encodeResource(res?: Resource): Uint8Array {\n if (!res) return wrapMessage(new Uint8Array(0));\n const parts: Uint8Array[] = [];\n for (const kv of res.attributes ?? []) {\n parts.push(...encodeBytesField(1, encodeKeyValue(kv))); // attributes = 1 (repeated)\n }\n return wrapMessage(concatParts(parts));\n}\n\nfunction encodeInstrumentationScope(scope?: InstrumentationScope): Uint8Array {\n const parts: Uint8Array[] = [];\n if (scope) {\n parts.push(...encodeStringField(1, scope.name)); // name = 1\n parts.push(...encodeStringField(2, scope.version)); // version = 2\n }\n return wrapMessage(concatParts(parts));\n}\n\nfunction encodeNumberDataPoint(ndp: NumberDataPoint): Uint8Array {\n const parts: Uint8Array[] = [];\n // We only encode the value as double (as_double = 4) and ignore timestamps/attributes for now\n parts.push(...encodeDoubleField(4, ndp.asDouble));\n return wrapMessage(concatParts(parts));\n}\n\nfunction encodeGauge(g: Gauge): Uint8Array {\n const parts: Uint8Array[] = [];\n for (const dp of g.dataPoints ?? []) {\n parts.push(...encodeBytesField(1, encodeNumberDataPoint(dp))); // data_points = 1\n }\n return wrapMessage(concatParts(parts));\n}\n\nfunction encodeMetric(m: Metric): Uint8Array {\n const parts: Uint8Array[] = [];\n parts.push(...encodeStringField(1, m.name));\n parts.push(...encodeStringField(2, m.description));\n parts.push(...encodeStringField(3, m.unit));\n if (m.gauge) {\n parts.push(...encodeBytesField(5, encodeGauge(m.gauge))); // gauge = 5\n }\n return wrapMessage(concatParts(parts));\n}\n\nfunction encodeScopeMetrics(sm: ScopeMetrics): Uint8Array {\n const parts: Uint8Array[] = [];\n parts.push(...encodeBytesField(1, encodeInstrumentationScope(sm.scope))); // scope = 1\n for (const metric of sm.metrics ?? []) {\n parts.push(...encodeBytesField(2, encodeMetric(metric))); // metrics = 2\n }\n return wrapMessage(concatParts(parts));\n}\n\nfunction encodeResourceMetrics(rm: ResourceMetrics): Uint8Array {\n const parts: Uint8Array[] = [];\n parts.push(...encodeBytesField(1, encodeResource(rm.resource))); // resource = 1\n for (const sm of rm.scopeMetrics ?? []) {\n parts.push(...encodeBytesField(2, encodeScopeMetrics(sm))); // scope_metrics = 2\n }\n return wrapMessage(concatParts(parts));\n}\n\nfunction wrapMessage(inner: Uint8Array): Uint8Array {\n // Caller will add the field tag and length for embedding; this wraps raw fields into a message body\n return inner;\n}\n\nexport function encodeExportMetricsServiceRequestToProto(req: ExportMetricsServiceRequest): Uint8Array {\n const parts: Uint8Array[] = [];\n for (const rm of req.resourceMetrics ?? []) {\n const rmBytes = encodeResourceMetrics(rm);\n parts.push(...encodeBytesField(1, rmBytes)); // resource_metrics = 1 (repeated)\n }\n return concatParts(parts);\n}\n", "\uFEFFexport const toIsoDateTime = (date: Date) => {\n const pad = (n: number) => String(n).padStart(2, '0');\n const pad3 = (n: number) => String(n).padStart(3, '0');\n\n return (\n date.getUTCFullYear() + '-' +\n pad(date.getUTCMonth() + 1) + '-' +\n pad(date.getUTCDate()) + 'T' +\n pad(date.getUTCHours()) + ':' +\n pad(date.getUTCMinutes()) + ':' +\n pad(date.getUTCSeconds()) + '.' +\n pad3(date.getUTCMilliseconds())\n );\n}", "\uFEFF// Minimal OTLP/HTTP 1.1 JSON type definitions for Metrics\n// These follow the protobuf JSON mapping for the OpenTelemetry Metrics protocol.\n// Only commonly used fields are included to keep the types lightweight but useful.\n\nimport type {Logger} from \"winston\";\nimport type {TrackingActivityNames, SeekaActivityAcceptedWebhookContent} from \"@seeka-labs/sdk-apps-server\";\n\nexport interface ExportMetricsServiceRequest {\n resourceMetrics: ResourceMetrics[];\n}\n\nexport interface ResourceMetrics {\n resource?: Resource;\n scopeMetrics: ScopeMetrics[];\n schemaUrl?: string;\n}\n\nexport interface Resource {\n attributes?: KeyValue[];\n droppedAttributesCount?: number;\n}\n\nexport interface ScopeMetrics {\n scope?: InstrumentationScope;\n metrics: Metric[];\n schemaUrl?: string;\n}\n\nexport interface InstrumentationScope {\n name: string;\n version?: string;\n attributes?: KeyValue[];\n droppedAttributesCount?: number;\n}\n\nexport interface Metric {\n name: string;\n description?: string;\n unit?: string;\n sum?: Sum;\n gauge?: Gauge;\n histogram?: Histogram;\n exponentialHistogram?: ExponentialHistogram;\n summary?: Summary; // kept for completeness (deprecated in OTLP but some exporters still accept)\n}\n\nexport interface Sum {\n dataPoints: NumberDataPoint[];\n aggregationTemporality: AggregationTemporality; // 0=Unspecified, 1=Delta, 2=Cumulative\n isMonotonic?: boolean;\n}\n\nexport interface Gauge {\n dataPoints: NumberDataPoint[];\n}\n\nexport interface Histogram {\n dataPoints: HistogramDataPoint[];\n aggregationTemporality: AggregationTemporality; // 0=Unspecified, 1=Delta, 2=Cumulative\n}\n\nexport interface ExponentialHistogram {\n dataPoints: ExponentialHistogramDataPoint[];\n aggregationTemporality: AggregationTemporality; // 0=Unspecified, 1=Delta, 2=Cumulative\n}\n\nexport interface Summary {\n dataPoints: SummaryDataPoint[];\n}\n\nexport interface NumberDataPoint {\n attributes?: KeyValue[];\n startTimeUnixNano?: string; // uint64 as string per JSON mapping\n timeUnixNano?: string; // uint64 as string per JSON mapping\n exemplars?: Exemplar[];\n flags?: number; // DataPointFlags bitfield\n asDouble?: number;\n asInt?: string | number; // int64 as string per JSON mapping; allow number for convenience\n}\n\nexport interface HistogramDataPoint {\n attributes?: KeyValue[];\n startTimeUnixNano?: string;\n timeUnixNano?: string;\n count: string | number; // uint64\n sum?: number;\n bucketCounts?: Array<string | number>; // repeated uint64\n explicitBounds?: number[];\n min?: number; // available depending on OTLP version/feature gate\n max?: number; // available depending on OTLP version/feature gate\n exemplars?: Exemplar[];\n flags?: number;\n}\n\nexport interface ExponentialHistogramDataPoint {\n attributes?: KeyValue[];\n startTimeUnixNano?: string;\n timeUnixNano?: string;\n count: string | number; // uint64\n sum?: number;\n scale?: number; // int32\n zeroCount?: string | number; // uint64\n positive?: ExponentialHistogramBuckets;\n negative?: ExponentialHistogramBuckets;\n min?: number;\n max?: number;\n exemplars?: Exemplar[];\n flags?: number;\n}\n\nexport interface ExponentialHistogramBuckets {\n offset?: number; // int32\n bucketCounts?: Array<string | number>; // repeated uint64\n}\n\nexport interface SummaryDataPoint {\n attributes?: KeyValue[];\n startTimeUnixNano?: string;\n timeUnixNano?: string;\n count: string | number; // uint64\n sum: number;\n quantileValues?: ValueAtQuantile[];\n flags?: number;\n}\n\nexport interface ValueAtQuantile {\n quantile: number;\n value: number;\n}\n\nexport interface Exemplar {\n filteredAttributes?: KeyValue[];\n timeUnixNano?: string;\n asDouble?: number;\n asInt?: string | number;\n spanId?: string; // base64-encoded or hex per exporter; keep string\n traceId?: string;\n}\n\n// Common attribute/value types\nexport interface KeyValue {\n key: string;\n value: AnyValue;\n}\n\nexport type AnyValue =\n { stringValue: string }\n | { boolValue: boolean }\n | { intValue: string | number }\n | { doubleValue: number }\n | { bytesValue: string }\n | { arrayValue: ArrayValue }\n | { kvlistValue: KeyValueList };\n\nexport interface ArrayValue {\n values: AnyValue[];\n}\n\nexport interface KeyValueList {\n values: KeyValue[];\n}\n\n// Enum mirrors otlp AggregationTemporality; we allow numbers to align with protobuf JSON mapping\nexport enum AggregationTemporality {\n AGGREGATION_TEMPORALITY_UNSPECIFIED = 0,\n AGGREGATION_TEMPORALITY_DELTA = 1,\n AGGREGATION_TEMPORALITY_CUMULATIVE = 2,\n}\n\n// Helpful alias for consumers\nexport type OtlpMetricsExportRequest = ExportMetricsServiceRequest;\n\n\n// Public types\nexport type SeekaTelemetryClientCoreOptions = {\n appId: string;\n appSecret: string;\n issuerUrl?: string;\n telemetryEndpointUrl: string;\n logger?: Logger;\n protobuf?: boolean;\n};\n\nexport type SeekaTelemetryInstallContext = {\n appId: string;\n appSecret: string;\n // organisationId: string;\n appInstallId: string;\n};\n\n\n// export interface AppRuntimeInfo {\n// type: string;\n// ver: string;\n// client: {\n// type: 'server' | 'browser' | string;\n// ver: string;\n// };\n// }\n\n\n// Activity Egress record type mirroring the C# model (JS-friendly)\nexport type ActivityEgressTelemetryRecord = ActivityEgressTelemetryRecordBase & ActivityEgressTelemetryRecordMetrics & {\n personId: string;\n originActivityId?: string;\n occurredAt?: Date | undefined;\n originSessionIdentifier: string;\n originDnsName: string;\n originActivityName: TrackingActivityNames;\n originActivityNameCustom?: string | null | undefined;\n};\n\nexport interface ActivityEgressTelemetryRecordBase {\n publishedPayload: unknown;\n destinationPlatformTypeKey:\n | 'google.ads'\n | 'google.analytics'\n | 'meta.capi'\n | 'pinterest.capi'\n | 'tiktok.capi'\n | 'snapchat.capi'\n | (string & {});\n destinationPlatformEgressType: string;\n destinationPlatformIdentifier: string;\n}\n\nexport interface ActivityEgressTelemetryRecordMetrics {\n egressQualityMetrics: Record<string, boolean>;\n egressIdentityMetrics: { qualityRating: number; dataPoints: number };\n}\n\nexport const createEgressTelemetryRecord = (egressRecord: ActivityEgressTelemetryRecordBase, egressMetrics: ActivityEgressTelemetryRecordMetrics, originActivity: SeekaActivityAcceptedWebhookContent): ActivityEgressTelemetryRecord => {\n return {\n ...egressMetrics,\n ...egressRecord,\n // tenantId: appInstallState.organisationId,\n // egressQualityMetrics: {'fn': true, 'em': true},\n // egressIdentityMetrics: {qualityRating: 0.8, dataPoints: 7},\n personId: originActivity.personId as string,\n originActivityId: originActivity.activity?.activityId,\n // convergeInstanceId: process.env.SEEKA_CONVERGE_INSTANCE_ID as string,\n // organisationBrandId: appInstallState.organisationBrandId,\n occurredAt: new Date(),\n originActivityName: originActivity.activity?.activityName as TrackingActivityNames,\n originActivityNameCustom: originActivity.activity?.activityNameCustom,\n originSessionIdentifier: originActivity.source?.sess as string,\n originDnsName: new URL(originActivity.source?.loc ||'').hostname.toLowerCase()\n }\n};\n\n\nexport interface SeekaTelemetryClientCore {\n sendMetric: (metric: ExportMetricsServiceRequest, installContext: SeekaTelemetryInstallContext) => Promise<void>;\n // Convenience helper to send a standardised activity egress metric\n sendEgressMetric: (record: ActivityEgressTelemetryRecord, installContext: SeekaT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rCachedAppInstallToken", "textEncoder", "encodeVarint", "value", "v", "bytes", "encodeTag", "fieldNumber", "wireType", "key", "encodeStringField", "str", "encodeBytesField", "encodeDoubleField", "buf", "concatParts", "parts", "filtered", "p", "total", "sum", "out", "off", "encodeAnyValue", "inner", "encodeKeyValue", "kv", "encodeResource", "res", "encodeInstrumentationScope", "scope", "encodeNumberDataPoint", "ndp", "encodeGauge", "g", "dp", "encodeMetric", "m", "encodeScopeMetrics", "sm", "metric", "encodeResourceMetrics", "rm", "encodeExportMetricsServiceRequestToProto", "req", "parts", "rm", "rmBytes", "encodeResourceMetrics", "encodeBytesField", "concatParts", "toIsoDateTime", "date", "pad", "n", "pad3", "urls", "attrPrefix", "SeekaTelemetryClientCoreImpl", "options", "key", "value", "attrs", "targetKey", "attr", "a", "record", "installContext", "stringifyJson", "v", "now", "toIsoDateTime", "metric", "telemetryEndpointUrl", "logger", "issuerUrl", "config", "token", "getNewOrCachedAppInstallToken", "base", "url", "decoded", "jwtDecode", "headers", "UndiciHeaders", "body", "encodeExportMetricsServiceRequestToProto", "resp", "undiciFetch", "text", "msg", "createSeekaTelemetryClient", "AggregationTemporality", "createEgressTelemetryRecord", "egressRecord", "egressMetrics", "originActivity"]
|
|
4
|
+
"sourcesContent": ["\uFEFF\n\n// We use undici's fetch for Node environments\nimport { fetch as undiciFetch, Headers as UndiciHeaders } from 'undici';\n// For safely requiring CJS modules from ESM (used under Jest)\n// import { createRequire } from 'node:module';\n\nimport {jwtDecode, type JwtPayload} from \"jwt-decode\";\n\n// OTLP metric types (type-safe input)\nimport {type AppRuntimeInfo, getNewOrCachedAppInstallToken} from \"@seeka-labs/sdk-apps-server\";\nimport type {\n ActivityEgressTelemetryRecord,\n ExportMetricsServiceRequest, KeyValue, SeekaTelemetryClientCore, SeekaTelemetryClientCoreOptions,\n SeekaTelemetryInstallContext\n} from \"./models.ts\";\nimport { encodeExportMetricsServiceRequestToProto } from './otlpEncoder.ts';\nimport {toIsoDateTime} from \"./helpers.ts\";\nimport * as winston from \"winston\";\nimport {urls} from \"@seeka-labs/sdk-apps-server\";\n\nconst attrPrefix = 'seeka.tel';\n\nclass SeekaTelemetryClientCoreImpl implements SeekaTelemetryClientCore {\n private readonly options: SeekaTelemetryClientCoreOptions;\n\n constructor(options: SeekaTelemetryClientCoreOptions) {\n this.options = options;\n }\n\n private pushStr = (key: string, value: string | undefined | null, attrs: KeyValue[]) => {\n if (value == null) return;\n attrs.push({ key: `${attrPrefix}.${key}`, value: { stringValue: String(value) } });\n };\n\n private getStr(key: string, attrs: KeyValue[]): string | undefined {\n const targetKey = `${attrPrefix}.${key}`;\n const attr = attrs.find((a) => a.key === targetKey);\n\n if (attr?.value && 'stringValue' in attr.value) {\n return attr.value.stringValue;\n }\n\n return undefined;\n }\n\n // Convenience: build and send a standardised record.activity.egress metric\n public sendEgressMetric = async (\n record: ActivityEgressTelemetryRecord,\n installContext: SeekaTelemetryInstallContext\n ): Promise<void> => {\n const attrs: KeyValue[] = [];\n\n const stringifyJson = (v: unknown): string => {\n if (typeof v === 'string') return v;\n try { return JSON.stringify(v ?? {}); } catch { return '\"\"'; }\n };\n\n const now = new Date();\n // Required core attributes (resource-level) \u2014 default certain values from installContext when sensible\n this.pushStr('type', 'record.activity.egress', attrs);\n // this.pushStr('tenantId', record.tenantId ?? installContext.organisationId, attrs);\n this.pushStr('originActivityId', record.originActivityId, attrs);\n // this.pushStr('convergeInstanceId', record.convergeInstanceId, attrs);\n // this.pushStr('organisationBrandId', record.organisationBrandId, attrs);\n this.pushStr('occurredAt', toIsoDateTime(record.occurredAt || now), attrs);\n this.pushStr('timestamp', toIsoDateTime(now), attrs);\n // pushStr('occurredAt', (record.occurredAt || now).toISOString());\n // pushStr('timestamp', now.toISOString());\n\n // Strings\n this.pushStr('personId', record.personId, attrs);\n this.pushStr('originSessionIdentifier', record.originSessionIdentifier, attrs);\n this.pushStr('originDnsName', record.originDnsName, attrs);\n this.pushStr('destinationPlatformIdentifier', record.destinationPlatformIdentifier, attrs);\n this.pushStr('destinationPlatformEgressType', record.destinationPlatformEgressType, attrs);\n this.pushStr('destinationPlatformTypeKey', record.destinationPlatformTypeKey, attrs);\n this.pushStr('originActivityName', record.originActivityName, attrs);\n this.pushStr('originActivityNameCustom', record.originActivityNameCustom, attrs);\n\n // JSON payloads as strings per validation expectations\n this.pushStr('publishedPayload', stringifyJson(record.publishedPayload), attrs);\n this.pushStr('egressQualityMetrics', stringifyJson(record.egressQualityMetrics), attrs);\n this.pushStr('egressIdentityMetrics', stringifyJson(record.egressIdentityMetrics), attrs);\n\n const metric: ExportMetricsServiceRequest = {\n resourceMetrics: [\n {\n resource: {\n attributes: attrs\n },\n scopeMetrics: [\n {\n scope: { name: 'seeka.telemetry.apps-server-core', version: '0.0.0' },\n metrics: [\n {\n name: 'record.activity.egress',\n description: 'Activity egress record',\n unit: '1',\n gauge: {\n dataPoints: [\n {\n asDouble: 1\n }\n ]\n }\n }\n ]\n }\n ]\n }\n ]\n };\n\n await this.sendMetric(metric, installContext);\n };\n\n // Minimal serverless-friendly metric sender using OTLP/HTTP 1.1 Protobuf\n public sendMetric = async (metric: ExportMetricsServiceRequest, installContext: SeekaTelemetryInstallContext): Promise<void> => {\n const { telemetryEndpointUrl, logger, issuerUrl, appId, appSecret } = this.options;\n\n // Minimal runtime guard to help diagnose common shape mistakes without heavy validation\n if (!metric || !Array.isArray((metric as any).resourceMetrics)) {\n throw new Error('SeekaTelemetry: metric must be an OTLP ExportMetricsServiceRequest with a resourceMetrics array');\n }\n\n // Lazily load the server SDK. Prefer require() so Jest can map to a CJS mock.\n // let getNewOrCachedAppInstallToken: any;\n // try {\n // const req = createRequire(import.meta.url);\n // const mod = req('@seeka-labs/sdk-apps-server');\n // getNewOrCachedAppInstallToken = mod.getNewOrCachedAppInstallToken || mod.default?.getNewOrCachedAppInstallToken;\n // } catch {\n // // Fallback to dynamic import (ESM)\n // try {\n // ({ getNewOrCachedAppInstallToken } = await import('@seeka-labs/sdk-apps-server'));\n // } catch {\n // // Last resort: explicit ESM file path (if package exports are strict)\n // ({ getNewOrCachedAppInstallToken } = await import('@seeka-labs/sdk-apps-server/dist/sdk-apps-server.module.mjs'));\n // }\n // }\n\n // Build a minimal config POJO with the fields used by the auth flow\n const config: any = {\n appId,\n appSecret,\n issuerUrl: issuerUrl,\n ingestUrl: telemetryEndpointUrl,\n // organisationId: installContext.organisationId,\n applicationInstallId: installContext.appInstallId,\n logger,\n grantedPermissions: [],\n runtime: this.getRuntimeInfo()\n };\n\n const token = await\n getNewOrCachedAppInstallToken(config as any);\n\n if (!token || !token.access_token) {\n throw new Error('SeekaTelemetry: failed to get access token for install');\n }\n\n const base = telemetryEndpointUrl.endsWith('/') ? telemetryEndpointUrl : telemetryEndpointUrl + '/';\n const url = new URL('v1/metrics', base).toString();\n const decoded = jwtDecode<JwtPayload & {converge_instance_id: string, org_brand_id: string, tenantid: string}>(token.access_token);\n\n const headers = new UndiciHeaders();\n headers.set('Content-Type', this.options.protobuf ? 'application/x-protobuf' : 'application/json');\n headers.set('Accept', this.options.protobuf ? 'application/x-protobuf' : 'application/json');\n headers.set('Authorization', `Bearer ${token.access_token}`);\n headers.set('X-OrgId', decoded.tenantid);\n\n // Encode to Protobuf (OTLP/HTTP 1.1 over HTTP/1.1)\n // const attrs = metric.resourceMetrics[0].resource.attributes['convergeInstanceId'] = ;\n const attrs = metric.resourceMetrics[0]?.resource?.attributes || [];\n\n this.pushStr('tenantId', decoded.tenantid, attrs);\n this.pushStr('organisationBrandId', decoded.org_brand_id, attrs);\n if(this.getStr('type', attrs) === 'record.activity.egress'){\n // set convergeInstanceId to the converge_instance_id claim of the token\n // get claims from jwt token.access_token\n // console.log(JSON.stringify(decoded));\n\n this.pushStr('convergeInstanceId', decoded.converge_instance_id, attrs);\n }\n\n const body = this.options.protobuf ? encodeExportMetricsServiceRequestToProto(metric) : JSON.stringify(metric);\n\n // Avoid batching entirely: send exactly what we were given, immediately await response\n const resp = await undiciFetch(url, {\n method: 'POST',\n headers: headers as any,\n body\n });\n\n if (!resp.ok) {\n const text = await resp.text().catch(() => '');\n const msg = `SeekaTelemetry: metric send failed with status ${resp.status} ${resp.statusText}`;\n logger?.error(msg, { body: text });\n throw new Error(msg);\n }\n else{\n logger?.debug(`SeekaTelemetry: metric send succeeded`);\n }\n }\n\n public shutdown = async (): Promise<void> => {\n // Core package has no SDK to shutdown; provided for API symmetry.\n }\n\n // NodeSDK support is intentionally omitted from the core package.\n\n private getRuntimeInfo(): AppRuntimeInfo {\n // TODO: proper runtime info for this lib version and the caller / app lib version\n return {\n type: 'sdk/js/apps-server-telemetry-core',\n ver: '0.0.0',\n client: {\n type: 'server',\n ver: process.versions?.node || 'unknown'\n }\n };\n }\n}\n\nexport const createSeekaTelemetryClient = (options?: SeekaTelemetryClientCoreOptions | null | undefined, logger?: winston.Logger): SeekaTelemetryClientCore => {\n return new SeekaTelemetryClientCoreImpl({\n ...options,\n appId: options?.appId || process.env.SEEKA_APP_ID as string,\n appSecret: options?.appSecret || process.env.SEEKA_APP_SECRET as string,\n telemetryEndpointUrl: options?.telemetryEndpointUrl || process.env.SEEKA_TELEMETRY_URL || urls.defaultTelemetryUrl,\n issuerUrl: options?.issuerUrl || process.env.SEEKA_ISSUER_URL || urls.defaultIssuerUrl,\n logger\n });\n};\n", "\uFEFF// Minimal OTLP Metrics protobuf encoder for the subset we use (HTTP/1.1, no HTTP/2)\n// We hand-encode only the fields we need for our gauge metric with string attributes.\n// This avoids pulling in a full protobuf runtime and keeps the package light.\n\nimport type {\n AnyValue,\n ExportMetricsServiceRequest,\n Gauge,\n InstrumentationScope,\n KeyValue,\n Metric,\n NumberDataPoint,\n Resource,\n ResourceMetrics,\n ScopeMetrics,\n} from './models.ts';\n\n// Protobuf wire types\n// const WT_VARINT = 0;\nconst WT_64BIT = 1; // fixed64 / double\nconst WT_LEN = 2; // length-delimited (strings, bytes, submessages)\n\n// Utilities\nconst textEncoder = new TextEncoder();\n\nfunction encodeVarint(value: number): Uint8Array {\n // Support up to 32-bit values used in tags/lengths; sufficient for our use.\n let v = value >>> 0;\n const bytes: number[] = [];\n while (v >= 0x80) {\n bytes.push((v & 0x7f) | 0x80);\n v >>>= 7;\n }\n bytes.push(v);\n return Uint8Array.from(bytes);\n}\n\nfunction encodeTag(fieldNumber: number, wireType: number): Uint8Array {\n const key = (fieldNumber << 3) | wireType;\n return encodeVarint(key);\n}\n\nfunction encodeStringField(fieldNumber: number, value: string | undefined): Uint8Array[] {\n if (value == null) return [];\n const str = textEncoder.encode(value);\n return [encodeTag(fieldNumber, WT_LEN), encodeVarint(str.length), str];\n}\n\nfunction encodeBytesField(fieldNumber: number, value: Uint8Array): Uint8Array[] {\n return [encodeTag(fieldNumber, WT_LEN), encodeVarint(value.length), value];\n}\n\nfunction encodeDoubleField(fieldNumber: number, value: number | undefined): Uint8Array[] {\n if (value == null) return [];\n const buf = new ArrayBuffer(8);\n new DataView(buf).setFloat64(0, value, true); // little-endian\n return [encodeTag(fieldNumber, WT_64BIT), new Uint8Array(buf)];\n}\n\nfunction concatParts(parts: (Uint8Array | undefined)[]): Uint8Array {\n const filtered = parts.filter((p): p is Uint8Array => p instanceof Uint8Array);\n const total = filtered.reduce((sum, p) => sum + p.length, 0);\n const out = new Uint8Array(total);\n let off = 0;\n for (const p of filtered) { out.set(p, off); off += p.length; }\n return out;\n}\n\nfunction encodeAnyValue(value: AnyValue | undefined): Uint8Array {\n if (!value) return new Uint8Array(0);\n // We only support stringValue directly; other types are coerced to string via JSON.\n let str: string | undefined = undefined;\n if ('stringValue' in value && typeof value.stringValue === 'string') {\n str = value.stringValue;\n } else {\n // Coerce any present field to a string representation to keep encoder simple\n const v = (value as any).doubleValue ?? (value as any).intValue ?? (value as any).boolValue ?? (value as any).bytesValue ?? (value as any).arrayValue ?? (value as any).kvlistValue;\n try { str = typeof v === 'string' ? v : JSON.stringify(v); } catch { str = String(v); }\n }\n const inner = concatParts(encodeStringField(1, str)); // AnyValue.string_value = 1\n return wrapMessage(inner);\n}\n\nfunction encodeKeyValue(kv: KeyValue): Uint8Array {\n const parts: Uint8Array[] = [];\n parts.push(...encodeStringField(1, kv.key)); // key = 1\n parts.push(...encodeBytesField(2, encodeAnyValue(kv.value))); // value = 2 (submessage)\n return wrapMessage(concatParts(parts));\n}\n\nfunction encodeResource(res?: Resource): Uint8Array {\n if (!res) return wrapMessage(new Uint8Array(0));\n const parts: Uint8Array[] = [];\n for (const kv of res.attributes ?? []) {\n parts.push(...encodeBytesField(1, encodeKeyValue(kv))); // attributes = 1 (repeated)\n }\n return wrapMessage(concatParts(parts));\n}\n\nfunction encodeInstrumentationScope(scope?: InstrumentationScope): Uint8Array {\n const parts: Uint8Array[] = [];\n if (scope) {\n parts.push(...encodeStringField(1, scope.name)); // name = 1\n parts.push(...encodeStringField(2, scope.version)); // version = 2\n }\n return wrapMessage(concatParts(parts));\n}\n\nfunction encodeNumberDataPoint(ndp: NumberDataPoint): Uint8Array {\n const parts: Uint8Array[] = [];\n // We only encode the value as double (as_double = 4) and ignore timestamps/attributes for now\n parts.push(...encodeDoubleField(4, ndp.asDouble));\n return wrapMessage(concatParts(parts));\n}\n\nfunction encodeGauge(g: Gauge): Uint8Array {\n const parts: Uint8Array[] = [];\n for (const dp of g.dataPoints ?? []) {\n parts.push(...encodeBytesField(1, encodeNumberDataPoint(dp))); // data_points = 1\n }\n return wrapMessage(concatParts(parts));\n}\n\nfunction encodeMetric(m: Metric): Uint8Array {\n const parts: Uint8Array[] = [];\n parts.push(...encodeStringField(1, m.name));\n parts.push(...encodeStringField(2, m.description));\n parts.push(...encodeStringField(3, m.unit));\n if (m.gauge) {\n parts.push(...encodeBytesField(5, encodeGauge(m.gauge))); // gauge = 5\n }\n return wrapMessage(concatParts(parts));\n}\n\nfunction encodeScopeMetrics(sm: ScopeMetrics): Uint8Array {\n const parts: Uint8Array[] = [];\n parts.push(...encodeBytesField(1, encodeInstrumentationScope(sm.scope))); // scope = 1\n for (const metric of sm.metrics ?? []) {\n parts.push(...encodeBytesField(2, encodeMetric(metric))); // metrics = 2\n }\n return wrapMessage(concatParts(parts));\n}\n\nfunction encodeResourceMetrics(rm: ResourceMetrics): Uint8Array {\n const parts: Uint8Array[] = [];\n parts.push(...encodeBytesField(1, encodeResource(rm.resource))); // resource = 1\n for (const sm of rm.scopeMetrics ?? []) {\n parts.push(...encodeBytesField(2, encodeScopeMetrics(sm))); // scope_metrics = 2\n }\n return wrapMessage(concatParts(parts));\n}\n\nfunction wrapMessage(inner: Uint8Array): Uint8Array {\n // Caller will add the field tag and length for embedding; this wraps raw fields into a message body\n return inner;\n}\n\nexport function encodeExportMetricsServiceRequestToProto(req: ExportMetricsServiceRequest): Uint8Array {\n const parts: Uint8Array[] = [];\n for (const rm of req.resourceMetrics ?? []) {\n const rmBytes = encodeResourceMetrics(rm);\n parts.push(...encodeBytesField(1, rmBytes)); // resource_metrics = 1 (repeated)\n }\n return concatParts(parts);\n}\n", "\uFEFFexport const toIsoDateTime = (date: Date) => {\n const pad = (n: number) => String(n).padStart(2, '0');\n const pad3 = (n: number) => String(n).padStart(3, '0');\n\n return (\n date.getUTCFullYear() + '-' +\n pad(date.getUTCMonth() + 1) + '-' +\n pad(date.getUTCDate()) + 'T' +\n pad(date.getUTCHours()) + ':' +\n pad(date.getUTCMinutes()) + ':' +\n pad(date.getUTCSeconds()) + '.' +\n pad3(date.getUTCMilliseconds())\n );\n}", "\uFEFF// Minimal OTLP/HTTP 1.1 JSON type definitions for Metrics\n// These follow the protobuf JSON mapping for the OpenTelemetry Metrics protocol.\n// Only commonly used fields are included to keep the types lightweight but useful.\n\nimport type {Logger} from \"winston\";\nimport type {TrackingActivityNames, SeekaActivityAcceptedWebhookContent} from \"@seeka-labs/sdk-apps-server\";\n\nexport interface ExportMetricsServiceRequest {\n resourceMetrics: ResourceMetrics[];\n}\n\nexport interface ResourceMetrics {\n resource?: Resource;\n scopeMetrics: ScopeMetrics[];\n schemaUrl?: string;\n}\n\nexport interface Resource {\n attributes?: KeyValue[];\n droppedAttributesCount?: number;\n}\n\nexport interface ScopeMetrics {\n scope?: InstrumentationScope;\n metrics: Metric[];\n schemaUrl?: string;\n}\n\nexport interface InstrumentationScope {\n name: string;\n version?: string;\n attributes?: KeyValue[];\n droppedAttributesCount?: number;\n}\n\nexport interface Metric {\n name: string;\n description?: string;\n unit?: string;\n sum?: Sum;\n gauge?: Gauge;\n histogram?: Histogram;\n exponentialHistogram?: ExponentialHistogram;\n summary?: Summary; // kept for completeness (deprecated in OTLP but some exporters still accept)\n}\n\nexport interface Sum {\n dataPoints: NumberDataPoint[];\n aggregationTemporality: AggregationTemporality; // 0=Unspecified, 1=Delta, 2=Cumulative\n isMonotonic?: boolean;\n}\n\nexport interface Gauge {\n dataPoints: NumberDataPoint[];\n}\n\nexport interface Histogram {\n dataPoints: HistogramDataPoint[];\n aggregationTemporality: AggregationTemporality; // 0=Unspecified, 1=Delta, 2=Cumulative\n}\n\nexport interface ExponentialHistogram {\n dataPoints: ExponentialHistogramDataPoint[];\n aggregationTemporality: AggregationTemporality; // 0=Unspecified, 1=Delta, 2=Cumulative\n}\n\nexport interface Summary {\n dataPoints: SummaryDataPoint[];\n}\n\nexport interface NumberDataPoint {\n attributes?: KeyValue[];\n startTimeUnixNano?: string; // uint64 as string per JSON mapping\n timeUnixNano?: string; // uint64 as string per JSON mapping\n exemplars?: Exemplar[];\n flags?: number; // DataPointFlags bitfield\n asDouble?: number;\n asInt?: string | number; // int64 as string per JSON mapping; allow number for convenience\n}\n\nexport interface HistogramDataPoint {\n attributes?: KeyValue[];\n startTimeUnixNano?: string;\n timeUnixNano?: string;\n count: string | number; // uint64\n sum?: number;\n bucketCounts?: Array<string | number>; // repeated uint64\n explicitBounds?: number[];\n min?: number; // available depending on OTLP version/feature gate\n max?: number; // available depending on OTLP version/feature gate\n exemplars?: Exemplar[];\n flags?: number;\n}\n\nexport interface ExponentialHistogramDataPoint {\n attributes?: KeyValue[];\n startTimeUnixNano?: string;\n timeUnixNano?: string;\n count: string | number; // uint64\n sum?: number;\n scale?: number; // int32\n zeroCount?: string | number; // uint64\n positive?: ExponentialHistogramBuckets;\n negative?: ExponentialHistogramBuckets;\n min?: number;\n max?: number;\n exemplars?: Exemplar[];\n flags?: number;\n}\n\nexport interface ExponentialHistogramBuckets {\n offset?: number; // int32\n bucketCounts?: Array<string | number>; // repeated uint64\n}\n\nexport interface SummaryDataPoint {\n attributes?: KeyValue[];\n startTimeUnixNano?: string;\n timeUnixNano?: string;\n count: string | number; // uint64\n sum: number;\n quantileValues?: ValueAtQuantile[];\n flags?: number;\n}\n\nexport interface ValueAtQuantile {\n quantile: number;\n value: number;\n}\n\nexport interface Exemplar {\n filteredAttributes?: KeyValue[];\n timeUnixNano?: string;\n asDouble?: number;\n asInt?: string | number;\n spanId?: string; // base64-encoded or hex per exporter; keep string\n traceId?: string;\n}\n\n// Common attribute/value types\nexport interface KeyValue {\n key: string;\n value: AnyValue;\n}\n\nexport type AnyValue =\n { stringValue: string }\n | { boolValue: boolean }\n | { intValue: string | number }\n | { doubleValue: number }\n | { bytesValue: string }\n | { arrayValue: ArrayValue }\n | { kvlistValue: KeyValueList };\n\nexport interface ArrayValue {\n values: AnyValue[];\n}\n\nexport interface KeyValueList {\n values: KeyValue[];\n}\n\n// Enum mirrors otlp AggregationTemporality; we allow numbers to align with protobuf JSON mapping\nexport enum AggregationTemporality {\n AGGREGATION_TEMPORALITY_UNSPECIFIED = 0,\n AGGREGATION_TEMPORALITY_DELTA = 1,\n AGGREGATION_TEMPORALITY_CUMULATIVE = 2,\n}\n\n// Helpful alias for consumers\nexport type OtlpMetricsExportRequest = ExportMetricsServiceRequest;\n\n\n// Public types\nexport type SeekaTelemetryClientCoreOptions = {\n appId: string;\n appSecret: string;\n issuerUrl?: string;\n telemetryEndpointUrl: string;\n logger?: Logger;\n protobuf?: boolean;\n};\n\nexport type SeekaTelemetryInstallContext = {\n // appId: string;\n // appSecret: string;\n // organisationId: string;\n appInstallId: string;\n};\n\n\n// export interface AppRuntimeInfo {\n// type: string;\n// ver: string;\n// client: {\n// type: 'server' | 'browser' | string;\n// ver: string;\n// };\n// }\n\n\n// Activity Egress record type mirroring the C# model (JS-friendly)\nexport type ActivityEgressTelemetryRecord = ActivityEgressTelemetryRecordBase & ActivityEgressTelemetryRecordMetrics & {\n personId: string;\n originActivityId?: string;\n occurredAt?: Date | undefined;\n originSessionIdentifier: string;\n originDnsName: string;\n originActivityName: TrackingActivityNames;\n originActivityNameCustom?: string | null | undefined;\n};\n\nexport interface ActivityEgressTelemetryRecordBase {\n publishedPayload: unknown;\n destinationPlatformTypeKey:\n | 'google.ads'\n | 'google.analytics'\n | 'meta.capi'\n | 'pinterest.capi'\n | 'tiktok.capi'\n | 'snapchat.capi'\n | (string & {});\n destinationPlatformEgressType: string;\n destinationPlatformIdentifier: string;\n}\n\nexport interface ActivityEgressTelemetryRecordMetrics {\n egressQualityMetrics: Record<string, boolean>;\n egressIdentityMetrics: { qualityRating: number; dataPoints: number };\n}\n\nexport const createEgressTelemetryRecord = (egressRecord: ActivityEgressTelemetryRecordBase, egressMetrics: ActivityEgressTelemetryRecordMetrics, originActivity: SeekaActivityAcceptedWebhookContent): ActivityEgressTelemetryRecord => {\n return {\n ...egressMetrics,\n ...egressRecord,\n // tenantId: appInstallState.organisationId,\n // egressQualityMetrics: {'fn': true, 'em': true},\n // egressIdentityMetrics: {qualityRating: 0.8, dataPoints: 7},\n personId: originActivity.personId as string,\n originActivityId: originActivity.activity?.activityId,\n // convergeInstanceId: process.env.SEEKA_CONVERGE_INSTANCE_ID as string,\n // organisationBrandId: appInstallState.organisationBrandId,\n occurredAt: new Date(),\n originActivityName: originActivity.activity?.activityName as TrackingActivityNames,\n originActivityNameCustom: originActivity.activity?.activityNameCustom,\n originSessionIdentifier: originActivity.source?.sess as string,\n originDnsName: new URL(originActivity.source?.loc ||'').hostname.toLowerCase()\n }\n};\n\n\nexport interface SeekaTelemetryClientCore {\n sendMetric: (metric: ExportMetricsServiceRequest, installContext: SeekaTelemetryInstallContext) => Promise<void>;\n // Convenience helper to send a standardised activity egress metric\n sendEgressMetric: (record: ActivityEgressTelemetryRecord, installContext: SeekaTelemetryInstallContext) => Promise<void>;\n shutdown: () => Promise<void>;\n}\n"],
|
|
5
|
+
"mappings": "AAGA,OAAS,SAASA,EAAa,WAAWC,MAAqB,SAI/D,OAAQ,aAAAC,MAAiC,aAGzC,OAA6B,iCAAAC,MAAoC,8BCajE,IAAMC,EAAc,IAAI,YAExB,SAASC,EAAaC,EAA2B,CAE/C,IAAIC,EAAID,IAAU,EACZE,EAAkB,CAAC,EACzB,KAAOD,GAAK,KACVC,EAAM,KAAMD,EAAI,IAAQ,GAAI,EAC5BA,KAAO,EAET,OAAAC,EAAM,KAAKD,CAAC,EACL,WAAW,KAAKC,CAAK,CAC9B,CAEA,SAASC,EAAUC,EAAqBC,EAA8B,CACpE,IAAMC,EAAOF,GAAe,EAAKC,EACjC,OAAON,EAAaO,CAAG,CACzB,CAEA,SAASC,EAAkBH,EAAqBJ,EAAyC,CACvF,GAAIA,GAAS,KAAM,MAAO,CAAC,EAC3B,IAAMQ,EAAMV,EAAY,OAAOE,CAAK,EACpC,MAAO,CAACG,EAAUC,EAAa,CAAM,EAAGL,EAAaS,EAAI,MAAM,EAAGA,CAAG,CACvE,CAEA,SAASC,EAAiBL,EAAqBJ,EAAiC,CAC9E,MAAO,CAACG,EAAUC,EAAa,CAAM,EAAGL,EAAaC,EAAM,MAAM,EAAGA,CAAK,CAC3E,CAEA,SAASU,EAAkBN,EAAqBJ,EAAyC,CACvF,GAAIA,GAAS,KAAM,MAAO,CAAC,EAC3B,IAAMW,EAAM,IAAI,YAAY,CAAC,EAC7B,WAAI,SAASA,CAAG,EAAE,WAAW,EAAGX,EAAO,EAAI,EACpC,CAACG,EAAUC,EAAa,CAAQ,EAAG,IAAI,WAAWO,CAAG,CAAC,CAC/D,CAEA,SAASC,EAAYC,EAA+C,CAClE,IAAMC,EAAWD,EAAM,OAAQE,GAAuBA,aAAa,UAAU,EACvEC,EAAQF,E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,SACzB,iBAAkBA,EAAe,UAAU,WAG3C,WAAY,IAAI,KAChB,mBAAoBA,EAAe,UAAU,aAC7C,yBAA0BA,EAAe,UAAU,mBACnD,wBAAyBA,EAAe,QAAQ,KAChD,cAAe,IAAI,IAAIA,EAAe,QAAQ,KAAM,EAAE,EAAE,SAAS,YAAY,CACjF",
|
|
6
|
+
"names": ["undiciFetch", "UndiciHeaders", "jwtDecode", "getNewOrCachedAppInstallToken", "textEncoder", "encodeVarint", "value", "v", "bytes", "encodeTag", "fieldNumber", "wireType", "key", "encodeStringField", "str", "encodeBytesField", "encodeDoubleField", "buf", "concatParts", "parts", "filtered", "p", "total", "sum", "out", "off", "encodeAnyValue", "inner", "encodeKeyValue", "kv", "encodeResource", "res", "encodeInstrumentationScope", "scope", "encodeNumberDataPoint", "ndp", "encodeGauge", "g", "dp", "encodeMetric", "m", "encodeScopeMetrics", "sm", "metric", "encodeResourceMetrics", "rm", "encodeExportMetricsServiceRequestToProto", "req", "parts", "rm", "rmBytes", "encodeResourceMetrics", "encodeBytesField", "concatParts", "toIsoDateTime", "date", "pad", "n", "pad3", "urls", "attrPrefix", "SeekaTelemetryClientCoreImpl", "options", "key", "value", "attrs", "targetKey", "attr", "a", "record", "installContext", "stringifyJson", "v", "now", "toIsoDateTime", "metric", "telemetryEndpointUrl", "logger", "issuerUrl", "appId", "appSecret", "config", "token", "getNewOrCachedAppInstallToken", "base", "url", "decoded", "jwtDecode", "headers", "UndiciHeaders", "body", "encodeExportMetricsServiceRequestToProto", "resp", "undiciFetch", "text", "msg", "createSeekaTelemetryClient", "AggregationTemporality", "createEgressTelemetryRecord", "egressRecord", "egressMetrics", "originActivity"]
|
|
7
7
|
}
|
package/dist/types/models.d.ts
CHANGED
|
@@ -154,8 +154,6 @@ export type SeekaTelemetryClientCoreOptions = {
|
|
|
154
154
|
protobuf?: boolean;
|
|
155
155
|
};
|
|
156
156
|
export type SeekaTelemetryInstallContext = {
|
|
157
|
-
appId: string;
|
|
158
|
-
appSecret: string;
|
|
159
157
|
appInstallId: string;
|
|
160
158
|
};
|
|
161
159
|
export type ActivityEgressTelemetryRecord = ActivityEgressTelemetryRecordBase & ActivityEgressTelemetryRecordMetrics & {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seeka-labs/sdk-apps-server-telemetry-core",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.6",
|
|
4
4
|
"description": "Seeka - Apps SDK - Server Telemetry Core (lightweight OTLP/HTTP exporter wrapper)",
|
|
5
5
|
"author": "SEEKA <platform@seeka.co>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@babel/core": "^7",
|
|
45
45
|
"@babel/preset-env": "^7",
|
|
46
46
|
"@babel/preset-typescript": "^7",
|
|
47
|
-
"@seeka-labs/sdk-apps-server": "2.2.
|
|
47
|
+
"@seeka-labs/sdk-apps-server": "2.2.6",
|
|
48
48
|
"@types/node": "^24",
|
|
49
49
|
"ava": "^6",
|
|
50
50
|
"axios": "^1",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"undici": "^7",
|
|
60
60
|
"winston": "^3"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "7cb859a39dc4f1c1a447ae2cf0eb8b1a57aa54cd"
|
|
63
63
|
}
|