@hanzo/event 0.3.21 → 0.3.22

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/dist/index.cjs CHANGED
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ var events = require('@hanzo/events');
4
+
3
5
  // src/attribution.ts
4
6
  var SOCIAL_HOSTS = [
5
7
  "facebook.",
@@ -89,59 +91,6 @@ function dsnForProduct(product, key) {
89
91
  return `https://${key}@api.hanzo.ai/v1/sentry/${projectId}`;
90
92
  }
91
93
 
92
- // src/events.ts
93
- var EVENTS = {
94
- // Signup funnel: view -> submit -> verify -> completed -> first action.
95
- SIGNUP_VIEWED: "signup_viewed",
96
- SIGNUP_SUBMITTED: "signup_submitted",
97
- SIGNUP_VERIFIED: "signup_verified",
98
- SIGNUP_COMPLETED: "signup_completed",
99
- /** A RETURNING user authenticated — the non-signup half of the IAM callback.
100
- * Keeping it distinct is what stops returning logins from inflating signups. */
101
- LOGIN_COMPLETED: "login_completed",
102
- /** Activation: the first moment of real value. ONE event for every product —
103
- * the product-specific moment is the `action` property (api_call, app_live,
104
- * chat_reply), never a new event name. */
105
- FIRST_ACTION: "first_action",
106
- // Waitlist + referral.
107
- WAITLIST_JOINED: "waitlist_joined",
108
- WAITLIST_SHARED: "waitlist_shared",
109
- REFERRAL_USED: "referral_used",
110
- REFERRAL_CLAIMED: "referral_claimed",
111
- // Upgrade-intent + purchase.
112
- PRICING_VIEWED: "pricing_viewed",
113
- PLAN_CLICKED: "plan_clicked",
114
- CHECKOUT_STARTED: "checkout_started",
115
- ORDER_COMPLETED: "order_completed",
116
- // Feature usage — generic + the common key surfaces across products.
117
- FEATURE_USED: "feature_used",
118
- API_KEY_CREATED: "api_key_created",
119
- APP_CREATED: "app_created",
120
- PROJECT_CREATED: "project_created",
121
- AGENT_CREATED: "agent_created",
122
- CHAT_STARTED: "chat_started",
123
- CHAT_MESSAGE_SENT: "chat_message_sent",
124
- /** The user switched model/endpoint — the single strongest quality signal a
125
- * chat surface emits (a switch usually follows a bad answer). */
126
- MODEL_SWITCHED: "model_switched",
127
- TASK_STARTED: "task_started",
128
- TASK_COMPLETED: "task_completed",
129
- // Build → ship. `build_*` is a MODEL producing an artifact; `deploy_*` is that
130
- // artifact going live. Intent (build_started) is never the same event as the
131
- // artifact existing (app_created) — conflating them makes the funnel lie.
132
- BUILD_STARTED: "build_started",
133
- /** A model finished producing an artifact (an app build, a chat reply, an agent
134
- * run). Carries `durationMs` — the outcome event owns its own duration, so no
135
- * paired start event is needed. */
136
- GENERATION_COMPLETED: "generation_completed",
137
- GENERATION_FAILED: "generation_failed",
138
- DEPLOY_STARTED: "deploy_started",
139
- DEPLOY_SUCCEEDED: "deploy_succeeded",
140
- DEPLOY_FAILED: "deploy_failed"
141
- };
142
- var PAGEVIEW = "$pageview";
143
- var EXCEPTION = "$exception";
144
-
145
94
  // src/scrub.ts
146
95
  var REDACTED = "[redacted]";
147
96
  var EMAIL_MARK = "[email]";
@@ -893,7 +842,7 @@ var Analytics = class {
893
842
  /** pageview records a $pageview for the current (or given) location. */
894
843
  pageview(path, properties) {
895
844
  const p = path ?? (isBrowser() ? window.location.pathname : void 0);
896
- this.enqueue("pageview", PAGEVIEW, { path: p, properties });
845
+ this.enqueue("pageview", events.PAGEVIEW, { path: p, properties });
897
846
  }
898
847
  /** capture records a named product event with optional properties. Commerce
899
848
  * fields (productId/quantity/revenue/currency) may be passed for order events. */
@@ -926,7 +875,7 @@ var Analytics = class {
926
875
  const handled = context?.handled ?? true;
927
876
  const ex = normalizeError2(err);
928
877
  ex.handled = handled;
929
- this.enqueue("event", EXCEPTION, {
878
+ this.enqueue("event", events.EXCEPTION, {
930
879
  error: ex,
931
880
  properties: {
932
881
  ...context?.properties,
@@ -1096,11 +1045,11 @@ var FUNNELS = {
1096
1045
  products: ["site"],
1097
1046
  join: "person",
1098
1047
  steps: [
1099
- s(PAGEVIEW, "Landed"),
1100
- s(EVENTS.SIGNUP_VIEWED, "Opened signup"),
1101
- s(EVENTS.SIGNUP_SUBMITTED, "Redirected to Hanzo ID"),
1102
- s(EVENTS.SIGNUP_COMPLETED, "Account created"),
1103
- s(EVENTS.FIRST_ACTION, "First action")
1048
+ s(events.PAGEVIEW, "Landed"),
1049
+ s(events.EVENTS.SIGNUP_VIEWED, "Opened signup"),
1050
+ s(events.EVENTS.SIGNUP_SUBMITTED, "Redirected to Hanzo ID"),
1051
+ s(events.EVENTS.SIGNUP_COMPLETED, "Account created"),
1052
+ s(events.EVENTS.FIRST_ACTION, "First action")
1104
1053
  ]
1105
1054
  },
1106
1055
  /** The developer activation path: an account is worth nothing until a key has
@@ -1111,9 +1060,9 @@ var FUNNELS = {
1111
1060
  products: ["site", "cloud"],
1112
1061
  join: "person",
1113
1062
  steps: [
1114
- s(EVENTS.SIGNUP_COMPLETED, "Account created"),
1115
- s(EVENTS.API_KEY_CREATED, "Key minted"),
1116
- s(EVENTS.FIRST_ACTION, "First successful API call", {
1063
+ s(events.EVENTS.SIGNUP_COMPLETED, "Account created"),
1064
+ s(events.EVENTS.API_KEY_CREATED, "Key minted"),
1065
+ s(events.EVENTS.FIRST_ACTION, "First successful API call", {
1117
1066
  property: "action",
1118
1067
  equals: "api_call"
1119
1068
  })
@@ -1125,10 +1074,10 @@ var FUNNELS = {
1125
1074
  products: ["site", "app", "console"],
1126
1075
  join: "person",
1127
1076
  steps: [
1128
- s(EVENTS.PRICING_VIEWED, "Viewed pricing"),
1129
- s(EVENTS.PLAN_CLICKED, "Chose a plan"),
1130
- s(EVENTS.CHECKOUT_STARTED, "Started checkout"),
1131
- s(EVENTS.ORDER_COMPLETED, "Paid")
1077
+ s(events.EVENTS.PRICING_VIEWED, "Viewed pricing"),
1078
+ s(events.EVENTS.PLAN_CLICKED, "Chose a plan"),
1079
+ s(events.EVENTS.CHECKOUT_STARTED, "Started checkout"),
1080
+ s(events.EVENTS.ORDER_COMPLETED, "Paid")
1132
1081
  ]
1133
1082
  },
1134
1083
  /** hanzo.app: describe → build → deploy → live URL. The whole product thesis
@@ -1138,11 +1087,11 @@ var FUNNELS = {
1138
1087
  products: ["app"],
1139
1088
  join: "person",
1140
1089
  steps: [
1141
- s(PAGEVIEW, "Landed"),
1142
- s(EVENTS.BUILD_STARTED, "Described an app"),
1143
- s(EVENTS.GENERATION_COMPLETED, "Got a working build"),
1144
- s(EVENTS.DEPLOY_STARTED, "Hit publish"),
1145
- s(EVENTS.DEPLOY_SUCCEEDED, "Live URL")
1090
+ s(events.PAGEVIEW, "Landed"),
1091
+ s(events.EVENTS.BUILD_STARTED, "Described an app"),
1092
+ s(events.EVENTS.GENERATION_COMPLETED, "Got a working build"),
1093
+ s(events.EVENTS.DEPLOY_STARTED, "Hit publish"),
1094
+ s(events.EVENTS.DEPLOY_SUCCEEDED, "Live URL")
1146
1095
  ]
1147
1096
  },
1148
1097
  /** hanzo.chat: visit → first message → answer. `generation_completed` is what
@@ -1152,10 +1101,10 @@ var FUNNELS = {
1152
1101
  products: ["chat"],
1153
1102
  join: "person",
1154
1103
  steps: [
1155
- s(PAGEVIEW, "Landed"),
1156
- s(EVENTS.CHAT_STARTED, "Started a conversation"),
1157
- s(EVENTS.CHAT_MESSAGE_SENT, "Sent a message"),
1158
- s(EVENTS.GENERATION_COMPLETED, "Got an answer")
1104
+ s(events.PAGEVIEW, "Landed"),
1105
+ s(events.EVENTS.CHAT_STARTED, "Started a conversation"),
1106
+ s(events.EVENTS.CHAT_MESSAGE_SENT, "Sent a message"),
1107
+ s(events.EVENTS.GENERATION_COMPLETED, "Got an answer")
1159
1108
  ]
1160
1109
  },
1161
1110
  /** The cross-surface handoff: the hanzo.ai composer forwards its prompt to
@@ -1167,15 +1116,15 @@ var FUNNELS = {
1167
1116
  products: ["site", "chat"],
1168
1117
  join: "aggregate",
1169
1118
  steps: [
1170
- s(EVENTS.CHAT_STARTED, "Submitted the hanzo.ai composer", {
1119
+ s(events.EVENTS.CHAT_STARTED, "Submitted the hanzo.ai composer", {
1171
1120
  property: "source",
1172
1121
  equals: "composer"
1173
1122
  }),
1174
- s(EVENTS.CHAT_STARTED, "Landed in hanzo.chat", {
1123
+ s(events.EVENTS.CHAT_STARTED, "Landed in hanzo.chat", {
1175
1124
  property: "referrerProduct",
1176
1125
  equals: "site"
1177
1126
  }),
1178
- s(EVENTS.GENERATION_COMPLETED, "Got an answer")
1127
+ s(events.EVENTS.GENERATION_COMPLETED, "Got an answer")
1179
1128
  ]
1180
1129
  }
1181
1130
  };
@@ -1188,14 +1137,14 @@ var GOALS = {
1188
1137
  // Signup: the conversion is signup_completed, along the site signup funnel.
1189
1138
  signup: {
1190
1139
  label: "Signup",
1191
- event: EVENTS.SIGNUP_COMPLETED,
1140
+ event: events.EVENTS.SIGNUP_COMPLETED,
1192
1141
  funnelId: "signup",
1193
1142
  funnel: eventsOf("signup")
1194
1143
  },
1195
1144
  // Sale: a completed order qualified as a plan purchase (kind=plan).
1196
1145
  sale: {
1197
1146
  label: "Sale",
1198
- event: EVENTS.ORDER_COMPLETED,
1147
+ event: events.EVENTS.ORDER_COMPLETED,
1199
1148
  funnelId: "upgrade",
1200
1149
  funnel: eventsOf("upgrade"),
1201
1150
  filter: { property: "kind", equals: "plan" }
@@ -1203,7 +1152,7 @@ var GOALS = {
1203
1152
  // Upgrade intent: a plan click; pricing_viewed is the top of its funnel.
1204
1153
  upgradeIntent: {
1205
1154
  label: "Upgrade Intent",
1206
- event: EVENTS.PLAN_CLICKED,
1155
+ event: events.EVENTS.PLAN_CLICKED,
1207
1156
  funnelId: "upgrade",
1208
1157
  funnel: eventsOf("upgrade")
1209
1158
  },
@@ -1211,7 +1160,7 @@ var GOALS = {
1211
1160
  // valuable thing (a successful API call, a live app, a chat answer).
1212
1161
  activation: {
1213
1162
  label: "Activation",
1214
- event: EVENTS.FIRST_ACTION,
1163
+ event: events.EVENTS.FIRST_ACTION,
1215
1164
  funnelId: "apiActivation",
1216
1165
  funnel: eventsOf("apiActivation")
1217
1166
  }
@@ -1243,13 +1192,22 @@ var COHORTS = {
1243
1192
  * reformat of one copy is a diff against the other.
1244
1193
  */
1245
1194
 
1195
+ Object.defineProperty(exports, "EVENTS", {
1196
+ enumerable: true,
1197
+ get: function () { return events.EVENTS; }
1198
+ });
1199
+ Object.defineProperty(exports, "EXCEPTION", {
1200
+ enumerable: true,
1201
+ get: function () { return events.EXCEPTION; }
1202
+ });
1203
+ Object.defineProperty(exports, "PAGEVIEW", {
1204
+ enumerable: true,
1205
+ get: function () { return events.PAGEVIEW; }
1206
+ });
1246
1207
  exports.Analytics = Analytics;
1247
1208
  exports.COHORTS = COHORTS;
1248
- exports.EVENTS = EVENTS;
1249
- exports.EXCEPTION = EXCEPTION;
1250
1209
  exports.FUNNELS = FUNNELS;
1251
1210
  exports.GOALS = GOALS;
1252
- exports.PAGEVIEW = PAGEVIEW;
1253
1211
  exports.PRODUCTS = PRODUCTS;
1254
1212
  exports.PRODUCT_PROJECT = PRODUCT_PROJECT;
1255
1213
  exports.VERSION = VERSION;