@rasputin-ai/sveltekit 0.12.1 → 0.13.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.
@@ -1,10 +1,11 @@
1
+ import type { RasputinEnvironment } from '@rasputin-ai/core';
1
2
  /**
2
3
  * Public browser configuration only. The privileged project key cannot appear
3
4
  * here, so it is structurally excluded from the client hook API.
4
5
  */
5
6
  export type RasputinSvelteKitClientOptions = {
6
7
  dsn?: string;
7
- environment: string;
8
+ environment: RasputinEnvironment;
8
9
  release: string;
9
10
  buildId?: string;
10
11
  enabled?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/client/options.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,8BAA8B,GAAG;IAC5C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC"}
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/client/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE7D;;;GAGG;AACH,MAAM,MAAM,8BAA8B,GAAG;IAC5C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,mBAAmB,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/runtime/node.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAW7D,OAAO,KAAK,EACX,aAAa,EAKb,MAAM,0BAA0B,CAAC;AAElC,MAAM,MAAM,wBAAwB,GAAG,mBAAmB,CAAC;AAuK3D;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,wBAAwB,GAAG,aAAa,CAAC"}
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/runtime/node.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAc7D,OAAO,KAAK,EACX,aAAa,EAKb,MAAM,0BAA0B,CAAC;AAElC,MAAM,MAAM,wBAAwB,GAAG,mBAAmB,CAAC;AAkM3D;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,wBAAwB,GAAG,aAAa,CAAC"}
@@ -2,19 +2,22 @@
2
2
  import {
3
3
  copyRedactKeys,
4
4
  createClient,
5
- isClientEnabled
5
+ isClientEnabled,
6
+ resolveClientActivation
6
7
  } from "@rasputin-ai/core";
7
8
  import {
8
9
  bindAdaptiveRecorder,
10
+ bindFunctionMetrics,
9
11
  inertErrorObservation,
10
12
  installAutomaticExecutionRuntime,
11
13
  installGlobalHandlers,
14
+ releaseFunctionMetricsBindings,
12
15
  scheduleInstrumentationManifestUpload
13
16
  } from "@rasputin-ai/node/internal";
14
17
 
15
18
  // src/sdk-meta.ts
16
19
  var SDK_NAME = "@rasputin-ai/sveltekit";
17
- var SDK_VERSION = "0.12.1";
20
+ var SDK_VERSION = "0.13.1";
18
21
 
19
22
  // src/runtime/node.ts
20
23
  var inertScope = () => ({
@@ -45,7 +48,7 @@ var publicScope = (runtime, request) => {
45
48
  return inertScope();
46
49
  }
47
50
  };
48
- var bindClient = (client, runtime, installRuntime, manifest, uninstallHandlers, policy) => {
51
+ var bindClient = (client, runtime, installRuntime, manifest, uninstallHandlers, policy, metrics) => {
49
52
  const uninstallRuntime = installRuntime ? installAutomaticExecutionRuntime(runtime) : () => {
50
53
  };
51
54
  const manifestUpload = scheduleInstrumentationManifestUpload({
@@ -60,6 +63,7 @@ var bindClient = (client, runtime, installRuntime, manifest, uninstallHandlers,
60
63
  manifestUpload.disconnect();
61
64
  const startedAt = Date.now();
62
65
  await policy?.close();
66
+ await releaseFunctionMetricsBindings(metrics);
63
67
  await client.close();
64
68
  await manifestUpload.wait(Math.max(0, 2e3 - (Date.now() - startedAt)));
65
69
  };
@@ -76,10 +80,12 @@ var bindClient = (client, runtime, installRuntime, manifest, uninstallHandlers,
76
80
  await client.flush(timeoutMs);
77
81
  if (timeoutMs === void 0) {
78
82
  await policy?.flush();
83
+ await metrics?.exporter.flush();
79
84
  await manifestUpload.wait();
80
85
  return;
81
86
  }
82
87
  await policy?.flush(Math.max(0, timeoutMs - (Date.now() - startedAt)));
88
+ await metrics?.exporter.flush(Math.max(0, timeoutMs - (Date.now() - startedAt)));
83
89
  await manifestUpload.wait(Math.max(0, timeoutMs - (Date.now() - startedAt)));
84
90
  },
85
91
  close: shutdown
@@ -90,6 +96,23 @@ var bindClient = (client, runtime, installRuntime, manifest, uninstallHandlers,
90
96
  var createBoundRuntime = (options, hooks, capture) => {
91
97
  const enabled = capture && isClientEnabled(options);
92
98
  const recorderEnabled = enabled && options.executionRecorder?.enabled !== false;
99
+ const activation = resolveClientActivation({
100
+ enabled: options.enabled === false || !capture ? false : options.enabled,
101
+ dsn: options.dsn,
102
+ projectApiKey: options.projectApiKey,
103
+ apiUrl: options.apiUrl,
104
+ release: options.release,
105
+ environment: options.environment
106
+ });
107
+ const metrics = activation.enabled ? bindFunctionMetrics({
108
+ options: options.functionMetrics,
109
+ clientEnabled: true,
110
+ environment: activation.environment,
111
+ release: activation.release,
112
+ ingestToken: activation.ingestToken,
113
+ apiUrl: activation.apiUrl,
114
+ fetch: hooks.fetch
115
+ }) : void 0;
93
116
  const { runtime, policy } = bindAdaptiveRecorder({
94
117
  executionRecorder: options.executionRecorder,
95
118
  recorderEnabled,
@@ -102,7 +125,8 @@ var createBoundRuntime = (options, hooks, capture) => {
102
125
  enabled: options.enabled === false || !capture ? false : options.enabled,
103
126
  sdkName: SDK_NAME,
104
127
  sdkVersion: SDK_VERSION,
105
- scrubPII: options.scrubPII
128
+ scrubPII: options.scrubPII,
129
+ functionMetrics: metrics?.collector
106
130
  });
107
131
  const client = createClient(
108
132
  { ...options, enabled },
@@ -121,7 +145,7 @@ var createBoundRuntime = (options, hooks, capture) => {
121
145
  const bound = bindClient(
122
146
  client,
123
147
  runtime,
124
- recorderEnabled,
148
+ recorderEnabled || Boolean(metrics),
125
149
  {
126
150
  projectApiKey: options.projectApiKey,
127
151
  release: options.release,
@@ -133,7 +157,8 @@ var createBoundRuntime = (options, hooks, capture) => {
133
157
  logSuccess: options.logSuccess
134
158
  },
135
159
  () => uninstallHandlers(),
136
- policy
160
+ policy,
161
+ metrics
137
162
  );
138
163
  if (enabled && (hooks.installGlobalHandlers ?? options.installGlobalHandlers) === true) {
139
164
  uninstallHandlers = installGlobalHandlers(bound.client);
@@ -1,4 +1,4 @@
1
1
  /** Generated by scripts/generate-sdk-meta.ts — do not edit. */
2
2
  export declare const SDK_NAME = "@rasputin-ai/sveltekit";
3
- export declare const SDK_VERSION = "0.12.1";
3
+ export declare const SDK_VERSION = "0.13.1";
4
4
  //# sourceMappingURL=sdk-meta.d.ts.map