Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove duplicate dapp transaction analytics #11628

Closed
wants to merge 3 commits into from

Conversation

elefantel
Copy link
Contributor

@elefantel elefantel commented Oct 4, 2024

Description

The Dapp Transaction Completed analytics was being tracked & sent to Segment twice because in MetaMetrics we:

  1. Track any event coming through: it is sent to Segment with the flag anonymous: false
  2. Track that same again with if it contains sensitiveProperties: it is sent to Segment with the flag anonymous: true
    This was the case with the Dapp Transaction Completed as it contains sensitive properties active_currency and asset_type

Consequences:
The non-anonymous event in Segment contains:

  1. Location information
  2. User ID
"location": {
  "api_processing_time_ms": 0,
  "city": "",
  "country_code": "ZA",
  "region": "WC",
  "timezone": "Africa/Johannesburg"
}
"userId": "b6f6148f-edfc-44da-96a9-f83f61f96f82"

while the anonymous event does not contain this information and user ID

"location": {
  "error_message": "Anonymous User"
}
"userId": "0x0000000000000000"

which means we would lose location information of transaction events and also lose userId information.

NOTE
If we toggle the behaviour and only send the non-anonymous payload (like is the case with the rest of the events) then we would lose the sensitive information properties only namely active_currency and asset_type.

Full payload:
With anonymous info (the only data that would otherwise be logged with this PR change):

{
  "context": {
    "app": {
      "build": "1432",
      "name": "M***",
      "namespace": "io.metamask.MetaMask",
      "version": "7.31.0"
    },
    "device": {
      "id": "NULL",
      "manufacturer": "Apple",
      "model": "iPhone14,5",
      "name": "i***",
      "type": "ios"
    },
    "instanceId": "223fdb32-f6f6-4470-a1d4-524e756151f7",
    "ip": "0***.0***.0***.0***",
    "library": {
      "name": "@segment/analytics-react-native",
      "version": "2.17.0"
    },
    "locale": "en-ZA",
    "location": {
      "error_message": "Anonymous User"
    },
    "network": {
      "cellular": false,
      "wifi": true
    },
    "os": {
      "name": "i***",
      "version": "17.6.1"
    },
    "protocols": {
      "sourceId": "wygFTooEUUtcckty9kaMc"
    },
    "screen": {
      "height": 844,
      "width": 390
    },
    "timestamp_in_future": false,
    "timezone": "Africa/Johannesburg",
    "traits": {}
  },
  "event": "Dapp Transaction Completed",
  "integrations": {},
  "messageId": "95cd1cae-d01c-4232-8f2b-91bc512528a8",
  "originalTimestamp": "2024-10-03T15:01:13.179Z",
  "properties": {
    "account_type": "MetaMask",
    "active_currency": "ETH",
    "asset_type": "ETH",
    "chain_id": "11155111",
    "dapp_host_name": "wc::https://appkit-lab.reown.com/",
    "gas_estimate_type": "fee-market",
    "gas_mode": "Advanced",
    "is_smart_transaction": false,
    "ppom_debug_traceCall_count": 1,
    "ppom_eth_chainId_count": 1,
    "ppom_eth_createAccessList_count": 1,
    "ppom_eth_getBalance_count": 5,
    "ppom_eth_getBlockByNumber_count": 1,
    "ppom_eth_getCode_count": 4,
    "ppom_eth_getTransactionCount_count": 4,
    "ppom_trace_call_count": 1,
    "request_source": "WalletConnect",
    "security_alert_reason": "",
    "security_alert_response": "Benign",
    "security_alert_source": "local",
    "simulation_latency": 1.185,
    "simulation_receiving_assets_quantity": 0,
    "simulation_receiving_assets_type": [],
    "simulation_receiving_assets_value": [],
    "simulation_response": "balance_change",
    "simulation_sending_assets_quantity": 1,
    "simulation_sending_assets_type": [
      "NATIVE"
    ],
    "simulation_sending_assets_value": [
      "not_available"
    ]
  },
  "receivedAt": "2024-10-03T15:01:15.655Z",
  "sentAt": "2024-10-03T15:01:15.654Z",
  "timestamp": "2024-10-03T15:01:13.179Z",
  "type": "track",
  "userId": "0x0000000000000000"
}

Without anonymous info (the additional "duplicate" info that is currently logged in addition to the above):

