recordDeepLinkOpen method
Records a deep-link open. The newest open supersedes the previous one
(last-click) and starts a new session. A no-op when no linkId is known
(organic/unresolved open) — there is nothing to attribute to.
Implementation
Future<void> recordDeepLinkOpen({String? linkId, String? clickId}) async {
if (linkId == null) return;
final attribution = ActiveAttribution(
linkId: linkId,
clickId: clickId,
openedAt: DateTime.now().toUtc().toIso8601String(),
);
_active = attribution;
// A new deep-link open is the start of a new attributed journey.
_sessionId = _generateSessionId();
try {
await _storage.saveAttribution(jsonEncode(attribution.toJson()));
} catch (e) {
if (_debug) LinkFortyLogger.log('Failed to persist attribution: $e');
}
if (_debug) {
LinkFortyLogger.log(
'Attribution context set: link=$linkId session=$_sessionId',
);
}
}