Skip to content

Commit

Permalink
fix: save device token in SDK even if no profile identified (#354)
Browse files Browse the repository at this point in the history
  • Loading branch information
levibostian committed Jul 17, 2023
1 parent 12d8921 commit a49f72c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/test.yml
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

- name: Upload test report
uses: actions/upload-artifact@v2
Expand Down
13 changes: 6 additions & 7 deletions Sources/Tracking/CustomerIOImplementation.swift
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

0 comments on commit a49f72c

Please sign in to comment.