@getuserfeedback/protocol 0.6.1 → 0.7.2
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/app-event.d.ts +659 -17
- package/dist/app-event.d.ts.map +1 -1
- package/dist/app-event.js +71 -8
- package/dist/flow-assignments.d.ts +4 -4
- package/dist/host/constants.d.ts +2 -2
- package/dist/host/constants.d.ts.map +1 -1
- package/dist/host/constants.js +3 -1
- package/dist/host/sdk-types.d.ts +73 -28
- package/dist/host/sdk-types.d.ts.map +1 -1
- package/dist/host/sdk.d.ts.map +1 -1
- package/dist/identity-type.d.ts +4 -2
- package/dist/identity-type.d.ts.map +1 -1
- package/dist/identity-type.js +4 -2
- package/dist/index.d.ts +2 -86
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -6
- package/dist/widget-commands.d.ts +102 -3
- package/dist/widget-commands.d.ts.map +1 -1
- package/dist/widget-commands.js +5 -0
- package/dist/widget-config.d.ts +5 -5
- package/package.json +22 -2
- package/src/app-event.ts +211 -0
- package/src/client-meta.ts +25 -0
- package/src/defaults.ts +4 -0
- package/src/errors.ts +58 -0
- package/src/flow-assignments.test.ts +63 -0
- package/src/flow-assignments.ts +125 -0
- package/src/host/command-dispatch.ts +59 -0
- package/src/host/command-envelope.ts +41 -0
- package/src/host/command-settlement.ts +121 -0
- package/src/host/constants.ts +103 -0
- package/src/host/host-event-contract.ts +277 -0
- package/src/host/index.ts +13 -0
- package/src/host/lazy-handle-client.ts +207 -0
- package/src/host/request-id.ts +3 -0
- package/src/host/sdk-types.ts +506 -0
- package/src/host/sdk.ts +43 -0
- package/src/host/unique-id.ts +17 -0
- package/src/identity-type.ts +102 -0
- package/src/index.ts +136 -0
- package/src/protocol-root.test.ts +476 -0
- package/src/public-grant-scope.ts +25 -0
- package/src/runtime-endpoints.ts +69 -0
- package/src/scopes.ts +79 -0
- package/src/trpc-envelope.ts +9 -0
- package/src/version-resolution.ts +18 -0
- package/src/widget-commands.ts +152 -0
- package/src/widget-config.ts +157 -0
package/dist/app-event.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-event.d.ts","sourceRoot":"","sources":["../src/app-event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAG9B,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAEhE,eAAO,MAAM,sBAAsB;;;iBAGjC,CAAC;AAEH,KAAK,iBAAiB,GACnB,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,iBAAiB,EAAE,GACnB;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB,CAAA;CAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"app-event.d.ts","sourceRoot":"","sources":["../src/app-event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAG9B,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAEhE,eAAO,MAAM,sBAAsB;;;iBAGjC,CAAC;AAEH,KAAK,iBAAiB,GACnB,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,iBAAiB,EAAE,GACnB;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB,CAAA;CAAE,CAAC;AAExC,MAAM,MAAM,iBAAiB,GAC1B,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,iBAAiB,EAAE,GACnB;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB,CAAA;CAAE,CAAC;AAgCxC,eAAO,MAAM,0BAA0B;;;;iBAIrC,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;iBAY7B,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;;;iBAInC,CAAC;AAQH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAMhC,CAAC;AAEH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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YA1DD,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+BA6DvC,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC;AACtE,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACrE,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAC/D,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,wBAAwB,CAAC,CAAC"}
|
package/dist/app-event.js
CHANGED
|
@@ -13,6 +13,18 @@ const appEventFlagValueSchema = z.lazy(() => z.union([
|
|
|
13
13
|
z.array(appEventFlagValueSchema),
|
|
14
14
|
z.record(z.string(), appEventFlagValueSchema),
|
|
15
15
|
]));
|
|
16
|
+
const appEventJsonNumberSchema = z.number().check(z.refine(Number.isFinite, {
|
|
17
|
+
message: "Expected a finite JSON number.",
|
|
18
|
+
}));
|
|
19
|
+
const appEventJsonValueSchema = z.lazy(() => z.union([
|
|
20
|
+
z.string(),
|
|
21
|
+
appEventJsonNumberSchema,
|
|
22
|
+
z.boolean(),
|
|
23
|
+
z.null(),
|
|
24
|
+
z.array(appEventJsonValueSchema),
|
|
25
|
+
z.record(z.string(), appEventJsonValueSchema),
|
|
26
|
+
]));
|
|
27
|
+
const appEventJsonObjectSchema = z.record(z.string(), appEventJsonValueSchema);
|
|
16
28
|
export const appEventFlagProviderSchema = z.object({
|
|
17
29
|
name: z.string().check(z.trim(), z.minLength(1)),
|
|
18
30
|
project: z.optional(z.string().check(z.trim(), z.minLength(1))),
|
|
@@ -56,19 +68,70 @@ export const appEventBaseSchema = z.object({
|
|
|
56
68
|
const appEventSurveyReferenceSchema = z.object({
|
|
57
69
|
surveyId: z.string(),
|
|
58
70
|
});
|
|
59
|
-
export const
|
|
71
|
+
export const reservedSystemAppEventNames = [
|
|
72
|
+
"Response Submitted",
|
|
73
|
+
"Flow Viewed",
|
|
74
|
+
"Flow Dismissed",
|
|
75
|
+
"Identified",
|
|
76
|
+
];
|
|
77
|
+
const reservedSystemAppEventNameLowercaseSet = new Set(reservedSystemAppEventNames.map((event) => event.toLowerCase()));
|
|
78
|
+
const appEventSystemTrackNameSchema = z.enum(["Flow Viewed", "Flow Dismissed"]);
|
|
79
|
+
const appEventCustomerNameSchema = z.string().check(z.trim(), z.minLength(1), z.maxLength(255), z.check((ctx) => {
|
|
80
|
+
if (!reservedSystemAppEventNameLowercaseSet.has(ctx.value.toLowerCase())) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
ctx.issues.push({
|
|
84
|
+
code: "custom",
|
|
85
|
+
input: ctx.value,
|
|
86
|
+
message: "Customer app event names cannot use reserved system event names.",
|
|
87
|
+
continue: false,
|
|
88
|
+
});
|
|
89
|
+
}));
|
|
90
|
+
export const appEventSystemBaseSchema = z.extend(appEventBaseSchema, {
|
|
91
|
+
origin: z.literal("system"),
|
|
92
|
+
});
|
|
93
|
+
const normalizeSystemAppEventOrigin = (input) => {
|
|
94
|
+
const { origin: _origin, ...rest } = input;
|
|
95
|
+
return {
|
|
96
|
+
...rest,
|
|
97
|
+
origin: "system",
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
export const appEventSurveyViewedSchema = z.pipe(z.extend(appEventBaseSchema, {
|
|
101
|
+
origin: z.optional(z.literal("system")),
|
|
60
102
|
event: z.literal("Flow Viewed"),
|
|
61
103
|
references: appEventSurveyReferenceSchema,
|
|
62
|
-
});
|
|
63
|
-
export const appEventFlowDismissedSchema = z.extend(appEventBaseSchema, {
|
|
104
|
+
}), z.transform(normalizeSystemAppEventOrigin));
|
|
105
|
+
export const appEventFlowDismissedSchema = z.pipe(z.extend(appEventBaseSchema, {
|
|
106
|
+
origin: z.optional(z.literal("system")),
|
|
64
107
|
event: z.literal("Flow Dismissed"),
|
|
65
108
|
references: appEventSurveyReferenceSchema,
|
|
109
|
+
}), z.transform(normalizeSystemAppEventOrigin));
|
|
110
|
+
export const appEventSystemTrackSchema = z.extend(appEventSystemBaseSchema, {
|
|
111
|
+
event: appEventSystemTrackNameSchema,
|
|
112
|
+
references: appEventSurveyReferenceSchema,
|
|
66
113
|
});
|
|
67
|
-
|
|
68
|
-
|
|
114
|
+
const appEventLegacySystemTrackSchema = z.pipe(z.extend(appEventBaseSchema, {
|
|
115
|
+
origin: z.optional(z.literal("system")),
|
|
116
|
+
event: appEventSystemTrackNameSchema,
|
|
69
117
|
references: appEventSurveyReferenceSchema,
|
|
118
|
+
}), z.transform(normalizeSystemAppEventOrigin));
|
|
119
|
+
export const appEventCustomerTrackSchema = z.extend(appEventBaseSchema, {
|
|
120
|
+
origin: z.literal("customer"),
|
|
121
|
+
event: appEventCustomerNameSchema,
|
|
122
|
+
// TODO(migration): Normalize Date values in event properties to ISO strings.
|
|
123
|
+
// [from=manual-date-property-serialization] [to=protocol-date-property-normalization] [scope=slice] [priority=medium] [impact=medium] [risk=low]
|
|
124
|
+
properties: z.optional(appEventJsonObjectSchema),
|
|
70
125
|
});
|
|
71
|
-
export const
|
|
72
|
-
|
|
73
|
-
|
|
126
|
+
export const appEventTrackSchema = z.union([
|
|
127
|
+
appEventLegacySystemTrackSchema,
|
|
128
|
+
appEventCustomerTrackSchema,
|
|
129
|
+
]);
|
|
130
|
+
const appEventDiscriminatedPayloadSchema = z.discriminatedUnion("origin", [
|
|
131
|
+
appEventSystemTrackSchema,
|
|
132
|
+
appEventCustomerTrackSchema,
|
|
133
|
+
]);
|
|
134
|
+
export const appEventPayloadSchema = z.union([
|
|
135
|
+
appEventLegacySystemTrackSchema,
|
|
136
|
+
appEventDiscriminatedPayloadSchema,
|
|
74
137
|
]);
|
|
@@ -91,7 +91,7 @@ export declare const flowAssignmentTargetingContextSchema: z.ZodMiniObject<{
|
|
|
91
91
|
}, z.core.$strip>;
|
|
92
92
|
export declare const flowAssignmentRecipientRequestSchema: z.ZodMiniObject<{
|
|
93
93
|
identities: z.ZodMiniDefault<z.ZodMiniArray<z.ZodMiniObject<{
|
|
94
|
-
type: z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<"
|
|
94
|
+
type: z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<import("./identity-type.js").IdentityTypeValue, string>>;
|
|
95
95
|
value: z.ZodMiniString<string>;
|
|
96
96
|
}, z.core.$strip>>>;
|
|
97
97
|
context: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
@@ -236,7 +236,7 @@ export declare const listPendingFlowAssignmentsResponseSchema: z.ZodMiniObject<{
|
|
|
236
236
|
}, z.core.$strip>;
|
|
237
237
|
export declare const claimPendingFlowAssignmentsRequestSchema: z.ZodMiniObject<{
|
|
238
238
|
identities: z.ZodMiniDefault<z.ZodMiniArray<z.ZodMiniObject<{
|
|
239
|
-
type: z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<"
|
|
239
|
+
type: z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<import("./identity-type.js").IdentityTypeValue, string>>;
|
|
240
240
|
value: z.ZodMiniString<string>;
|
|
241
241
|
}, z.core.$strip>>>;
|
|
242
242
|
context: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
@@ -355,7 +355,7 @@ export declare const claimPendingFlowAssignmentsResponseSchema: z.ZodMiniObject<
|
|
|
355
355
|
}, z.core.$strip>;
|
|
356
356
|
export declare const updateFlowAssignmentLifecycleRequestSchema: z.ZodMiniObject<{
|
|
357
357
|
identities: z.ZodMiniDefault<z.ZodMiniArray<z.ZodMiniObject<{
|
|
358
|
-
type: z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<"
|
|
358
|
+
type: z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<import("./identity-type.js").IdentityTypeValue, string>>;
|
|
359
359
|
value: z.ZodMiniString<string>;
|
|
360
360
|
}, z.core.$strip>>>;
|
|
361
361
|
context: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
@@ -444,7 +444,7 @@ export declare const updateFlowAssignmentLifecycleRequestSchema: z.ZodMiniObject
|
|
|
444
444
|
}, z.core.$strip>;
|
|
445
445
|
export declare const releaseFlowAssignmentClaimRequestSchema: z.ZodMiniObject<{
|
|
446
446
|
identities: z.ZodMiniDefault<z.ZodMiniArray<z.ZodMiniObject<{
|
|
447
|
-
type: z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<"
|
|
447
|
+
type: z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<import("./identity-type.js").IdentityTypeValue, string>>;
|
|
448
448
|
value: z.ZodMiniString<string>;
|
|
449
449
|
}, z.core.$strip>>>;
|
|
450
450
|
holdGroupToken: z.ZodMiniString<string>;
|
package/dist/host/constants.d.ts
CHANGED
|
@@ -27,9 +27,9 @@ export declare const HOST_EVENT_KEYS: {
|
|
|
27
27
|
* Stable capability tokens announced by the browser SDK during init.
|
|
28
28
|
* These are versioned and namespaced to support forward-compatible negotiation.
|
|
29
29
|
*/
|
|
30
|
-
export declare const SDK_PROTOCOL_CAPABILITIES: readonly ["gx.protocol.public.v1", "gx.command.configure.v1", "gx.command.open.v1", "gx.command.prefetch.v1", "gx.command.prerender.v1", "gx.command.identify.v1", "gx.command.setContainer.v1", "gx.command.close.v1", "gx.command.reset.v1", "gx.command.setDefaultContainerPolicy.v1"];
|
|
30
|
+
export declare const SDK_PROTOCOL_CAPABILITIES: readonly ["gx.protocol.public.v1", "gx.command.configure.v1", "gx.command.open.v1", "gx.command.prefetch.v1", "gx.command.prerender.v1", "gx.command.identify.v1", "gx.command.setContainer.v1", "gx.command.close.v1", "gx.command.reset.v1", "gx.command.setDefaultContainerPolicy.v1", "gx.command.track.v1"];
|
|
31
31
|
export type SdkProtocolCapability = (typeof SDK_PROTOCOL_CAPABILITIES)[number];
|
|
32
32
|
export declare const LOADER_RUNTIME_GLOBAL_KEY: "__getuserfeedback_runtime";
|
|
33
|
-
export declare const LOADER_RUNTIME_PROTOCOL_VERSION: "
|
|
33
|
+
export declare const LOADER_RUNTIME_PROTOCOL_VERSION: "v2";
|
|
34
34
|
export declare const toHostEventName: (key: string) => string;
|
|
35
35
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/host/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,gBAAgB;;;;;;CAMnB,CAAC;AAEX,MAAM,MAAM,kBAAkB,GAC7B,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,OAAO,gBAAgB,CAAC,CAAC;AAI1D,eAAO,MAAM,eAAe,EAAG,kBAA2B,CAAC;AAE3D,eAAO,MAAM,mBAAmB,EAAG,kBAA2B,CAAC;AAI/D,eAAO,MAAM,iBAAiB,EAAG,kBAA2B,CAAC;AAE7D,eAAO,MAAM,eAAe;;;;;;;;;;;;;CAalB,CAAC;
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/host/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,gBAAgB;;;;;;CAMnB,CAAC;AAEX,MAAM,MAAM,kBAAkB,GAC7B,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,OAAO,gBAAgB,CAAC,CAAC;AAI1D,eAAO,MAAM,eAAe,EAAG,kBAA2B,CAAC;AAE3D,eAAO,MAAM,mBAAmB,EAAG,kBAA2B,CAAC;AAI/D,eAAO,MAAM,iBAAiB,EAAG,kBAA2B,CAAC;AAE7D,eAAO,MAAM,eAAe;;;;;;;;;;;;;CAalB,CAAC;AAkDX;;;GAGG;AACH,eAAO,MAAM,yBAAyB,kTAG5B,CAAC;AAEX,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,yBAAyB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/E,eAAO,MAAM,yBAAyB,EAAG,2BAAoC,CAAC;AAC9E,eAAO,MAAM,+BAA+B,EAAG,IAAa,CAAC;AAG7D,eAAO,MAAM,eAAe,GAAI,KAAK,MAAM,KAAG,MACjB,CAAC"}
|
package/dist/host/constants.js
CHANGED
|
@@ -36,6 +36,7 @@ const SDK_COMMAND_CAPABILITY_BY_KIND = {
|
|
|
36
36
|
close: "gx.command.close.v1",
|
|
37
37
|
reset: "gx.command.reset.v1",
|
|
38
38
|
setDefaultContainerPolicy: "gx.command.setDefaultContainerPolicy.v1",
|
|
39
|
+
track: "gx.command.track.v1",
|
|
39
40
|
};
|
|
40
41
|
const SDK_COMMAND_CAPABILITIES = [
|
|
41
42
|
SDK_COMMAND_CAPABILITY_BY_KIND.configure,
|
|
@@ -47,6 +48,7 @@ const SDK_COMMAND_CAPABILITIES = [
|
|
|
47
48
|
SDK_COMMAND_CAPABILITY_BY_KIND.close,
|
|
48
49
|
SDK_COMMAND_CAPABILITY_BY_KIND.reset,
|
|
49
50
|
SDK_COMMAND_CAPABILITY_BY_KIND.setDefaultContainerPolicy,
|
|
51
|
+
SDK_COMMAND_CAPABILITY_BY_KIND.track,
|
|
50
52
|
];
|
|
51
53
|
/**
|
|
52
54
|
* Stable capability tokens announced by the browser SDK during init.
|
|
@@ -57,6 +59,6 @@ export const SDK_PROTOCOL_CAPABILITIES = [
|
|
|
57
59
|
...SDK_COMMAND_CAPABILITIES,
|
|
58
60
|
];
|
|
59
61
|
export const LOADER_RUNTIME_GLOBAL_KEY = "__getuserfeedback_runtime";
|
|
60
|
-
export const LOADER_RUNTIME_PROTOCOL_VERSION = "
|
|
62
|
+
export const LOADER_RUNTIME_PROTOCOL_VERSION = "v2";
|
|
61
63
|
// Helper to construct full event name with prefix
|
|
62
64
|
export const toHostEventName = (key) => `${HOST_EVENT_PREFIX}${key}`;
|
package/dist/host/sdk-types.d.ts
CHANGED
|
@@ -4,14 +4,21 @@
|
|
|
4
4
|
* {@link FlowState} lives in `./host-event-contract` (re-exported from the `@getuserfeedback/protocol/host` barrel).
|
|
5
5
|
*/
|
|
6
6
|
import type { Scope } from "../scopes.js";
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Identifier types supported by event tracking and identity resolution.
|
|
9
|
+
*
|
|
10
|
+
* Use `custom.<name>` for business-specific identifiers such as
|
|
11
|
+
* `custom.shopifyCustomerId` or `custom.salesforceContactId`.
|
|
12
|
+
*
|
|
13
|
+
* @see https://getuserfeedback.com/docs/guides/identity-resolution
|
|
14
|
+
*/
|
|
15
|
+
export type AppEventIdentityType = "anonymousId" | "userId" | "traits.email" | "traits.phone" | "context.device.id" | "context.device.advertisingId" | "context.device.token" | `custom.${string}`;
|
|
16
|
+
/** A single identifier, such as a user ID, anonymous ID, email, or custom external ID. */
|
|
10
17
|
export type AppEventIdentity = {
|
|
11
18
|
type: AppEventIdentityType;
|
|
12
19
|
value: string;
|
|
13
20
|
};
|
|
14
|
-
/** Page and
|
|
21
|
+
/** Page, feature flag, and capability context attached to an event. */
|
|
15
22
|
export type AppEventContext = {
|
|
16
23
|
page?: {
|
|
17
24
|
path?: string;
|
|
@@ -23,14 +30,23 @@ export type AppEventContext = {
|
|
|
23
30
|
flags?: AppEventFlag[] | undefined;
|
|
24
31
|
capabilities?: AppEventCapability[] | undefined;
|
|
25
32
|
};
|
|
33
|
+
/** Supported feature flag value shape. */
|
|
26
34
|
export type AppEventFlagValue = string | number | boolean | null | AppEventFlagValue[] | {
|
|
27
35
|
[key: string]: AppEventFlagValue;
|
|
28
36
|
};
|
|
37
|
+
/**
|
|
38
|
+
* Supported event property value shape.
|
|
39
|
+
*
|
|
40
|
+
* @see https://getuserfeedback.com/docs/reference/events
|
|
41
|
+
*/
|
|
42
|
+
export type AppEventJsonValue = AppEventFlagValue;
|
|
43
|
+
/** Feature flag provider metadata. */
|
|
29
44
|
export type AppEventFlagProvider = {
|
|
30
45
|
name: string;
|
|
31
46
|
project?: string | undefined;
|
|
32
47
|
environment?: string | undefined;
|
|
33
48
|
};
|
|
49
|
+
/** Feature flag evaluation context attached to widget initialization or events. */
|
|
34
50
|
export type AppEventFlag = {
|
|
35
51
|
key: string;
|
|
36
52
|
target?: string | undefined;
|
|
@@ -42,14 +58,17 @@ export type AppEventFlag = {
|
|
|
42
58
|
reason?: string | undefined;
|
|
43
59
|
evaluatedAt?: string | undefined;
|
|
44
60
|
};
|
|
61
|
+
/** Host capability context attached to widget initialization or events. */
|
|
45
62
|
export type AppEventCapability = {
|
|
46
63
|
key: string;
|
|
47
64
|
source?: string | undefined;
|
|
48
65
|
provider?: AppEventFlagProvider | undefined;
|
|
49
66
|
};
|
|
67
|
+
/** Feature flag evaluations accepted by SDK initialization. */
|
|
50
68
|
export type FlagsInput = AppEventFlag[] | Record<string, AppEventFlagValue>;
|
|
69
|
+
/** Host capabilities accepted by SDK initialization. */
|
|
51
70
|
export type CapabilitiesInput = Array<string | AppEventCapability>;
|
|
52
|
-
/** Optional fields shared by
|
|
71
|
+
/** Optional fields shared by event payloads. */
|
|
53
72
|
export type AppEventBase = {
|
|
54
73
|
traits?: Record<string, unknown> | undefined;
|
|
55
74
|
identities?: AppEventIdentity[] | undefined;
|
|
@@ -57,34 +76,46 @@ export type AppEventBase = {
|
|
|
57
76
|
messageId?: string | undefined;
|
|
58
77
|
timestamp?: number | undefined;
|
|
59
78
|
};
|
|
60
|
-
/** Reference to a specific survey
|
|
79
|
+
/** Reference to a specific survey or flow. */
|
|
61
80
|
export type AppEventSurveyReference = {
|
|
62
81
|
surveyId: string;
|
|
63
82
|
};
|
|
64
|
-
/** Event payload when a flow is shown
|
|
83
|
+
/** Event payload emitted when a flow is shown. */
|
|
65
84
|
export type FlowViewedPayload = AppEventBase & {
|
|
85
|
+
origin?: "system" | undefined;
|
|
66
86
|
event: "Flow Viewed";
|
|
67
87
|
references: AppEventSurveyReference;
|
|
68
88
|
};
|
|
69
|
-
/** Event payload when a user dismisses a flow. */
|
|
89
|
+
/** Event payload emitted when a user dismisses a flow. */
|
|
70
90
|
export type FlowDismissedPayload = AppEventBase & {
|
|
91
|
+
origin?: "system" | undefined;
|
|
71
92
|
event: "Flow Dismissed";
|
|
72
93
|
references: AppEventSurveyReference;
|
|
73
94
|
};
|
|
74
95
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
96
|
+
* Event payload sent with `client.track()`.
|
|
97
|
+
*
|
|
98
|
+
* @see https://getuserfeedback.com/docs/reference/events
|
|
99
|
+
*/
|
|
100
|
+
export type CustomerTrackPayload = AppEventBase & {
|
|
101
|
+
origin: "customer";
|
|
102
|
+
event: string;
|
|
103
|
+
properties?: Record<string, AppEventJsonValue> | undefined;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Event payload union. Use `origin` as the discriminator when handling the
|
|
107
|
+
* union directly.
|
|
77
108
|
*/
|
|
78
|
-
export type AppEventPayload = FlowViewedPayload | FlowDismissedPayload;
|
|
79
|
-
/** How the widget was loaded
|
|
109
|
+
export type AppEventPayload = FlowViewedPayload | FlowDismissedPayload | CustomerTrackPayload;
|
|
110
|
+
/** How the widget was loaded, such as SDK, GTM, Segment, or a custom loader. */
|
|
80
111
|
export type ClientMetaLoader = "sdk" | "gtm" | "segment" | "rudderstack" | "tealium" | "custom";
|
|
81
|
-
/** Delivery method for the widget script
|
|
112
|
+
/** Delivery method for the widget script. */
|
|
82
113
|
export type ClientMetaTransport = "script-tag" | "esm" | "loader" | "tag-manager" | "snippet";
|
|
83
114
|
/** Detected or configured front-end framework. */
|
|
84
115
|
export type ClientMetaRuntimeFramework = "next" | "vite" | "webpack" | "plain";
|
|
85
116
|
/** Runtime environment (browser or edge). */
|
|
86
117
|
export type ClientMetaRuntimeEnv = "browser" | "edge";
|
|
87
|
-
/** Metadata about the client
|
|
118
|
+
/** Metadata about the client integration, used for diagnostics and support. */
|
|
88
119
|
export type ClientMeta = {
|
|
89
120
|
loader: ClientMetaLoader;
|
|
90
121
|
clientName?: string | undefined;
|
|
@@ -147,19 +178,23 @@ export type ConsentStatus = "pending" | "granted" | "denied" | "revoked";
|
|
|
147
178
|
export type GrantScope = Scope;
|
|
148
179
|
/** Consent configuration. Use a single decision for all scopes, or provide an explicit allow-list of granted scopes. */
|
|
149
180
|
export type ConsentConfig = ConsentStatus | Scope[];
|
|
150
|
-
/** Auth configuration
|
|
181
|
+
/** Auth configuration, such as a JWT for authenticated flows. */
|
|
151
182
|
export type AuthConfig = {
|
|
152
183
|
jwt?: {
|
|
153
184
|
token: string;
|
|
154
185
|
} | null | undefined;
|
|
155
186
|
};
|
|
156
|
-
/**
|
|
187
|
+
/**
|
|
188
|
+
* Runtime configuration updates accepted by `client.configure()`.
|
|
189
|
+
*
|
|
190
|
+
* @see https://getuserfeedback.com/docs/security-and-privacy/compliance-and-consent
|
|
191
|
+
*/
|
|
157
192
|
export type ConfigureOptions = {
|
|
158
193
|
colorScheme?: ColorSchemeConfig | undefined;
|
|
159
194
|
consent?: ConsentConfig | undefined;
|
|
160
195
|
auth?: AuthConfig | undefined;
|
|
161
196
|
};
|
|
162
|
-
/** @internal Options when initializing the widget: API key, color scheme, disableTelemetry, enableDebug, defaultConsent, capabilities, and optional
|
|
197
|
+
/** @internal Options when initializing the widget: API key, color scheme, disableTelemetry, enableDebug, defaultConsent, capabilities, and optional host targeting context. */
|
|
163
198
|
export type InitOptions = {
|
|
164
199
|
apiKey: string;
|
|
165
200
|
colorScheme?: ColorSchemeConfig | undefined;
|
|
@@ -177,7 +212,8 @@ export type ClientOptions = {
|
|
|
177
212
|
apiKey: string;
|
|
178
213
|
/** Color scheme config: host-driven (loader observes attributes) or explicit. */
|
|
179
214
|
colorScheme?: ColorSchemeConfig | undefined;
|
|
180
|
-
/**
|
|
215
|
+
/**
|
|
216
|
+
* Initial consent state.
|
|
181
217
|
*
|
|
182
218
|
* Default: `granted` (all scopes).
|
|
183
219
|
*
|
|
@@ -192,6 +228,8 @@ export type ClientOptions = {
|
|
|
192
228
|
* Essential baseline scopes are always granted for core widget operation and cannot be denied:
|
|
193
229
|
* - `functionality.storage`
|
|
194
230
|
* - `security.storage`
|
|
231
|
+
*
|
|
232
|
+
* @see https://getuserfeedback.com/docs/security-and-privacy/compliance-and-consent
|
|
195
233
|
*/
|
|
196
234
|
defaultConsent?: ConsentConfig | undefined;
|
|
197
235
|
/** When true, prints debug logs to console. Narrow down with a namespace string/array eg. ```["loader", "handshake"]```. Default `false`.
|
|
@@ -211,9 +249,9 @@ export type ClientOptions = {
|
|
|
211
249
|
* Excluded by default: user identity and detailed page fields (path/referrer/search).
|
|
212
250
|
*/
|
|
213
251
|
disableTelemetry?: boolean | undefined;
|
|
214
|
-
/**
|
|
252
|
+
/** Feature flag evaluations collected with widget initialization. */
|
|
215
253
|
flags?: FlagsInput | undefined;
|
|
216
|
-
/**
|
|
254
|
+
/** Host capabilities collected with widget initialization. */
|
|
217
255
|
capabilities?: CapabilitiesInput | undefined;
|
|
218
256
|
_loaderUrl?: string | undefined;
|
|
219
257
|
_coreUrl?: string | undefined;
|
|
@@ -262,11 +300,16 @@ export type IdentifyUserCommandPayload = {
|
|
|
262
300
|
};
|
|
263
301
|
/** Identify command payload: either traits-only or userId+traits shape. */
|
|
264
302
|
export type IdentifyCommandPayload = IdentifyTraitsOnlyCommandPayload | IdentifyUserCommandPayload;
|
|
265
|
-
/**
|
|
303
|
+
/**
|
|
304
|
+
* Command payload for `client.track()`.
|
|
305
|
+
*
|
|
306
|
+
* @see https://getuserfeedback.com/docs/reference/events
|
|
307
|
+
*/
|
|
266
308
|
export type TrackCommandPayload = AppEventBase & {
|
|
267
309
|
kind: "track";
|
|
268
|
-
|
|
269
|
-
|
|
310
|
+
origin: "customer";
|
|
311
|
+
event: string;
|
|
312
|
+
properties?: Record<string, AppEventJsonValue> | undefined;
|
|
270
313
|
};
|
|
271
314
|
/** Attach or detach a resolved flow handle from a host container. */
|
|
272
315
|
export type SetContainerCommandPayload = {
|
|
@@ -306,8 +349,8 @@ export type CloseCommandPayload = {
|
|
|
306
349
|
export type ResetCommandPayload = {
|
|
307
350
|
kind: "reset";
|
|
308
351
|
};
|
|
309
|
-
/** Union of
|
|
310
|
-
export type PublicCommandPayload = OpenCommandPayload | PrefetchCommandPayload | PrerenderCommandPayload | IdentifyCommandPayload | SetContainerCommandPayload | SetDefaultContainerPolicyCommandPayload | ConfigureCommandPayload | InitCommandPayload | CloseCommandPayload | ResetCommandPayload;
|
|
352
|
+
/** Union of widget action payloads such as open, prefetch, identify, configure, and track. */
|
|
353
|
+
export type PublicCommandPayload = OpenCommandPayload | PrefetchCommandPayload | PrerenderCommandPayload | IdentifyCommandPayload | SetContainerCommandPayload | SetDefaultContainerPolicyCommandPayload | ConfigureCommandPayload | InitCommandPayload | CloseCommandPayload | ResetCommandPayload | TrackCommandPayload;
|
|
311
354
|
/** Input for a single widget action; same shape as {@link PublicCommandPayload}. */
|
|
312
355
|
export type Command = PublicCommandPayload;
|
|
313
356
|
/** Wrapper for a widget action (version, request id, idempotency key, optional client metadata, and the action payload). */
|
|
@@ -324,9 +367,11 @@ export type TelemetryIdentityType = AppEventIdentityType;
|
|
|
324
367
|
/**
|
|
325
368
|
* Event passed to the `beforeSend` hook in {@link Client.use}.
|
|
326
369
|
* When `debug` is true, identities and full page context are included; when false, no identities and page is origin-only.
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
* generic TelemetryEvent
|
|
370
|
+
*
|
|
371
|
+
* TODO(migration): Rename this SDK-facing type to WidgetTelemetryEvent in the
|
|
372
|
+
* same change that updates SDK imports, so the generic TelemetryEvent name can
|
|
373
|
+
* retire here without colliding with shared telemetry.
|
|
374
|
+
* [from=TelemetryEvent-widget-surface] [to=WidgetTelemetryEvent] [scope=slice] [priority=low]
|
|
330
375
|
*/
|
|
331
376
|
export type TelemetryEvent = {
|
|
332
377
|
type: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-types.d.ts","sourceRoot":"","sources":["../../src/host/sdk-types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAI1C
|
|
1
|
+
{"version":3,"file":"sdk-types.d.ts","sourceRoot":"","sources":["../../src/host/sdk-types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAI1C;;;;;;;GAOG;AACH,MAAM,MAAM,oBAAoB,GAC7B,aAAa,GACb,QAAQ,GACR,cAAc,GACd,cAAc,GACd,mBAAmB,GACnB,8BAA8B,GAC9B,sBAAsB,GACtB,UAAU,MAAM,EAAE,CAAC;AAEtB,0FAA0F;AAC1F,MAAM,MAAM,gBAAgB,GAAG;IAC9B,IAAI,EAAE,oBAAoB,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,uEAAuE;AACvE,MAAM,MAAM,eAAe,GAAG;IAC7B,IAAI,CAAC,EAAE;QACN,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,MAAM,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,YAAY,EAAE,GAAG,SAAS,CAAC;IACnC,YAAY,CAAC,EAAE,kBAAkB,EAAE,GAAG,SAAS,CAAC;CAChD,CAAC;AAEF,0CAA0C;AAC1C,MAAM,MAAM,iBAAiB,GAC1B,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,iBAAiB,EAAE,GACnB;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,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,EAC7B,wBAAwB,EACxB,wBAAwB,GACxB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACX,wBAAwB,EACxB,SAAS,GACT,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACN,iCAAiC,EACjC,wBAAwB,EACxB,yBAAyB,EACzB,gCAAgC,GAChC,MAAM,0BAA0B,CAAC;AAClC,YAAY,EACX,kBAAkB,EAClB,YAAY,EACZ,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,UAAU,EACV,aAAa,EACb,OAAO,EACP,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,WAAW,EACX,oBAAoB,EACpB,qBAAqB,
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/host/sdk.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EACN,+BAA+B,EAC/B,sBAAsB,EACtB,6BAA6B,EAC7B,wBAAwB,EACxB,wBAAwB,GACxB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACX,wBAAwB,EACxB,SAAS,GACT,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACN,iCAAiC,EACjC,wBAAwB,EACxB,yBAAyB,EACzB,gCAAgC,GAChC,MAAM,0BAA0B,CAAC;AAClC,YAAY,EACX,kBAAkB,EAClB,YAAY,EACZ,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,UAAU,EACV,aAAa,EACb,OAAO,EACP,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,WAAW,EACX,oBAAoB,EACpB,qBAAqB,EAErB,cAAc,GACd,MAAM,gBAAgB,CAAC"}
|
package/dist/identity-type.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import * as z from "zod/mini";
|
|
2
2
|
export declare const IDENTITY_TYPE_VALUES: readonly ["anonymousId", "userId", "traits.email", "traits.phone", "context.device.id", "context.device.advertisingId", "context.device.token"];
|
|
3
|
-
export type
|
|
3
|
+
export type StandardIdentityTypeValue = (typeof IDENTITY_TYPE_VALUES)[number];
|
|
4
|
+
export type CustomIdentityTypeValue = `custom.${string}`;
|
|
5
|
+
export type IdentityTypeValue = StandardIdentityTypeValue | CustomIdentityTypeValue;
|
|
4
6
|
export declare const isIdentityTypeValue: (value: string) => value is IdentityTypeValue;
|
|
5
7
|
export declare const getIdentityTypeSuggestion: (value: string) => IdentityTypeValue | null;
|
|
6
8
|
export declare const buildIdentityTypeGuidanceMessage: (value: string) => string;
|
|
7
|
-
export declare const appEventIdentityTypeSchema: z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<
|
|
9
|
+
export declare const appEventIdentityTypeSchema: z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<IdentityTypeValue, string>>;
|
|
8
10
|
//# sourceMappingURL=identity-type.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity-type.d.ts","sourceRoot":"","sources":["../src/identity-type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAE9B,eAAO,MAAM,oBAAoB,iJAQvB,CAAC;AAEX,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"identity-type.d.ts","sourceRoot":"","sources":["../src/identity-type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAE9B,eAAO,MAAM,oBAAoB,iJAQvB,CAAC;AAEX,MAAM,MAAM,yBAAyB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAC9E,MAAM,MAAM,uBAAuB,GAAG,UAAU,MAAM,EAAE,CAAC;AACzD,MAAM,MAAM,iBAAiB,GAC1B,yBAAyB,GACzB,uBAAuB,CAAC;AA2B3B,eAAO,MAAM,mBAAmB,GAC/B,OAAO,MAAM,KACX,KAAK,IAAI,iBAE6B,CAAC;AAK1C,eAAO,MAAM,yBAAyB,GACrC,OAAO,MAAM,KACX,iBAAiB,GAAG,IACuD,CAAC;AAE/E,eAAO,MAAM,gCAAgC,GAAI,OAAO,MAAM,KAAG,MAehE,CAAC;AAkBF,eAAO,MAAM,0BAA0B,uFAWtC,CAAC"}
|
package/dist/identity-type.js
CHANGED
|
@@ -8,6 +8,7 @@ export const IDENTITY_TYPE_VALUES = [
|
|
|
8
8
|
"context.device.advertisingId",
|
|
9
9
|
"context.device.token",
|
|
10
10
|
];
|
|
11
|
+
const CUSTOM_IDENTITY_TYPE_PATTERN = /^custom\.[a-zA-Z0-9][a-zA-Z0-9_.-]*$/;
|
|
11
12
|
const IDENTITY_TYPE_ALIAS_SUGGESTIONS = {
|
|
12
13
|
advertising_id: "context.device.advertisingId",
|
|
13
14
|
anonymous_id: "anonymousId",
|
|
@@ -24,7 +25,8 @@ const COMMON_IDENTITY_TYPE_MAPPINGS = [
|
|
|
24
25
|
["user_id", "userId"],
|
|
25
26
|
];
|
|
26
27
|
const normalizeIdentityTypeAliasKey = (value) => value.trim().toLowerCase().replace(/-/g, "_");
|
|
27
|
-
export const isIdentityTypeValue = (value) => IDENTITY_TYPE_VALUES.some((candidate) => candidate === value)
|
|
28
|
+
export const isIdentityTypeValue = (value) => IDENTITY_TYPE_VALUES.some((candidate) => candidate === value) ||
|
|
29
|
+
CUSTOM_IDENTITY_TYPE_PATTERN.test(value);
|
|
28
30
|
const parseIdentityTypeValue = (value) => isIdentityTypeValue(value) ? value : null;
|
|
29
31
|
export const getIdentityTypeSuggestion = (value) => IDENTITY_TYPE_ALIAS_SUGGESTIONS[normalizeIdentityTypeAliasKey(value)] ?? null;
|
|
30
32
|
export const buildIdentityTypeGuidanceMessage = (value) => {
|
|
@@ -35,7 +37,7 @@ export const buildIdentityTypeGuidanceMessage = (value) => {
|
|
|
35
37
|
return `Unsupported identity type ${displayValue}. Use "${suggestion}" instead.`;
|
|
36
38
|
}
|
|
37
39
|
const mappingExamples = COMMON_IDENTITY_TYPE_MAPPINGS.map(([from, to]) => `${from} -> ${to}`).join(", ");
|
|
38
|
-
return `Unsupported identity type ${displayValue}. Use one of: ${IDENTITY_TYPE_VALUES.join(", ")}. Common mappings: ${mappingExamples}.`;
|
|
40
|
+
return `Unsupported identity type ${displayValue}. Use one of: ${IDENTITY_TYPE_VALUES.join(", ")}, or a custom identity type like "custom.shopifyCustomerId". Common mappings: ${mappingExamples}.`;
|
|
39
41
|
};
|
|
40
42
|
const identityTypeInputSchema = z.string().check(z.trim(), z.minLength(1, { error: "Identity type is required." }), z.check((ctx) => {
|
|
41
43
|
if (isIdentityTypeValue(ctx.value)) {
|