Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,6 @@
<ui:Label class="btn-label" text="Shutdown" />
<ui:Label class="btn-sig" text="shutdown()" />
</ui:Button>

<ui:Button name="btn-delete-data" class="with-sig">
<ui:Label class="btn-label" text="Delete data" />
<ui:Label class="btn-sig" text="deleteData()" />
</ui:Button>
</ui:VisualElement>

</ui:VisualElement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private static readonly (string TabId, string PanelId)[] Tabs =
private Toggle _testMode;
private DropdownField _initialConsent;
private Toggle _debug, _enableMobileAttribution;
private Button _btnInit, _btnFlush, _btnReset, _btnShutdown, _btnDeleteData, _btnRequestAtt;
private Button _btnInit, _btnFlush, _btnReset, _btnShutdown, _btnRequestAtt;

// ---- UXML element fields (Consent tab) ----

Expand Down Expand Up @@ -203,7 +203,6 @@ private void BindElements()
_btnFlush = Require<Button>("btn-flush");
_btnReset = Require<Button>("btn-reset");
_btnShutdown = Require<Button>("btn-shutdown");
_btnDeleteData = Require<Button>("btn-delete-data");
_btnRequestAtt = Require<Button>("btn-request-att");

ApplyMobilePlatformVisibility();
Expand Down Expand Up @@ -334,7 +333,6 @@ private void RegisterHandlers()
_btnFlush.clicked += async () => await OnFlushAsync();
_btnReset.clicked += OnReset;
_btnShutdown.clicked += OnShutdown;
_btnDeleteData.clicked += async () => await OnDeleteDataAsync();
_btnRequestAtt.clicked += async () => await OnRequestAttAsync();
_btnIdentify.clicked += OnIdentify;
_btnIdentifyTraits.clicked += OnIdentifyTraits;
Expand Down Expand Up @@ -635,7 +633,7 @@ private void RefreshConsentPills()

private void RefreshInitState()
{
foreach (var b in new[] { _btnFlush, _btnReset, _btnShutdown, _btnDeleteData, _btnCustomEvent, _btnIdentify, _btnIdentifyTraits })
foreach (var b in new[] { _btnFlush, _btnReset, _btnShutdown, _btnCustomEvent, _btnIdentify, _btnIdentifyTraits })
b.SetEnabled(_initialised);
foreach (var p in _consentPills.Values) p.SetEnabled(_initialised);
foreach (var btn in _typedEventsHost.Query<Button>().ToList()) btn.SetEnabled(_initialised);
Expand Down
14 changes: 0 additions & 14 deletions examples/audience/Assets/SampleApp/Scripts/AudienceSample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,6 @@ private async Task OnFlushAsync()
catch (Exception ex) { AppendLog("flush()", ex.Message, LogLevel.Err, LogSource.App); }
}

private async Task OnDeleteDataAsync()
{
AppendLog("deleteData()", "erasure request dispatched", LogLevel.Info, LogSource.App);
try
{
await ImmutableAudience.DeleteData();
AppendLog("deleteData()", "backend acknowledged", LogLevel.Ok, LogSource.App);
}
catch (Exception ex)
{
AppendLog("deleteData()", ex.Message, LogLevel.Err, LogSource.App);
}
}

private async Task OnRequestAttAsync()
{
AppendLog("requestTrackingAuthorizationAsync()", "ATT request dispatched", LogLevel.Info, LogSource.App);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,20 +388,6 @@ public IEnumerator Reset_RegeneratesAnonymousIdAndAcceptsTrack()
yield return FlushAndAssertNoErrors();
}

[UnityTest]
public IEnumerator DeleteData_AcknowledgesFromBackend()
{
// DeleteData hits the control-plane HTTP endpoint, distinct from
// the event-batch POST. Catches IL2CPP strips on the control HttpClient
// path that the regular Flush tests don't exercise.
yield return LoadAndInit();

_root!.Q<Button>(SampleAppUi.Buttons.DeleteData).Click();
yield return SampleAppTestHelpers.WaitForLogEntry(_root, SampleAppUi.LogLabels.DeleteData, LogLevels.Ok, 30f);

AssertNoErrors();
}

