https://github.com/zunda-pixel/firebaseanalytics-swift
Firebase Analytics Client Open Source Project for Swift
https://github.com/zunda-pixel/firebaseanalytics-swift
firebase firebaseanalytics google swift
Last synced: about 1 month ago
JSON representation
Firebase Analytics Client Open Source Project for Swift
- Host: GitHub
- URL: https://github.com/zunda-pixel/firebaseanalytics-swift
- Owner: zunda-pixel
- License: apache-2.0
- Created: 2025-02-14T01:44:14.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-12-01T08:40:44.000Z (6 months ago)
- Last Synced: 2025-12-03T19:56:31.986Z (6 months ago)
- Topics: firebase, firebaseanalytics, google, swift
- Language: Swift
- Homepage:
- Size: 40 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# firebaseanalytics-swift
> [!IMPORTANT]
> This project is under development
Firebase Analytics Client for Swift.
```swift
let clientInformation: ClientInformation = .init(
os: "ios",
osVersion: "18.3",
deviceModel: "iPhone17,3",
locale: "ja-jp",
localeId: 540,
installMethod: "manual_install",
bundleId: "com.apple.SampleApp",
appVersion: "1.0",
googleAppId: "1:21332412389:ios:11681asd2a3cd5d8"
)
let session: Session = .init(
firstInteraction: false,
firstOpenTime: 1_737_550_800_666,
nonPersonalizedAds: false,
sessionId: 1_737_555_666,
sessionNumber: 2,
lifetimeEngagement: 1_175_666,
sessionEngagement: 10055,
userId: "user-id"
)
let payload = Payload(
value: 1,
events: [
EventPayload(
eventName: "login",
parameters: [
.method: "Google",
.platform: "app",
],
previousTimestampMillis: UInt(Date.now.timeIntervalSince1970 * 100),
timestampMillis: UInt(Date.now.timeIntervalSince1970 * 100)
),
EventPayload(
eventName: "_e",
parameters: [
"_et": .uint(891),
.platform: "auto"
],
previousTimestampMillis: UInt(Date.now.timeIntervalSince1970 * 100),
timestampMillis: UInt(Date.now.timeIntervalSince1970 * 100)
),
],
sessionInformations: session.parameters,
value4: UInt(Date.now.timeIntervalSince1970 * 100), // upload_timestamp_millis
value5: UInt(Date.now.timeIntervalSince1970 * 100), // start_timestamp_millis
value6: UInt(Date.now.timeIntervalSince1970 * 100), // end_timestamp_millis
value7: UInt(Date.now.timeIntervalSince1970 * 100), // previous_bundle_end_timestamp_millis
os: clientInformation.os,
osVersion: clientInformation.osVersion,
deviceModel: clientInformation.deviceModel,
value11: clientInformation.locale,
value12: clientInformation.localeId,
installMethod: clientInformation.installMethod,
bundleId: clientInformation.bundleId,
appVersion: clientInformation.appVersion,
value17: 110700, // gmp_version
value18: 110700, // uploading_gmp_version
value21: "BC75E87831231231B7A179248F24080C", // fix // app_instance_id
value23: 25, // count up // bundle_sequential_index
googleAppId: clientInformation.googleAppId,
value26: UInt(Date.now.timeIntervalSince1970 * 100), // free // previous_bundle_start_timestamp_millis
value27: "CAIIJF38-E407-4954-BC16-F693A22F9FA9", // fix // resettable_device_id
value30: "d4Xw8qsfsadBoMYlsYHnot", // fix // firebase_instance_id
value31: 1, // app_version_major
value35: 1_727_127_969_769_945, // fix // config_version
value45: 42_820_019, // fix
value52: "G1--", // fix // consent_signals
value64: "google_signals", // fix
value71: "19911", // fix // consent_diagnostics
value72: 0, // fix
value77: 13 // count up
)
let analytics = Analytics(
httpClient: .urlSession(.shared),
userAgent: "SampleApp/1 CFNetwork/3826.400.120 Darwin/24.3.0",
clientInformation: clientInformation,
session: session
)
try await analytics.log(payload: payload)
```