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: assign deviceId correctly on new device #492

Merged
merged 3 commits into from
Apr 5, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: Test

on: [push, pull_request]
on:
pull_request:
push:
branches:
- main

jobs:
test:
Expand Down Expand Up @@ -32,9 +36,6 @@ jobs:
bundle install
pod install

- name: Validate Podfile
run: pod lib lint

- name: iOS Tests
run: |
xcodebuild test \
Expand Down
2 changes: 1 addition & 1 deletion Sources/Amplitude/Amplitude.m
Original file line number Diff line number Diff line change
Expand Up @@ -1686,7 +1686,7 @@ - (void)initializeDeviceInfo {
if (self.deviceId == nil) {
self.deviceId = [self.dbHelper getValue:DEVICE_ID];
if (![self isValidDeviceId:self.deviceId]) {
self.deviceId = [self _getDeviceId];
self->_deviceId = [self _getDeviceId];
bgiori marked this conversation as resolved.
Show resolved Hide resolved
[self.dbHelper insertOrReplaceKeyValue:DEVICE_ID value:self.deviceId];
}
}
Expand Down
4 changes: 2 additions & 2 deletions Tests/AmplitudeTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -1708,9 +1708,9 @@ - (void)testOpenURLFiresDeepLinkEvent {
- (void)testGetDeviceIdBeforeInit {
NSString *instanceName = @"testGetDeviceIdBeforeAndAfterInit";

// Clear device ID from db
// Delete DB before running the test to start fresh
AMPDatabaseHelper *dbHelper = [AMPDatabaseHelper getDatabaseHelper:instanceName];
[dbHelper insertOrReplaceKeyValue:@"device_id" value:nil];
[dbHelper deleteDB];

// Device ID should get generated before api key init
Amplitude *client = [Amplitude instanceWithName:instanceName];
Expand Down
Loading