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: save device token in SDK even if no profile identified #354

Merged
merged 2 commits into from
Jul 17, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 8 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@ jobs:
- name: Generate code coverage report from .xcresult/
run: ./scripts/generate-code-coverage-report.sh

- name: Upload code coverage report
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_UPLOAD_TOKEN }} # not required for public repos, but sometimes uploads fail without it so include it anyway
fail_ci_if_error: true # fail if upload fails so we can catch it and fix it right away.
verbose: true
directory: .build/generated
# Disable uploading code coverage for now until we investigate the 500 errors we're getting from Codecov.
# - name: Upload code coverage report
# uses: codecov/codecov-action@v2
# with:
# token: ${{ secrets.CODECOV_UPLOAD_TOKEN }} # not required for public repos, but sometimes uploads fail without it so include it anyway
# fail_ci_if_error: true # fail if upload fails so we can catch it and fix it right away.
# verbose: true
# directory: .build/generated
Comment on lines +47 to +54
Copy link
Member Author

Choose a reason for hiding this comment

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


- name: Upload test report
uses: actions/upload-artifact@v2
Expand Down
13 changes: 6 additions & 7 deletions Sources/Tracking/CustomerIOImplementation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,12 @@ internal class CustomerIOImplementation: CustomerIOInstance {
Adds device default and custom attributes and registers device token.
*/
private func addDeviceAttributes(deviceToken: String, customAttributes: [String: Any] = [:]) {
// check if the identifier is not null, blank or empty
logger.info("registering device token \(deviceToken)")
logger.debug("storing device token to device storage \(deviceToken)")
// no matter what, save the device token for use later. if a customer is identified later,
// we can reference the token and register it to a new profile.
globalDataStore.pushDeviceToken = deviceToken

guard let identifier = profileStore.identifier else {
logger.info("no profile identified, so not registering device token to a profile")
return
Expand All @@ -233,12 +238,6 @@ internal class CustomerIOImplementation: CustomerIOInstance {
return
}

logger.info("registering device token \(deviceToken)")
logger.debug("storing device token to device storage \(deviceToken)")
// no matter what, save the device token for use later. if a customer is identified later,
// we can reference the token and register it to a new profile.
globalDataStore.pushDeviceToken = deviceToken

// OS name might not be available if running on non-apple product. We currently only support iOS for the SDK
// and iOS should always be non-nil. Though, we are consolidating all Apple platforms under iOS but this check
// is
Expand Down