@nexalink/carecompass-sdk 0.1.0-beta.9 → 0.2.0-beta.12

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/TELEMETRY.md ADDED
@@ -0,0 +1,129 @@
1
+ # CareCompass SDK Telemetry Contract
2
+
3
+ Contract version: `1.0.0`
4
+
5
+ CareCompass SDK telemetry measures deployment health without collecting PHI,
6
+ PII, chat content, or credentials. The web SDK sends allowlisted anonymous
7
+ events directly to PostHog's public ingestion API. The CLI uses the same narrow
8
+ transport for onboarding funnel events. React Native and Flutter SDKs should
9
+ adopt the same event names and property contract.
10
+
11
+ ## Configuration
12
+
13
+ Telemetry is enabled automatically for every web SDK deployment. Integrators do
14
+ not need to run an additional CLI command, add a runtime config block, or manage
15
+ a PostHog token.
16
+
17
+ The web SDK sends events to Nexalink's PostHog project through the public US
18
+ ingestion endpoint. It uses a Nexalink-owned public PostHog project token
19
+ compiled into the SDK. The token permits event ingestion only; it is never a
20
+ PostHog personal or admin API key.
21
+
22
+ The anonymous deployment ID is derived from the public payer ID, environment,
23
+ and web platform. For example, payer `acme-health` in staging is reported as
24
+ `acme-health-staging-web`.
25
+
26
+ CLI invocations use an ephemeral random `cli_session_id` as their anonymous
27
+ PostHog `distinct_id`. It is created in memory for one process invocation and is
28
+ not persisted. Before the CLI has public payer context, events use
29
+ `anonymous-unknown-cli`; later events use the public payer ID and environment.
30
+
31
+ ## Event Taxonomy
32
+
33
+ Initialization and configuration:
34
+
35
+ - `carecompass_sdk_initialized`
36
+ - `carecompass_sdk_initialization_failed`
37
+ - `carecompass_sdk_configuration_validated`
38
+ - `carecompass_sdk_configuration_failed`
39
+
40
+ Component lifecycle:
41
+
42
+ - `carecompass_component_rendered`
43
+ - `carecompass_component_opened`
44
+ - `carecompass_component_closed`
45
+ - `carecompass_component_error`
46
+
47
+ Inference lifecycle:
48
+
49
+ - `carecompass_prompt_submitted`
50
+ - `carecompass_inference_succeeded`
51
+ - `carecompass_inference_failed`
52
+ - `carecompass_inference_rate_limited`
53
+
54
+ Customization and deployment health:
55
+
56
+ - `carecompass_theme_loaded`
57
+ - `carecompass_prompt_configuration_loaded`
58
+ - `carecompass_prompt_configuration_failed`
59
+
60
+ CLI onboarding:
61
+
62
+ - `carecompass_cli_started`
63
+ - `carecompass_cli_login_started`
64
+ - `carecompass_cli_login_succeeded`
65
+ - `carecompass_cli_login_failed`
66
+ - `carecompass_cli_init_started`
67
+ - `carecompass_cli_init_failed`
68
+ - `carecompass_cli_setup_kit_generated`
69
+ - `carecompass_cli_validation_succeeded`
70
+ - `carecompass_cli_validation_failed`
71
+ - `carecompass_cli_snippet_generated`
72
+ - `carecompass_cli_doctor_completed`
73
+ - `carecompass_cli_command_failed`
74
+
75
+ For the always-visible web embed, opened and closed map to mount and unmount.
76
+ Future mobile components should map these events to their equivalent visible
77
+ screen lifecycle.
78
+
79
+ ## Allowed Properties
80
+
81
+ Events contain only:
82
+
83
+ - `contract_version`
84
+ - `sdk_version`
85
+ - `component_version`
86
+ - `platform`
87
+ - `environment`
88
+ - `payer_id`
89
+ - `deployment_id`
90
+ - `event_timestamp`
91
+ - `duration_bucket`, when applicable
92
+ - `failure_category`, when applicable
93
+ - `error_code`, when applicable
94
+ - `cli_session_id`, for CLI events only
95
+ - `$process_person_profile: false`
96
+
97
+ The transport also sends the public PostHog project token, event name, anonymous
98
+ `distinct_id`, and timestamp required by the PostHog ingestion API. Web events
99
+ use the deployment ID as `distinct_id`; CLI events use the ephemeral
100
+ `cli_session_id`. It does not identify individual users or create person
101
+ profiles.
102
+
103
+ ## Prohibited Data
104
+
105
+ Never send:
106
+
107
+ - raw user prompts, model responses, chat history, or optional user context
108
+ - PHI, PII, member IDs, policy IDs, names, emails, or phone numbers
109
+ - API keys, access tokens, cookies, credentials, or session secrets
110
+ - CLI arguments, terminal input, or file paths
111
+ - SageMaker credentials, internal infrastructure details, or privileged tokens
112
+ - raw error objects, stack traces, request payloads, or response bodies
113
+ - payer prompt text; use an approved non-sensitive configuration ID in a future
114
+ contract version if needed
115
+
116
+ The web SDK intentionally does not bundle `posthog-js`. It does not enable
117
+ session replay, autocapture, DOM capture, form capture, cookies, persistence,
118
+ surveys, feature flags, or user identification.
119
+
120
+ Package download counts remain registry-owned metrics. CLI telemetry begins when
121
+ the user invokes the installed package.
122
+
123
+ ## Verification
124
+
125
+ 1. Mount a development component, submit a non-PHI prompt, and complete an
126
+ inference.
127
+ 2. Confirm the expected lifecycle events arrive in Nexalink's PostHog project.
128
+ 3. Inspect event payloads and verify they contain only the allowlisted
129
+ properties above.
package/dist/cli.d.ts CHANGED
@@ -3,6 +3,8 @@ type CliIO = {
3
3
  stdout: Pick<NodeJS.WriteStream, "write">;
4
4
  stderr: Pick<NodeJS.WriteStream, "write">;
5
5
  env: NodeJS.ProcessEnv;
6
+ stdin?: NodeJS.ReadStream;
7
+ prompt?: (question: string) => Promise<string>;
6
8
  };
7
9
  export declare function runCareCompassCli(argv?: string[], io?: CliIO): Promise<1 | 0>;
8
10
  export {};