[UnityTest]
public IEnumerator ReInit_AfterShutdown_AcceptsTrack()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ internal static class Buttons
internal const string Flush = "btn-flush";
internal const string Reset = "btn-reset";
internal const string Shutdown = "btn-shutdown";
internal const string DeleteData = "btn-delete-data";
internal const string ConsentNone = "btn-consent-none";
internal const string ConsentAnon = "btn-consent-anon";
internal const string ConsentFull = "btn-consent-full";
Expand Down Expand Up @@ -148,7 +147,6 @@ internal static class LogLabels
internal const string Flush = "flush()";
internal const string Reset = "reset()";
internal const string Shutdown = "shutdown()";
internal const string DeleteData = "deleteData()";
internal const string Track = "track()";
internal const string SetConsent = "setConsent()";
internal const string Identify = "identify()";
Expand Down
3 changes: 0 additions & 3 deletions src/Packages/Audience/Runtime/Core/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ internal static class Constants

internal const string MessagesPath = "/v1/audience/messages";
internal const string ConsentPath = "/v1/audience/tracking-consent";
internal const string DataPath = "/v1/audience/data";

internal const int DefaultFlushIntervalSeconds = 5;
internal const int DefaultFlushSize = 20;
Expand All @@ -29,8 +28,6 @@ internal static string MessagesUrl(string? baseUrlOverride = null) =>
BaseUrl(baseUrlOverride) + MessagesPath;
internal static string ConsentUrl(string? baseUrlOverride = null) =>
BaseUrl(baseUrlOverride) + ConsentPath;
internal static string DataUrl(string? baseUrlOverride = null) =>
BaseUrl(baseUrlOverride) + DataPath;

internal static string BaseUrl(string? baseUrlOverride = null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Packages/Audience/Runtime/Core/Identity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal sealed class Identity
private static volatile string? _cachedDeviceId;
private static readonly object _sync = new object();

// Returns the existing anonymous ID without creating one. Used by DeleteData.
// Returns the existing anonymous ID without creating one.
internal static string? Get(string persistentDataPath)
{
if (_cachedAnonId != null) return _cachedAnonId;
Expand Down
61 changes: 0 additions & 61 deletions src/Packages/Audience/Runtime/ImmutableAudience.cs
Original file line number Diff line number Diff line change
Expand Up @@ -580,67 +580,6 @@ public static void Reset()
newSession?.Start();
}

/// <summary>
/// Asks the backend to erase this player's data.
/// </summary>
/// <param name="userId">
/// Optional. The known user ID to delete. When null, the SDK uses
/// the device's persisted anonymous ID.
/// </param>
/// <returns>A task that completes when the backend has responded.</returns>
public static Task DeleteData(string? userId = null)
{
if (!_initialized) return Task.CompletedTask;

var config = _config;
var client = _controlClient;
if (config == null || client == null) return Task.CompletedTask;

string query;
if (!string.IsNullOrEmpty(userId))
{
query = "userId=" + Uri.EscapeDataString(userId);
}
else
{
// Get (not GetOrCreate): a fresh install must not register an id just to delete it.
var anonymousId = Identity.Get(config.PersistentDataPath!);
if (string.IsNullOrEmpty(anonymousId))
return Task.CompletedTask;
query = "anonymousId=" + Uri.EscapeDataString(anonymousId);
}

var url = Constants.DataUrl(config.BaseUrl) + "?" + query;
var onError = config.OnError;
var publishableKey = config.PublishableKey;
var cancellationToken = _shutdownCancellationSource?.Token ?? CancellationToken.None;

return Task.Run(async () =>
{
try
{
using var request = new HttpRequestMessage(HttpMethod.Delete, url);
request.Headers.Add(Constants.PublishableKeyHeader, publishableKey);
using var response = await client.SendAsync(request, cancellationToken).ConfigureAwait(false);

if (!response.IsSuccessStatusCode)
{
NotifyErrorCallback(onError, AudienceErrorCode.NetworkError,
$"Data delete failed with status {(int)response.StatusCode}");
}
}
catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested)
{
// Shutdown cancelled; caller is tearing down, no error fired.
}
catch (Exception ex)
{
NotifyErrorCallback(onError, AudienceErrorCode.NetworkError,
$"Data delete threw: {ex.Message}");
}
});
}

private static void NotifyErrorCallback(Action<AudienceError>? onError, AudienceErrorCode code, string message)
{
if (onError == null) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public void Reset_DeletesFile()
}

// -----------------------------------------------------------------
// Get (non-creating read for DeleteData)
// Get (non-creating read)
// -----------------------------------------------------------------

[Test]
Expand Down
Loading
Loading