Skip to content

Commit d08fe12

Browse files
docs(audience): drop internal pipeline name from comments
Rewrites the comments on IdentityType.ToLowercaseString, the Identify(string) and Alias(string) overloads in ImmutableAudience, and the matching test comments and assertion messages so they explain why identityType is mandatory — downstream data-deletion needs it to match a user's events — without naming the specific internal pipeline. Same invariant, just no internal name in the source. The test comment on ToLowercaseString_UnknownValue_Throws is also rewritten to read cold: leads with the rule and a concrete bad-cast example, names what ToLowercaseString emits and how the backend uses it, then explains why a default return would hide the bug. Addresses PR #696 review thread (discussion_r3122316478). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent d5d8099 commit d08fe12

4 files changed

Lines changed: 20 additions & 17 deletions

File tree

src/Packages/Audience/Runtime/IdentityType.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@ public enum IdentityType
1717

1818
internal static class IdentityTypeExtensions
1919
{
20-
// Throws on unknown casts. The CDP pipeline requires identityType on
21-
// every identify / alias event to match records to the correct
22-
// identity namespace during data deletion, so an out-of-range cast
23-
// must fail loudly rather than ship an event with a missing or
24-
// empty namespace.
20+
// Throws on unknown casts. Every identify / alias event must carry an
21+
// identityType so downstream data-deletion requests can match records
22+
// to the correct identity namespace; an out-of-range cast must fail
23+
// loudly rather than ship an event with a missing or empty namespace.
2524
internal static string ToLowercaseString(this IdentityType type) => type switch
2625
{
2726
IdentityType.Passport => "passport",

src/Packages/Audience/Runtime/ImmutableAudience.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,9 @@ public static void Identify(string userId, IdentityType identityType, Dictionary
176176
// Attach a known user id to subsequent events. String overload for
177177
// providers not in IdentityType.
178178
//
179-
// identityType is required: CDP uses it to match identify events to
180-
// the correct identity namespace when processing data-deletion
181-
// requests, so an event without one cannot be cleaned up.
179+
// identityType is required: data-deletion processing relies on it to
180+
// match identify events to the correct identity namespace, so an
181+
// event without one cannot be cleaned up.
182182
public static void Identify(string userId, string identityType, Dictionary<string, object>? traits = null)
183183
{
184184
if (!_initialized) return;
@@ -213,9 +213,8 @@ public static void Alias(string fromId, IdentityType fromType, string toId, Iden
213213
// Link two user ids for the same player. String overload for
214214
// providers not in IdentityType.
215215
//
216-
// fromType and toType are required: CDP uses them to match alias
217-
// events to the correct identity namespaces when processing
218-
// data-deletion requests.
216+
// fromType and toType are required: data-deletion processing uses
217+
// them to match alias events to the correct identity namespaces.
219218
public static void Alias(string fromId, string fromType, string toId, string toType)
220219
{
221220
if (!_initialized) return;

src/Packages/Audience/Tests/Runtime/IdentityTypeTests.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,15 @@ public void ToLowercaseString_MapsEachEnumValueToLowercaseBackendString(Identity
2222
[Test]
2323
public void ToLowercaseString_UnknownValue_Throws()
2424
{
25-
// CDP matches identify / alias events by identityType during data
26-
// deletion; an out-of-range cast would otherwise ship an event
27-
// with an empty namespace that CDP cannot clean up. Fail loud so
28-
// the programmer error surfaces at the call site instead.
25+
// An out-of-range cast like `(IdentityType)999` must throw.
26+
// ToLowercaseString emits the "identityType" string on every
27+
// identify / alias event (e.g. "passport"), and the backend uses
28+
// that string to find and delete a user's events on request.
29+
//
30+
// An unknown enum value must throw so the bug surfaces at the
31+
// cast site. Returning a default string instead would ship the
32+
// event with a blank identityType — invisible to the deletion
33+
// lookup — and hide the bug.
2934
var invalid = (IdentityType)999;
3035

3136
Assert.Throws<ArgumentOutOfRangeException>(() => invalid.ToLowercaseString());

src/Packages/Audience/Tests/Runtime/ImmutableAudienceTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public void Identify_InvalidIdentityTypeCast_Throws()
142142
Assert.Throws<ArgumentOutOfRangeException>(
143143
() => ImmutableAudience.Identify("user1", invalid),
144144
"invalid enum cast must throw so a broken call fails loud rather than " +
145-
"shipping an identify event CDP cannot match for deletion");
145+
"shipping an identify event that cannot be matched for deletion");
146146
}
147147

148148
[Test]
@@ -155,7 +155,7 @@ public void Alias_InvalidIdentityTypeCast_Throws()
155155
Assert.Throws<ArgumentOutOfRangeException>(
156156
() => ImmutableAudience.Alias("fromId", invalid, "toId", IdentityType.Steam),
157157
"invalid enum cast must throw so a broken alias call fails loud rather " +
158-
"than shipping an event CDP cannot match for deletion");
158+
"than shipping an event that cannot be matched for deletion");
159159
}
160160

161161
[Test]

0 commit comments

Comments
 (0)