├── ATInternetTracker
├── .build
│ └── manifest.db
├── Sources
│ ├── TrackerBundle.bundle
│ │ ├── back64@2x.png
│ │ ├── info48@2x.png
│ │ ├── save48@2x.png
│ │ ├── sent48@2x.png
│ │ ├── tv48@2x.png
│ │ ├── audio48@2x.png
│ │ ├── error48@2x.png
│ │ ├── target32@2X.png
│ │ ├── touch48@2x.png
│ │ ├── trash48@2x.png
│ │ ├── trash64@2x.png
│ │ ├── video48@2x.png
│ │ ├── database64@2x.png
│ │ ├── product48@2x.png
│ │ ├── refresh64@2x.png
│ │ ├── warning48@2x.png
│ │ ├── smartphone48@2x.png
│ │ └── atinternet-logo@2x.png
│ ├── ATBundle.swift
│ ├── Info-iOS.plist
│ ├── Info-tvOS.plist
│ ├── Info-watchOS.plist
│ ├── Info-iOS-Extension.plist
│ ├── TrackerTests-Bridging-Header.h
│ ├── DefaultConfiguration.plist
│ ├── DefaultConfiguration~ipad.plist
│ ├── DefaultConfiguration~ipod.plist
│ ├── DefaultConfiguration~iphone.plist
│ ├── EventsHelper.swift
│ ├── Hash.h
│ ├── URLExtension.swift
│ ├── Tracker.h
│ ├── tvOSTracker.h
│ ├── TrackerExtension.h
│ ├── watchOSTracker.h
│ ├── Crash.h
│ ├── RequiredPropertiesDataObject.swift
│ ├── Plugin.swift
│ ├── Hash.m
│ ├── OnAppAd.swift
│ ├── NSObjectExtension.swift
│ ├── UpdateCart.swift
│ ├── BusinessObject.swift
│ ├── EcommerceObjectProperties.swift
│ ├── RemoveProduct.swift
│ ├── DeliveryCheckout.swift
│ ├── PaymentCheckout.swift
│ ├── AVInsights.swift
│ ├── NuggAd.swift
│ ├── DefaultTrackerDelegate.swift
│ ├── Location.swift
│ ├── DisplayProduct.swift
│ ├── DisplayPageProduct.swift
│ ├── DisplayCart.swift
│ ├── Context.swift
│ ├── AddProduct.swift
│ ├── ECommerce.swift
│ ├── GeneratedEvents.swift
│ ├── Cart.swift
│ ├── StringExtension.swift
│ ├── InternalSearch.swift
│ ├── DynamicRefresh.swift
│ ├── DictionaryExtension.swift
│ ├── Offline.swift
│ ├── Campaign.swift
│ ├── MvTesting.swift
│ ├── BackgroundTask.swift
│ ├── CustomTreeStructure.swift
│ └── CartAwaitingPayment.swift
├── ATInternetTracker.xcodeproj
│ ├── project.xcworkspace
│ │ └── contents.xcworkspacedata
│ ├── xcuserdata
│ │ └── xbellenger.xcuserdatad
│ │ │ └── xcschemes
│ │ │ └── xcschememanagement.plist
│ └── xcshareddata
│ │ └── xcschemes
│ │ ├── Tracker iOS.xcscheme
│ │ ├── Tracker tvOS.xcscheme
│ │ ├── Tracker watchOS.xcscheme
│ │ ├── Tracker iOS Extension.xcscheme
│ │ ├── TrackerTests.xcscheme
│ │ └── tvOSTrackerTests.xcscheme
└── Tests
│ ├── Info-iOS.plist
│ ├── Info-tvOS.plist
│ ├── CrashTests.swift
│ ├── CustomTreeStructureTests.swift
│ ├── AisleTests.swift
│ ├── MvTestingTests.swift
│ ├── MediaPlayerTests.swift
│ ├── EventsTests.swift
│ ├── CustomVarTests.swift
│ ├── ContextTests.swift
│ ├── BufferTests.swift
│ ├── GPSTests.swift
│ ├── ConfigurationTests.swift
│ └── InternalSearchTests.swift
├── ATAnalytics.xcworkspace
├── contents.xcworkspacedata
└── xcshareddata
│ └── IDEWorkspaceChecks.plist
├── .gitignore
├── .github
└── workflows
│ └── stale.yml
├── ATInternet-Apple-SDK-AppExtension.podspec
├── LICENSE.md
├── ATInternet-Apple-SDK.podspec
└── README.md
/ATInternetTracker/.build/manifest.db:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/at-internet/atinternet-apple-sdk/HEAD/ATInternetTracker/.build/manifest.db
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/TrackerBundle.bundle/back64@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/at-internet/atinternet-apple-sdk/HEAD/ATInternetTracker/Sources/TrackerBundle.bundle/back64@2x.png
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/TrackerBundle.bundle/info48@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/at-internet/atinternet-apple-sdk/HEAD/ATInternetTracker/Sources/TrackerBundle.bundle/info48@2x.png
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/TrackerBundle.bundle/save48@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/at-internet/atinternet-apple-sdk/HEAD/ATInternetTracker/Sources/TrackerBundle.bundle/save48@2x.png
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/TrackerBundle.bundle/sent48@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/at-internet/atinternet-apple-sdk/HEAD/ATInternetTracker/Sources/TrackerBundle.bundle/sent48@2x.png
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/TrackerBundle.bundle/tv48@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/at-internet/atinternet-apple-sdk/HEAD/ATInternetTracker/Sources/TrackerBundle.bundle/tv48@2x.png
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/TrackerBundle.bundle/audio48@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/at-internet/atinternet-apple-sdk/HEAD/ATInternetTracker/Sources/TrackerBundle.bundle/audio48@2x.png
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/TrackerBundle.bundle/error48@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/at-internet/atinternet-apple-sdk/HEAD/ATInternetTracker/Sources/TrackerBundle.bundle/error48@2x.png
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/TrackerBundle.bundle/target32@2X.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/at-internet/atinternet-apple-sdk/HEAD/ATInternetTracker/Sources/TrackerBundle.bundle/target32@2X.png
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/TrackerBundle.bundle/touch48@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/at-internet/atinternet-apple-sdk/HEAD/ATInternetTracker/Sources/TrackerBundle.bundle/touch48@2x.png
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/TrackerBundle.bundle/trash48@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/at-internet/atinternet-apple-sdk/HEAD/ATInternetTracker/Sources/TrackerBundle.bundle/trash48@2x.png
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/TrackerBundle.bundle/trash64@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/at-internet/atinternet-apple-sdk/HEAD/ATInternetTracker/Sources/TrackerBundle.bundle/trash64@2x.png
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/TrackerBundle.bundle/video48@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/at-internet/atinternet-apple-sdk/HEAD/ATInternetTracker/Sources/TrackerBundle.bundle/video48@2x.png
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/TrackerBundle.bundle/database64@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/at-internet/atinternet-apple-sdk/HEAD/ATInternetTracker/Sources/TrackerBundle.bundle/database64@2x.png
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/TrackerBundle.bundle/product48@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/at-internet/atinternet-apple-sdk/HEAD/ATInternetTracker/Sources/TrackerBundle.bundle/product48@2x.png
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/TrackerBundle.bundle/refresh64@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/at-internet/atinternet-apple-sdk/HEAD/ATInternetTracker/Sources/TrackerBundle.bundle/refresh64@2x.png
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/TrackerBundle.bundle/warning48@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/at-internet/atinternet-apple-sdk/HEAD/ATInternetTracker/Sources/TrackerBundle.bundle/warning48@2x.png
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/TrackerBundle.bundle/smartphone48@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/at-internet/atinternet-apple-sdk/HEAD/ATInternetTracker/Sources/TrackerBundle.bundle/smartphone48@2x.png
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/TrackerBundle.bundle/atinternet-logo@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/at-internet/atinternet-apple-sdk/HEAD/ATInternetTracker/Sources/TrackerBundle.bundle/atinternet-logo@2x.png
--------------------------------------------------------------------------------
/ATAnalytics.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ATInternetTracker/ATInternetTracker.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ATAnalytics.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | *.xcuserstate
3 |
4 | ## Various settings
5 | *.pbxuser
6 | !default.pbxuser
7 | *.mode1v3
8 | !default.mode1v3
9 | *.mode2v3
10 | !default.mode2v3
11 | *.perspectivev3
12 | !default.perspectivev3
13 | xcuserdata/
14 |
15 | ## Other
16 | *.moved-aside
17 | *.xcuserstate
18 | *.xccheckout
19 | *.xcscmblueprint
20 | .DS_Store
21 | *.xcodeproj/*
22 | !*.xcodeproj/project.pbxproj
23 | docs/
24 | *.swp
25 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/ATBundle.swift:
--------------------------------------------------------------------------------
1 | //
2 | // File.swift
3 | // Tracker iOS
4 | //
5 | // Created by Théo Damaville on 15/06/2018.
6 | //
7 |
8 | import Foundation
9 |
10 | func pathFor(asset: String) -> String? {
11 | let bundlePath = Bundle(for: Tracker.self).path(forResource: "TrackerBundle", ofType: "bundle")
12 | if let bp = bundlePath {
13 | let bundle = Bundle(path: bp)
14 | return bundle?.path(forResource: asset, ofType: "png")
15 | } else {
16 | return nil
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/.github/workflows/stale.yml:
--------------------------------------------------------------------------------
1 | name: Mark stale issues and pull requests
2 |
3 | on:
4 | schedule:
5 | - cron: "0 0 * * *"
6 |
7 | jobs:
8 | stale:
9 |
10 | runs-on: ubuntu-latest
11 |
12 | steps:
13 | - uses: actions/stale@v1
14 | with:
15 | repo-token: ${{ secrets.GITHUB_TOKEN }}
16 | stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days'
17 | days-before-stale: 30
18 | days-before-close: 5
19 |
--------------------------------------------------------------------------------
/ATInternetTracker/Tests/Info-iOS.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 2.23.10
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 2.23.10
23 |
24 |
25 |
--------------------------------------------------------------------------------
/ATInternetTracker/Tests/Info-tvOS.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.20.10
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1.20.10
23 |
24 |
25 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/Info-iOS.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 2.23.10
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | $(CURRENT_PROJECT_VERSION)
23 | NSPrincipalClass
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/Info-tvOS.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.20.10
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | $(CURRENT_PROJECT_VERSION)
23 | NSPrincipalClass
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/Info-watchOS.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.20.10
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | $(CURRENT_PROJECT_VERSION)
23 | NSPrincipalClass
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/Info-iOS-Extension.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 2.23.10
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | $(CURRENT_PROJECT_VERSION)
23 | NSPrincipalClass
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/ATInternet-Apple-SDK-AppExtension.podspec:
--------------------------------------------------------------------------------
1 | Pod::Spec.new do |s|
2 | s.name = "ATInternet-Apple-SDK-AppExtension"
3 | s.version = '2.23.10'
4 | s.summary = "AT Internet mobile analytics solution for Apple devices"
5 | s.homepage = "https://github.com/at-internet/atinternet-apple-sdk"
6 | s.documentation_url = 'https://developers.atinternet-solutions.com/apple-en/getting-started-apple-en/operating-principle-apple-en/'
7 | s.license = "MIT"
8 | s.author = "AT Internet"
9 | s.requires_arc = true
10 | s.source = { :git => "https://github.com/at-internet/atinternet-apple-sdk.git", :tag => s.version}
11 | s.module_name = 'TrackerAppExtension'
12 | s.ios.deployment_target = '10.0'
13 | s.pod_target_xcconfig = { 'OTHER_SWIFT_FLAGS' => '-DAT_EXTENSION' }
14 | s.source_files = "ATInternetTracker/Sources/*.{h,m,swift}"
15 | s.exclude_files = ["ATInternetTracker/Sources/BackgroundTask.swift","ATInternetTracker/Sources/Debugger.swift","ATInternetTracker/Sources/TrackerTests-Bridging-Header.h"]
16 | s.platform = :ios, "10.0"
17 | s.resources = "ATInternetTracker/Sources/DefaultConfiguration*", "ATInternetTracker/Sources/TrackerBundle.bundle"
18 | end
19 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/TrackerTests-Bridging-Header.h:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 |
25 |
26 |
27 |
28 | //
29 | // Use this file to import your target's public headers that you would like to expose to Swift.
30 | //
31 |
32 | #import "Crash.h"
33 | #import "Hash.h"
34 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/DefaultConfiguration.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | maxHitSize
6 | 8000
7 | proxyType
8 | none
9 | proxyAddress
10 |
11 | UUIDDuration
12 | 397
13 | UUIDExpirationMode
14 | fixed
15 | sendHitWhenOptOut
16 | true
17 | ignoreLimitedAdTracking
18 | false
19 | sendOnApplicationState
20 | all
21 | campaignLifetime
22 | 30
23 | sessionBackgroundDuration
24 | 60
25 | campaignLastPersistence
26 | true
27 | persistIdentifiedVisitor
28 | true
29 | hashUserId
30 | false
31 | enableBackgroundTask
32 | false
33 | storage
34 | never
35 | plugins
36 |
37 | log
38 |
39 | logSSL
40 |
41 | domain
42 | xiti.com
43 | pixelPath
44 | /hit.xiti
45 | site
46 |
47 | identifier
48 | uuid
49 | downloadSource
50 | ext
51 |
52 |
53 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/DefaultConfiguration~ipad.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | maxHitSize
6 | 8000
7 | proxyType
8 | none
9 | proxyAddress
10 |
11 | UUIDDuration
12 | 397
13 | UUIDExpirationMode
14 | fixed
15 | sendHitWhenOptOut
16 | true
17 | ignoreLimitedAdTracking
18 | false
19 | sendOnApplicationState
20 | all
21 | sessionBackgroundDuration
22 | 60
23 | campaignLastPersistence
24 | true
25 | campaignLifetime
26 | 30
27 | persistIdentifiedVisitor
28 | true
29 | hashUserId
30 | false
31 | enableBackgroundTask
32 | false
33 | storage
34 | never
35 | plugins
36 |
37 | log
38 |
39 | logSSL
40 |
41 | domain
42 | xiti.com
43 | pixelPath
44 | /hit.xiti
45 | site
46 |
47 | identifier
48 | uuid
49 | downloadSource
50 | ext
51 |
52 |
53 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/DefaultConfiguration~ipod.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | maxHitSize
6 | 8000
7 | proxyType
8 | none
9 | proxyAddress
10 |
11 | UUIDDuration
12 | 397
13 | UUIDExpirationMode
14 | fixed
15 | sendHitWhenOptOut
16 | true
17 | ignoreLimitedAdTracking
18 | false
19 | sendOnApplicationState
20 | all
21 | sessionBackgroundDuration
22 | 60
23 | campaignLastPersistence
24 | true
25 | campaignLifetime
26 | 30
27 | persistIdentifiedVisitor
28 | true
29 | hashUserId
30 | false
31 | enableBackgroundTask
32 | false
33 | storage
34 | never
35 | plugins
36 |
37 | log
38 |
39 | logSSL
40 |
41 | domain
42 | xiti.com
43 | pixelPath
44 | /hit.xiti
45 | site
46 |
47 | identifier
48 | uuid
49 | downloadSource
50 | ext
51 |
52 |
53 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/DefaultConfiguration~iphone.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | maxHitSize
6 | 8000
7 | proxyType
8 | none
9 | proxyAddress
10 |
11 | UUIDDuration
12 | 397
13 | UUIDExpirationMode
14 | fixed
15 | sendHitWhenOptOut
16 | true
17 | ignoreLimitedAdTracking
18 | false
19 | sendOnApplicationState
20 | all
21 | sessionBackgroundDuration
22 | 60
23 | campaignLastPersistence
24 | true
25 | campaignLifetime
26 | 30
27 | persistIdentifiedVisitor
28 | true
29 | hashUserId
30 | false
31 | enableBackgroundTask
32 | false
33 | storage
34 | never
35 | plugins
36 |
37 | log
38 |
39 | logSSL
40 |
41 | domain
42 | xiti.com
43 | pixelPath
44 | /hit.xiti
45 | site
46 |
47 | identifier
48 | uuid
49 | downloadSource
50 | ext
51 |
52 |
53 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/EventsHelper.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 | The above copyright notice and this permission notice shall be included in all
11 | copies or substantial portions of the Software.
12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18 | SOFTWARE.
19 | */
20 |
21 | //
22 | // EventsHelper.swift
23 | // Tracker
24 | //
25 | import Foundation
26 |
27 | public class EventsHelper: NSObject {
28 |
29 | var events : Events
30 |
31 | init(events: Events) {
32 | self.events = events
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/Hash.h:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 |
25 |
26 |
27 |
28 | //
29 | // Hash.h
30 | // Tracker
31 | //
32 |
33 | #import
34 |
35 | @interface Hash : NSObject
36 |
37 | /**
38 | Get SHA256 string from a string
39 | */
40 | + (NSString *)sha256Value:(NSString *)value;
41 |
42 | @end
43 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/URLExtension.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 |
25 |
26 |
27 |
28 | //
29 | // URLExtension.swift
30 | // Tracker
31 | //
32 |
33 | import Foundation
34 |
35 | extension URL {
36 | init?(percentEncodedString string: String) {
37 | if #available(iOS 17.0, *) {
38 | self.init(string: string.percentDecodedString)
39 | } else {
40 | self.init(string: string)
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/ATInternetTracker/Tests/CrashTests.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 |
25 |
26 |
27 |
28 | //
29 | // CrashTests.swift
30 | // Tracker
31 | //
32 |
33 | import UIKit
34 | import XCTest
35 |
36 | class CrashTests: XCTestCase {
37 |
38 | func testCompute() {
39 | let report = (Crash.compute() as NSDictionary?) as! [String: Any]?
40 | if let _ = report {
41 | XCTAssert(false, "Il ne doit pas y'avoir de données relatives à un crash")
42 | }
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/Tracker.h:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 |
25 | #import
26 |
27 | //! Project version number for Tracker.
28 | FOUNDATION_EXPORT double TrackerVersionNumber;
29 |
30 | //! Project version string for Tracker.
31 | FOUNDATION_EXPORT const unsigned char TrackerVersionString[];
32 |
33 | // In this header, you should import all the public headers of your framework using statements like #import
34 | #import "Crash.h"
35 | #import "Hash.h"
36 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/tvOSTracker.h:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 |
25 | #import
26 |
27 | //! Project version number for Tracker.
28 | FOUNDATION_EXPORT double tvOSTrackerVersionNumber;
29 |
30 | //! Project version string for Tracker.
31 | FOUNDATION_EXPORT const unsigned char tvOSTrackerVersionString[];
32 |
33 | // In this header, you should import all the public headers of your framework using statements like #import
34 | #import "Crash.h"
35 | #import "Hash.h"
36 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/TrackerExtension.h:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 |
25 | #import
26 |
27 | //! Project version number for Tracker.
28 | FOUNDATION_EXPORT double ExtensionTrackerVersionNumber;
29 |
30 | //! Project version string for Tracker.
31 | FOUNDATION_EXPORT const unsigned char ExtensionTrackerVersionString[];
32 |
33 | // In this header, you should import all the public headers of your framework using statements like #import
34 | #import "Crash.h"
35 | #import "Hash.h"
36 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/watchOSTracker.h:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 | #include
25 |
26 | #if TARGET_OS_WATCH
27 | #import
28 | #endif
29 |
30 | //! Project version number for Tracker.
31 | FOUNDATION_EXPORT double watchOSTrackerVersionNumber;
32 |
33 | //! Project version string for Tracker.
34 | FOUNDATION_EXPORT const unsigned char watchOSTrackerVersionString[];
35 |
36 |
37 | // In this header, you should import all the public headers of your framework using statements like #import
38 | #import "Crash.h"
39 | #import "Hash.h"
40 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/Crash.h:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 |
25 |
26 |
27 |
28 | //
29 | // Crash.h
30 | // Tracker
31 | //
32 |
33 | #import
34 |
35 | @interface Crash : NSObject
36 |
37 | /**
38 | PRIVATE - Prepare a crash log
39 |
40 | :returns: a dictionnary ready to be added to xtcustom
41 | */
42 | + (NSDictionary *)compute;
43 |
44 | + (NSDictionary *)recover;
45 |
46 | /**
47 | PRIVATE - Enable crash handler
48 | */
49 | + (void)handle;
50 |
51 | /// PRIVATE - Last tracked screen
52 | + (void)lastScreen:(NSString *)screenName;
53 |
54 | + (NSArray *)crashFilesContent;
55 |
56 | @end
57 |
--------------------------------------------------------------------------------
/ATInternetTracker/ATInternetTracker.xcodeproj/xcuserdata/xbellenger.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | SmartTracker iOS.xcscheme_^#shared#^_
8 |
9 | orderHint
10 | 0
11 |
12 | Tracker iOS Extension.xcscheme_^#shared#^_
13 |
14 | orderHint
15 | 2
16 |
17 | Tracker iOS.xcscheme_^#shared#^_
18 |
19 | orderHint
20 | 1
21 |
22 | Tracker tvOS.xcscheme_^#shared#^_
23 |
24 | orderHint
25 | 3
26 |
27 | Tracker watchOS.xcscheme_^#shared#^_
28 |
29 | orderHint
30 | 4
31 |
32 |
33 | SuppressBuildableAutocreation
34 |
35 | 4F47A3DD1D351E8100702747
36 |
37 | primary
38 |
39 |
40 | 4F47A3F81D351EA700702747
41 |
42 | primary
43 |
44 |
45 | 4F47A4071D351F9C00702747
46 |
47 | primary
48 |
49 |
50 | 4F47A4311D3532A900702747
51 |
52 | primary
53 |
54 |
55 | 4F47A54F1D35465100702747
56 |
57 | primary
58 |
59 |
60 | 4F47A6BD1D3D0A3000702747
61 |
62 | primary
63 |
64 |
65 | 4F47A6DB1D3D10E000702747
66 |
67 | primary
68 |
69 |
70 | 4F47A9201D3E2FE100702747
71 |
72 | primary
73 |
74 |
75 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/RequiredPropertiesDataObject.swift:
--------------------------------------------------------------------------------
1 | //
2 | // RequiredPropertiesDataObject.swift
3 | // Tracker
4 | //
5 | import Foundation
6 |
7 | public class RequiredPropertiesDataObject : NSObject {
8 |
9 | fileprivate let propertiesSynchronizer = DispatchQueue(label: "PropertiesSynchronizer")
10 | fileprivate var properties = [String : Any]()
11 |
12 | @objc public func get(key: String) -> Any? {
13 | var val : Any? = nil
14 | self.propertiesSynchronizer.sync {
15 | val = self.properties[key]
16 | }
17 | return val
18 | }
19 |
20 | @objc public func set(key: String, value: Any) -> RequiredPropertiesDataObject {
21 | self.propertiesSynchronizer.async {
22 | self.properties[key] = value
23 | }
24 | return self
25 | }
26 |
27 | @objc public func del(key: String) -> RequiredPropertiesDataObject {
28 | self.propertiesSynchronizer.async {
29 | self.properties.removeValue(forKey: key)
30 | }
31 | return self
32 | }
33 |
34 | @objc public func getProps() -> [String : Any] {
35 | var props: [String : Any] = [String : Any]()
36 | self.propertiesSynchronizer.sync {
37 | props = self.properties
38 | }
39 | return props
40 | }
41 |
42 | @objc public func setProps(obj: [String : Any]) -> RequiredPropertiesDataObject {
43 | self.propertiesSynchronizer.async {
44 | for (k,v) in obj {
45 | self.properties[k] = v
46 | }
47 | }
48 | return self
49 | }
50 |
51 | @objc public func delProps() -> RequiredPropertiesDataObject {
52 | self.propertiesSynchronizer.async {
53 | self.properties.removeAll()
54 | }
55 | return self
56 | }
57 |
58 | @available(*, deprecated, message: "Use 'setProps()' method instead")
59 | @objc public func setAll(obj: [String : Any]) -> RequiredPropertiesDataObject {
60 | return setProps(obj: obj)
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/Plugin.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 |
25 |
26 |
27 |
28 | //
29 | // Partner.swift
30 | // Tracker
31 | //
32 |
33 | import Foundation
34 |
35 | /// Plugin management
36 | class Plugin: NSObject {
37 |
38 | /// Response returned by the execute function
39 | var response: String
40 | /// Tracker instance
41 | var tracker: Tracker
42 | /// Parameter key where to set response
43 | var paramKey: String
44 |
45 | /**
46 | Execute the code of the plugin to retrieve the response (abstract)
47 | */
48 | func execute() {
49 |
50 | }
51 |
52 | /**
53 | Default initializer
54 |
55 | - returns: a Plugin instance
56 | */
57 | required init(tracker: Tracker) {
58 | self.response = "{}"
59 | self.tracker = tracker
60 | self.paramKey = "stc"
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/Hash.m:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 |
25 |
26 |
27 |
28 | //
29 | // Hash.m
30 | // Tracker
31 | //
32 |
33 | #import "Hash.h"
34 | #import
35 |
36 | @implementation Hash
37 | + (NSString *)sha256Value:(NSString *)value {
38 | const char *cstr = [value cStringUsingEncoding:NSUTF8StringEncoding];
39 | NSData *data = [NSData dataWithBytes:cstr length:value.length];
40 | uint8_t digest[CC_SHA256_DIGEST_LENGTH];
41 |
42 | CC_SHA256(data.bytes, (CC_LONG)data.length, digest);
43 |
44 | NSMutableString* output = [NSMutableString stringWithCapacity:CC_SHA256_DIGEST_LENGTH * 2];
45 |
46 | // Parse through the CC_SHA256 results (stored inside of digest[]).
47 | for(int i = 0; i < CC_SHA256_DIGEST_LENGTH; i++) {
48 | [output appendFormat:@"%02x", digest[i]];
49 | }
50 |
51 | return output;
52 | }
53 | @end
54 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/OnAppAd.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 |
25 |
26 |
27 |
28 | //
29 | // OnAppAd.swift
30 | // Tracker
31 | //
32 |
33 | import Foundation
34 |
35 |
36 | /// Abstract class to manage Advertising tracking
37 | public class OnAppAd: BusinessObject {
38 |
39 | /// Action types
40 | ///
41 | /// - view: Ad tracking impression
42 | /// - touch: Ad tracking touch
43 | @objc
44 | public enum OnAppAdAction: Int {
45 | case view = 0
46 | case touch = 1
47 | }
48 |
49 | /// Action
50 | @objc public var action: OnAppAdAction = OnAppAdAction.view
51 |
52 | internal class func getOnAppAddActionRawValue(_ value: Int) -> String {
53 | switch value {
54 | case 1:
55 | return "atc"
56 | default:
57 | return "ati"
58 | }
59 | }
60 |
61 | /// Set parameters in buffer
62 | override func setParams() {
63 |
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/NSObjectExtension.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 |
25 | import Foundation
26 |
27 | extension NSObject {
28 |
29 | /// Allow to get the Class name of an object
30 | /// Swift equivalent of NSStringFromClass([self class])
31 | @objc var classLabel: String {
32 | let str = NSStringFromClass(self.classForCoder)
33 |
34 | if let name = str.components(separatedBy: ".").last {
35 | return name
36 | }
37 |
38 | return ""
39 | }
40 |
41 | /**
42 | Check if a property is present in the object using reflexion
43 |
44 | - parameter property: the property to check the existence
45 |
46 | - returns: true is the property is present in the object
47 | */
48 | @objc func at_hasProperty(_ property: String) -> Bool {
49 | let cp = class_getProperty(object_getClass(self), property)
50 | if cp != nil {
51 | if let _ = self.value(forKey: property) {
52 | return true
53 | }
54 | }
55 | return false
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/UpdateCart.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 | The above copyright notice and this permission notice shall be included in all
11 | copies or substantial portions of the Software.
12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18 | SOFTWARE.
19 | */
20 |
21 | //
22 | // UpdateCart.swift
23 | // Tracker
24 | //
25 | import Foundation
26 |
27 | /// Wrapper class for UpdateCart event tracking (SalesInsight)
28 | public class UpdateCart: Event {
29 |
30 | /// Cart property
31 | @objc public lazy var cart : ECommerceCart = ECommerceCart()
32 |
33 | override var data: [String : Any] {
34 | get {
35 | let cartProps = cart.getProps()
36 | if !cartProps.isEmpty {
37 | _data["cart"] = cartProps
38 | }
39 | return super.data
40 | }
41 | set {
42 | _data = newValue
43 | }
44 | }
45 |
46 | init() {
47 | super.init(name: "cart.update")
48 | }
49 | }
50 |
51 | /// Wrapper class to manage UpdateCart event instances
52 | public class UpdateCarts : EventsHelper {
53 |
54 | /// Add update cart event tracking
55 | ///
56 | /// - Returns: UpdateCart instance
57 | @objc public func add() -> UpdateCart {
58 | let uc = UpdateCart()
59 | _ = events.add(event: uc)
60 | return uc
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/BusinessObject.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 |
25 |
26 |
27 |
28 | //
29 | // BusinessObject.swift
30 | // Tracker
31 | //
32 |
33 | import Foundation
34 |
35 |
36 | /// Super class for object tracking. Not recommended for normal use. If you need special markers you can subclass BusinessObject.
37 | open class BusinessObject: NSObject {
38 | /// Tracker instance
39 | var tracker: Tracker!
40 | /// Screen ID
41 | let id: String = UUID().uuidString
42 | /// Creation date
43 | var timeStamp : UInt64 = UInt64(0)
44 |
45 | /**
46 | Default initializer
47 | */
48 | override init() {
49 | super.init()
50 | }
51 |
52 | /**
53 | BusinessObject initializer
54 | - parameter tracker: the tracker instance
55 | - returns: BusinessObject instance
56 | */
57 | init(tracker: Tracker) {
58 | self.tracker = tracker
59 | var info = mach_timebase_info()
60 | mach_timebase_info(&info)
61 | self.timeStamp = mach_absolute_time() * UInt64(info.numer) / UInt64(info.denom)
62 | }
63 |
64 | /// Set parameters in buffer
65 | func setParams() {
66 |
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/EcommerceObjectProperties.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 | The above copyright notice and this permission notice shall be included in all
11 | copies or substantial portions of the Software.
12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18 | SOFTWARE.
19 | */
20 |
21 | //
22 | // EcommerceObjectProperties.swift
23 | // Tracker
24 | //
25 |
26 | import Foundation
27 |
28 | public class ECommerceCart: RequiredPropertiesDataObject {
29 |
30 | @objc var version : String = ""
31 |
32 | override init() {
33 | super.init()
34 | let id = Foundation.UUID().uuidString
35 | self.version = String(id[.. "https://github.com/at-internet/atinternet-apple-sdk.git", :tag => s.version}
11 | s.module_name = 'Tracker'
12 | s.ios.deployment_target = '10.0'
13 | s.tvos.deployment_target = '10.0'
14 | s.watchos.deployment_target = '3.0'
15 |
16 | s.subspec 'Tracker' do |tracker|
17 | tracker.source_files = "ATInternetTracker/Sources/*.{h,m,swift}"
18 | tracker.resources = "ATInternetTracker/Sources/DefaultConfiguration*", "ATInternetTracker/Sources/TrackerBundle.bundle"
19 | tracker.platform = :ios
20 | end
21 |
22 | s.subspec 'AppExtension' do |appExt|
23 | appExt.pod_target_xcconfig = { 'OTHER_SWIFT_FLAGS' => '-DAT_EXTENSION' }
24 | appExt.source_files = "ATInternetTracker/Sources/*.{h,m,swift}"
25 | appExt.exclude_files = ["ATInternetTracker/Sources/BackgroundTask.swift","ATInternetTracker/Sources/Debugger.swift","ATInternetTracker/Sources/TrackerTests-Bridging-Header.h"]
26 | appExt.platform = :ios
27 | appExt.resources = "ATInternetTracker/Sources/DefaultConfiguration*", "ATInternetTracker/Sources/TrackerBundle.bundle"
28 | end
29 |
30 | s.subspec 'watchOSTracker' do |wos|
31 | wos.source_files = "ATInternetTracker/Sources/*.{h,m,swift}"
32 | wos.exclude_files = ["ATInternetTracker/Sources/BackgroundTask.swift","ATInternetTracker/Sources/ATReachability.swift","ATInternetTracker/Sources/Debugger.swift","ATInternetTracker/Sources/TrackerTests-Bridging-Header.h"]
33 | wos.platform = :watchos
34 | wos.resources = "ATInternetTracker/Sources/DefaultConfiguration.plist","ATInternetTracker/Sources/core.manifest.json"
35 | end
36 |
37 | s.subspec 'tvOSTracker' do |tvos|
38 | tvos.source_files = "ATInternetTracker/Sources/*.{h,m,swift}"
39 | tvos.exclude_files = ["ATInternetTracker/Sources/TrackerTests-Bridging-Header.h", "ATInternetTracker/Sources/watchOSTracker.h"]
40 | tvos.resources = "ATInternetTracker/Sources/DefaultConfiguration*", "ATInternetTracker/Sources/TrackerBundle.bundle"
41 | tvos.platform = :tvos
42 | end
43 | end
44 |
--------------------------------------------------------------------------------
/ATInternetTracker/Tests/CustomTreeStructureTests.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 |
25 |
26 |
27 |
28 | //
29 | // CustomTreeStructureTests.swift
30 | // Tracker
31 | //
32 |
33 | import UIKit
34 | import XCTest
35 |
36 | class CustomTreeStructureTests: XCTestCase {
37 |
38 | lazy var cts: CustomTreeStructure = CustomTreeStructure(tracker: Tracker())
39 | lazy var ctss: CustomTreeStructures = CustomTreeStructures(tracker: Tracker())
40 |
41 | func testSetCustomTree() {
42 | cts.category1 = 1
43 | cts.category2 = 2
44 | cts.category3 = 3
45 | cts.setParams()
46 |
47 | XCTAssertEqual(cts.tracker.buffer.volatileParameters.count, 1, "Le nombre de paramètres volatiles doit être égal à 1")
48 | XCTAssert(cts.tracker.buffer.volatileParameters["ptype"]!.values[0]() == "1-2-3", "La valeur du premier paramètre doit être 1-2-3")
49 | }
50 |
51 | func testAddCustomTree() {
52 | ctss.tracker = cts.tracker
53 | cts = ctss.add(1)
54 |
55 | XCTAssert(ctss.tracker.businessObjects.count == 1, "Le nombre d'objet en attente doit être égale à 1")
56 | XCTAssert(cts.category1 == 1, "la catégorie 1 de l'arbo perso doit être égale à 1")
57 | XCTAssert((ctss.tracker.businessObjects[cts.id] as! CustomTreeStructure).category1 == 1, "la catégorie 1 de l'arbo perso doit être égale à 1")
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/RemoveProduct.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 | The above copyright notice and this permission notice shall be included in all
11 | copies or substantial portions of the Software.
12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18 | SOFTWARE.
19 | */
20 |
21 | //
22 | // RemoveProduct.swift
23 | // Tracker
24 | //
25 | import Foundation
26 |
27 | /// Wrapper class for RemoveProduct event tracking (SalesInsight)
28 | public class RemoveProduct: Event {
29 |
30 | /// Product property
31 | @objc public lazy var product : ECommerceProduct = ECommerceProduct()
32 |
33 | /// Cart property
34 | @objc public lazy var cart : ECommerceCart = ECommerceCart()
35 |
36 | override var data: [String : Any] {
37 | get {
38 | let productProps = product.getProps()
39 | if !productProps.isEmpty {
40 | _data["product"] = productProps
41 | }
42 | let cartProps = cart.getProps()
43 | if !cartProps.isEmpty {
44 | _data["cart"] = cartProps
45 | }
46 | return super.data
47 | }
48 | set {
49 | _data = newValue
50 | }
51 | }
52 |
53 | init() {
54 | super.init(name: "product.remove_from_cart")
55 | }
56 | }
57 |
58 | /// Wrapper class to manage RemoveProduct event instances
59 | public class RemoveProducts : EventsHelper {
60 |
61 | /// Add remove product event tracking
62 | ///
63 | /// - Returns: RemoveProduct instance
64 | @objc public func add() -> RemoveProduct {
65 | let rp = RemoveProduct()
66 | _ = events.add(event: rp)
67 | return rp
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/DeliveryCheckout.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 | The above copyright notice and this permission notice shall be included in all
11 | copies or substantial portions of the Software.
12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18 | SOFTWARE.
19 | */
20 |
21 | //
22 | // DeliveryCheckout.swift
23 | // Tracker
24 | //
25 | import Foundation
26 |
27 | /// Wrapper class for DeliveryCheckout event tracking (SalesInsight)
28 | public class DeliveryCheckout: Event {
29 |
30 | /// Cart property
31 | @objc public lazy var cart : ECommerceCart = ECommerceCart()
32 |
33 | /// Shipping property
34 | @objc public var shipping : ECommerceShipping = ECommerceShipping()
35 |
36 | override var data: [String : Any] {
37 | get {
38 | let cartProps = cart.getProps()
39 | if !cartProps.isEmpty {
40 | _data["cart"] = cartProps
41 | }
42 | let shippingProps = shipping.getProps()
43 | if !shippingProps.isEmpty {
44 | _data["shipping"] = shippingProps
45 | }
46 | return super.data
47 | }
48 | set {
49 | _data = newValue
50 | }
51 | }
52 |
53 | init() {
54 | super.init(name: "cart.delivery")
55 | }
56 | }
57 |
58 | /// Wrapper class to manage DeliveryCheckout event instances
59 | public class DeliveryCheckouts : EventsHelper {
60 |
61 | /// Add click product event tracking
62 | ///
63 | /// - Returns: DeliveryCheckout instance
64 | @objc public func add() -> DeliveryCheckout {
65 | let dc = DeliveryCheckout()
66 | _ = events.add(event: dc)
67 | return dc
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/PaymentCheckout.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 | The above copyright notice and this permission notice shall be included in all
11 | copies or substantial portions of the Software.
12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18 | SOFTWARE.
19 | */
20 |
21 | //
22 | // PaymentCheckout.swift
23 | // Tracker
24 | //
25 | import Foundation
26 |
27 | /// Wrapper class for PaymentCheckout event tracking (SalesInsight)
28 | public class PaymentCheckout: Event {
29 |
30 | /// Cart property
31 | @objc public lazy var cart : ECommerceCart = ECommerceCart()
32 |
33 | /// Shipping property
34 | @objc public lazy var shipping : ECommerceShipping = ECommerceShipping()
35 |
36 | override var data: [String : Any] {
37 | get {
38 | let cartProps = cart.getProps()
39 | if !cartProps.isEmpty {
40 | _data["cart"] = cartProps
41 | }
42 | let shippingProps = shipping.getProps()
43 | if !shippingProps.isEmpty {
44 | _data["shipping"] = shippingProps
45 | }
46 | return super.data
47 | }
48 | set {
49 | _data = newValue
50 | }
51 | }
52 |
53 | init() {
54 | super.init(name: "cart.payment")
55 | }
56 | }
57 |
58 | /// Wrapper class to manage PaymentCheckout event instances
59 | public class PaymentCheckouts : EventsHelper {
60 |
61 | /// Add payment checkout event tracking
62 | ///
63 | /// - Returns: PaymentCheckout instance
64 | @objc public func add() -> PaymentCheckout {
65 | let pc = PaymentCheckout()
66 | _ = events.add(event: pc)
67 | return pc
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/AVInsights.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 |
25 |
26 |
27 |
28 | //
29 | // AVInsights.swift
30 | // Tracker
31 | //
32 | import Foundation
33 |
34 | public class AVInsights: NSObject {
35 | private var events : Events
36 |
37 | init(tracker: Tracker) {
38 | self.events = tracker.events
39 | }
40 |
41 | @objc public var media : AVMedia {
42 | get {
43 | return AVMedia(events: self.events, sessionId: nil)
44 | }
45 | }
46 |
47 | @objc public func Media(heartbeat: Int, bufferHeartbeat: Int) -> AVMedia {
48 | return AVMedia(events: self.events, heartbeat: nil, bufferHeartbeat: nil, sessionId: nil)
49 | }
50 |
51 | @objc public func Media(heartbeat: Int, bufferHeartbeat: Int, sessionId: String?) -> AVMedia {
52 | return AVMedia(events: self.events, heartbeat: nil, bufferHeartbeat: nil, sessionId: sessionId)
53 | }
54 |
55 | @objc(MediaWithDynamicValues::)
56 | public func Media(heartbeat: [Int:Int]?, bufferHeartbeat: [Int:Int]?) -> AVMedia {
57 | return AVMedia(events: self.events, heartbeat: heartbeat, bufferHeartbeat: bufferHeartbeat, sessionId: nil)
58 | }
59 |
60 | @objc(MediaWithDynamicValues:::)
61 | public func Media(heartbeat: [Int:Int]?, bufferHeartbeat: [Int:Int]?, sessionId: String?) -> AVMedia {
62 | return AVMedia(events: self.events, heartbeat: heartbeat, bufferHeartbeat: bufferHeartbeat, sessionId: sessionId)
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/ATInternetTracker/Tests/AisleTests.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 |
25 |
26 |
27 |
28 | //
29 | // AisleTests.swift
30 | // Tracker
31 | //
32 |
33 | import UIKit
34 | import XCTest
35 |
36 | class AisleTests: XCTestCase {
37 |
38 | lazy var aisle: Aisle = Aisle(tracker: Tracker())
39 | lazy var aisles: Aisles = Aisles(tracker: Tracker())
40 |
41 | func testSetAisle() {
42 | aisle.level1 = "Vêtement"
43 | aisle.level2 = "Chaussures"
44 | aisle.level3 = "Basket"
45 | aisle.setParams()
46 |
47 | XCTAssertEqual(aisle.tracker.buffer.volatileParameters.count, 1, "Le nombre de paramètres volatiles doit être égal à 1")
48 | XCTAssert(aisle.tracker.buffer.volatileParameters["aisl"]?.key == "aisl", "Le premier paramètre doit être aisle")
49 | XCTAssert(aisle.tracker.buffer.volatileParameters["aisl"]?.values[0]() == "Vêtement::Chaussures::Basket", "La valeur du premier paramètre doit être Vêtement::Chaussures::Basket")
50 | }
51 |
52 | func testAddAisle() {
53 | aisles.tracker = aisle.tracker
54 | aisle = aisles.add(level1: "chaussure")
55 |
56 | XCTAssert(aisles.tracker.businessObjects.count == 1, "Le nombre d'objet en attente doit être égale à 1")
57 | XCTAssert(aisle.level1 == "chaussure", "le niveau 1 du rayon doit être égal à chaussure")
58 | XCTAssert((aisles.tracker.businessObjects[aisle.id] as! Aisle).level1 == "chaussure", "le niveau 1 du rayond doit être égal à Godasse")
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/ATInternetTracker/Tests/MvTestingTests.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 |
25 |
26 |
27 |
28 | //
29 | // MvTestingTests.swift
30 | // Tracker
31 | //
32 |
33 | import UIKit
34 | import XCTest
35 |
36 | class MvTestingTests: XCTestCase {
37 |
38 | func testInitMvTesting() {
39 | let mvt: MvTesting = MvTesting(tracker: Tracker())
40 | XCTAssertTrue(mvt.test == "", "Test doit être vide")
41 | XCTAssertTrue(mvt.waveId == -1, "WaveId doit etre égal à -1")
42 | XCTAssertTrue(mvt.creation == "", "Creation doit être vide")
43 | }
44 |
45 | func testSetMvTesting() {
46 | let mvt1 = Tracker().mvTestings.add("test", waveId: 1, creation: "crea")
47 | _ = mvt1.variables.add("var", version: "vers")
48 | mvt1.setParams()
49 |
50 | XCTAssertEqual(mvt1.tracker.buffer.volatileParameters.count, 3, "Le nombre de paramètres volatiles doit être égal à 3")
51 |
52 | XCTAssert(mvt1.tracker.buffer.volatileParameters["type"]!.key == "type", "Le premier paramètre doit être type")
53 | XCTAssert(mvt1.tracker.buffer.volatileParameters["type"]!.values[0]() == "mvt", "La valeur du premier paramètre doit être mvt")
54 |
55 | XCTAssert(mvt1.tracker.buffer.volatileParameters["abmvc"]!.key == "abmvc", "Le second paramètre doit être abmvc")
56 | XCTAssert(mvt1.tracker.buffer.volatileParameters["abmvc"]!.values[0]() == "test-1-crea", "La valeur du second paramètre doit être test-1-crea")
57 |
58 | XCTAssert(mvt1.tracker.buffer.volatileParameters["abmv1"]!.key == "abmv1", "Le 4ème paramètre doit être abmv1")
59 | XCTAssert(mvt1.tracker.buffer.volatileParameters["abmv1"]!.values[0]() == "var-vers", "La valeur du 4ème paramètre doit être var-vers")
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/NuggAd.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 |
25 |
26 |
27 |
28 | //
29 | // NuggAd.swift
30 | // Tracker
31 | //
32 |
33 | import Foundation
34 |
35 | /// Wrapper class to enable NuggAd partner usage
36 | public class NuggAd: BusinessObject {
37 | let key = "nuggad"
38 |
39 | /// NuggAd response data
40 | lazy open var data: [String: Any] = [String: Any]()
41 |
42 | /// Set parameters in buffer
43 | override func setParams() {
44 | if let optPlugin = self.tracker.configuration.parameters["plugins"] {
45 | if (optPlugin.range(of: "nuggad") != nil) {
46 | let option = ParamOption()
47 | option.append = true
48 | option.encode = true
49 | _ = self.tracker.setParam("stc", value: [self.key: self.data], options:option)
50 | }
51 | else {
52 | self.tracker.delegate?.warningDidOccur?("NuggAd not enabled")
53 | }
54 | } else {
55 | self.tracker.delegate?.warningDidOccur?("NuggAd not enabled")
56 | }
57 | }
58 | }
59 |
60 | /// Wrapper class to manage NuggAd instances
61 | public class NuggAds: NSObject {
62 | /// Tracker instance
63 | var tracker: Tracker
64 |
65 | /**
66 | NuggAds initializer
67 | - parameter tracker: the tracker instance
68 | - returns: NuggAds instance
69 | */
70 | init(tracker: Tracker) {
71 | self.tracker = tracker
72 | }
73 |
74 | /// Add NuggAd data
75 | ///
76 | /// - Parameter data: NuggAd response data
77 | /// - Returns: NuggAd instance
78 | @objc public func add(_ data: [String: Any]) -> NuggAd {
79 | let ad = NuggAd(tracker: tracker)
80 | ad.data = data
81 | tracker.businessObjects[ad.id] = ad
82 |
83 | return ad
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/ATInternetTracker/Tests/MediaPlayerTests.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 |
25 |
26 |
27 |
28 | //
29 | // MediaPlayerTests.swift
30 | // Tracker
31 | //
32 |
33 | import UIKit
34 | import XCTest
35 |
36 | class MediaPlayerTests: XCTestCase {
37 |
38 | lazy var mediaPlayer: MediaPlayer = MediaPlayer(tracker: Tracker())
39 | lazy var mediaPlayers: MediaPlayers = MediaPlayers(tracker: Tracker())
40 |
41 | func testSetMediaPlayer() {
42 | mediaPlayer.playerId = 42
43 |
44 | XCTAssert(mediaPlayer.playerId == 42, "L'identifiant doit être 42")
45 | XCTAssertNotNil(mediaPlayer.videos, "La propriété n'est pas correctement initalisée")
46 | XCTAssertNotNil(mediaPlayer.audios, "La propriété n'est pas correctement initalisée")
47 | XCTAssertNotNil(mediaPlayer.liveAudios, "La propriété n'est pas correctement initalisée")
48 | XCTAssertNotNil(mediaPlayer.liveVideos, "La propriété n'est pas correctement initalisée")
49 | }
50 |
51 | func testAddMediaPlayer() {
52 | _ = mediaPlayers.add()
53 | _ = mediaPlayers.add(42)
54 |
55 | XCTAssert(mediaPlayers.playerIds.count == 2, "Le nombre d'objet doit être égale à 2")
56 | XCTAssert(mediaPlayers.playerIds[42] != nil, "Le player devrait exister pour cet identifiant")
57 | }
58 |
59 | func testRemoveAllMediaPlayers() {
60 | _ = mediaPlayers.add()
61 | _ = mediaPlayers.add()
62 | _ = mediaPlayers.removeAll()
63 |
64 | XCTAssert(mediaPlayers.playerIds.count == 0, "Le nombre d'objet doit être égale à 2")
65 | }
66 |
67 | func testRemoveMediaPlayer() {
68 | _ = mediaPlayers.add(72)
69 | _ = mediaPlayers.remove(72)
70 |
71 | XCTAssert(mediaPlayers.playerIds.count == 0, "Le nombre d'objet doit être égale à 2")
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/ATInternetTracker/Tests/EventsTests.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 |
25 |
26 |
27 |
28 | //
29 | // EventsTests.swift
30 | // Tracker
31 | //
32 |
33 | import XCTest
34 |
35 | class EventsTests: XCTestCase {
36 |
37 | lazy var tracker = Tracker()
38 | lazy var events: Events = Events(tracker: tracker)
39 |
40 | override func setUp() {
41 | super.setUp()
42 | tracker.resetScreenContext()
43 | }
44 |
45 | func testSetParamsOne() {
46 | _ = events.add(name: "act", data: ["test1" : "value1"])
47 | events.setParams()
48 |
49 | XCTAssertEqual(events.tracker.buffer.volatileParameters.count, 2, "Le nombre de paramètres volatiles doit être égal à 5")
50 |
51 | XCTAssertEqual(events.tracker.buffer.volatileParameters["col"]!.values.count, 1, "Le nombre de valeurs dans col doit être égal à 1")
52 | XCTAssert(events.tracker.buffer.volatileParameters["col"]!.values[0]() == "2", "La valeur de col paramètre doit être 2")
53 |
54 | XCTAssertEqual(events.tracker.buffer.volatileParameters["events"]!.values.count, 1, "Le nombre de valeurs dans events doit être égal à 1")
55 |
56 | let evts = ATJSON.parse(events.tracker.buffer.volatileParameters["events"]!.values[0]())
57 |
58 | XCTAssertEqual(evts.array!.count, 1, "Le nombre d'events doit être égal à 1")
59 |
60 | let evt = evts[0]
61 | XCTAssertEqual(evt.dictionaryObject!.count, 2, "Le nombre de proprietes dans l'event doit être égal à 2")
62 | XCTAssertEqual(evt.dictionaryObject!["name"] as! String, "act", "La propriété name doit etre égale a act")
63 |
64 | let data = evt.dictionaryObject!["data"] as! [String : Any]
65 | XCTAssertEqual(data.count, 1, "Le nombre de proprietes dans data doit être égal à 1")
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/ATInternetTracker/ATInternetTracker.xcodeproj/xcshareddata/xcschemes/Tracker iOS.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
43 |
44 |
50 |
51 |
52 |
53 |
59 |
60 |
66 |
67 |
68 |
69 |
71 |
72 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/DefaultTrackerDelegate.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 | import Foundation
25 |
26 |
27 | /// Helper to provide a simple tracker delegate that log all messages pushed by the SDK (verbose, warning, error...)
28 | /// Note: tracker.delegate is a weak var, so you have to reference the DefaultTrackerDelegate strongly somewhere.
29 | /// tracker.delegate = DefaultTrackerDelegate() // not working because the variable will be dealloc at the end of the function.
30 | public class DefaultTrackerDelegate: NSObject, TrackerDelegate {
31 | let separator = "\n\t"
32 |
33 | public func trackerNeedsFirstLaunchApproval(_ message: String) {
34 | print("ATINTERNET Debugging message:\(separator)Event: First Launch\(separator)Message: \(message)")
35 | }
36 | public func buildDidEnd(_ status: HitStatus, message: String) {
37 | print("ATINTERNET Debugging message:\(separator)Event: Building Hit\(separator)Status: \(status)\(separator)Message: \(message)")
38 | }
39 | public func sendDidEnd(_ status: HitStatus, message: String) {
40 | print("ATINTERNET Debugging message:\(separator)Event: Sending Hit\(separator)Message: \(message)")
41 | }
42 | public func saveDidEnd(_ message: String) {
43 | print("ATINTERNET Debugging message:\(separator)Event: Saving Hit\(separator)Message: \(message)")
44 | }
45 | public func didCallPartner(_ response: String) {
46 | print("ATINTERNET Debugging message:\(separator)Event: Calling Partner\(separator)Message: \(response)")
47 | }
48 | public func warningDidOccur(_ message: String) {
49 | print("ATINTERNET Debugging message:\(separator)Event: Warning\(separator)Message: \(message)")
50 | }
51 | public func errorDidOccur(_ message: String) {
52 | print("ATINTERNET Debugging message:\(separator)Event: Error\(separator)Message: \(message)")
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/ATInternetTracker/ATInternetTracker.xcodeproj/xcshareddata/xcschemes/Tracker tvOS.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
43 |
44 |
50 |
51 |
52 |
53 |
59 |
60 |
66 |
67 |
68 |
69 |
71 |
72 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/ATInternetTracker/ATInternetTracker.xcodeproj/xcshareddata/xcschemes/Tracker watchOS.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
43 |
44 |
50 |
51 |
52 |
53 |
59 |
60 |
66 |
67 |
68 |
69 |
71 |
72 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/Location.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 |
25 |
26 |
27 |
28 | //
29 | // GPS.swift
30 | // Tracker
31 | //
32 |
33 | import Foundation
34 |
35 | /// Wrapper class for gps location tracking
36 | public class Location: ScreenInfo {
37 | /// latitude
38 | @objc public var latitude: Double = 0.0
39 | /// longitude
40 | @objc public var longitude: Double = 0.0
41 |
42 | @objc public init(latitude: Double, longitude: Double) {
43 | super.init()
44 |
45 | self.latitude = latitude
46 | self.longitude = longitude
47 | }
48 |
49 | override init(tracker: Tracker) {
50 | super.init(tracker: tracker)
51 | }
52 |
53 | /// Set parameters in buffer
54 | override func setParams() {
55 | _ = tracker.setParam(HitParam.gpsLatitude.rawValue, value: String(format: "%.2f", latitude))
56 | _ = tracker.setParam(HitParam.gpsLongitude.rawValue, value: String(format: "%.2f", longitude))
57 | }
58 | }
59 |
60 | /// /// Wrapper class to manage Locations instances
61 | public class Locations: NSObject {
62 | /// Tracker instance
63 | @objc var tracker: Tracker
64 |
65 | /**
66 | Locations initializer
67 | - parameter tracker: the tracker instance
68 | - returns: Locations instance
69 | */
70 | @objc init(tracker: Tracker) {
71 | self.tracker = tracker
72 | }
73 |
74 | /// Add a location
75 | ///
76 | /// - Parameters:
77 | /// - latitude: latitude x
78 | /// - longitude: longitude y
79 | /// - Returns: a new location instance
80 | @objc public func add(_ latitude: Double, longitude: Double) -> Location {
81 | let location = Location(tracker: tracker)
82 | location.latitude = latitude
83 | location.longitude = longitude
84 | tracker.businessObjects[location.id] = location
85 |
86 | return location
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/ATInternetTracker/ATInternetTracker.xcodeproj/xcshareddata/xcschemes/Tracker iOS Extension.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
43 |
44 |
50 |
51 |
52 |
53 |
59 |
60 |
66 |
67 |
68 |
69 |
71 |
72 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/ATInternetTracker/ATInternetTracker.xcodeproj/xcshareddata/xcschemes/TrackerTests.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
42 |
43 |
53 |
54 |
60 |
61 |
62 |
63 |
69 |
70 |
72 |
73 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/ATInternetTracker/ATInternetTracker.xcodeproj/xcshareddata/xcschemes/tvOSTrackerTests.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
42 |
43 |
53 |
54 |
60 |
61 |
62 |
63 |
69 |
70 |
72 |
73 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/DisplayProduct.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 | The above copyright notice and this permission notice shall be included in all
11 | copies or substantial portions of the Software.
12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18 | SOFTWARE.
19 | */
20 |
21 | //
22 | // DisplayPageProduct.swift
23 | // Tracker
24 | //
25 | import Foundation
26 |
27 | /// Wrapper class for DisplayPageProduct event tracking (SalesInsight)
28 | public class DisplayProduct: Event {
29 |
30 | /// List property
31 | @objc public lazy var products : [ECommerceProduct] = [ECommerceProduct]()
32 |
33 | override var data: [String : Any] {
34 | get {
35 | if !products.isEmpty {
36 | let firstProductProps = products.remove(at: 0).getProps()
37 | if !firstProductProps.isEmpty {
38 | _data["product"] = firstProductProps
39 | }
40 | }
41 | return super.data
42 | }
43 | set {
44 | _data = newValue
45 | }
46 | }
47 |
48 | init() {
49 | super.init(name: "product.display")
50 | }
51 |
52 | @objc public func setProducts(products: [ECommerceProduct]) {
53 | self.products = products
54 | }
55 |
56 | override func getAdditionalEvents() -> [Event] {
57 | var generatedEvents = super.getAdditionalEvents()
58 |
59 | for p in products {
60 | /// SALES INSIGHTS
61 | let dp = DisplayProduct()
62 | let productProps = p.getProps()
63 | if !productProps.isEmpty {
64 | dp._data["product"] = productProps
65 | }
66 | generatedEvents.append(dp)
67 | }
68 |
69 | return generatedEvents
70 | }
71 | }
72 |
73 | /// Wrapper class to manage DisplayProducts event instances
74 | public class DisplayProducts : EventsHelper {
75 |
76 | /// Add display products event tracking
77 | ///
78 | /// - Returns: DisplayProduct instance
79 | @objc public func add() -> DisplayProduct {
80 | let dp = DisplayProduct()
81 | _ = events.add(event: dp)
82 | return dp
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/DisplayPageProduct.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 | The above copyright notice and this permission notice shall be included in all
11 | copies or substantial portions of the Software.
12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18 | SOFTWARE.
19 | */
20 |
21 | //
22 | // DisplayPageProduct.swift
23 | // Tracker
24 | //
25 | import Foundation
26 |
27 | /// Wrapper class for DisplayPageProduct event tracking (SalesInsight)
28 | public class DisplayPageProduct: Event {
29 |
30 | /// Product property
31 | @objc public lazy var product : ECommerceProduct = ECommerceProduct()
32 |
33 | override var data: [String : Any] {
34 | get {
35 | let productProps = product.getProps()
36 | if !productProps.isEmpty {
37 | _data["product"] = productProps
38 | }
39 | return super.data
40 | }
41 | set {
42 | _data = newValue
43 | }
44 | }
45 |
46 | init() {
47 | super.init(name: "product.page_display")
48 | }
49 | }
50 |
51 | /// Wrapper class to manage DisplayPageProducts event instances
52 | public class DisplayPageProducts : EventsHelper {
53 |
54 | override init(events: Events) {
55 | super.init(events: events)
56 | }
57 |
58 | /// Add display page product event tracking
59 | ///
60 | /// - Returns: DisplayPageProduct instance
61 | @objc public func add() -> DisplayPageProduct {
62 | let dpp = DisplayPageProduct()
63 | _ = events.add(event: dpp)
64 | return dpp
65 | }
66 |
67 | /// Add display page product event tracking
68 | ///
69 | /// - Parameter screenLabel: a screen label
70 | /// - Returns: DisplayPageProduct instance
71 | @available(*, deprecated, message: "Use 'add()' method instead")
72 | @objc public func add(screenLabel: String?) -> DisplayPageProduct {
73 | return add()
74 | }
75 |
76 | /// Add display page product event tracking
77 | ///
78 | /// - Parameter screen: a screen instance
79 | /// - Returns: DisplayPageProduct instance
80 | @available(*, deprecated, message: "Use 'add()' method instead")
81 | @objc public func add(screen: Screen?) -> DisplayPageProduct {
82 | return add()
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/DisplayCart.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 | The above copyright notice and this permission notice shall be included in all
11 | copies or substantial portions of the Software.
12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18 | SOFTWARE.
19 | */
20 |
21 | //
22 | // DisplayCart.swift
23 | // Tracker
24 | //
25 | import Foundation
26 |
27 | /// Wrapper class for DisplayCart event tracking (SalesInsight)
28 | public class DisplayCart: Event {
29 |
30 | /// Products list
31 | @objc public lazy var products : [ECommerceProduct] = [ECommerceProduct]()
32 |
33 | /// Cart property
34 | @objc public lazy var cart : ECommerceCart = ECommerceCart()
35 |
36 | override var data: [String : Any] {
37 | get {
38 | let cartProps = cart.getProps()
39 | if !cartProps.isEmpty {
40 | _data["cart"] = cartProps
41 | }
42 | return super.data
43 | }
44 | set {
45 | _data = newValue
46 | }
47 | }
48 |
49 | @objc public func setProducts(products: [ECommerceProduct]) {
50 | self.products = products
51 | }
52 |
53 | init() {
54 | super.init(name: "cart.display")
55 | }
56 | }
57 |
58 | /// Wrapper class to manage DisplayCart event instances
59 | public class DisplayCarts : EventsHelper {
60 |
61 | override init(events: Events) {
62 | super.init(events: events)
63 | }
64 |
65 | /// Add display cart event tracking
66 | ///
67 | /// - Returns: DisplayCart instance
68 | @objc public func add() -> DisplayCart {
69 | let dp = DisplayCart()
70 | _ = events.add(event: dp)
71 | return dp
72 | }
73 |
74 | /// Add display cart event tracking
75 | ///
76 | /// - Parameter screenLabel: a screen label
77 | /// - Returns: DisplayCart instance
78 | @available(*, deprecated, message: "Use 'add()' method instead")
79 | @objc public func add(screenLabel: String?) -> DisplayCart {
80 | return add()
81 | }
82 |
83 | /// Add display cart event tracking
84 | ///
85 | /// - Parameter screen: a screen instance
86 | /// - Returns: DisplayCart instance
87 | @available(*, deprecated, message: "Use 'add()' method instead")
88 | @objc public func add(screen: Screen?) -> DisplayCart {
89 | return add()
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # AT Internet Apple SDK
2 |
3 | The AT Internet tag allows you to follow your users activity throughout your application’s lifecycle.
4 | To help you, the tag makes available classes (helpers) enabling the quick implementation of tracking for different application events (screen loads, gestures, video plays…)
5 |
6 | ### Requirements
7 | iOS 10.0+ or tvOS 10.0+ or watchOS 3.0
8 |
9 | Supported devices :
10 | * iPhone
11 | * iPad
12 | * Apple TV
13 | * Apple Watch
14 | * App Extension supported (you may need a different pod to avoid module conflicts, see below)
15 |
16 | ### How to get started
17 | - Install our library on your project (see below)
18 | - Check out the [documentation page] for an overview of the functionalities and code examples. _Note that this repository is refered as SDK 2.5+_
19 |
20 | ### Integration
21 | Find the integration information by following [this link]
22 |
23 | ### Installation with CocoaPods
24 |
25 | CocoaPods is a dependency manager which automates and simplifies the process of using 3rd-party libraries in your projects.
26 |
27 | ### Podfile
28 |
29 | - iOS application :
30 |
31 | ```ruby
32 | target 'MyProject' do
33 | pod "ATInternet-Apple-SDK/Tracker",">=2.0"
34 | use_frameworks!
35 | end
36 | ```
37 | - tvOS application :
38 |
39 | ```ruby
40 | target 'MyProject' do
41 | pod "ATInternet-Apple-SDK/tvOSTracker",">=2.0"
42 | use_frameworks!
43 | end
44 | ```
45 | - watchOS application :
46 |
47 | ```ruby
48 | target 'MyProject' do
49 | pod "ATInternet-Apple-SDK/watchOSTracker",">=2.0"
50 | use_frameworks!
51 | end
52 | ```
53 |
54 |
55 | - App Extension :
56 |
57 | ```ruby
58 |
59 | target 'MyProject App Extension' do
60 | pod "ATInternet-Apple-SDK/AppExtension",">=2.0"
61 | use_frameworks!
62 | end
63 | ```
64 |
65 | NB : To avoid conflicts caused by [CocoaPods](https://github.com/CocoaPods/CocoaPods/issues/8206), it's possible to use an independent pod:
66 | ```ruby
67 |
68 | target 'MyProject App Extension' do
69 | pod "ATInternet-Apple-SDK-AppExtension",">=2.0"
70 | use_frameworks!
71 | end
72 | ```
73 |
74 | ### Installation with Carthage
75 |
76 | Carthage is an alternative to **Cocoapods**. It’s a simple dependency manager for Mac and iOS, created by a group of developers from Github.
77 |
78 | ### Carthage
79 |
80 | https://developers.atinternet-solutions.com/apple-universal-fr/bien-commencer-apple-universal-fr/integration-de-la-bibliotheque-swift-apple-universal-fr/#utilisation-de-carthage_7
81 |
82 | ## Integration samples
83 | ### Tracker
84 | ```swift
85 | // AppDelegate.swift
86 | import Tracker
87 | let trackerDelegate = DefaultTrackerDelegate() // weak var !
88 |
89 | let tracker: Tracker = ATInternet.sharedInstance.defaultTracker
90 | tracker.setSiteId(410501, sync: true, completionHandler: nil) // required
91 | tracker.setLog("logp", sync: true, completionHandler: nil) // required
92 | // tracker.enableDebugger = true // track the hit sent
93 | // tracker.delegate = trackerDelegate // verbose mode
94 | tracker.screens.add().sendView() // send a screen hit
95 | ```
96 |
97 | ### License
98 | MIT
99 |
100 | [documentation page]:
101 | [here]:
102 |
--------------------------------------------------------------------------------
/ATInternetTracker/Tests/CustomVarTests.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 |
25 |
26 |
27 |
28 | //
29 | // CustomVarTests.swift
30 | // Tracker
31 | //
32 |
33 | import UIKit
34 | import XCTest
35 |
36 | class CustomVarTests: XCTestCase {
37 |
38 | lazy var customVar: CustomVar = CustomVar(tracker: Tracker())
39 | lazy var customVars: CustomVars = CustomVars(tracker: Tracker())
40 |
41 | func testSetCustomVarSite() {
42 | let screen = customVars.tracker.screens.add("Home")
43 | screen.setParams()
44 | customVar = customVars.add(123, value: "coucou", type: .app)
45 | customVar.setParams()
46 |
47 | XCTAssertEqual(customVars.tracker.buffer.volatileParameters.count, 2, "Le nombre de paramètres volatiles doit être égal à 2")
48 |
49 | XCTAssert(customVars.tracker.buffer.volatileParameters["p"]!.key == "p", "Le troisième paramètre doit être p")
50 | XCTAssert(customVars.tracker.buffer.volatileParameters["p"]!.values[0]() == "Home", "La valeur du troisième paramètre doit être Home")
51 |
52 | XCTAssert(customVars.tracker.buffer.volatileParameters["x123"]!.key == "x123", "Le 4ème paramètre doit être x123")
53 | XCTAssert(customVars.tracker.buffer.volatileParameters["x123"]!.values[0]() == "coucou", "La valeur du 4ème paramètre doit être coucou")
54 | }
55 |
56 | func testSetCustomVarPage() {
57 | let screen = customVars.tracker.screens.add("Home")
58 | screen.setParams()
59 | customVar = customVars.add(123, value: "coucou", type: .screen)
60 | customVar.setParams()
61 |
62 | XCTAssertEqual(customVars.tracker.buffer.volatileParameters.count, 2, "Le nombre de paramètres volatiles doit être égal à 2")
63 |
64 | XCTAssert(customVars.tracker.buffer.volatileParameters["p"]!.key == "p", "Le troisième paramètre doit être p")
65 | XCTAssert(customVars.tracker.buffer.volatileParameters["p"]!.values[0]() == "Home", "La valeur du troisième paramètre doit être Home")
66 |
67 | XCTAssert(customVars.tracker.buffer.volatileParameters["f123"]!.key == "f123", "Le 4ème paramètre doit être f123")
68 | XCTAssert(customVars.tracker.buffer.volatileParameters["f123"]!.values[0]() == "coucou", "La valeur du 4ème paramètre doit être coucou")
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/ATInternetTracker/Tests/ContextTests.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 |
25 |
26 |
27 |
28 | //
29 | // ContextTests.swift
30 | // Tracker
31 | //
32 |
33 | import UIKit
34 | import XCTest
35 |
36 | class ContextTests: XCTestCase {
37 |
38 | let tracker = Tracker()
39 |
40 | func testBackgroundMode() {
41 | if (tracker.context.backgroundMode != .normal) {
42 | XCTAssertTrue(false, "Par défaut le mode background doit être à .normal")
43 | }
44 | tracker.context.backgroundMode = .fetch
45 | XCTAssertTrue(tracker.context.backgroundMode == .fetch, "Le mode background doit être fetch")
46 | var p = tracker.buffer.persistentParameters[HitParam.backgroundMode.rawValue] as Param?
47 | XCTAssertTrue(p!.key == HitParam.backgroundMode.rawValue, "Le dernier paramètre persistent doit être le mode background")
48 | XCTAssertTrue(p?.values[0]() == "fetch", "Le dernier paramètre persistent doit avoir la valeur fetch")
49 | tracker.context.backgroundMode = .task
50 | p = tracker.buffer.persistentParameters[HitParam.backgroundMode.rawValue] as Param?
51 | XCTAssertTrue(p!.key == HitParam.backgroundMode.rawValue, "Le dernier paramètre persistent doit être le mode background")
52 | XCTAssertTrue(p?.values[0]() == "task", "Le dernier paramètre persistent doit avoir la valeur task")
53 | tracker.context.backgroundMode = .normal
54 | p = tracker.buffer.persistentParameters[HitParam.backgroundMode.rawValue] as Param?
55 | XCTAssertTrue(p == nil, "Le paramètre ne doit plus etre present dans le buffer")
56 | }
57 |
58 | func testLevel2() {
59 | if (tracker.context.level2 != -1) {
60 | XCTAssertTrue(false, "Par défaut le level2 doit être à -1")
61 | }
62 | tracker.context.level2 = 123
63 | var p = tracker.buffer.persistentParameters[HitParam.level2.rawValue] as Param?
64 | XCTAssertTrue(p!.key == HitParam.level2.rawValue, "Le dernier paramètre persistent doit être le level 2")
65 | XCTAssertTrue(p?.values[0]() == "123", "Le dernier paramètre persistent doit avoir la valeur 123")
66 | tracker.context.level2 = -1
67 | p = tracker.buffer.persistentParameters[HitParam.level2.rawValue] as Param?
68 | XCTAssertTrue(p == nil, "Le paramètre ne doit plus etre present dans le buffer")
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/Context.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 |
25 |
26 |
27 |
28 | //
29 | // Context
30 | // Tracker
31 | //
32 |
33 | import Foundation
34 |
35 |
36 | /// Global context tracking
37 | public class Context: NSObject {
38 | /// Tracker instance
39 | var tracker: Tracker
40 |
41 | init(tracker: Tracker) {
42 | self.tracker = tracker;
43 | }
44 |
45 | // MARK: - Level 2
46 |
47 | internal var _level2: String? = nil
48 |
49 | /// Global level 2
50 | @objc public var level2: Int {
51 | get {
52 | if let l = level2String {
53 | return Int(l) ?? -1
54 | }
55 | return -1
56 | }
57 | set {
58 | if newValue >= 0 {
59 | level2String = String(newValue)
60 | } else {
61 | level2String = nil
62 | }
63 | }
64 | }
65 |
66 | @objc public var level2String: String? {
67 | get {
68 | return _level2
69 | }
70 | set {
71 | _level2 = newValue
72 |
73 | if let l = _level2{
74 | let option = ParamOption()
75 | option.persistent = true;
76 |
77 | _ = tracker.setParam(HitParam.level2.rawValue, value: l, options: option)
78 | } else {
79 | tracker.unsetParam(HitParam.level2.rawValue)
80 | }
81 | }
82 | }
83 |
84 | // MARK: - Background Mode
85 |
86 | internal var _backgroundMode: BackgroundMode = BackgroundMode.normal
87 |
88 | /// Tracker background mode. See BackgroundMode
89 | @objc public var backgroundMode: BackgroundMode {
90 | get {
91 | return _backgroundMode
92 | }
93 | set {
94 | _backgroundMode = newValue
95 |
96 | let option = ParamOption()
97 | option.persistent = true
98 |
99 | switch _backgroundMode {
100 | case .fetch:
101 | _ = tracker.setParam(HitParam.backgroundMode.rawValue, value: "fetch", options: option)
102 | case .task:
103 | _ = tracker.setParam(HitParam.backgroundMode.rawValue, value: "task", options: option)
104 | default:
105 | tracker.unsetParam(HitParam.backgroundMode.rawValue)
106 | }
107 | }
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/AddProduct.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 | The above copyright notice and this permission notice shall be included in all
11 | copies or substantial portions of the Software.
12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18 | SOFTWARE.
19 | */
20 |
21 | //
22 | // AddProduct.swift
23 | // Tracker
24 | //
25 | import Foundation
26 |
27 | /// Wrapper class for AddProduct event tracking (SalesInsight)
28 | public class AddProduct: Event {
29 |
30 | /// Product property
31 | @objc public lazy var product : ECommerceProduct = ECommerceProduct()
32 |
33 | /// Cart property
34 | @objc public lazy var cart : ECommerceCart = ECommerceCart()
35 |
36 | override var data: [String : Any] {
37 | get {
38 | let productProps = product.getProps()
39 | if !productProps.isEmpty {
40 | _data["product"] = productProps
41 | }
42 | let cartProps = cart.getProps()
43 | if !cartProps.isEmpty {
44 | _data["cart"] = cartProps
45 | }
46 | return super.data
47 | }
48 | set {
49 | _data = newValue
50 | }
51 | }
52 |
53 | init() {
54 | super.init(name: "product.add_to_cart")
55 | }
56 |
57 | override func getAdditionalEvents() -> [Event] {
58 | var generatedEvents = super.getAdditionalEvents()
59 |
60 | if String(describing: product.get(key: "cartcreation") ?? false).toBool() {
61 | let cc = CartCreation()
62 | let quantity = Int(String(describing: product.get(key: "quantity") ?? 0)) ?? 0
63 |
64 | _ = cc.cart.set(key: "id", value: String(describing: cart.get(key: "id") ?? ""))
65 | .set(key: "currency", value: String(describing: product.get(key: "currency") ?? ""))
66 | .set(key: "turnovertaxincluded", value: (Double(String(describing: product.get(key: "pricetaxincluded") ?? 0)) ?? 0) * Double(quantity))
67 | .set(key: "turnovertaxfree", value: (Double(String(describing: product.get(key: "pricetaxfree") ?? 0)) ?? 0) * Double(quantity))
68 | .set(key: "quantity", value: quantity)
69 | .set(key: "nbdistinctproduct", value: 1)
70 |
71 | generatedEvents.append(cc)
72 | }
73 |
74 | return generatedEvents
75 | }
76 | }
77 |
78 | /// Wrapper class to manage AddProduct event instances
79 | public class AddProducts : EventsHelper {
80 |
81 | /// Add add product event tracking
82 | ///
83 | /// - Returns: AddProduct instance
84 | @objc public func add() -> AddProduct {
85 | let ap = AddProduct()
86 | _ = events.add(event: ap)
87 | return ap
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/ECommerce.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 |
25 |
26 |
27 |
28 | //
29 | // ECommerce.swift
30 | // Tracker
31 | //
32 | import Foundation
33 |
34 | public class ECommerce: NSObject {
35 | private var tracker : Tracker
36 | private var events : Events
37 |
38 | @objc public lazy var displayPageProducts: DisplayPageProducts = DisplayPageProducts(events: self.events)
39 |
40 | @objc public lazy var displayProducts: DisplayProducts = DisplayProducts(events: self.events)
41 |
42 | @objc public lazy var addProducts: AddProducts = AddProducts(events: self.events)
43 |
44 | @objc public lazy var removeProducts: RemoveProducts = RemoveProducts(events: self.events)
45 |
46 | @objc public lazy var displayCarts: DisplayCarts = DisplayCarts(events: self.events)
47 |
48 | @objc public lazy var updateCarts: UpdateCarts = UpdateCarts(events: self.events)
49 |
50 | @objc public lazy var deliveryCheckouts: DeliveryCheckouts = DeliveryCheckouts(events: self.events)
51 |
52 | @objc public lazy var paymentCheckouts: PaymentCheckouts = PaymentCheckouts(events: self.events)
53 |
54 | @objc public lazy var cartAwaitingPayments: CartAwaitingPayments = CartAwaitingPayments(events: self.events)
55 |
56 | @objc public lazy var transactionConfirmations: TransactionConfirmations = TransactionConfirmations(events: self.events)
57 |
58 | init(tracker: Tracker) {
59 | self.tracker = tracker
60 | self.events = tracker.events
61 | }
62 |
63 | /// Enable automatic sales tracker
64 | ///
65 | /// - Parameters:
66 | /// - enabled: /
67 | /// - sync: perform the operation synchronously (optional, default: false)
68 | /// - completionHandler: called when the operation has been done
69 | @available(*, deprecated, message: "since 2.17.0, configuration is unused")
70 | @objc public func setAutoSalesTrackerEnabled(_ enabled: Bool, sync: Bool = false, completionHandler: ((_ isSet: Bool) -> Void)?) {
71 | tracker.delegate?.warningDidOccur?("Useless method")
72 | }
73 |
74 | /// Set a new collect domain
75 | ///
76 | /// - Parameters:
77 | /// - domain: the new domain
78 | /// - sync: perform the operation synchronously (optional, default: false)
79 | /// - completionHandler: called when the operation has been done
80 | /// - Deprecated : Since 2.16.0, default log domain used
81 | @objc @available(*, deprecated, message: "since 2.16.0, default log domain used")
82 | public func setCollectDomain(_ domain: String, sync: Bool = false, completionHandler: ((_ isSet: Bool) -> Void)?) {
83 | tracker.delegate?.warningDidOccur?("Useless method, default log domain used")
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/GeneratedEvents.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 | The above copyright notice and this permission notice shall be included in all
11 | copies or substantial portions of the Software.
12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18 | SOFTWARE.
19 | */
20 |
21 | //
22 | // CartCreation.swift
23 | // Tracker
24 | //
25 |
26 | /// Wrapper class for CartCreation event tracking (SalesInsight)
27 | class CartCreation: Event {
28 |
29 | /// Cart property
30 | var cart : ECommerceCart = ECommerceCart()
31 |
32 | override var data: [String : Any] {
33 | get {
34 | let cartProps = cart.getProps()
35 | if !cartProps.isEmpty {
36 | _data["cart"] = cartProps
37 | }
38 | return super.data
39 | }
40 | set {
41 | _data = newValue
42 | }
43 | }
44 |
45 | init() {
46 | super.init(name: "cart.creation")
47 | }
48 | }
49 |
50 | class ProductPurchased: Event {
51 |
52 | /// Product property
53 | lazy var product : ECommerceProduct = ECommerceProduct()
54 |
55 | /// Transaction property
56 | lazy var transaction : ECommerceTransaction = ECommerceTransaction()
57 |
58 | /// Cart property
59 | var cart = ECommerceCart()
60 |
61 | override var data: [String : Any] {
62 | get {
63 | let productProps = product.getProps()
64 | if !productProps.isEmpty {
65 | _data["product"] = productProps
66 | }
67 | let cartProps = cart.getProps()
68 | if !cartProps.isEmpty {
69 | _data["cart"] = cartProps
70 | }
71 | let transactionProps = transaction.getProps()
72 | if !transactionProps.isEmpty {
73 | _data["transaction"] = transactionProps
74 | }
75 | return super.data
76 | }
77 | set {
78 | _data = newValue
79 | }
80 | }
81 |
82 | init() {
83 | super.init(name: "product.purchased")
84 | }
85 | }
86 |
87 | class ProductAwaitingPayment: Event {
88 |
89 | /// Product property
90 | lazy var product : ECommerceProduct = ECommerceProduct()
91 |
92 | /// Cart property
93 | var cart = ECommerceCart()
94 |
95 | override var data: [String : Any] {
96 | get {
97 | let productProps = product.getProps()
98 | if !productProps.isEmpty {
99 | _data["product"] = productProps
100 | }
101 | let cartProps = cart.getProps()
102 | if !cartProps.isEmpty {
103 | _data["cart"] = cartProps
104 | }
105 | return super.data
106 | }
107 | set {
108 | _data = newValue
109 | }
110 | }
111 |
112 | init() {
113 | super.init(name: "product.awaiting_payment")
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/ATInternetTracker/Tests/BufferTests.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 |
25 |
26 |
27 |
28 | //
29 | // BufferTests.swift
30 | // Tracker
31 | //
32 |
33 | import UIKit
34 | import XCTest
35 |
36 | class BufferTests: XCTestCase {
37 |
38 | // On instancie deux objets de type Parameter
39 | let paramPer = Param(key:"model", value:{"[apple]-[ipad4,4]"})
40 | let paramVol = Param(key:"p", value: {"home"})
41 |
42 | // On instancie deux tableaux contenant des objets de type Parameter
43 | let arrayPer = [Param(key:"key0p", value: {"value0p"}), Param(key:"key1p", value: {"value1p"})]
44 | let arrayVol = [Param(key:"key0v", value: {"value0v"}), Param(key:"key1v", value: {"value1v"})]
45 |
46 | // Instance de buffer utilisée pour les tests
47 | let buffer = Buffer(tracker: Tracker(configuration: ["log":"logp", "logSSL":"logs", "domain":"xiti.com", "pixelPath":"/hit.xiti", "site":"549808", "secure":"false", "identifier":"uuid", "sessionBackgroundDuration":"60" ]))
48 |
49 | override func setUp() {
50 | super.setUp()
51 | }
52 |
53 | override func tearDown() {
54 | super.tearDown()
55 | }
56 |
57 | // On vérifie qu'il est possible d'ajouter un paramètre persistant dans le buffer
58 | func testAddParamPer() {
59 | buffer.persistentParameters[paramPer.key] = paramPer
60 | #if os(iOS)
61 | XCTAssertEqual(buffer.persistentParameters.count, 16, "persistentParameters doit contenir un élément")
62 | #elseif os(tvOS)
63 | XCTAssertEqual(buffer.persistentParameters.count, 15, "persistentParameters doit contenir un élément")
64 | #endif
65 | }
66 |
67 | // On vérifie qu'il est possible d'ajouter un paramètre volatile dans le buffer
68 | func testAddParamVol() {
69 | buffer.volatileParameters[paramVol.key] = paramVol
70 | XCTAssertEqual(buffer.volatileParameters.count, 1, "volatileParameters doit contenir un élément")
71 | }
72 |
73 | // On vérifie qu'il est possible de récupérer un paramètre persistant depuis le buffer
74 | func testGetParamPer() {
75 | buffer.persistentParameters[paramPer.key] = paramPer
76 | XCTAssert(paramPer.values[0]() == buffer.persistentParameters[paramPer.key]?.values[0](), "param et paramPer doivent avoir la même valeur pour key et value")
77 | }
78 |
79 | // On vérifie qu'il est possible d'instancier plusieurs fois Buffer
80 | func testMultiInstance() {
81 | let buffer1 = Buffer(tracker: Tracker(configuration: ["log":"logp", "logSSL":"logs", "domain":"xiti.com", "pixelPath":"/hit.xiti", "site":"549808", "secure":"false", "identifier":"uuid"]))
82 | let buffer2 = Buffer(tracker: Tracker(configuration: ["log":"logp", "logSSL":"logs", "domain":"xiti.com", "pixelPath":"/hit.xiti", "site":"549808", "secure":"false", "identifier":"uuid"]))
83 | XCTAssert(buffer1 !== buffer2, "buffer1 et buffer2 ne doivent pas pointer vers la même référence")
84 | }
85 |
86 |
87 | }
88 |
--------------------------------------------------------------------------------
/ATInternetTracker/Tests/GPSTests.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 |
25 |
26 |
27 |
28 | //
29 | // GPSTests.swift
30 | // Tracker
31 | //
32 |
33 | import UIKit
34 | import XCTest
35 |
36 | class GPSTests: XCTestCase {
37 |
38 | lazy var location: Location = Location(tracker: Tracker())
39 | lazy var locations: Locations = Locations(tracker: Tracker())
40 |
41 | func testInitLocation() {
42 | XCTAssertTrue(location.latitude == 0.0, "La latitude doit être égale à 0")
43 | XCTAssertTrue(location.longitude == 0.0, "La longitude doit être égale à 0")
44 | }
45 |
46 | func testSetLocation() {
47 | let screen = locations.tracker.screens.add("Home")
48 | screen.setParams()
49 | location = locations.add(40.0, longitude: 50.0)
50 | location.setParams()
51 |
52 | XCTAssertEqual(locations.tracker.buffer.volatileParameters.count, 3, "Le nombre de paramètres volatiles doit être égal à 3")
53 |
54 | XCTAssert(locations.tracker.buffer.volatileParameters["p"]?.key == "p", "Le troisième paramètre doit être p")
55 | XCTAssert(locations.tracker.buffer.volatileParameters["p"]?.values[0]() == "Home", "La valeur du troisième paramètre doit être Home")
56 |
57 | XCTAssert(locations.tracker.buffer.volatileParameters["gy"]?.key == "gy", "Le 4ème paramètre doit être gy")
58 | XCTAssert(locations.tracker.buffer.volatileParameters["gy"]?.values[0]() == "40.00", "La valeur du 4ème paramètre doit être 40")
59 |
60 | XCTAssert(locations.tracker.buffer.volatileParameters["gx"]?.key == "gx", "Le 5ème paramètre doit être gx")
61 | XCTAssert(locations.tracker.buffer.volatileParameters["gx"]?.values[0]() == "50.00", "La valeur du 5ème paramètre doit être 50")
62 | }
63 |
64 | func testSetLongLocation() {
65 | let screen = locations.tracker.screens.add("Home")
66 | screen.setParams()
67 | location = locations.add(40.12345, longitude: 50.6789)
68 | location.setParams()
69 |
70 | XCTAssertEqual(locations.tracker.buffer.volatileParameters.count, 3, "Le nombre de paramètres volatiles doit être égal à 3")
71 | XCTAssert(locations.tracker.buffer.volatileParameters["p"]?.key == "p", "Le troisième paramètre doit être p")
72 | XCTAssert(locations.tracker.buffer.volatileParameters["p"]?.values[0]() == "Home", "La valeur du troisième paramètre doit être Home")
73 |
74 | XCTAssert(locations.tracker.buffer.volatileParameters["gy"]?.key == "gy", "Le 4ème paramètre doit être gy")
75 | XCTAssert(locations.tracker.buffer.volatileParameters["gy"]?.values[0]() == "40.12", "La valeur du 4ème paramètre doit être 40.12")
76 |
77 | XCTAssert(locations.tracker.buffer.volatileParameters["gx"]?.key == "gx", "Le 5ème paramètre doit être gx")
78 | XCTAssert(locations.tracker.buffer.volatileParameters["gx"]?.values[0]() == "50.68", "La valeur du 5ème paramètre doit être 50.68")
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/Cart.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 |
25 |
26 |
27 |
28 | //
29 | // Cart.swift
30 | // Tracker
31 | //
32 |
33 |
34 | /// Wrapper class to manage your cart
35 | public class Cart: BusinessObject {
36 |
37 | /// Cart identifier
38 | @objc public var cartId: String = ""
39 |
40 | /// Cart products
41 | @objc public lazy var products: Products = Products(cart: self)
42 |
43 | /// Product list
44 | lazy var productList: [Product] = [Product]()
45 |
46 | /// Set a cart
47 | ///
48 | /// - Parameter cartId: the cart identifier
49 | /// - Returns: the cart
50 | @objc public func set(_ cartId: String) -> Cart {
51 | if(cartId != self.cartId) {
52 | products.removeAll()
53 | }
54 |
55 | self.cartId = cartId
56 | self.tracker.businessObjects[self.id] = self
57 |
58 | return self
59 | }
60 |
61 | /**
62 | Unset the cart
63 | */
64 | @objc public func unset() {
65 | self.cartId = ""
66 | self.products.removeAll()
67 |
68 | self.tracker.businessObjects.removeValue(forKey: self.id)
69 | }
70 |
71 | /**
72 | Send the cart
73 | */
74 | @objc public func send() {
75 | self.tracker.dispatcher.dispatch([self])
76 | self.unset()
77 | }
78 |
79 | /// Set parameters in buffer
80 | override func setParams() {
81 | _ = tracker.setParam("idcart", value: cartId)
82 |
83 | let encodingOption = ParamOption()
84 | encodingOption.encode = true
85 | for(i, product) in productList.enumerated() {
86 | _ = tracker.setParam("pdt" + String(i+1), value: product.buildProductName(), options:encodingOption)
87 |
88 | if product.quantity != -1 {
89 | _ = tracker.setParam("qte" + String(i+1), value: product.quantity)
90 | }
91 |
92 | if product.unitPriceTaxFree != -1 {
93 | _ = tracker.setParam("mtht" + String(i+1), value: product.unitPriceTaxFree)
94 | }
95 |
96 | if product.unitPriceTaxIncluded != -1 {
97 | _ = tracker.setParam("mt" + String(i+1), value: product.unitPriceTaxIncluded)
98 | }
99 |
100 | if product.discountTaxFree != -1 {
101 | _ = tracker.setParam("dscht" + String(i+1), value: product.discountTaxFree)
102 | }
103 |
104 | if product.discountTaxIncluded != -1 {
105 | _ = tracker.setParam("dsc" + String(i+1), value: product.discountTaxIncluded)
106 | }
107 |
108 | if let optPromotionalCode = product.promotionalCode {
109 | _ = tracker.setParam("pcode" + String(i+1), value: optPromotionalCode, options:encodingOption)
110 | }
111 | }
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/StringExtension.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 |
25 |
26 |
27 |
28 | //
29 | // StringExtension.swift
30 | // Tracker
31 | //
32 |
33 | import Foundation
34 |
35 | /// Properties for extending String object
36 | extension String {
37 | /// Returns a percent encoded string
38 | var percentEncodedString: String {
39 | let toEncodeSet = CharacterSet(charactersIn:"! #$@'()*+,/:;=?@[]\"%-.<>\\^_{}|~&").inverted
40 | return self.addingPercentEncoding(withAllowedCharacters: toEncodeSet)!
41 | }
42 |
43 | /// Returns a percent decoded sgtring
44 | var percentDecodedString:String {
45 | if let decodedString = self.removingPercentEncoding {
46 | return decodedString
47 | } else {
48 | return ""
49 | }
50 | }
51 |
52 | var sha256Value: String {
53 | return Hash.sha256Value("AT" + self)
54 | }
55 |
56 | var encrypt: String? {
57 | return Crypt().encrypt(data: self)
58 | }
59 |
60 | var decrypt: String {
61 | return Crypt().decrypt(data: self)!
62 | }
63 |
64 | /**
65 | Converts a String into a NSDictionary or NSArray
66 |
67 | - returns: NSDictionary or NSArray
68 | */
69 | func toJSONObject() -> Any? {
70 | let data = self.data(using: String.Encoding.utf8, allowLossyConversion: false)
71 | if let jsonData = data {
72 | // Will return an object or nil if JSON decoding fails
73 | return try? JSONSerialization.jsonObject(with: jsonData, options: JSONSerialization.ReadingOptions.mutableContainers)
74 | } else {
75 | // Lossless conversion of the string was not possible
76 | return nil
77 | }
78 | }
79 |
80 | func toBool() -> Bool {
81 | return self == "True"
82 | || self == "true"
83 | || self == "yes"
84 | || self == "1"
85 | }
86 |
87 | func toInt() -> Int {
88 | if let i = Int(self) {
89 | return i
90 | }
91 | return 0
92 | }
93 |
94 | /**
95 | Removes white spaces inside of a string
96 |
97 | - returns: a string
98 | */
99 | func removeSpaces() -> String {
100 | return self.replacingOccurrences(of: " ", with: "", options: NSString.CompareOptions.literal, range: nil)
101 | }
102 |
103 | subscript(_ range: CountableRange) -> String {
104 | let start = index(startIndex, offsetBy: max(0, range.lowerBound))
105 | let end = index(start, offsetBy: min(self.count - range.lowerBound,
106 | range.upperBound - range.lowerBound))
107 | return String(self[start..) -> String {
111 | let start = index(startIndex, offsetBy: max(0, range.lowerBound))
112 | return String(self[start...])
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/InternalSearch.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 |
25 |
26 |
27 |
28 | //
29 | // InternalSearch.swift
30 | // Tracker
31 | //
32 |
33 | import Foundation
34 |
35 |
36 | /// Wrapper class for internal search tracking
37 | public class InternalSearch: BusinessObject {
38 | /// Searched keywords
39 | @objc public var keyword: String = ""
40 | /// Number of page result
41 | @objc public var resultScreenNumber: Int = 1
42 | /// Position of result in list
43 | @objc public var resultPosition: Int = -1
44 |
45 | override init(tracker: Tracker) {
46 | super.init(tracker: tracker)
47 | }
48 |
49 | /// Create a new InternalSearch
50 | ///
51 | /// - Parameters:
52 | /// - keyword: internal search keyword
53 | /// - resultScreenNumber: number of screens returned
54 | @objc public init(keyword: String, resultScreenNumber: Int) {
55 | super.init()
56 |
57 | self.keyword = keyword
58 | self.resultScreenNumber = resultScreenNumber
59 | }
60 |
61 | /// Set parameters in buffer
62 | override func setParams() {
63 | let pOpt = ParamOption()
64 | pOpt.encode = true
65 | _ = tracker.setParam("mc", value: keyword, options: pOpt)
66 | _ = tracker.setParam("np", value: resultScreenNumber)
67 |
68 | if(resultPosition > -1) {
69 | _ = tracker.setParam("mcrg", value: resultPosition)
70 | }
71 | }
72 | }
73 |
74 | /// Wrapper class to managed
75 | public class InternalSearches: NSObject {
76 | /// Tracker instance
77 | var tracker: Tracker
78 |
79 | /**
80 | InternalSearches initializer
81 | - parameter tracker: the tracker instance
82 | - returns: InternalSearches instance
83 | */
84 | init(tracker: Tracker) {
85 | self.tracker = tracker
86 | }
87 |
88 | /// Add an internal search
89 | ///
90 | /// - Parameters:
91 | /// - keyword: keyword search
92 | /// - resultScreenNumber: page number result
93 | /// - Returns: a new internal search instance
94 | @objc public func add(_ keyword: String, resultScreenNumber: Int) -> InternalSearch {
95 | let search = InternalSearch(tracker: tracker)
96 | search.keyword = keyword
97 | search.resultScreenNumber = resultScreenNumber
98 | tracker.businessObjects[search.id] = search
99 |
100 | return search
101 | }
102 |
103 | /// Add an internal search
104 | ///
105 | /// - Parameters:
106 | /// - keyword: keyword search
107 | /// - resultScreenNumber: page number result
108 | /// - resultPosition: the result position in the list
109 | /// - Returns: a new internal search instance
110 | @objc public func add(_ keyword: String, resultScreenNumber: Int, resultPosition: Int) -> InternalSearch {
111 | let search = add(keyword, resultScreenNumber: resultScreenNumber)
112 | search.resultPosition = resultPosition
113 |
114 | return search
115 | }
116 | }
117 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/DynamicRefresh.swift:
--------------------------------------------------------------------------------
1 | //
2 | // DynamicRefresh.swift
3 | // refreshdynamic
4 | //
5 | // Created by Théo Damaville on 14/05/2018.
6 | // Copyright © 2018 Théo Damaville. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | /// Custom Timer
12 | class DynamicRefresher {
13 | private let configuration: DynamicRefreshConfiguration
14 | private let sendRefresh: (() -> ()) // called when a refresh hit should be sent
15 |
16 | private var elapsedTime: Int = 0 // total time
17 | private var curr = 0 // current index of DynamicRefreshConfiguration
18 | private var timer: Timer? {
19 | willSet { self.timer?.invalidate() }
20 | }
21 | private var lastTick = Date(); // needed to handle pause
22 |
23 | deinit {
24 | self.timer = nil
25 | }
26 |
27 | init(configuration: DynamicRefreshConfiguration, sendRefresh: @escaping (() -> ()) ) {
28 | self.configuration = configuration
29 | self.sendRefresh = sendRefresh
30 | }
31 |
32 | public func start() {
33 | let refresh = self.configuration.getRefreshDuration(i: self.curr)
34 | self.timer = Timer.scheduledTimer(timeInterval: Double(refresh), target: self, selector: #selector(DynamicRefresher.process), userInfo: nil, repeats: false)
35 | }
36 |
37 | // called every tick
38 | @objc public func process() {
39 | let refresh = self.configuration.getRefreshDuration(i: self.curr)
40 | self.elapsedTime += refresh
41 | self.lastTick = Date()
42 | self.sendRefresh()
43 |
44 | if !self.configuration.isLastIndex(i: self.curr) {
45 | let nextMinute = self.configuration.getTime(i: self.curr+1)
46 | let nextRefreshDuration = self.configuration.getRefreshDuration(i: self.curr+1)
47 | if self.elapsedTime >= nextMinute * 60 {
48 | self.curr += 1
49 | self.timer = Timer.scheduledTimer(timeInterval: Double(nextRefreshDuration), target: self, selector: #selector(DynamicRefresher.process), userInfo: nil, repeats: false)
50 | return
51 | }
52 | }
53 | self.timer = Timer.scheduledTimer(timeInterval: Double(refresh), target: self, selector: #selector(DynamicRefresher.process), userInfo: nil, repeats: false)
54 | }
55 |
56 | public func pause() {
57 | let delta = -(self.lastTick.timeIntervalSinceNow)
58 | self.elapsedTime += Int(delta)
59 | self.timer = nil
60 | }
61 |
62 | public func resume() {
63 | self.start()
64 | }
65 |
66 | public func stop() {
67 | self.timer = nil
68 | self.elapsedTime = 0
69 | self.curr = 0
70 | }
71 | }
72 |
73 | /// Base object - can be sorted by startTime
74 | class DynamicRefresh: Comparable, CustomStringConvertible {
75 | public let startTime: Int
76 | public let refreshDuration: Int
77 | init(startTime: Int, refreshDuration: Int) {
78 | self.startTime = startTime
79 | self.refreshDuration = refreshDuration
80 | }
81 |
82 | var description: String {return "{\(startTime):\(refreshDuration)}"}
83 |
84 | static func < (lhs: DynamicRefresh, rhs: DynamicRefresh) -> Bool {
85 | return lhs.startTime < rhs.startTime
86 | }
87 |
88 | static func == (lhs: DynamicRefresh, rhs: DynamicRefresh) -> Bool {
89 | return lhs.startTime == rhs.startTime
90 | }
91 | }
92 |
93 | /// Collection of - Each entry is converted in DynamicRefresh, added and then sorted
94 | class DynamicRefreshConfiguration {
95 | private let dynamicRefreshes: Array
96 | init(configuration: Dictionary) {
97 | self.dynamicRefreshes = configuration.map { (start, rd) -> DynamicRefresh in
98 | return DynamicRefresh(startTime: start, refreshDuration: rd)
99 | }.sorted()
100 | }
101 |
102 | public func isLastIndex(i: Int) -> Bool {
103 | return i+1 == dynamicRefreshes.count
104 | }
105 |
106 | public func get(i: Int) -> DynamicRefresh {
107 | return self.dynamicRefreshes[i]
108 | }
109 |
110 | public func getTime(i: Int) -> Int {
111 | return self.dynamicRefreshes[i].startTime
112 | }
113 |
114 | public func getRefreshDuration(i: Int) -> Int {
115 | return self.dynamicRefreshes[i].refreshDuration
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/DictionaryExtension.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 |
25 | import Foundation
26 |
27 | public protocol EnumCollection: Hashable {
28 | static func cases() -> AnySequence
29 | static var allValues: [Self] { get }
30 | }
31 |
32 | public extension EnumCollection {
33 |
34 | static func cases() -> AnySequence {
35 | return AnySequence { () -> AnyIterator in
36 | var raw = 0
37 | return AnyIterator {
38 | let current: Self = withUnsafePointer(to: &raw) { $0.withMemoryRebound(to: self, capacity: 1) { $0.pointee } }
39 | guard current.hashValue == raw else {
40 | return nil
41 | }
42 | raw += 1
43 | return current
44 | }
45 | }
46 | }
47 |
48 | static var allValues: [Self] {
49 | return Array(self.cases())
50 | }
51 | }
52 |
53 | extension Dictionary {
54 | mutating func append(_ dictionaries: Dictionary...) {
55 | for dict in dictionaries {
56 | for(key, value) in dict {
57 | self.updateValue(value as! Value, forKey: key as! Key)
58 | }
59 | }
60 | }
61 |
62 | /**
63 | toJson: A method to get the JSON String representation of the dictionary
64 |
65 | - returns: the JSON String representation - An Empty String if it fails
66 | */
67 | func toJSON() -> String {
68 | if JSONSerialization.isValidJSONObject(self) {
69 | if let data = try?JSONSerialization.data(withJSONObject: self, options: []) {
70 | if let string = NSString(data: data, encoding: String.Encoding.utf8.rawValue) {
71 | return string as String
72 | }
73 | }
74 | }
75 | return ""
76 | }
77 |
78 | mutating func setValue(value: Any, forKeyPath keyPath: String, separator: String) {
79 | var keys = keyPath.components(separatedBy: separator)
80 | guard let first = keys.first as? Key else { return }
81 | keys.remove(at: 0)
82 | if keys.isEmpty, let settable = value as? Value {
83 | self[first] = settable
84 | return
85 | }
86 | let rejoined = keys.joined(separator: separator)
87 | var subdict: [NSObject : AnyObject] = [:]
88 | if let sub = self[first] as? [NSObject : AnyObject] {
89 | subdict = sub
90 | }
91 | subdict.setValue(value: value, forKeyPath: rejoined, separator: separator)
92 | if let settable = subdict as? Value {
93 | self[first] = settable
94 | }
95 | }
96 |
97 | func valueForKeyPath(keyPath: String, separator: String) -> T? {
98 | var keys = keyPath.components(separatedBy: separator)
99 | guard let first = keys.first as? Key else { return nil }
100 | guard let value = self[first] else { return nil }
101 | keys.remove(at: 0)
102 | if !keys.isEmpty, let subDict = value as? [NSObject : AnyObject] {
103 | let rejoined = keys.joined(separator: separator)
104 | return subDict.valueForKeyPath(keyPath: rejoined, separator: separator)
105 | }
106 | return value as? T
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/Offline.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 |
25 |
26 |
27 |
28 | //
29 | // Offline.swift
30 | // Tracker
31 | //
32 |
33 | import Foundation
34 |
35 | /// Class to manage offline hits stored
36 | public class Offline: NSObject {
37 | /// Tracker instance
38 | var tracker: Tracker
39 | var offlineMode: String
40 |
41 | /**
42 | Offline initializer
43 | - parameter tracker: the tracker instance
44 | - returns: Offline instance
45 | */
46 | init(tracker: Tracker) {
47 | self.tracker = tracker;
48 | self.offlineMode = tracker.configuration.parameters["storage"] ?? "never"
49 | }
50 |
51 | /// Send all hits stored
52 | @objc public func dispatch() {
53 | Sender.sendOfflineHits(self.tracker, forceSendOfflineHits: true, async: true)
54 | }
55 |
56 | /// Get all offline hits stored in database
57 | ///
58 | /// - Returns: collection of offline hits
59 | @objc public func get() -> [Hit] {
60 | return Storage.sharedInstanceOf(offlineMode, forceStorageAccess: true).get()
61 | }
62 |
63 | /// Get the number of offline hits stored in database
64 | ///
65 | /// - Returns: number of offline hits
66 | @objc public func count() -> Int {
67 | return Storage.sharedInstanceOf(offlineMode, forceStorageAccess: true).count()
68 | }
69 |
70 | /// Delete all offline hits stored in database
71 | ///
72 | /// - Returns: number of deleted hits (-1 if an error occured)
73 | @objc public func delete() -> Int {
74 | return Storage.sharedInstanceOf(offlineMode, forceStorageAccess: true).delete()
75 | }
76 |
77 | /// Delete offline hits older than the number of days passed in parameter
78 | ///
79 | /// - Parameter olderThan: Number of days of offline hits to keep in database
80 | /// - Returns: number of deleted hits (-1 if an error occured)
81 | @objc(deleteOlderThanInt:)
82 | public func delete(_ olderThan: Int) -> Int {
83 | let storage = Storage.sharedInstanceOf(offlineMode, forceStorageAccess: true)
84 |
85 | let now = Date()
86 | var dateComponent = DateComponents()
87 | dateComponent.day = -olderThan
88 |
89 | let past = Calendar.current.date(byAdding: dateComponent, to: now)
90 |
91 | return storage.delete(past!)
92 | }
93 |
94 | /// Delete offline hits older than the date passed in parameter
95 | ///
96 | /// - Parameter olderThan: Date from which the hits will be deleted
97 | /// - Returns: number of deleted hits (-1 if an error occured)
98 | @objc(deleteOlderThanDate:)
99 | public func delete(_ olderThan: Date) -> Int {
100 | return Storage.sharedInstanceOf(offlineMode, forceStorageAccess: true).delete(olderThan)
101 | }
102 |
103 | /// Get the first hit stored in database
104 | ///
105 | /// - Returns: the oldest hit
106 | @objc public func oldest() -> Hit? {
107 | return Storage.sharedInstanceOf(offlineMode, forceStorageAccess: true).first()
108 | }
109 |
110 | /// Get the latest hit stored in database
111 | ///
112 | /// - Returns: the latest hit
113 | @objc public func latest() -> Hit? {
114 | return Storage.sharedInstanceOf(offlineMode, forceStorageAccess: true).last()
115 | }
116 | }
117 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/Campaign.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 |
25 |
26 |
27 |
28 | //
29 | // Campaign.swift
30 | // Tracker
31 | //
32 |
33 | import Foundation
34 |
35 | enum CampaignKeys: String, EnumCollection {
36 | case ATCampaign = "ATCampaign"
37 | case ATCampaignDate = "ATCampaignDate"
38 | case ATCampaignAdded = "ATCampaignAdded"
39 | }
40 |
41 | /// Wrapper class for marketing campaign tracking
42 | public class Campaign: ScreenInfo {
43 | /// Campaign id (XTO)
44 | @objc public var campaignId: String = ""
45 |
46 | override init(tracker: Tracker) {
47 | super.init(tracker: tracker)
48 | }
49 |
50 | /// Create a new campaign with an identifier
51 | ///
52 | /// - Parameter campaignId: campaignId identifier
53 | @objc public init(campaignId: String) {
54 | super.init()
55 |
56 | self.campaignId = campaignId
57 | }
58 |
59 | /// Set parameters in buffer
60 | override func setParams() {
61 | let userDefaults = UserDefaults.standard
62 | let encodeOption = ParamOption()
63 | encodeOption.encode = true
64 |
65 | if let remanentCampaign = userDefaults.value(forKey: CampaignKeys.ATCampaign.rawValue) as? String, let campaignDate = userDefaults.object(forKey: CampaignKeys.ATCampaignDate.rawValue) as? Date {
66 | let nbDays: Int = Tool.daysBetweenDates(campaignDate, toDate: Date())
67 |
68 | if let campaignValue = tracker.configuration.parameters["campaignLifetime"], let campaignIntValue = Int(campaignValue), nbDays > campaignIntValue {
69 | userDefaults.removeObject(forKey: CampaignKeys.ATCampaign.rawValue)
70 | } else {
71 | let remanent = remanentCampaign
72 |
73 | _ = tracker.setParam("xtor", value: remanent, options: encodeOption)
74 | }
75 | } else {
76 | _ = Privacy.storeData(Privacy.StorageFeature.campaign, pairs: (CampaignKeys.ATCampaignDate.rawValue, Date()), (CampaignKeys.ATCampaign.rawValue, campaignId))
77 | }
78 |
79 | _ = tracker.setParam("xto", value: campaignId, options: encodeOption)
80 | _ = Privacy.storeData(Privacy.StorageFeature.campaign, pairs: (CampaignKeys.ATCampaignAdded.rawValue, true))
81 |
82 | if(tracker.configuration.parameters["campaignLastPersistence"]?.lowercased() == "true") {
83 | _ = Privacy.storeData(Privacy.StorageFeature.campaign, pairs: (CampaignKeys.ATCampaignDate.rawValue, Date()), (CampaignKeys.ATCampaign.rawValue, campaignId))
84 | }
85 | }
86 | }
87 |
88 | /// Wrapper class to manage Campaign instances
89 | public class Campaigns: NSObject {
90 | /// Tracker instance
91 | var tracker: Tracker
92 |
93 | /**
94 | Campaigns initializer
95 | - parameter tracker: the tracker instance
96 | - returns: Campaigns instance
97 | */
98 | init(tracker: Tracker) {
99 | self.tracker = tracker;
100 | }
101 |
102 | /// Add tagging data for a campaign
103 | ///
104 | /// - Parameter campaignId: campaign identifier
105 | /// - Returns: the Campaign instance
106 | @objc public func add(campaignId: String) -> Campaign {
107 | let campaign = Campaign(tracker: tracker)
108 | campaign.campaignId = campaignId
109 | tracker.businessObjects[campaign.id] = campaign
110 |
111 | return campaign
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/ATInternetTracker/Tests/ConfigurationTests.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 |
25 |
26 |
27 |
28 | //
29 | // ConfigurationTests.swift
30 | // Tracker
31 | //
32 |
33 | import UIKit
34 | import XCTest
35 |
36 | class ConfigurationTests: XCTestCase {
37 |
38 | // Configuration définie
39 | let myConf = ["log":"customlog", "logSSL":"customlogs", "domain":"customdomain", "pixelPath":"custompixelpath","site":"customsite", "secure":"customsecure", "identifier":"customidentifier", "plugins":"", "enableBackgroundTask":"false", "storage":"never", "hashUserId":"false", "persistIdentifiedVisitor":"true","sessionBackgroundDuration":"60", "campaignLastPersistence": "true", "campaignLifetime": "30","downloadSource":"ext", "sendOnApplicationState":"all", "ignoreLimitedAdTracking":"false","sendHitWhenOptOut":"true", "maxHitSize": "4000", "UUIDDuration": "34", "UUIDExpirationMode": "relative", "proxyType": "http", "proxyAddress":"127.0.0.1:8888"]
40 | // Configuration par défaut
41 | let defaultConf = ["log":"", "logSSL":"", "domain":"xiti.com", "pixelPath":"/hit.xiti", "site":"", "identifier":"uuid", "plugins":"", "enableBackgroundTask":"false", "storage":"never", "hashUserId":"false", "persistIdentifiedVisitor":"true","sessionBackgroundDuration":"60", "campaignLastPersistence": "true", "campaignLifetime": "30","downloadSource":"ext", "sendOnApplicationState":"all", "ignoreLimitedAdTracking":"false","sendHitWhenOptOut":"true", "maxHitSize": "8000", "UUIDDuration": "397", "UUIDExpirationMode": "fixed", "proxyType": "none", "proxyAddress":""]
42 |
43 | override func setUp() {
44 | super.setUp()
45 | }
46 |
47 | override func tearDown() {
48 | super.tearDown()
49 | }
50 |
51 | // On vérifie que qu'il est possible d'instancier plusieurs fois Configuration
52 | func testMultiInstance() {
53 | let config1 = Configuration()
54 | let config2 = Configuration()
55 | XCTAssert(config1 !== config2, "config1 et config2 ne doivent pas pointer vers la même référence")
56 | }
57 |
58 | // On vérifie l'initialisation avec la configuration par défaut
59 | func testDefaultConfigurationGetter() {
60 | var testOK = true;
61 | let config = Configuration().parameters
62 |
63 | for (key,value) in config {
64 | if (defaultConf[key] != value) {
65 | print("\(key) : -> \(String(describing: defaultConf[key])) !== ->\(value)")
66 | testOK = false;
67 | break;
68 | }
69 | }
70 |
71 | if (testOK) {
72 | if (defaultConf.count != config.count) {
73 | print("count failure")
74 | testOK = false;
75 | }
76 | }
77 |
78 | XCTAssert(testOK, "la configuration retournée doit être identique à la configuration par défaut")
79 | }
80 |
81 | // On vérifie l'initialisation avec la configuration définie
82 | func testCustomConfigurationGetter() {
83 | var testOK = true;
84 | let config = Configuration(customConfiguration: myConf).parameters
85 |
86 | for (key,value) in config {
87 | if (myConf[key] != value) {
88 | testOK = false;
89 | }
90 | }
91 |
92 | if (testOK) {
93 | if (myConf.count != config.count) {
94 | testOK = false;
95 | }
96 | }
97 |
98 | XCTAssert(testOK, "la configuration retournée doit être identique à la configuration définie")
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/MvTesting.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 |
25 |
26 |
27 |
28 | //
29 | // MvTesting.swift
30 | // Tracker
31 | //
32 |
33 | import Foundation
34 |
35 | /// Wrapper class to manage SalesTracker Order feature
36 | public class MvTesting: BusinessObject {
37 |
38 | /// Test
39 | @objc public var test: String = ""
40 |
41 | /// WaveId
42 | @objc public var waveId: Int = -1
43 |
44 | /// WaveId
45 | @objc public var creation: String = ""
46 |
47 | /// Custom variables
48 | @objc public lazy var variables: MvTestingVars = MvTestingVars()
49 |
50 | /// Send
51 | @objc public func send() {
52 | self.tracker.dispatcher.dispatch([self])
53 | }
54 |
55 | /// Set parameters in buffer
56 | override func setParams() {
57 | let encodingOption = ParamOption()
58 | encodingOption.encode = true
59 |
60 | _ = tracker.setParam("type", value: "mvt")
61 | .setParam("abmvc", value: String(format: "%@-%d-%@", self.test, self.waveId, self.creation), options: encodingOption)
62 |
63 | for(i, mvtVar) in variables.list.enumerated() {
64 | _ = tracker.setParam("abmv" + String(i + 1), value: String(format: "%@-%@", mvtVar.variable, mvtVar.version), options: encodingOption)
65 | }
66 |
67 | }
68 | }
69 |
70 | /// Wrapper class to manage MvTestings instances
71 | public class MvTestings: NSObject {
72 | /// Tracker instance
73 | var tracker: Tracker
74 |
75 | /**
76 | MvTestings initializer
77 | - parameter tracker: the tracker instance
78 | - returns: MvTestings instance
79 | */
80 | init(tracker: Tracker) {
81 | self.tracker = tracker;
82 | }
83 |
84 | /// Add an mvtesting
85 | ///
86 | /// - Parameters:
87 | /// - test: mvtesting test
88 | /// - waveId: mvtesting wave id
89 | /// - creation: mvtesting creation
90 | /// - Returns: MvTesting instance
91 | @objc public func add(_ test: String, waveId: Int, creation: String) -> MvTesting {
92 | let mvtesting = MvTesting(tracker: tracker)
93 | mvtesting.test = test
94 | mvtesting.waveId = waveId
95 | mvtesting.creation = creation
96 | tracker.businessObjects[mvtesting.id] = mvtesting
97 |
98 | return mvtesting
99 | }
100 | }
101 |
102 | /// Wrapper class for tracking mvtesting variables
103 | public class MvTestingVar: NSObject {
104 |
105 | /// Custom var variable
106 | @objc public var variable: String = ""
107 | /// Custom var version
108 | @objc public var version: String = ""
109 |
110 | /// initializer
111 | ///
112 | /// - Parameters:
113 | /// - variable: var variable
114 | /// - version: var version
115 | init(variable: String, version: String) {
116 | self.variable = variable
117 | self.version = version
118 | }
119 | }
120 |
121 | /// Wrapper class to manage MvTestingVar instances
122 | public class MvTestingVars: NSObject {
123 |
124 | /// Custom var list
125 | lazy var list: [MvTestingVar] = []
126 |
127 | /// Add a custom var
128 | ///
129 | /// - Parameters:
130 | /// - variable: var variable
131 | /// - version: var version
132 | /// - Returns: the MvTestingVar instance
133 | @objc public func add(_ variable: String, version: String) -> MvTestingVar {
134 | let customVar = MvTestingVar(variable: variable, version: version)
135 |
136 | list.append(customVar)
137 |
138 | return customVar
139 | }
140 | }
141 |
--------------------------------------------------------------------------------
/ATInternetTracker/Tests/InternalSearchTests.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 |
25 |
26 |
27 |
28 | //
29 | // InternalSearchTests.swift
30 | // Tracker
31 | //
32 |
33 | import UIKit
34 | import XCTest
35 |
36 | class InternalSearchTests: XCTestCase {
37 |
38 | lazy var internalSearch: InternalSearch = InternalSearch(tracker: Tracker())
39 | lazy var internalSearches: InternalSearches = InternalSearches(tracker: Tracker())
40 |
41 | func testSetInternalSearch() {
42 | internalSearch.keyword = "veryGoodSearch"
43 | internalSearch.resultScreenNumber = 3
44 | internalSearch.resultPosition = 1
45 | internalSearch.setParams()
46 |
47 | XCTAssertEqual(internalSearch.tracker.buffer.volatileParameters.count, 3, "Le nombre de paramètres volatiles doit être égal à 3")
48 |
49 | XCTAssert(internalSearch.tracker.buffer.volatileParameters["mc"]?.key == "mc", "Le premier paramètre doit être mc")
50 | XCTAssert(internalSearch.tracker.buffer.volatileParameters["mc"]?.values[0]() == "veryGoodSearch", "La valeur du premier paramètre doit être veryGoodSearch")
51 |
52 | XCTAssert(internalSearch.tracker.buffer.volatileParameters["np"]?.key == "np", "Le premier paramètre doit être np")
53 | XCTAssert(internalSearch.tracker.buffer.volatileParameters["np"]?.values[0]() == "3", "La valeur du deuxième paramètre doit être 3")
54 |
55 | XCTAssert(internalSearch.tracker.buffer.volatileParameters["mcrg"]?.key == "mcrg", "Le premier paramètre doit être mcfg")
56 | XCTAssert(internalSearch.tracker.buffer.volatileParameters["mcrg"]?.values[0]() == "1", "La valeur du troisième paramètre doit être 1")
57 | }
58 |
59 | func testAddInternalSearchNoPosition() {
60 | internalSearches.tracker = internalSearch.tracker
61 | internalSearch = internalSearches.add("watch", resultScreenNumber: 3)
62 |
63 | XCTAssert(internalSearch.tracker.businessObjects.count == 1, "Le nombre d'objet en attente doit être égale à 1")
64 |
65 | XCTAssert(internalSearch.keyword == "watch", "le keyword de la recherche doit être égal à watch")
66 | XCTAssert((internalSearch.tracker.businessObjects[internalSearch.id] as! InternalSearch).keyword == "watch", "le keyword de la recherche doit être égal à watch")
67 |
68 | XCTAssert(internalSearch.resultScreenNumber == 3, "le numéro de page de la recherche doit être égal à 3")
69 | XCTAssert((internalSearch.tracker.businessObjects[internalSearch.id] as! InternalSearch).resultScreenNumber == 3, "le numéro de page de la recherche doit être égal à 3")
70 | }
71 |
72 | func testAddInternalSearchPosition() {
73 | internalSearches.tracker = internalSearch.tracker
74 | internalSearch = internalSearches.add("watch", resultScreenNumber: 3, resultPosition: 1)
75 |
76 | XCTAssert(internalSearch.tracker.businessObjects.count == 1, "Le nombre d'objet en attente doit être égale à 1")
77 |
78 | XCTAssert(internalSearch.keyword == "watch", "le keyword de la recherche doit être égal à watch")
79 | XCTAssert((internalSearch.tracker.businessObjects[internalSearch.id] as! InternalSearch).keyword == "watch", "le keyword de la recherche doit être égal à watch")
80 |
81 | XCTAssert(internalSearch.resultScreenNumber == 3, "le numéro de page de la recherche doit être égal à 3")
82 | XCTAssert((internalSearch.tracker.businessObjects[internalSearch.id] as! InternalSearch).resultScreenNumber == 3, "le numéro de page de la recherche doit être égal à 3")
83 |
84 | XCTAssert(internalSearch.resultPosition == 1, "le numéro de position de la recherche doit être égal à 1")
85 | XCTAssert((internalSearch.tracker.businessObjects[internalSearch.id] as! InternalSearch).resultPosition == 1, "le numéro de position de la recherche doit être égal à 1")
86 | }
87 |
88 | }
89 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/BackgroundTask.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 | The above copyright notice and this permission notice shall be included in all
11 | copies or substantial portions of the Software.
12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18 | SOFTWARE.
19 | */
20 |
21 |
22 |
23 |
24 |
25 | //
26 | // BackgroundTaskManager.swift
27 | // Tracker
28 | //
29 | import Foundation
30 | #if canImport(UIKit)
31 | import UIKit
32 | #endif
33 |
34 | /// Background task
35 | public class BackgroundTask: NSObject {
36 | struct Static {
37 | static var instance: BackgroundTask?
38 | static var token: Int = 0
39 | }
40 |
41 | fileprivate static var __once: () = {
42 | Static.instance = BackgroundTask()
43 | }()
44 |
45 | typealias completionBlock = () -> Void
46 |
47 | /// Number of running tasks
48 | lazy var taskCounter: Int = 0
49 | /// Array of tasks identifiers
50 | lazy var tasks = [Int: Int]()
51 | /// Array of tasks completion block
52 | lazy var tasksCompletionBlocks = [Int: completionBlock]()
53 | /// A lock to protect access to the task counter from multiple threads.
54 | private var taskCounterLock = NSLock()
55 | /// A recursive lock to protect access to the tasks array from multiple threads.
56 | private var tasksLock = NSRecursiveLock()
57 |
58 | /**
59 | Private initializer (cannot instantiate BackgroundTaskManager)
60 | */
61 | fileprivate override init() {
62 |
63 | }
64 |
65 | /// BackgroundTaskManager singleton
66 | class var sharedInstance: BackgroundTask {
67 | _ = BackgroundTask.__once
68 |
69 | return Static.instance!
70 | }
71 |
72 | /**
73 | Starts a background task
74 | */
75 | func begin() -> Int {
76 | return begin(nil)
77 | }
78 |
79 | /// Starts a background and call the callback function when done
80 | ///
81 | /// - Parameter completion: completion block to call right before task ends
82 | /// - Returns: the taskKey
83 | func begin(_ completion: (() -> Void)!) -> Int {
84 | var taskKey = 0
85 |
86 | self.taskCounterLock.lock()
87 | taskKey = taskCounter
88 | taskCounter += 1
89 | self.taskCounterLock.unlock()
90 |
91 | #if canImport(UIKit) && !AT_EXTENSION
92 | let identifier = UIApplication.shared.beginBackgroundTask(expirationHandler: {
93 | self.end(taskKey)
94 | })
95 | tasks[taskKey] = identifier.rawValue
96 |
97 | if(completion != nil) {
98 | tasksCompletionBlocks[taskKey] = completion
99 | }
100 |
101 | return taskKey
102 | #else
103 | return -1
104 | #endif
105 | }
106 |
107 | /// Force task to end
108 | ///
109 | /// - Parameter key: ID of the task to end
110 | func end(_ key: Int) {
111 | self.tasksLock.lock()
112 | defer {
113 | self.tasksLock.unlock()
114 | }
115 |
116 | if let completionBlock = tasksCompletionBlocks[key] {
117 | completionBlock()
118 | tasksCompletionBlocks.removeValue(forKey: key)
119 | }
120 |
121 | if let taskId = tasks[key] {
122 | // On stoppe tous les envoi de hits offline en cours si le délais en background est expiré
123 | for operation in TrackerQueue.sharedInstance.queue.operations {
124 | if let sender = operation as? Sender {
125 | if(!sender.isExecuting && sender.hit.isOffline) {
126 | sender.cancel()
127 | }
128 | }
129 | }
130 |
131 | #if canImport(UIKit) && !AT_EXTENSION
132 | // On arrete la tache en arrière plan
133 | UIApplication.shared.endBackgroundTask(UIBackgroundTaskIdentifier(rawValue: taskId))
134 |
135 | tasks[key] = UIBackgroundTaskIdentifier.invalid.rawValue
136 | tasks.removeValue(forKey: key)
137 | #endif
138 | }
139 | }
140 | }
141 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/CustomTreeStructure.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 |
25 |
26 |
27 |
28 | //
29 | // CustomTreeStructure.swift
30 | // Tracker
31 | //
32 |
33 | import Foundation
34 |
35 |
36 | /// Wrapper class for custom tree structure tracking
37 | public class CustomTreeStructure: ScreenInfo {
38 | /// Custom tree structure first category label
39 | @objc public var category1: Int = 0
40 | /// Custom tree structure first category label
41 | @objc public var category2: Int = 0
42 | /// Custom tree structure first category label
43 | @objc public var category3: Int = 0
44 |
45 | override init(tracker: Tracker) {
46 | super.init(tracker: tracker)
47 | }
48 |
49 |
50 | /// Create a new CustomTreeStructure
51 | ///
52 | /// - Parameter category1: first custom tree structure category
53 | @objc public init(category1: Int) {
54 | super.init()
55 |
56 | self.category1 = category1
57 | }
58 |
59 | /// Create a new CustomTreeStructure
60 | ///
61 | /// - Parameters:
62 | /// - category1: first custom tree structure category
63 | /// - category2: second custom tree structure category
64 | @objc public convenience init(category1: Int, category2: Int) {
65 | self.init(category1: category1)
66 |
67 | self.category2 = category2
68 | }
69 |
70 | /// Create a new CustomTreeStructure
71 | ///
72 | /// - Parameters:
73 | /// - category1: first custom tree structure category
74 | /// - category2: second custom tree structure category
75 | /// - category3: third custom tree structure category
76 | @objc public convenience init(category1: Int, category2: Int, category3: Int) {
77 | self.init(category1: category1, category2: category2)
78 |
79 | self.category3 = category3
80 | }
81 |
82 | /// Set parameters in buffer
83 | override func setParams() {
84 | _ = tracker.setParam("ptype", value: String(format: "%d-%d-%d", category1, category2, category3))
85 | }
86 | }
87 |
88 |
89 | /// Wrapper class to manage custom tree structure instances
90 | public class CustomTreeStructures: NSObject {
91 | /// Tracker instance
92 | var tracker: Tracker
93 |
94 | /**
95 | CustomTreeStructures initializer
96 | - parameter tracker: the tracker instance
97 | - returns: CustomTreeStructures instance
98 | */
99 | init(tracker: Tracker) {
100 | self.tracker = tracker;
101 | }
102 |
103 | /// Add a custom tree structure info to screen hit
104 | ///
105 | /// - Parameters:
106 | /// - category1: category1 label
107 | /// - Returns: CustomTreeStructure instance
108 | public func add(_ category1: Int) -> CustomTreeStructure {
109 | let cts = CustomTreeStructure(tracker: tracker)
110 | cts.category1 = category1
111 | tracker.businessObjects[cts.id] = cts
112 |
113 | return cts
114 | }
115 |
116 | /// Add a custom tree structure info to screen hit
117 | ///
118 | /// - Parameters:
119 | /// - category1: category1 label
120 | /// - category2: category2 label
121 | /// - Returns: CustomTreeStructure instance
122 | public func add(_ category1: Int, category2: Int) -> CustomTreeStructure {
123 | let cts = add(category1)
124 | cts.category2 = category2
125 |
126 | return cts
127 | }
128 |
129 | /// Add a custom tree structure info to screen hit
130 | ///
131 | /// - Parameters:
132 | /// - category1: category1 label
133 | /// - category2: category2 label
134 | /// - category3: category3 label
135 | /// - Returns: CustomTreeStructure instance
136 | public func add(_ category1: Int, category2: Int, category3: Int) -> CustomTreeStructure {
137 | let cts = add(category1, category2: category2)
138 | cts.category3 = category3
139 |
140 | return cts
141 | }
142 | }
143 |
--------------------------------------------------------------------------------
/ATInternetTracker/Sources/CartAwaitingPayment.swift:
--------------------------------------------------------------------------------
1 | /*
2 | This SDK is licensed under the MIT license (MIT)
3 | Copyright (c) 2015- Applied Technologies Internet SAS (registration number B 403 261 258 - Trade and Companies Register of Bordeaux – France)
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 | The above copyright notice and this permission notice shall be included in all
11 | copies or substantial portions of the Software.
12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18 | SOFTWARE.
19 | */
20 |
21 | //
22 | // CartAwaitingPayment.swift
23 | // Tracker
24 | //
25 | import Foundation
26 |
27 | /// Wrapper class for UpdateCart event tracking (SalesInsight)
28 | public class CartAwaitingPayment: Event {
29 |
30 | /// Cart property
31 | @objc public lazy var cart : ECommerceCart = ECommerceCart()
32 |
33 | /// Products list
34 | @objc public lazy var products : [ECommerceProduct] = [ECommerceProduct]()
35 |
36 | /// Transaction property
37 | @objc public lazy var transaction : ECommerceTransaction = ECommerceTransaction()
38 |
39 | /// Shipping property
40 | @objc public lazy var shipping : ECommerceShipping = ECommerceShipping()
41 |
42 | /// Payment property
43 | @objc public lazy var payment : ECommercePayment = ECommercePayment()
44 |
45 | override var data: [String : Any] {
46 | get {
47 | var cartProps = cart.getProps()
48 | if !cartProps.isEmpty {
49 | cartProps["version"] = cart.version
50 | _data["cart"] = cartProps
51 | }
52 | let paymentProps = payment.getProps()
53 | if !paymentProps.isEmpty {
54 | _data["payment"] = paymentProps
55 | }
56 | let shippingProps = shipping.getProps()
57 | if !shippingProps.isEmpty {
58 | _data["shipping"] = shippingProps
59 | }
60 | let transactionProps = transaction.getProps()
61 | if !transactionProps.isEmpty {
62 | _data["transaction"] = transactionProps
63 | }
64 | return super.data
65 | }
66 | set {
67 | _data = newValue
68 | }
69 | }
70 |
71 | init() {
72 | super.init(name: "cart.awaiting_payment")
73 | }
74 |
75 | @objc public func setProducts(products: [ECommerceProduct]) {
76 | self.products = products
77 | }
78 |
79 | override func getAdditionalEvents() -> [Event] {
80 | var generatedEvents = super.getAdditionalEvents()
81 |
82 | for p in products {
83 | let pap = ProductAwaitingPayment()
84 | _ = pap.cart.setProps(obj:
85 | [
86 | "id": String(describing: cart.get(key: "id") ?? ""),
87 | "version": cart.version
88 | ])
89 | let productProps = p.getProps()
90 | if !productProps.isEmpty {
91 | _ = pap.product.setProps(obj: productProps)
92 | }
93 | generatedEvents.append(pap)
94 | }
95 |
96 | return generatedEvents
97 | }
98 | }
99 |
100 | /// Wrapper class to manage UpdateCart event instances
101 | public class CartAwaitingPayments : EventsHelper {
102 |
103 | override init(events: Events) {
104 | super.init(events: events)
105 | }
106 |
107 | /// Add cart awaiting payment event tracking
108 | ///
109 | /// - Returns: CartAwaitingPayment instance
110 | @objc public func add() -> CartAwaitingPayment {
111 | let cap = CartAwaitingPayment()
112 | _ = events.add(event: cap)
113 | return cap
114 | }
115 |
116 | /// Add cart awaiting payment event tracking
117 | ///
118 | /// - Parameter screenLabel: a screen label
119 | /// - Returns: CartAwaitingPayment instance
120 | @available(*, deprecated, message: "Use 'add()' method instead")
121 | @objc public func add(screenLabel: String?) -> CartAwaitingPayment {
122 | return add()
123 | }
124 |
125 | /// Add cart awaiting payment event tracking
126 | ///
127 | /// - Parameter screen: a screen instance
128 | /// - Returns: CartAwaitingPayment instance
129 | @available(*, deprecated, message: "Use 'add()' method instead")
130 | @objc public func add(screen: Screen?) -> CartAwaitingPayment {
131 | return add()
132 | }
133 | }
134 |
--------------------------------------------------------------------------------