Skip to content

Instantly share code, notes, and snippets.

@zntfdr
Last active September 24, 2024 06:29

Revisions

  1. zntfdr revised this gist Feb 7, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion firebase-iOS-breakdown.swift
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    // 3. Click "View device models" in that widget (this opens the "Tech details" Firebase Analytics page)
    // 4. Above the table shown in the new page, click on the “Device model” drop down menu and select “OS with Version”
    // 5. Make sure to select “OS with version” and not “OS Version”
    // 6. On the top right corner of the page, click on the “Share comparison” icon (next to the date)
    // 6. On the top right corner of the page, click on the “Share this report” icon (next to the date)
    // 7. Click “Download file” on the new side bar, then “Download CSV"
    // 8. Open the file and select the iOS/Android breakdown raw data
    // 9. Replace the sample data in this script with your data
  2. zntfdr revised this gist Nov 23, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion firebase-iOS-breakdown.swift
    Original file line number Diff line number Diff line change
    @@ -35,7 +35,7 @@ var iOSDictionary: [String: Int] = [:]

    for line in lines where line.hasPrefix("iOS"){
    let iOSVersion: String = String(line.split(separator: ".").first!)
    let numberOfUsers = Int(line.split(separator: ",").last!)!
    let numberOfUsers = Int(line.split(separator: ",")[1])!
    iOSDictionary[iOSVersion, default: 0] += numberOfUsers
    }

  3. zntfdr revised this gist Nov 22, 2021. 1 changed file with 28 additions and 26 deletions.
    54 changes: 28 additions & 26 deletions firebase-iOS-breakdown.swift
    Original file line number Diff line number Diff line change
    @@ -1,45 +1,47 @@
    // How to:
    // 1. Go in the Firebase Analytics Dashboard
    // 2. Filter iOS Platform only
    // 3. Scroll down to the "What is your audience like?" widget, select the `Devices` tab
    // 4. Export the CSV data (top right corner, there's a "Download CSV" button)
    // 5. Open the file and select the iOS breakdown raw data
    // 6. Replace the sample data in this script with your data
    // 7. Run the script in a Xcode Playground
    // 8. See the terminal output
    // 1. Open the Firebase Analytics Dashboard
    // 2. Scroll to bottom, where you see the "Users by Device model" widget
    // 3. Click "View device models" in that widget (this opens the "Tech details" Firebase Analytics page)
    // 4. Above the table shown in the new page, click on the “Device model” drop down menu and select “OS with Version”
    // 5. Make sure to select “OS with version” and not “OS Version”
    // 6. On the top right corner of the page, click on the “Share comparison” icon (next to the date)
    // 7. Click “Download file” on the new side bar, then “Download CSV"
    // 8. Open the file and select the iOS/Android breakdown raw data
    // 9. Replace the sample data in this script with your data
    // 10. Run the script in a Xcode Playground or command line
    // 11. See the terminal output

    import Foundation

    var data = """
    ios 13.1.3,38215
    iOS 13.1.3,14333
    ios 13.2.3,12667
    iOS 13.2.3,9568
    ios 12.4.1,8392
    ios 13.2.2,6816
    ios 13.1.2,6652
    ios 13.2,5439
    ios 12.4.2,4008
    ios 12.4.3,3715
    iOS 12.4.1,3111
    ios 12.3.1,3021
    iOS 13.1.2,2514
    iOS 12.4.3,2455
    iOS 15.0.2,3160,890
    iOS 15.1,3049,814
    iOS 14.8,2882,574
    Android 11,2636,743
    iOS 14.8.1,1877,234
    Android 10,1255,280
    iOS 14.7.1,1155,261
    Android 9,459,122
    iOS 15.0,411,209
    iOS 14.6,391,92
    iOS 15.0.1,353,175
    iOS 14.4.2,147,39
    iOS 15.1.1,135,28
    """

    let lines = data.split { $0.isNewline }

    var iOSDictionary: [String: Int] = [:]

    for line in lines {
    let iOSVersion: String = String(line.split(separator: ".").first!).lowercased()
    for line in lines where line.hasPrefix("iOS"){
    let iOSVersion: String = String(line.split(separator: ".").first!)
    let numberOfUsers = Int(line.split(separator: ",").last!)!
    iOSDictionary[iOSVersion, default: 0] += numberOfUsers
    }

    let totalUsers: Int = iOSDictionary.values.reduce(into: 0, { $0 += $1 })

    for (iOSVersion, numberOfUsers) in iOSDictionary {
    for (iOSVersion, numberOfUsers) in iOSDictionary.sorted(by: >) {
    let percent = String(format: "%.2f", Double(numberOfUsers) / Double(totalUsers) * Double(100))
    print("\(iOSVersion): \(percent)%")
    }
    }
  4. zntfdr revised this gist Aug 26, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion firebase-iOS-breakdown.swift
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    // How to:
    // 1. Go in the Firebase Analytics Dashboard
    // 2. Filter iOS Platform only
    // 3. Scroll down to the "What is your audience like?" widget, select the `Device` tab
    // 3. Scroll down to the "What is your audience like?" widget, select the `Devices` tab
    // 4. Export the CSV data (top right corner, there's a "Download CSV" button)
    // 5. Open the file and select the iOS breakdown raw data
    // 6. Replace the sample data in this script with your data
  5. zntfdr revised this gist Aug 26, 2021. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions firebase-iOS-breakdown.swift
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,10 @@
    // How to:
    // 1. Go in the Firebase Analytics Dashboard
    // 2. Filter iOS Platform only
    // 3. Scroll down, select `Device` under the "What is your audience like?" widget
    // 4. Export the CSV data (top right corner, there's a download button with Download CSV option)
    // 3. Scroll down to the "What is your audience like?" widget, select the `Device` tab
    // 4. Export the CSV data (top right corner, there's a "Download CSV" button)
    // 5. Open the file and select the iOS breakdown raw data
    // 6. Replace your data with the sample data in this script
    // 6. Replace the sample data in this script with your data
    // 7. Run the script in a Xcode Playground
    // 8. See the terminal output

  6. zntfdr revised this gist Apr 11, 2021. 1 changed file with 1 addition and 92 deletions.
    93 changes: 1 addition & 92 deletions firebase-iOS-breakdown.swift
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    // 1. Go in the Firebase Analytics Dashboard
    // 2. Filter iOS Platform only
    // 3. Scroll down, select `Device` under the "What is your audience like?" widget
    // 4. Export the CSV data (top right of the corner, there's a `...` menu with Download CSV option)
    // 4. Export the CSV data (top right corner, there's a download button with Download CSV option)
    // 5. Open the file and select the iOS breakdown raw data
    // 6. Replace your data with the sample data in this script
    // 7. Run the script in a Xcode Playground
    @@ -25,97 +25,6 @@ iOS 12.4.1,3111
    ios 12.3.1,3021
    iOS 13.1.2,2514
    iOS 12.4.3,2455
    ios 12.4,2119
    ios 13.0,1500
    ios 12.2,1225
    iOS 12.3.1,1197
    ios 13.1.1,1060
    ios 11.4.1,965
    iOS 12.4,771
    ios 12.1.4,753
    ios 13.1,585
    iOS 13.0,559
    iOS 13.2,559
    iOS 13.2.2,530
    iOS 12.4.2,480
    ios 12.1.2,435
    iOS 12.2,425
    iOS 13.1.1,422
    iOS 11.4.1,395
    ios 13.3,340
    ios 12.1,333
    ios 11.4,287
    iOS 12.1.4,266
    ios 12.3.2,230
    iOS 13.1,219
    ios 12.0.1,208
    ios 10.3.3,206
    ios 11.3.1,200
    ios 11.2.6,178
    iOS 12.1.2,168
    ios 10.3.4,157
    ios 12.0,154
    iOS 13.3,132
    iOS 12.1,125
    ios 11.2.1,120
    ios 11.3,117
    iOS 11.4,112
    ios 12.3,109
    ios 11.1.2,107
    ios 10.2.1,103
    ios 10.3.2,86
    iOS 12.0.1,85
    ios 11.2.5,82
    iOS 11.3.1,71
    iOS 10.3.3,70
    ios 11.0.3,70
    ios 12.1.1,69
    iOS 12.0,67
    ios 12.1.3,67
    iOS 11.2.6,65
    iOS 12.3.2,60
    ios 10.1.1,48
    ios 11.2,48
    iOS 10.3.4,46
    ios 10.2,43
    iOS 11.2.1,42
    iOS 11.3,42
    iOS 12.3,42
    ios 11.0,42
    ios 11.0.2,36
    ios 11.1,36
    ios 11.1.1,34
    ios 11.2.2,34
    iOS 12.1.1,32
    iOS 10.2.1,31
    iOS 11.2.5,30
    iOS 10.3.2,29
    iOS 11.0.3,29
    iOS 12.1.3,26
    iOS 11.1.2,24
    ios 10.3.1,24
    ios 11.0.1,24
    iOS 11.2,22
    iOS 11.1.1,18
    iOS 11.2.2,17
    iOS 10.1.1,16
    iOS 11.0,16
    iOS 10.2,15
    ios 10.0.2,15
    iOS 11.1,14
    iOS 11.0.2,13
    iOS 10.3.1,10
    ios 10.1,10
    iOS 11.0.1,9
    iOS 10.0.2,7
    ios 10.0.1,5
    ios 10.3,4
    iOS 10.1,3
    iOS 10.0.1,2
    iOS 10.3,2
    ios 10.0,2
    iOS 10.0.3,1
    iOS 9.3.5,1
    """

    let lines = data.split { $0.isNewline }
  7. zntfdr renamed this gist Nov 12, 2020. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  8. zntfdr revised this gist Dec 11, 2019. 1 changed file with 108 additions and 51 deletions.
    159 changes: 108 additions & 51 deletions firebase-iOS-breakdown
    Original file line number Diff line number Diff line change
    @@ -8,65 +8,122 @@
    // 7. Run the script in a Xcode Playground
    // 8. See the terminal output

    import Foundation

    var data = """
    ios 13.1.3,60599
    ios 13.1.2,43022
    ios 12.4.1,24814
    ios 12.4.2,11399
    ios 12.3.1,6736
    ios 13.2,6170
    ios 12.4,4643
    ios 13.0,4474
    ios 13.1.1,3476
    ios 12.2,2475
    ios 13.1,2263
    ios 11.4.1,1906
    ios 12.1.4,1498
    ios 12.1.2,876
    ios 12.1,668
    ios 11.4,581
    ios 10.3.3,532
    ios 12.3.2,452
    ios 12.0.1,433
    ios 10.3.4,410
    ios 11.3.1,385
    ios 11.2.6,361
    ios 12.0,348
    ios 12.4.3,274
    ios 11.3,256
    ios 10.2.1,224
    ios 11.2.1,221
    ios 12.3,192
    ios 11.1.2,179
    ios 11.2.5,179
    ios 10.3.2,158
    ios 11.0.3,149
    ios 12.1.3,128
    ios 12.1.1,115
    ios 10.1.1,105
    ios 10.2,97
    ios 11.2.2,90
    ios 11.2,82
    ios 11.0,78
    ios 11.1,64
    ios 11.0.2,62
    ios 10.3.1,61
    ios 11.1.1,54
    ios 10.0.2,40
    ios 11.0.1,39
    ios 10.1,12
    ios 10.0.1,11
    ios 10.3,8
    ios 10.0.3,2
    ios 9.1,1
    ios 13.1.3,38215
    iOS 13.1.3,14333
    ios 13.2.3,12667
    iOS 13.2.3,9568
    ios 12.4.1,8392
    ios 13.2.2,6816
    ios 13.1.2,6652
    ios 13.2,5439
    ios 12.4.2,4008
    ios 12.4.3,3715
    iOS 12.4.1,3111
    ios 12.3.1,3021
    iOS 13.1.2,2514
    iOS 12.4.3,2455
    ios 12.4,2119
    ios 13.0,1500
    ios 12.2,1225
    iOS 12.3.1,1197
    ios 13.1.1,1060
    ios 11.4.1,965
    iOS 12.4,771
    ios 12.1.4,753
    ios 13.1,585
    iOS 13.0,559
    iOS 13.2,559
    iOS 13.2.2,530
    iOS 12.4.2,480
    ios 12.1.2,435
    iOS 12.2,425
    iOS 13.1.1,422
    iOS 11.4.1,395
    ios 13.3,340
    ios 12.1,333
    ios 11.4,287
    iOS 12.1.4,266
    ios 12.3.2,230
    iOS 13.1,219
    ios 12.0.1,208
    ios 10.3.3,206
    ios 11.3.1,200
    ios 11.2.6,178
    iOS 12.1.2,168
    ios 10.3.4,157
    ios 12.0,154
    iOS 13.3,132
    iOS 12.1,125
    ios 11.2.1,120
    ios 11.3,117
    iOS 11.4,112
    ios 12.3,109
    ios 11.1.2,107
    ios 10.2.1,103
    ios 10.3.2,86
    iOS 12.0.1,85
    ios 11.2.5,82
    iOS 11.3.1,71
    iOS 10.3.3,70
    ios 11.0.3,70
    ios 12.1.1,69
    iOS 12.0,67
    ios 12.1.3,67
    iOS 11.2.6,65
    iOS 12.3.2,60
    ios 10.1.1,48
    ios 11.2,48
    iOS 10.3.4,46
    ios 10.2,43
    iOS 11.2.1,42
    iOS 11.3,42
    iOS 12.3,42
    ios 11.0,42
    ios 11.0.2,36
    ios 11.1,36
    ios 11.1.1,34
    ios 11.2.2,34
    iOS 12.1.1,32
    iOS 10.2.1,31
    iOS 11.2.5,30
    iOS 10.3.2,29
    iOS 11.0.3,29
    iOS 12.1.3,26
    iOS 11.1.2,24
    ios 10.3.1,24
    ios 11.0.1,24
    iOS 11.2,22
    iOS 11.1.1,18
    iOS 11.2.2,17
    iOS 10.1.1,16
    iOS 11.0,16
    iOS 10.2,15
    ios 10.0.2,15
    iOS 11.1,14
    iOS 11.0.2,13
    iOS 10.3.1,10
    ios 10.1,10
    iOS 11.0.1,9
    iOS 10.0.2,7
    ios 10.0.1,5
    ios 10.3,4
    iOS 10.1,3
    iOS 10.0.1,2
    iOS 10.3,2
    ios 10.0,2
    iOS 10.0.3,1
    iOS 9.3.5,1
    """

    let lines = data.split { $0.isNewline }

    var iOSDictionary: [String: Int] = [:]

    for line in lines {
    let iOSVersion: String = String(line.split(separator: ".").first!)
    let iOSVersion: String = String(line.split(separator: ".").first!).lowercased()
    let numberOfUsers = Int(line.split(separator: ",").last!)!
    iOSDictionary[iOSVersion, default: 0] += numberOfUsers
    }
  9. zntfdr revised this gist Nov 6, 2019. 1 changed file with 7 additions and 6 deletions.
    13 changes: 7 additions & 6 deletions firebase-iOS-breakdown
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,12 @@
    // How to:
    // 1. Go in the Firebase Analytics Dashboard
    // 2. Scroll down, select `Device` under the "What is your audience like?" widget
    // 3. Export the CSV data (top right of the corner, there's a `...` menu with Download CSV option)
    // 4. Open the file and select the iOS breakdown raw data
    // 5. Replace your data with the sample data in this script
    // 6. Run the script in a Xcode Playground
    // 7. See the terminal output
    // 2. Filter iOS Platform only
    // 3. Scroll down, select `Device` under the "What is your audience like?" widget
    // 4. Export the CSV data (top right of the corner, there's a `...` menu with Download CSV option)
    // 5. Open the file and select the iOS breakdown raw data
    // 6. Replace your data with the sample data in this script
    // 7. Run the script in a Xcode Playground
    // 8. See the terminal output

    var data = """
    ios 13.1.3,60599
  10. zntfdr created this gist Nov 6, 2019.
    78 changes: 78 additions & 0 deletions firebase-iOS-breakdown
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,78 @@
    // How to:
    // 1. Go in the Firebase Analytics Dashboard
    // 2. Scroll down, select `Device` under the "What is your audience like?" widget
    // 3. Export the CSV data (top right of the corner, there's a `...` menu with Download CSV option)
    // 4. Open the file and select the iOS breakdown raw data
    // 5. Replace your data with the sample data in this script
    // 6. Run the script in a Xcode Playground
    // 7. See the terminal output

    var data = """
    ios 13.1.3,60599
    ios 13.1.2,43022
    ios 12.4.1,24814
    ios 12.4.2,11399
    ios 12.3.1,6736
    ios 13.2,6170
    ios 12.4,4643
    ios 13.0,4474
    ios 13.1.1,3476
    ios 12.2,2475
    ios 13.1,2263
    ios 11.4.1,1906
    ios 12.1.4,1498
    ios 12.1.2,876
    ios 12.1,668
    ios 11.4,581
    ios 10.3.3,532
    ios 12.3.2,452
    ios 12.0.1,433
    ios 10.3.4,410
    ios 11.3.1,385
    ios 11.2.6,361
    ios 12.0,348
    ios 12.4.3,274
    ios 11.3,256
    ios 10.2.1,224
    ios 11.2.1,221
    ios 12.3,192
    ios 11.1.2,179
    ios 11.2.5,179
    ios 10.3.2,158
    ios 11.0.3,149
    ios 12.1.3,128
    ios 12.1.1,115
    ios 10.1.1,105
    ios 10.2,97
    ios 11.2.2,90
    ios 11.2,82
    ios 11.0,78
    ios 11.1,64
    ios 11.0.2,62
    ios 10.3.1,61
    ios 11.1.1,54
    ios 10.0.2,40
    ios 11.0.1,39
    ios 10.1,12
    ios 10.0.1,11
    ios 10.3,8
    ios 10.0.3,2
    ios 9.1,1
    """

    let lines = data.split { $0.isNewline }

    var iOSDictionary: [String: Int] = [:]

    for line in lines {
    let iOSVersion: String = String(line.split(separator: ".").first!)
    let numberOfUsers = Int(line.split(separator: ",").last!)!
    iOSDictionary[iOSVersion, default: 0] += numberOfUsers
    }

    let totalUsers: Int = iOSDictionary.values.reduce(into: 0, { $0 += $1 })

    for (iOSVersion, numberOfUsers) in iOSDictionary {
    let percent = String(format: "%.2f", Double(numberOfUsers) / Double(totalUsers) * Double(100))
    print("\(iOSVersion): \(percent)%")
    }