{
  "context": {
    "app": {
      "build": "1432",
      "name": "M***",
      "namespace": "io.metamask.MetaMask",
      "version": "7.31.0"
    },
    "device": {
      "id": "NULL",
      "manufacturer": "Apple",
      "model": "iPhone14,5",
      "name": "i***",
      "type": "ios"
    },
    "instanceId": "223fdb32-f6f6-4470-a1d4-524e756151f7",
    "ip": "0***.0***.0***.0***",
    "library": {
      "name": "@segment/analytics-react-native",
      "version": "2.17.0"
    },
    "locale": "en-ZA",
    "location": {
      "api_processing_time_ms": 0,
      "city": "",
      "country_code": "ZA",
      "region": "WC",
      "timezone": "Africa/Johannesburg"
    },
    "network": {
      "cellular": false,
      "wifi": true
    },
    "os": {
      "name": "i***",
      "version": "17.6.1"
    },
    "protocols": {
      "sourceId": "wygFTooEUUtcckty9kaMc"
    },
    "screen": {
      "height": 844,
      "width": 390
    },
    "timestamp_in_future": false,
    "timezone": "Africa/Johannesburg",
    "traits": {}
  },
  "event": "Dapp Transaction Completed",
  "integrations": {},
  "messageId": "b9f4f037-b37f-40b9-9fae-5c776317c2fb",
  "originalTimestamp": "2024-10-03T15:01:13.178Z",
  "properties": {
    "account_type": "MetaMask",
    "chain_id": "11155111",
    "dapp_host_name": "wc::https://appkit-lab.reown.com/",
    "gas_estimate_type": "fee-market",
    "gas_mode": "Advanced",
    "is_smart_transaction": false,
    "ppom_debug_traceCall_count": 1,
    "ppom_eth_chainId_count": 1,
    "ppom_eth_createAccessList_count": 1,
    "ppom_eth_getBalance_count": 5,
    "ppom_eth_getBlockByNumber_count": 1,
    "ppom_eth_getCode_count": 4,
    "ppom_eth_getTransactionCount_count": 4,
    "ppom_trace_call_count": 1,
    "request_source": "WalletConnect",
    "security_alert_reason": "",
    "security_alert_response": "Benign",
    "security_alert_source": "local",
    "simulation_latency": 1.185,
    "simulation_receiving_assets_quantity": 0,
    "simulation_receiving_assets_type": [],
    "simulation_receiving_assets_value": [],
    "simulation_response": "balance_change",
    "simulation_sending_assets_quantity": 1,
    "simulation_sending_assets_type": [
      "NATIVE"
    ],
    "simulation_sending_assets_value": [
      "not_available"
    ]
  },
  "receivedAt": "2024-10-03T15:01:15.655Z",
  "sentAt": "2024-10-03T15:01:15.654Z",
  "timestamp": "2024-10-03T15:01:13.178Z",
  "type": "track",
  "userId": "b6f6148f-edfc-44da-96a9-f83f61f96f82"
}

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

@elefantel elefantel requested a review from a team as a code owner October 4, 2024 13:57
@elefantel elefantel self-assigned this Oct 4, 2024
Copy link
Contributor

github-actions bot commented Oct 4, 2024

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@github-actions github-actions bot added the team-sdk SDK team label Oct 4, 2024
@metamaskbot metamaskbot added the INVALID-PR-TEMPLATE PR's body doesn't match template label Oct 4, 2024
@elefantel elefantel added No QA Needed Apply this label when your PR does not need any QA effort. needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) team-sdk SDK team and removed team-sdk SDK team INVALID-PR-TEMPLATE PR's body doesn't match template labels Oct 4, 2024
Copy link

sonarqubecloud bot commented Oct 7, 2024

@metamaskbot metamaskbot added the INVALID-PR-TEMPLATE PR's body doesn't match template label Oct 7, 2024
@elefantel elefantel removed the INVALID-PR-TEMPLATE PR's body doesn't match template label Oct 7, 2024
@worldlyjohn
Copy link

i was asked to comment on this ticket, but it's not clear what the result of this PR would correct from the description alone.

In the case of an event, like Dapp Transaction Completed, that includes sensitiveProperties if this ticket gets merged would we ONLY be sending [1] event of this name without the userId (i.e. as anonymous)? If so, this is likely not the behavior we want and it would break nearly all the important reporting KPIs based on transactions.

If this is not the case, it would be helpful to understand both the before and after effects of this PR.

@metamaskbot metamaskbot added the INVALID-PR-TEMPLATE PR's body doesn't match template label Oct 9, 2024
@worldlyjohn
Copy link

Sorry, I still don't understand what this ticket is trying to address. Happy to jump on a call if helpful.

Generally,

  • we use the non-anonymous event (anonymous: false) for most analytics events as having a userId is important to look at conversion rates on important product funnels. impossible without a userId
  • we fire 2 events when sensitiveProperties is set. We would fire the usual event with the userId for most properties, but exclude any sensitiveProperties in this payload. The second (anon) event would include these sensitiveProperties.
  • We define sensitiveProperties as any properties that contain onchain data. Examples include gas properties, specific token amounts, etc.

Copy link
Contributor

@NicolasMassart NicolasMassart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is global change breaking all the anonymous system for all the app. I don't think this is what you want to do...

@NicolasMassart NicolasMassart marked this pull request as draft October 23, 2024 14:41
@elefantel elefantel requested a review from a team October 23, 2024 14:56
Copy link
Contributor

This PR has been automatically marked as stale because it has not had recent activity in the last 90 days. It will be closed in 7 days. Thank you for your contributions.

@github-actions github-actions bot added the stale Issues that have not had activity in the last 90 days label Jan 21, 2025
Copy link
Contributor

This PR was closed because there has been no follow up activity in 7 days. Thank you for your contributions.

@github-actions github-actions bot closed this Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
INVALID-PR-TEMPLATE PR's body doesn't match template needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) No QA Needed Apply this label when your PR does not need any QA effort. stale Issues that have not had activity in the last 90 days team-sdk SDK team
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants